Tuesday 25 November 2014

Aspera File Transfer Integration with Liferay and Alfresco


About Aspera:

Many a times, we have requirement for transferring large amount of files. 

  • Aspera software solutions helps us to move large volumes of data over public and private IP networks efficiently.
  • Aspera works on fasp™ transfer technology.
  • This technology delivers maximum transfer speed regardless of network conditions and transfer distance. 
  • It eliminates the inherent weaknesses of conventional file transfer technologies such as FTP, HTTP and dramatically speeds transfers over public and private IP networks securely. 
  • Also it tracks down failed file transfers. And if destination server is down, Aspera automatically resumes partial transfers and retries failed transfers.

For more Information : AsperaSoft




 Liferay Portal can be used as front end and AlfrescoECM as backend technology for File Transfers:

1. Download Aspera Connect Plugin from http://downloads.asperasoft.com
2. Create a custom portlet in Liferay that allows users to upload files. 
3. Configure Aspera API to upload multiple files to Aspera Connect (Aspera Server).  
4. Aspera server is configured to inject the files into Alfresco repository using REST based API.


Alfresco Server:
The content ingestion is performed using importer script. The importer can be deployed by copying the 'webscripts' directory (and all its contents ) to [Alfresco_HOME]/ tomcat/shared/classes/alfresco/extension/templates. The 'templates' directory shall not be existing so create it prior to copying.


Note that in [ALFRESCO_HOME]/tomcat/shared/classes/alfresco-global.properties, 
"dir.root" property is set to an absolute path. This path will also be used for Aspera Server as docroot directory.

Create a new site in Alfresco repository via Alfresco Share. Create a folder in the site, eg. uploadsFromAspera. 
This folder will be the root directory for all the uploads that will be done.
It also is the root directory for all the contents that will be ingested into the Alfresco CMS.
From Alfresco view point, this folder will referenced using either its nodeRef or its path. Both values can be fetched using the administration console.

We can use the Repository Browser - http://HOSTNAME:PORT/share/page/repository - to navigate and get the path of the newly created folder:
eg. Sites/siteName/documentLibrary/uploadsFromAspera

Aspera Server:
In [ASPERA_HOME]/etc/aspera.conf, configure the docroot directory to be at least a sub-directory of Alfresco ${dir.root}/contentstore.
Eg. FILE: [ALFRESCO_HOME]/tomcat/shared/classes/alfresco-global.properties
dir.root=C:/Alfresco/alf_data
FILE: [ASPERA_HOME]/etc/aspera.conf

Liferay:
There is metadata information needed by Alfresco importer (name, title,
description, mime-type, encoding, locale of file to be uploaded).
 There is a front end directory provided by Aspera which contains several Javascript files:
- e.g. - asperaweb-2.js : the Aspera Connect plugin API

Custom portlet developed in Liferay, needs to provide below information:

- a transfer specification object

transferSpec = {
"paths": [],
"remote_host": remoteAsperaServer,
"remote_user": remoteUser,
"remote_password": remotePassword,
"direction": "send",
"target_rate" : 5000,
"resume_check" : "sparse",
"create_dir":true
};

- a call to perform the upload

asperaWeb.startTransfer(transferSpec, aspera_connect_settings, callbacks = {
error : function(obj) {
console.log("Upload failed to start : " +
JSON.stringify(obj, null, 4));
},
success:function () {
console.log("success ...");
disableButton("#upload_form
#upload_button");
}
});

Encode the content’s metadata as cookie for the transfer specification. Cookie format:

COOKIE="mimetype":" encoding":"locale":"cm:title":"cm:name":"cm:description";
Example:
cookie="video/mp4 : UTF-8: en_US_: My Title:my_file.mp4: My description"
The metadata can also be encoded using tags attributes of transferSpec. Tags convention for transfer specification is tags.company or tags.domain. 


Aspera Pre/Post Processing
The uploaded file are available in the docroot path configured in aspera.conf (configuration file of Aspera Server). To make the link with Alfresco CMS, the content will be ingested in CMS when the upload is completed. Aspera pre/post processing offers the possibility to run programs on the occurrence of events during the lifetime of transfer session and transfer files. When a file is successfully uploaded (two conditions TYPE is file and STATE is success), a script (ingest.pl - perl script ) is called to perform the ingestion into CMS. The ingestion is done using the REST API supplied by Alfresco.

Thanks for reading. Happy Learning!