23 Feb

New A.A.A.R. Alfresco audit analysis and reporting v1.1 release

Thanking to the contribution of some users with interesting practical cases, a new version 1.1 of the A.A.A.R. – Alfresco audit analisys and reporting has been released.

Here some useful links for the interested of you.

As soon as possible, a post with the instructions to upgrade the v1.0 to the latest v1.1.

19 Feb

Liferay 6.1.1 CE GA2 IDE on Tomcat 7 with Eclipse Juno

Eclipse_IconIn this post is shared the installation of Liferay 6.1.1 Community Edition GA2 IDE on Ubuntu 12.04 LTS 64bit with Apache Tomcat Application Server 7.0.32 and PostgreSQL 8.4.15. The post is based on the installation tutorial described in the ‘Step by step installation of Liferay 6.1.1 CE GA2 on Ubuntu 12.04 LTS 64bit and Tomcat 7… no bundle please!‘ and supposes you have the same environment installed and working in your system.

As we like and prefer, the installation is a step by step list of commands and tasks… simpler to understand, to do and to test. Hope you’ll be agree.

Sources

In this paragraph are collected the used sources for the installation. I suggest to download and store them in a safe repository for future purposes (re-installation, maintainance, etc.).

  • Eclipse IDE for Java EE Developers – Juno release from Eclipse Downloads (‘eclipse-jee-juno-SR1-linux-gtk-x86_64.tar.gz’).
  • Liferay 6.1.1 GA2 on Tomcat Bundle from Liferay Portal Download (‘liferay-portal-tomcat-6.1.1-ce-ga2-….zip’).
  • Liferay 6.1 JavaDoc from Liferay Portal Download (‘liferay-portal-doc-6.1.1-ce-ga2-….zip’).
  • Liferay 6.1 Source from Liferay Portal Download (‘liferay-portal-src-6.1.1-ce-ga2-….zip’).

Eclipse Juno installation

Connect to the server (or the virtual machine like in our case) as ‘liferay’ user. We discourage the use of the root user for security reasons.

  • Open a terminal and execute:
cd /home/liferay/Desktop/
cp /mnt/.../eclipse-jee-juno-SR1-linux-gtk-x86_64.tar.gz .
tar zxvf eclipse-jee-juno-SR1-linux-gtk-x86_64.tar.gz
rm -rf eclipse-jee-juno-SR1-linux-gtk-x86_64.tar.gz
  • Let’s run eclipse and use it.
/home/liferay/Desktop/eclipse/eclipse &
  • In the menus bar: Help -> Check for update. Update, if requested, and restart.

Eclipse EGit installation

To have a professional version control of your source code you need a CVS, SVN, Git (or similar) module installed on Eclipse. Here we prefer EGit Eclipse that you can install as described below.

Liferay IDE installation

Liferay IDE, like all the Liferay suite, it’s very well documented here. Liferay IDE installation is documented here and it’s described below.

Liferay SDK installation

service liferay stop.
  • Unzip Liferay SDK (‘liferay-plugins-sdk-6.1.1-ce-ga2-….zip’) in /opt/liferay-plugins-sdk-6.1.1
chown -R liferay:liferay /opt/liferay-plugins-sdk-6.1.1
  • In Eclipse go to New Liferay SDK in the Liferay icon menu.
  • Location: ‘/opt/liferay-plugins-sdk-6.1.1’ and click Ok.

Liferay JavaDoc and Source installation

  • Copy liferay-portal-doc-6.1.1-ce-ga2-….zip in ‘/opt/liferay’.
  • Copy liferay-portal-src-6.1.1-ce-ga2-….zip in ‘/opt/liferay’.
  • In Eclipse go to New Liferay Server in the Liferay icon menu.
  • Liferay v6.1 (on Tomcat 7) and then press Next.
  • Liferay Tomcat Directory:’/opt/liferay/tomcat’. Press Next.
  • ‘Browse Zip’ of Liferay Javadoc URL selecting ‘/opt/liferay/liferay-portal-doc-6.1.1-ce-ga2-….zip’.
  • ‘Browse Zip’ of Liferay Source URL selecting ‘/opt/liferay/liferay-portal-src-6.1.1-ce-ga2-….zip’.
  • Do not configure the bundle link (not done yet!).
  • Press Next then Finish.
  • In Eclipse go to Servers in the window and start the Liferay server.

Now you are ready to develop your first portlet.

12 Feb

Alfresco restore from a cold backup

1359432616_backupIn the Alfresco wiki is described the backup and restore strategy but is not so clear how to do it in detail. In this post is shared a practical way to perform a restore of a backuped Alfresco in the way I like: a list of commands and tasks to execute… simpler to understand, to do and to test.

In this example is supposed that Alfresco is alfresco-logo.pnginstalled in ‘/opt/alfresco’ folder and the DBMS used is PostgreSQL. The restore strategy supposes that the backup is done as a “cold backup” described in this ‘Alfresco backup script‘ post.

Let’s start…

First of all proceed to stop alfresco.

service alfresco stop

Supposing the DBMS runs using the ‘postgres’ user, proceed as first task to restore the PostgreSQL database.

su - postgres
psql
DROP DATABASE alfresco;
CREATE DATABASE alfresco WITH OWNER alfresco;

Digit CTRL+d to exit from the shell.

psql -U alfresco -d alfresco
ALTER USER alfresco WITH PASSWORD 'alfresco';

Digit CTRL+d to exit from the shell. Supposing the DBMS backup is stored in the ‘alfresco_postgres.tar’ file conforming to the backup strategy described here, let’s go ahead with the restoring of the database.

pg_restore -d alfresco alfresco_postgres.tar
exit

Now it’s time to restore the ‘alf_data’ folder with documents and indexes. Also in this case is supposed that the files are stored in a ‘alfresco_data.tgz’ file conforming to the backup strategy described here.

cd /opt/alfresco
mv alf_data alf_data.old
tar zxvf alfresco_data.tgz

That’s all!
Now it’s time to start again Alfresco and use it normally.

service alfresco start
06 Feb

Alfresco backup script

1359432616_backupIn the Alfresco wiki is described the backup and restore strategy but is not so clear how is defined a script and how to do it more exactly. To be more precise the backup strategy could be a “cold backup” or a “hot backup”. In this post is shared a practical way to perform a “cold backup” in the way I like: a list of commands and tasks to execute… simpler to understand, to do and to test.

In this example is supposed that Alfresco is instalalfresco-logo.pngled in ‘/opt/alfresco’ folder and the DBMS used is PostgreSQL. The script is developed to have a 10 days backup history. If in your case is requested more or less than 10 days you can simply modify the ‘NUM_DUMP’ variable.

Let’s start…

cd /opt/alfresco
nano alfrescoBackup.sh

.

#
# Cold backup of Alfresco.
#

# Configuration.
ALF_HOME="/opt/alfresco"
NUM_DUMP=10
ALF_DATA_SUBDIR="alf_data"
DB_HOME="/opt/postgresql"
DB_TYPE="postgresql"

# Check
if [ -d "$1" ]; then

  TARGET_FOLDER="$1"
  CURRENT_FOLDER="$(pwd)"
  TIMESTAMP="$(date +%F_%H-%M)"
  CHECK=1

  # 1) Alfresco stop.
  service alfresco stop

  # 2) Backup of the database of Alfresco with vendor service.
  DB_DUMP=${TIMESTAMP}_alfresco_${DB_TYPE}.tar
  if [ "$DB_TYPE" = "postgresql" ]; then
    cd $TARGET_FOLDER
    $DB_HOME/bin/pg_dump -Ft -b alfresco > $TARGET_FOLDER/$DB_DUMP
    cd $CURRENT_FOLDER
    if [ ! -f "$TARGET_FOLDER/$DB_DUMP" ]; then
      CHECK=0
    fi
  else
    echo "Unknown database type '${DB_TYPE}'"
    CHECK=0
  fi

  # 3) Backup of the Alfresco's data folder.
  if [ "$CHECK" = 1 ]; then
    ALF_DUMP=${TIMESTAMP}_alfresco_data.tgz
    cd $ALF_HOME
    tar zcf $TARGET_FOLDER/$ALF_DUMP $ALF_DATA_SUBDIR
    cd $CURRENT_FOLDER
    if [ ! -f "$TARGET_FOLDER/$ALF_DUMP" ]; then
      CHECK=0
    fi
  fi

  # 4) Merge the two backups.
  if [ "$CHECK" = 1 ]; then
    BACKUP_FILE="${TIMESTAMP}_alfresco_dump.tgz"
    cd $TARGET_FOLDER
    tar zcf $BACKUP_FILE $ALF_DUMP $DB_DUMP
    if [ ! -f "$BACKUP_FILE" ]; then
      CHECK=0
    else
      rm $ALF_DUMP
      rm $DB_DUMP
    fi
    cd $CURRENT_FOLDER
  fi

  # 5) Alfresco start.
  service alfresco start

  # 6) Delete dump older than a certains number of days.
  if [ "$CHECK" = 1 ]; then
    find $TARGET_FOLDER/*.tgz -type f -mtime +${NUM_DUMP} -exec rm {} ;
  fi

else
  echo "usage: $0 [targetPath]"
fi

Exit with CTRL+X and confirm saving. Let’s go ahead defining permits and preparing the repository folder. Talking about the repository folder here is presented an example but in practical cases is suggested to mount an external file system used specifically for backup purpose.

chmod uga+x /opt/alfresco/alfrescoBackup.sh
mkdir /opt/alfresco/backup

Now everything is set and it’s time to activate the crontab to perform automatic backup, probably during the night time. Please, observe that the user used to run Alfresco is named ‘alfresco’ (do not run it as root) and the crontab is performed as ‘alfresco’ user with ‘-u alfresco’.

sudo crontab -u alfresco -e

.

00 01 * * * /opt/alfresco/alfrescoBackup.sh /opt/alfresco/backup

In this example the cold backup of Alfresco is performed at 01:00 am. To read more about crontab see here.

01 Feb

Step by step installation of Liferay 6.1.1 CE GA2 on Ubuntu 12.04 LTS 64bit and Tomcat 7… no bundle please!

liferay-logoIn this post is shared the installation of Liferay 6.1.1 Community Edition GA2 on Ubuntu 12.04 LTS 64bit with Apache Tomcat 7.0.35 and PostgreSQL 8.4.15. The purpose installation is not the bundle one but the more “robust” alternative for an enterprise configuration.

The post is based on the installation tutorial described in the ‘Step by step installation of Liferay 6.1.1 CE GA2 on Ubuntu 12.04 LTS and JBoss 7 64bit… no bundle please!‘ with the difference that in this case the installation is on Apache Tomcat instead of Jboss Application Server.

As we like and prefer, the installation is a step by step list of commands and tasks… simpler to understand, to do and to test. Hope you’ll be agree.

Sources

In this paragraph are collected the used sources for the installation. I suggest to download and store them in a safe repository for future purposes (re-installation, maintainance, etc.).

Creation of a Virtual Machine with Ubuntu 12.04 LTS – 64bit – Desktop

For development purpose you should create your own environment on a virtual machine useful to customizations and tests. Of course if you are in a production environment you can jump directly to the next paragraph talking about the JDK installation.

In this case we use the Oracle VirtualBox as virtualization product but nothing should happen if you prefer VMPlayer or other solutions.

As first step, create the virtual machine with at least 2Gb RAM and start it using the ‘ubuntu-12.04.1-desktop-amd64.iso’ file. During the installation you receive some easy questions, driving you in the installation task.

Below some suggestions:

  • Admit downloading and installation of third party software and update during installation.
  • Machine name: liferay
  • Password: liferay
  • Launch update manager and reboot (more times until no update or errors). This task is not mandatory but suggested.
  • VirtualBoxMenu -> Devices -> Install Guest Additions
  • Open a terminal and execute:
sudo apt-get update
  • VirtualBoxMenu -> Devices -> Shared folders -> Add a new folder called ‘Desktop’ linked to your desktop.
  • Execute in the terminal:
sudo mount -t vboxsf Desktop /mnt
ls -la /mnt

The last command is done to check everything is properly set.

Java 1.7u9

  • Execute in the terminal:
sudo mkdir -p /opt/java
sudo chown liferay:liferay /opt/java
sudo cp -r /mn/.../jdk-7u9-linux-x64.tar.gz /opt/java
cd /opt/java
gunzip jdk-7u9-linux-x64.tar.gz
tar xvf jdk-7u9-linux-x64.tar
rm jdk-7u9-linux-x64.tar
sudo nano /etc/profile.d/java.sh

.

export JAVA_HOME=/opt/java/jdk1.7.0_09
export PATH=$PATH:$HOME/bin:$JAVA_HOME/bin
  • Exit saving the file content.
  • Exit from the user session (disconnect the user session) and reconnect again to receive the changes.
  • Open a terminal and execute the commands below to test if everything is properly set.
java -version
javac -version

Postgresql 8.4.15

We always prefer to compile PostgreSQL from the sources to have a full control of the installation and customizations.

  • Execute in the terminal:
sudo mkdir -p /opt/postgresql
sudo chown liferay:liferay /opt/postgresql
sudo cp /mnt/.../postgresql-8.4.15.tar.gz /opt/postgresql
cd /opt/postgresql
gunzip postgresql-8.4.15.tar.gz
tar xvf postgresql-8.4.15.tar
rm postgresql-8.4.15.tar
mkdir -p /opt/postgresql/8.4.15
cd /opt/postgresql/postgresql-8.4.15/
sudo apt-get install libreadline-dev
sudo apt-get install zlib1g-dev
./configure exec_prefix=/opt/postgresql/8.4.15
sudo make exec_prefix=/opt/postgresql/8.4.15
sudo make install exec_prefix=/opt/postgresql/8.4.15
  • Let’s create the data directory to store all data files and some configurations comprise defining the postgres user.
mkdir /opt/postgresql/8.4.15/data
mkdir /opt/postgresql/8.4.15/log
sudo adduser postgres
  • Use ‘postgres’. Other informations are optional.
sudo chown -R postgres:postgres /opt/postgresql
 su - postgres
  • Digit the password ‘postgres’.
nano .environment-8.4.15

.

export POSTGRES_VERSION=8.4.15
export LD_LIBRARY_PATH=/opt/postgres/${POSTGRES_VERSION}/lib
export PATH=/opt/postgres/${POSTGRES_VERSION}/bin:${PATH}
  • Exit from the editor saving the file content.
chmod 777 .environment-8.4.15
. .environment-8.4.15
/opt/postgresql/8.4.15/bin/initdb -D /opt/postgresql/8.4.15/data/ --encoding=UNICODE
exit
  • Back to the liferay user, let’s define some scripts used to manage the services.
sudo nano /etc/init.d/postgresql.8.4.15

.

case "$1" in

start)
 echo "Starting postgres"
 /bin/su - postgres -c "/home/postgres/postgresql-8.4.15 start"
 ;;
stop)
 echo "Stopping postgres"
 /bin/su - postgres -c "/home/postgres/postgresql-8.4.15 stop"
 ;;
* )
 echo "Usage: /sbin/service postgresql.8.4.15 {start|stop}"
 exit 1

esac

exit 0
  • Exit from the editor saving the file content.
sudo chmod 777 /etc/init.d/postgresql.8.4.15
su - postgres
  • Digit the password ‘postgres’.
. .environment-8.4.15
nano /home/postgres/postgresql-8.4.15

.

# Parameters: start or stop.
export POSTGRES_VERSION=8.4.15
# Check parameter.
if [ "$1" != "start" ] && [ "$1" != "stop" ]; then
 echo "Specify start or stop as first parameter."
 exit
fi

# Add stop switch.
__STOP_SWITCH=""
if [ "$1" = "stop" ]; then
 __STOP_MODE="smart"
 __STOP_SWITCH="-m $__STOP_MODE"
 echo "Stop switch is: $__STOP_SWITCH"

fi

# Do it.
export LD_LIBRARY_PATH=/opt/postgresql/${POSTGRES_VERSION}/lib
~/.environment-${POSTGRES_VERSION}
/opt/postgresql/${POSTGRES_VERSION}/bin/pg_ctl 
    -D /opt/postgresql/${POSTGRES_VERSION}/data 
    -l /opt/postgresql/${POSTGRES_VERSION}/log/postgresql.log 
    $1 $__STOP_SWITCH

# Alternative command.
# /opt/postgresql/${POSTGRES_VERSION}/bin/postgres -D /opt/postgresql/${POSTGRES_VERSION}/data
  • Exit from the editor saving the file content.
chmod 777 /home/postgres/postgresql-8.4.15
service postgresql.8.4.15 start
exit
  • Back to the liferay user, let’s create the database used from liferay.
su - postgres
  • Digit the password ‘postgres’.
. .environment-8.4.15
/opt/postgresql/8.4.15/bin/psql

.

CREATE ROLE liferay WITH PASSWORD 'liferay' LOGIN;
CREATE DATABASE lportal WITH OWNER liferay;
<ctrl> + d

.

/opt/postgresql/8.4.15/bin/psql -U liferay -d lportal
ALTER USER liferay WITH PASSWORD 'liferay';
<ctrl> + d

.

exit
  • Back to the liferay user.

Apache Tomcat 7.0.35

Now it’s time to install Apache Tomcat.

sudo mkdir /opt/liferay
sudo chown liferay:liferay /opt/liferay
cp /mnt/.../apache-tomcat-7.0.35.tar.gz /opt/liferay
cd /opt/liferay
tar -xvf apache-tomcat-7.0.35.tar.gz
rm -rf apache-tomcat-7.0.35.tar.gz
sudo mv apache-tomcat-7.0.35 /opt/liferay/tomcat
  • Done! Let’s start Tomcat to test everything is working properly.
/opt/liferay/tomcat/bin/startup.sh
  • Open your browser and access to ‘http://localhost:8080’ to test the default Apache page is rendered.
  • Shutdown the server
/opt/liferay/tomcat/bin/shutdown.sh

Liferay 6.1.1 Community Edition GA2 on Tomcat

Not many documentations are well done like the Liferay ones. To this link the steps for Tomcat installation of Liferay.

mkdir /opt/liferay/tomcat/lib/ext
cd /opt/liferay/tomcat/lib/ext
cp /mnt/.../liferay-portal-dependencies-6.1.1-ce-ga2-...zip /opt/liferay/tomcat/lib/ext
unzip liferay-portal-dependencies-6.1.1-ce-ga2-...zip
rm -rf liferay-portal-dependencies-6.1.1-ce-ga2-...zip
mv liferay-portal-dependencies-6.1.1-ce-ga2/*.jar .
rm -rf liferay-portal-dependencies-6.1.1-ce-ga2
  • Extract the Liferay src in a temporary folder. Starting from now we’ll call it $LIFERAY_SOURCE.
  • Copy from $LIFERAY_SOURCE/lib/development to your $TOMCAT_HOME/lib/ext: activation.jar, jms.jar, jta.jar, jutf7.jar, mail.jar, persistence.jar.
  • Copy from $LIFERAY_SOURCE/lib/portal to $TOMCAT_HOME/lib/ext: ccpp.jar.
mkdir -p /opt/liferay/tomcat/temp/liferay/com/liferay/portal/deploy/dependencies
  • Copy from $LIFERAY_SOURCE/lib/development to your $TOMCAT_HOME/temp/liferay/com/liferay/portal/deploy/dependencies: resin.jar, script-10.jar.
sudo cp /mnt/.../postgresql-8.4-703.jdbc4.jar $TOMCAT_HOME/lib/ext.
sudo cp /mnt/.../jta...jar $TOMCAT_HOME/lib/ext.
nano /opt/liferay/tomcat/bin/setenv.sh

.

JAVA_OPTS="$JAVA_OPTS -Dfile.encoding=UTF8 -Dorg.apache.catalina.loader.WebappClassLoader.ENABLE_CLEAR_REFERENCES=false -Duser.timezone=GMT -Xmx1024m -XX:MaxPermSize=256m"
  • Exit from the editor saving the file content.
mkdir -p /opt/liferay/tomcat/conf/Catalina/localhost
nano /opt/liferay/tomcat/conf/Catalina/localhost/ROOT.xml

.

<Context path="" crossContext="true">

<!-- JAAS -->

<!--<Realm
    className="org.apache.catalina.realm.JAASRealm"
    appName="PortalRealm"
    userClassNames="com.liferay.portal.kernel.security.jaas.PortalPrincipal"
    roleClassNames="com.liferay.portal.kernel.security.jaas.PortalRole"
/>-->

<!--
Uncomment the following to disable persistent sessions across reboots.
-->

<!--<Manager pathname="" />-->

<!--
Uncomment the following to not use sessions. See the property
"session.disabled" in portal.properties.
-->

<!--<Manager className="com.liferay.support.tomcat.session.SessionLessManagerBase" />-->

</Context>
  • Exit from the editor saving the file content.
nano /opt/liferay/tomcat/conf/catalina.properties
  • Replace:
common.loader=${catalina.base}/lib,${catalina.base}/lib/*.jar,${catalina.home}/lib,${catalina.home}/lib/*.jar

with:

common.loader=${catalina.base}/lib,${catalina.base}/lib/*.jar,${catalina.home}/lib,${catalina.home}/lib/*.jar,${catalina.home}/lib/ext,${catalina.home}/lib/ext/*.jar
  • Exit from the editor saving the file content.
nano /opt/liferay/tomcat/conf/server.xml
  • Modify with the …URIEncoding…:
<Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" URIEncoding="UTF-8" />
  • Exit from the editor saving the file content.
  • Make sure there is no support-catalina.jar file in your $TOMCAT_HOME/webapps directory. If you find one, remove it.
rm -rf /opt/liferay/tomcat/webapps/ROOT/*
cp liferay-portal-6.1.1-ce-ga2-...war /opt/liferay/tomcat/webapps/ROOT
cd /opt/liferay/tomcat/webapps/ROOT
jar -xf /opt/liferay/tomcat/webapps/ROOT/liferay-portal-6.1.1-ce-ga2-...war
rm /opt/liferay/tomcat/webapps/ROOT/liferay-portal-6.1.1-ce-ga2-...war
nano /opt/liferay/tomcat/webapps/ROOT/WEB-INF/classes/portal-ext.properties

.

jdbc.default.driverClassName=org.postgresql.Driver
jdbc.default.url=jdbc:postgresql://localhost:5432/lportal
jdbc.default.username=liferay
jdbc.default.password=liferay

setup.wizard.enabled=true
  • Exit from the editor saving the file content.
/opt/liferay/tomcat/bin/startup.sh
tail -f /opt/liferay/tomcat/logs/catalina.out
  • Browse configuration wizard at ‘http://localhost:8080’.
  • Set administrator with login:admin, password:admin. During nexts steps confirm ‘admin’ password.
nano /opt/liferay/tomcat/webapps/ROOT/WEB-INF/classes/portal-ext.properties

.

#setup.wizard.enabled=true
  • Exit from the editor saving the file content.
/opt/liferay/tomcat/bin/shutdown.sh
sudo nano /etc/init.d/liferay

.

case "$1" in

start)
 /bin/su - liferay -c "/opt/liferay/tomcat/bin/startup.sh"
 ;;
stop)
 /bin/su - liferay -c "/opt/liferay/tomcat/bin/shutdown.sh"

 ;;
* )
 echo "Usage:service liferay {start|stop}"
 exit 1

esac

exit 0
  • Exit from the editor saving the file content.
sudo chmod 777 /etc/init.d/liferay
service liferay start

My personal compliments… Liferay on Tomcat and PostgreSQL is installed with success!