Message Boards

ExportImportConfiguration

Daniel G, modified 2 Years ago.

ExportImportConfiguration

Regular Member Posts: 141 Join Date: 3/14/17 Recent Posts

Hi,

I am trying to import programatically a navigation menu from one site to another. I export from the control panel the file from origin site, and then I recover it from database with this:


configuration = ExportImportConfigurationLocalServiceUtil.getExportImportConfiguration(siteId);
file = ExportImportLocalServiceUtil.exportLayoutsAsFile(
    configuration );

Now I am trying to import to other file with this

ExportImportLocalService.importLayouts(ExportImportConfiguration exportImportConfiguration, File file)

but I don't know how to create the new ExportImportConfiguration object. Could anyone help me?

Thanks in advance

Regards,

thumbnail
Zsigmond Rab, modified 2 Years ago.

RE: ExportImportConfiguration

Liferay Master Posts: 727 Join Date: 1/5/10 Recent Posts

Hi Daniel,

Have you tried the examples that you can find in the portal source?

For example: https://github.com/liferay/liferay-portal/blob/master/portal-impl/src/com/liferay/portal/events/ServicePreAction.java#L225-L266

Can that work to you?

Regards,

Zsigmond

Daniel G, modified 2 Years ago.

RE: ExportImportConfiguration

Regular Member Posts: 141 Join Date: 3/14/17 Recent Posts

Hi,

First of all, thanks for the help. I was able to create exportIMport configuration with you link, but when I try to import, I received a 

com.liferay.exportimport.kernel.exception.LARTypeException

The file which I am trying to import is a lar file generated from the control panel, and not modified. Do you have any idea wy this is happening?

Thanks!

Regards

thumbnail
Zsigmond Rab, modified 2 Years ago.

RE: ExportImportConfiguration

Liferay Master Posts: 727 Join Date: 1/5/10 Recent Posts

Hi Daniel,

That may come if the LAR type is not one of the predifined ones, "layout-prototype", "layout-set" or "layout-set-prototype". You could debug on the code level to see what is coming during processing the LAR.

Otherwise, knowing where on the Control Panel you generated the LAR file exactly or a step by step description of what your trying may help to find the problem.

Zsigmond

Daniel G, modified 2 Years ago.

RE: ExportImportConfiguration

Regular Member Posts: 141 Join Date: 3/14/17 Recent Posts

Hi,

Thanks for the help. I was generating an export lar file of the navigation menu a site(Liferay 7.3). Menu - Site Builder -  Navigation menus

Regards,

thumbnail
Zsigmond Rab, modified 2 Years ago.

RE: ExportImportConfiguration

Liferay Master Posts: 727 Join Date: 1/5/10 Recent Posts

Hi,

Ok, I think the problem is that the LAR file you exported there is a portlet type LAR file that contains all the data from the Navigation Menus portlet. That won't work in your code as that is for layouts. You can use LAR file that has been exported from a site, site temple, or page template.

Regards,

Zsigmond