« Back

Tips for importing Liferay LAR files

We've been importing from our old Liferay 6.1 instance to a clean Liferay 6.1 instance to remove the junk and fix permissions. Even though both versions are the same, you still might have to extract the LAR file, make some changes and then re-zip it to be successful.

Change the language to match your locale

Our original site was set to en_AU but our new site was set correctly to en_AU. We can't import without fixing all the references first:

find . -name "*.xml" -exec perl -i -pe 's/en_AU/en_AU/g' {} \;

Changing the locale also requires a "titleMap" to be created for each article:

find . -name "article.xml" -exec perl -i -pe 's/<__title>(.*)<\/__title>/<__title><?xml version='1.0' encoding='UTF-8'?><root available-locales="en_AU" default-locale="en_AU"><Title language-id="en_AU">\1<\/Title><\/root><\/__title>/g' {} \;

Otherwise you'll get the following exception:

    at com.liferay.portlet.journal.service.impl.JournalArticleLocalServiceImpl.validate(JournalArticleLocalServiceImpl.java:3459)
    at com.liferay.portlet.journal.service.impl.JournalArticleLocalServiceImpl.validate(JournalArticleLocalServiceImpl.java:3549)
    at com.liferay.portlet.journal.service.impl.JournalArticleLocalServiceImpl.addArticle(JournalArticleLocalServiceImpl.java:192)

Set the upload request size

Make sure your upload file limit is sufficient in portal-ext.properties:

# Set the maximum file size. Default is 1024 * 1024 * 100.

Otherwise you'll get the following exception because the uploaded LAR file will disappear:

    at com.liferay.portlet.layoutsadmin.action.ImportLayoutsAction.processAction(ImportLayoutsAction.java:67)
    at com.liferay.portal.struts.PortletRequestProcessor.process(PortletRequestProcessor.java:169)
    at com.liferay.portlet.StrutsPortlet.processAction(StrutsPortlet.java:212)
    at com.liferay.portlet.FilterChainImpl.doFilter(FilterChainImpl.java:70)
    at com.liferay.portal.kernel.portlet.PortletFilterUtil.doFilter(PortletFilterUtil.java:48)
    at com.liferay.portlet.InvokerPortletImpl.invoke(InvokerPortletImpl.java:548)
    at com.liferay.portlet.InvokerPortletImpl.invokeAction(InvokerPortletImpl.java:579)
    at com.liferay.portlet.InvokerPortletImpl.processAction(InvokerPortletImpl.java:294)
    at com.liferay.portal.action.LayoutAction.processPortletRequest(LayoutAction.java:944)
    at com.liferay.portal.action.LayoutAction.processLayout(LayoutAction.java:688)
    at com.liferay.portal.action.LayoutAction.execute(LayoutAction.java:249)

Preserve the user history

Liferay uses the UUID for each user to restore the history of who changed information such as blogs, forum posts, etc. Unfortunately, our new instance has completely different UUIDs to the old one but the same screen names. To fix this, I had to create a mapping between the new and old UUIDs for each user using the screen name. In the two databases, I ran the following query:

select screenName, UUID_ from User_;

I then massaged this into the following search/replace via LibreOffice Calc:

find . -name "*.xml" -exec perl -pi -w -e s/e94d8920-c5ca-4e1e-b4c7-0463930fcbc1/e94d8920-c5ca-4e1e-b4c7-0463930fcbc1/g {} \;
find . -name "*.xml" -exec perl -pi -w -e s/afd2437e-3130-4056-94e2-2160bf7aa732/afd2437e-3130-4056-94e2-2160bf7aa732/g {} \;
find . -name "*.xml" -exec perl -pi -w -e s/45db6666-5ca6-4589-bc5c-4b5795812268/45db6666-5ca6-4589-bc5c-4b5795812268/g {} \;
find . -name "*.xml" -exec perl -pi -w -e s/5b90e1c9-12d6-4495-875e-2ce5a97a16f1/5b90e1c9-12d6-4495-875e-2ce5a97a16f1/g {} \;
find . -name "*.xml" -exec perl -pi -w -e s/b245b26a-43c3-4cd8-af3a-3f8aa157e68a/b245b26a-43c3-4cd8-af3a-3f8aa157e68a/g {} \;
find . -name "*.xml" -exec perl -pi -w -e s/6698913f-ab46-4acc-8c66-8cc80a3b209f/6698913f-ab46-4acc-8c66-8cc80a3b209f/g {} \;





No comments yet. Be the first.