Scandinavian Linknet AB blir nu Avantec Consulting AB. (Samma org.nr. som tidigare.)
Securing an Alfresco dashlet
In a recent project, we wanted to disable some information for any other user than the Site Administratiors. This can be done by using the Remote API.
custom-sitedashlet.get.js
function main()
{
var siteId = page.url.templateArgs.site;
var result = remote.call("/api/sites/" + siteId + "/memberships?format=json&nf=" + stringUtils.urlEncode(user.name));
var json = eval('(' + result + ')');
if (json[0].role == "SiteManager") {
model.manager = true;
}else{
model.manager = false;
}
model.site = siteId;
}
main();
custom-sitedashlet.get.html.ftl
<script type="text/javascript">//<![CDATA[
new Alfresco.DnavetDashlet("${args.htmlid}").setOptions(
{
"componentId": "${instance.object.id}"
});
//]]></script>
<div>
<div class="title">${msg("header.dashlet-title")}</div>
<div>
<#if manager>
SiteManager only content…
</#if>
</div>
</div>
If you just want to limit content to system administrators, user.isAdmin is always available.
How to start Alfresco at boot time as a user other than root.
It’s possible to start Alfresco at boot time by adding a simple line to /etc/rc.d/rc.local on Red Hat-like distros or some similar equivalence on Debian-based systems. The problem with that, however, is that you won’t start and stop Alfresco the correct way if you reboot, which can lead to old PID files being left behind blocking Tomcat. Instead, we use a script in the init.d folder which catches reboots and shutdowns.
If starting and stopping Alfresco correctly at reboots was all you wanted to do, you could have just used a symbolic link in init.d pointing to the alfresco script in the installation folder (alfresco.sh e.g.), but since we want to run the system as an arbitrary, non-privileged user, e.g. user ‘alfresco’, we need a wrapper script that uses su.
Here is an example of the above for Ubuntu 10.10 with Alfresco 4 (use sudo with the commands below if you’re not running as root):
touch /etc/init.d/alfresco- (Owner should be root)
chmod 755 /etc/init.d/alfresco- (Make it executable)
update-rc.d alfresco defaults 80- This connects the script with the default rcN.d links, and priority 80 which makes it very likely it will be run last of the scripts per runlevel.
emacs /etc/init.d/alfresco- Enter the following in the file:
#!/bin/sh
#
# Wrapper service script that changes user to Alfresco
#
case "$1" in
start)
echo -n "Starting Alfresco: "
su -l -c '/opt/alfresco-4.0.x/alfresco.sh start > /dev/null 2>&1 &' alfresco
;;
stop)
echo -n "Stopping Alfresco: "
/opt/alfresco-4.0.x/alfresco.sh stop
;;
restart)
$0 stop
$0 start
;;
reload)
;;
*)
echo "Usage: $0 {start|stop|restart|reload|status}"
exit 1
esac
exit 0
- Replace ”/opt/alfresco-4.0.x” above with the name of your installation folder.
- Note that you may need to change a few of the default ports in Alfresco to unprivileged ports, since you’re not running as root, e.g. the ports for CIFS if you’re using that.
- (Note that the su flag ‘-l’ above isn’t bound by any order among the options, as opposed to the synonym ‘-’ flag which must be the last su option.)
Användarvänliga url i Liferay
Användarvänliga url’s är något man ska eftersträva att ha. I liferay sätts url utgångsläge till http://localhost:8080/web/guest/home. Liferay lägger alltså till /web/guest/ i url’n.
Det skulle vara trevligt att kunna skriva om url’n till http://www.minsida.se.
Liferay v6
Med version 6 har det blivit mycket enkelt. Gå till startsidan (/web/guest) och välj Manage-> Settings -> Virtual host.
Under Public virtual host skriver vi in vårt servernamn (www.minsida.se). Save!
Liferay v5
Liferay v4
För att åstadkomma detta kan man använda sig av tuckey UrlRewrite.
I filen urlrewrite.xml i katalogen <liferay-portal-home>\tomcat-X.X.X\webapps\ROOT\WEB-INF görs följande tillägg
<rule match-type=”regex”>
<from>(.*)/web/guest/(.*)$</from>
<to type=”permanent-redirect”>$1/$2</to>
</rule>
<outbound-rule>
<from>(.*)/web/guest/(.*)$</from>
<to type=”permanent-redirect”>$1/$2</to>
</outbound-rule>
Liferay + Alfresco presentation
Följande presentation visar på en mycket intressant setup som vi på Linknet tror stakt på.
Innehåll i Alfresco som presenteras via CMIS av Liferay. Mer info på detta ämne kommer..
Stora batchjobb i Alfresco
Bloggen är tillbaka!
Efter två års frånvaro är nu Linknet-bloggen tillbaka. Vi har öppnat upp den igen i samband med att vi släppt vår nya hemsida.
Jag hoppas att alla gamla läsare hittar tillbaka och att vi hittar några nya. Innehållet på bloggen kommer som förut i huvudsak att vara lösningar på problem vi stöter på i vårt vardagliga jobb som java-utvecklare.
Målsättningen är att publicera ett inlägg varje vecka ungefär. Det händer mycket spännande nu, så förvänta er inlägg om java-uteveckling, javascriptramverk som Yahoos YUI, Alfreso, Liferay, Solr, Mule och annat som vi springer på.
Man kan även följa oss på Facebook: http://www.facebook.com/pages/Scandinavian-Linknet-AB/155187724535263
