Example usage for com.liferay.portal.kernel.zip ZipReader getEntryAsByteArray

List of usage examples for com.liferay.portal.kernel.zip ZipReader getEntryAsByteArray

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.zip ZipReader getEntryAsByteArray.

Prototype

public byte[] getEntryAsByteArray(String name);

Source Link

Usage

From source file:de.unioninvestment.eai.portal.portlet.crud.export.CrudPortletDataHandler.java

License:Apache License

@Override
public PortletPreferences doImportData(PortletDataContext context, String portletId,
        PortletPreferences preferences, String data) throws PortletDataException {

    long communityId = context.getScopeGroupId();

    LOGGER.debug("Importing CRUD portlet data for portletId {}, communityId {}", portletId, communityId);

    checkCompatibility(preferences);/*ww w  .j a v a 2s  .  co m*/

    try {
        ZipReader zipReader = context.getZipReader();
        byte[] portletConfigData = zipReader.getEntryAsByteArray(portletId + "/portletConfiguration.xml");

        if (portletConfigData != null) {
            configurationService.storeConfigurationFile(data, portletConfigData, portletId, communityId,
                    "import");

            Map<String, Long> newRoleIds = createResourceRoles(portletId, communityId, preferences);

            importPermissions(context, preferences, newRoleIds);
        }

        return null;

    } catch (RuntimeException e) {
        throw new PortletDataException("Error importing portlet " + portletId + "/" + communityId, e);
    }
}