Example usage for com.liferay.portal.kernel.model Group isLayoutPrototype

List of usage examples for com.liferay.portal.kernel.model Group isLayoutPrototype

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.model Group isLayoutPrototype.

Prototype

public boolean isLayoutPrototype();

Source Link

Usage

From source file:com.liferay.asset.publisher.internal.util.AssetPublisherHelperImpl.java

License:Open Source License

@Override
public String getScopeId(Group group, long scopeGroupId) {
    String key = null;/*ww w  .j  av a 2  s  .co m*/

    if (group.isLayout()) {
        Layout layout = _layoutLocalService.fetchLayout(group.getClassPK());

        key = SCOPE_ID_LAYOUT_UUID_PREFIX + layout.getUuid();
    } else if (group.isLayoutPrototype() || (group.getGroupId() == scopeGroupId)) {

        key = SCOPE_ID_GROUP_PREFIX + GroupConstants.DEFAULT;
    } else {
        Group scopeGroup = _groupLocalService.fetchGroup(scopeGroupId);

        if (scopeGroup.hasAncestor(group.getGroupId())
                && SitesUtil.isContentSharingWithChildrenEnabled(group)) {

            key = SCOPE_ID_PARENT_GROUP_PREFIX + group.getGroupId();
        } else if (group.hasAncestor(scopeGroup.getGroupId())) {
            key = SCOPE_ID_CHILD_GROUP_PREFIX + group.getGroupId();
        } else {
            key = SCOPE_ID_GROUP_PREFIX + group.getGroupId();
        }
    }

    return key;
}

From source file:com.liferay.asset.publisher.web.internal.ChildSitesItemSelectorView.java

License:Open Source License

@Override
public boolean isVisible(ThemeDisplay themeDisplay) {
    Group siteGroup = themeDisplay.getSiteGroup();

    if (siteGroup.isLayoutPrototype()) {
        return false;
    }/*  w w  w. j  a  v a  2s  .c o  m*/

    if (siteGroup.isLayoutSetPrototype()) {
        return false;
    }

    int groupsCount = _groupLocalService.getGroupsCount(themeDisplay.getCompanyId(), siteGroup.getGroupId(),
            Boolean.TRUE);

    if (groupsCount > 0) {
        return true;
    }

    return false;
}

From source file:com.liferay.asset.publisher.web.internal.ParentSitesItemSelectorView.java

License:Open Source License

@Override
public boolean isVisible(ThemeDisplay themeDisplay) {
    Group siteGroup = themeDisplay.getSiteGroup();

    if (siteGroup.isLayoutPrototype()) {
        return false;
    }// w w  w . j  ava  2 s  . co  m

    if (siteGroup.isLayoutSetPrototype()) {
        return false;
    }

    if (siteGroup.isRoot()) {
        return false;
    }

    return true;
}

From source file:com.liferay.asset.publisher.web.internal.SitesThatIAdministerItemSelectorView.java

License:Open Source License

@Override
public boolean isVisible(ThemeDisplay themeDisplay) {
    Group siteGroup = themeDisplay.getSiteGroup();

    if (siteGroup.isLayoutPrototype()) {
        return false;
    }//from   ww w  . ja  va 2s  .c  om

    if (siteGroup.isLayoutSetPrototype()) {
        return false;
    }

    if (PrefsPropsUtil.getBoolean(themeDisplay.getCompanyId(),
            PropsKeys.SITES_CONTENT_SHARING_THROUGH_ADMINISTRATORS_ENABLED)) {

        return true;
    }

    return false;
}

From source file:com.liferay.asset.publisher.web.util.AssetPublisherUtil.java

License:Open Source License

public static String getScopeId(Group group, long scopeGroupId) {
    String key = null;/*w  w  w. j a v a  2s . c  o m*/

    if (group.isLayout()) {
        Layout layout = _layoutLocalService.fetchLayout(group.getClassPK());

        key = SCOPE_ID_LAYOUT_UUID_PREFIX + layout.getUuid();
    } else if (group.isLayoutPrototype() || (group.getGroupId() == scopeGroupId)) {

        key = SCOPE_ID_GROUP_PREFIX + GroupConstants.DEFAULT;
    } else {
        Group scopeGroup = _groupLocalService.fetchGroup(scopeGroupId);

        if (scopeGroup.hasAncestor(group.getGroupId())
                && SitesUtil.isContentSharingWithChildrenEnabled(group)) {

            key = SCOPE_ID_PARENT_GROUP_PREFIX + group.getGroupId();
        } else if (group.hasAncestor(scopeGroup.getGroupId())) {
            key = SCOPE_ID_CHILD_GROUP_PREFIX + group.getGroupId();
        } else {
            key = SCOPE_ID_GROUP_PREFIX + group.getGroupId();
        }
    }

    return key;
}

From source file:com.liferay.exportimport.controller.LayoutExportController.java

License:Open Source License

protected File doExport(PortletDataContext portletDataContext) throws Exception {

    Map<String, String[]> parameterMap = portletDataContext.getParameterMap();

    boolean ignoreLastPublishDate = MapUtil.getBoolean(parameterMap,
            PortletDataHandlerKeys.IGNORE_LAST_PUBLISH_DATE);
    boolean permissions = MapUtil.getBoolean(parameterMap, PortletDataHandlerKeys.PERMISSIONS);

    if (_log.isDebugEnabled()) {
        _log.debug("Export permissions " + permissions);
    }/*  w ww  . jav  a  2  s .c  o m*/

    long companyId = portletDataContext.getCompanyId();

    long defaultUserId = _userLocalService.getDefaultUserId(companyId);

    ServiceContext serviceContext = ServiceContextThreadLocal.popServiceContext();

    if (serviceContext == null) {
        serviceContext = new ServiceContext();
    }

    serviceContext.setCompanyId(companyId);
    serviceContext.setSignedIn(true);

    if (BackgroundTaskThreadLocal.hasBackgroundTask()) {
        BackgroundTask backgroundTask = _backgroundTaskLocalService
                .getBackgroundTask(BackgroundTaskThreadLocal.getBackgroundTaskId());

        serviceContext.setUserId(backgroundTask.getUserId());
    } else {
        serviceContext.setUserId(defaultUserId);
    }

    serviceContext.setAttribute("exporting", Boolean.TRUE);

    long layoutSetBranchId = MapUtil.getLong(parameterMap, "layoutSetBranchId");

    serviceContext.setAttribute("layoutSetBranchId", layoutSetBranchId);

    ServiceContextThreadLocal.pushServiceContext(serviceContext);

    if (ignoreLastPublishDate) {
        portletDataContext.setEndDate(null);
        portletDataContext.setStartDate(null);
    }

    StopWatch stopWatch = new StopWatch();

    stopWatch.start();

    Document document = SAXReaderUtil.createDocument();

    Element rootElement = document.addElement("root");

    portletDataContext.setExportDataRootElement(rootElement);

    Element headerElement = rootElement.addElement("header");

    headerElement.addAttribute("available-locales",
            StringUtil.merge(LanguageUtil.getAvailableLocales(portletDataContext.getScopeGroupId())));

    headerElement.addAttribute("build-number", String.valueOf(ReleaseInfo.getBuildNumber()));

    headerElement.addAttribute("schema-version", ExportImportConstants.EXPORT_IMPORT_SCHEMA_VERSION);

    headerElement.addAttribute("export-date", Time.getRFC822());

    if (portletDataContext.hasDateRange()) {
        headerElement.addAttribute("start-date", String.valueOf(portletDataContext.getStartDate()));
        headerElement.addAttribute("end-date", String.valueOf(portletDataContext.getEndDate()));
    }

    headerElement.addAttribute("company-id", String.valueOf(portletDataContext.getCompanyId()));
    headerElement.addAttribute("company-group-id", String.valueOf(portletDataContext.getCompanyGroupId()));
    headerElement.addAttribute("group-id", String.valueOf(portletDataContext.getGroupId()));
    headerElement.addAttribute("user-personal-site-group-id",
            String.valueOf(portletDataContext.getUserPersonalSiteGroupId()));
    headerElement.addAttribute("private-layout", String.valueOf(portletDataContext.isPrivateLayout()));

    Group group = _groupLocalService.fetchGroup(portletDataContext.getGroupId());

    String type = "layout-set";

    if (group.isLayoutPrototype()) {
        type = "layout-prototype";

        LayoutPrototype layoutPrototype = _layoutPrototypeLocalService.getLayoutPrototype(group.getClassPK());

        headerElement.addAttribute("type-uuid", layoutPrototype.getUuid());
    } else if (group.isLayoutSetPrototype()) {
        type = "layout-set-prototype";

        LayoutSetPrototype layoutSetPrototype = _layoutSetPrototypeLocalService
                .getLayoutSetPrototype(group.getClassPK());

        headerElement.addAttribute("type-uuid", layoutSetPrototype.getUuid());
    }

    headerElement.addAttribute("type", type);
    portletDataContext.setType(type);

    Element missingReferencesElement = rootElement.addElement("missing-references");

    portletDataContext.setMissingReferencesElement(missingReferencesElement);

    rootElement.addElement("site-portlets");
    rootElement.addElement("site-services");

    // Export the group

    LayoutSet layoutSet = _layoutSetLocalService.getLayoutSet(portletDataContext.getGroupId(),
            portletDataContext.isPrivateLayout());

    String layoutSetPrototypeUuid = layoutSet.getLayoutSetPrototypeUuid();

    boolean layoutSetPrototypeSettings = MapUtil.getBoolean(portletDataContext.getParameterMap(),
            PortletDataHandlerKeys.LAYOUT_SET_PROTOTYPE_SETTINGS);

    if (!group.isStaged() && Validator.isNotNull(layoutSetPrototypeUuid) && layoutSetPrototypeSettings) {

        LayoutSetPrototype layoutSetPrototype = _layoutSetPrototypeLocalService
                .getLayoutSetPrototypeByUuidAndCompanyId(layoutSetPrototypeUuid, companyId);

        headerElement.addAttribute("layout-set-prototype-uuid", layoutSetPrototypeUuid);

        headerElement.addAttribute("layout-set-prototype-name",
                layoutSetPrototype.getName(LocaleUtil.getDefault()));
    }

    StagedGroup stagedGroup = ModelAdapterUtil.adapt(group, Group.class, StagedGroup.class);

    StagedModelDataHandlerUtil.exportStagedModel(portletDataContext, stagedGroup);

    // Export other models

    _portletExportController.exportAssetLinks(portletDataContext);
    _portletExportController.exportExpandoTables(portletDataContext);
    _portletExportController.exportLocks(portletDataContext);

    portletDataContext.addDeletionSystemEventStagedModelTypes(new StagedModelType(StagedAssetLink.class));

    _deletionSystemEventExporter.exportDeletionSystemEvents(portletDataContext);

    if (permissions) {
        _permissionExporter.exportPortletDataPermissions(portletDataContext);
    }

    _exportImportHelper.writeManifestSummary(document, portletDataContext.getManifestSummary());

    if (_log.isInfoEnabled()) {
        _log.info("Exporting layouts takes " + stopWatch.getTime() + " ms");
    }

    portletDataContext.addZipEntry("/manifest.xml", document.formattedString());

    ZipWriter zipWriter = portletDataContext.getZipWriter();

    return zipWriter.getFile();
}

From source file:com.liferay.exportimport.controller.LayoutImportController.java

License:Open Source License

protected void doImportFile(PortletDataContext portletDataContext, long userId) throws Exception {

    Map<String, String[]> parameterMap = portletDataContext.getParameterMap();

    Group group = _groupLocalService.getGroup(portletDataContext.getGroupId());

    String layoutsImportMode = MapUtil.getString(parameterMap, PortletDataHandlerKeys.LAYOUTS_IMPORT_MODE,
            PortletDataHandlerKeys.LAYOUTS_IMPORT_MODE_MERGE_BY_LAYOUT_UUID);
    boolean permissions = MapUtil.getBoolean(parameterMap, PortletDataHandlerKeys.PERMISSIONS);

    if (group.isLayoutSetPrototype()) {
        parameterMap.put(PortletDataHandlerKeys.LAYOUT_SET_PROTOTYPE_LINK_ENABLED,
                new String[] { Boolean.FALSE.toString() });
    }//from ww  w .ja  v a2  s . c  om

    if (_log.isDebugEnabled()) {
        _log.debug("Import permissions " + permissions);
    }

    StopWatch stopWatch = new StopWatch();

    stopWatch.start();

    LayoutCache layoutCache = new LayoutCache();

    long companyId = portletDataContext.getCompanyId();

    ServiceContext serviceContext = ServiceContextThreadLocal.getServiceContext();

    if (serviceContext == null) {
        serviceContext = new ServiceContext();
    }

    serviceContext.setCompanyId(companyId);
    serviceContext.setSignedIn(false);
    serviceContext.setUserId(userId);

    ServiceContextThreadLocal.pushServiceContext(serviceContext);

    // LAR validation

    validateFile(companyId, portletDataContext.getGroupId(), parameterMap, portletDataContext.getZipReader());

    // Source and target group id

    Map<Long, Long> groupIds = (Map<Long, Long>) portletDataContext.getNewPrimaryKeysMap(Group.class);

    groupIds.put(portletDataContext.getSourceGroupId(), portletDataContext.getGroupId());

    // Manifest

    ManifestSummary manifestSummary = _exportImportHelper.getManifestSummary(portletDataContext);

    portletDataContext.setManifestSummary(manifestSummary);

    // Layout and layout set prototype

    Element rootElement = portletDataContext.getImportDataRootElement();

    Element headerElement = rootElement.element("header");

    String layoutSetPrototypeUuid = headerElement.attributeValue("layout-set-prototype-uuid");

    String larType = headerElement.attributeValue("type");

    portletDataContext.setType(larType);

    if (group.isLayoutPrototype() && larType.equals("layout-prototype")) {
        parameterMap.put(PortletDataHandlerKeys.DELETE_MISSING_LAYOUTS,
                new String[] { Boolean.FALSE.toString() });

        LayoutPrototype layoutPrototype = _layoutPrototypeLocalService.getLayoutPrototype(group.getClassPK());

        String layoutPrototypeUuid = GetterUtil.getString(headerElement.attributeValue("type-uuid"));

        LayoutPrototype existingLayoutPrototype = null;

        if (Validator.isNotNull(layoutPrototypeUuid)) {
            try {
                existingLayoutPrototype = _layoutPrototypeLocalService
                        .getLayoutPrototypeByUuidAndCompanyId(layoutPrototypeUuid, companyId);
            } catch (NoSuchLayoutPrototypeException nslpe) {

                // LPS-52675

                if (_log.isDebugEnabled()) {
                    _log.debug(nslpe, nslpe);
                }
            }
        }

        if (existingLayoutPrototype == null) {
            List<Layout> layouts = _layoutLocalService
                    .getLayoutsByLayoutPrototypeUuid(layoutPrototype.getUuid());

            layoutPrototype.setUuid(layoutPrototypeUuid);

            _layoutPrototypeLocalService.updateLayoutPrototype(layoutPrototype);

            for (Layout layout : layouts) {
                layout.setLayoutPrototypeUuid(layoutPrototypeUuid);

                _layoutLocalService.updateLayout(layout);
            }
        }
    } else if (group.isLayoutSetPrototype() && larType.equals("layout-set-prototype")) {

        parameterMap.put(PortletDataHandlerKeys.LAYOUT_SET_PROTOTYPE_SETTINGS,
                new String[] { Boolean.TRUE.toString() });

        LayoutSetPrototype layoutSetPrototype = _layoutSetPrototypeLocalService
                .getLayoutSetPrototype(group.getClassPK());

        String importedLayoutSetPrototypeUuid = GetterUtil.getString(headerElement.attributeValue("type-uuid"));

        LayoutSetPrototype existingLayoutSetPrototype = null;

        if (Validator.isNotNull(importedLayoutSetPrototypeUuid)) {
            try {
                existingLayoutSetPrototype = _layoutSetPrototypeLocalService
                        .getLayoutSetPrototypeByUuidAndCompanyId(importedLayoutSetPrototypeUuid, companyId);
            } catch (NoSuchLayoutSetPrototypeException nslspe) {

                // LPS-52675

                if (_log.isDebugEnabled()) {
                    _log.debug(nslspe, nslspe);
                }
            }
        }

        if (existingLayoutSetPrototype == null) {
            List<LayoutSet> layoutSets = _layoutSetLocalService
                    .getLayoutSetsByLayoutSetPrototypeUuid(layoutSetPrototype.getUuid());

            layoutSetPrototype.setUuid(importedLayoutSetPrototypeUuid);

            _layoutSetPrototypeLocalService.updateLayoutSetPrototype(layoutSetPrototype);

            for (LayoutSet curLayoutSet : layoutSets) {
                curLayoutSet.setLayoutSetPrototypeUuid(importedLayoutSetPrototypeUuid);

                _layoutSetLocalService.updateLayoutSet(curLayoutSet);
            }
        }
    } else if (larType.equals("layout-set-prototype")) {
        parameterMap.put(PortletDataHandlerKeys.LAYOUT_SET_PROTOTYPE_SETTINGS,
                new String[] { Boolean.TRUE.toString() });

        layoutSetPrototypeUuid = GetterUtil.getString(headerElement.attributeValue("type-uuid"));
    }

    if (Validator.isNotNull(layoutSetPrototypeUuid)) {
        portletDataContext.setLayoutSetPrototypeUuid(layoutSetPrototypeUuid);
    }

    List<Element> portletElements = fetchPortletElements(rootElement);

    if (permissions) {
        for (Element portletElement : portletElements) {
            String portletPath = portletElement.attributeValue("path");

            Document portletDocument = SAXReaderUtil.read(portletDataContext.getZipEntryAsString(portletPath));

            _permissionImporter.checkRoles(layoutCache, companyId, portletDataContext.getGroupId(), userId,
                    portletDocument.getRootElement());
        }

        _permissionImporter.readPortletDataPermissions(portletDataContext);
    }

    if (!layoutsImportMode.equals(PortletDataHandlerKeys.LAYOUTS_IMPORT_MODE_CREATED_FROM_PROTOTYPE)) {

        _portletImportController.readExpandoTables(portletDataContext);
    }

    _portletImportController.readLocks(portletDataContext);

    // Import the group

    Element groupsElement = portletDataContext.getImportDataGroupElement(StagedGroup.class);

    for (Element groupElement : groupsElement.elements()) {
        StagedModelDataHandlerUtil.importStagedModel(portletDataContext, groupElement);
    }

    // Asset links

    _portletImportController.importAssetLinks(portletDataContext);

    // Site

    _groupLocalService.updateSite(portletDataContext.getGroupId(), true);

    if (_log.isInfoEnabled()) {
        _log.info("Importing layouts takes " + stopWatch.getTime() + " ms");
    }

    ZipReader zipReader = portletDataContext.getZipReader();

    zipReader.close();
}

From source file:com.liferay.exportimport.controller.LayoutImportController.java

License:Open Source License

protected void validateFile(long companyId, long groupId, Map<String, String[]> parameterMap,
        ZipReader zipReader) throws Exception {

    // XML/*www .ja v a 2 s.c o  m*/

    String xml = zipReader.getEntryAsString("/manifest.xml");

    if (xml == null) {
        throw new LARFileException(LARFileException.TYPE_MISSING_MANIFEST);
    }

    Element rootElement = null;

    try {
        Document document = SAXReaderUtil.read(xml);

        rootElement = document.getRootElement();
    } catch (Exception e) {
        throw new LARFileException(LARFileException.TYPE_INVALID_MANIFEST, e);
    }

    // Bundle compatibility

    Element headerElement = rootElement.element("header");

    int importBuildNumber = GetterUtil.getInteger(headerElement.attributeValue("build-number"));

    if (importBuildNumber < ReleaseInfo.RELEASE_7_0_0_BUILD_NUMBER) {
        int buildNumber = ReleaseInfo.getBuildNumber();

        if (buildNumber != importBuildNumber) {
            throw new LayoutImportException(LayoutImportException.TYPE_WRONG_BUILD_NUMBER,
                    new Object[] { importBuildNumber, buildNumber });
        }
    } else {
        BiPredicate<Version, Version> majorVersionBiPredicate = (currentVersion, importVersion) -> Objects
                .equals(currentVersion.getMajor(), importVersion.getMajor());

        BiPredicate<Version, Version> minorVersionBiPredicate = (currentVersion, importVersion) -> {
            int currentMinorVersion = GetterUtil.getInteger(currentVersion.getMinor(), -1);
            int importedMinorVersion = GetterUtil.getInteger(importVersion.getMinor(), -1);

            if (((currentMinorVersion == -1) && (importedMinorVersion == -1))
                    || (currentMinorVersion < importedMinorVersion)) {

                return false;
            }

            return true;
        };

        BiPredicate<Version, Version> manifestVersionBiPredicate = (currentVersion, importVersion) -> {
            BiPredicate<Version, Version> versionBiPredicate = majorVersionBiPredicate
                    .and(minorVersionBiPredicate);

            return versionBiPredicate.test(currentVersion, importVersion);
        };

        String importSchemaVersion = GetterUtil.getString(headerElement.attributeValue("schema-version"),
                "1.0.0");

        if (!manifestVersionBiPredicate.test(
                Version.getInstance(ExportImportConstants.EXPORT_IMPORT_SCHEMA_VERSION),
                Version.getInstance(importSchemaVersion))) {

            throw new LayoutImportException(LayoutImportException.TYPE_WRONG_LAR_SCHEMA_VERSION,
                    new Object[] { importSchemaVersion, ExportImportConstants.EXPORT_IMPORT_SCHEMA_VERSION });
        }
    }

    // Type

    String larType = headerElement.attributeValue("type");

    String[] expectedLARTypes = { "layout-prototype", "layout-set", "layout-set-prototype" };

    Stream<String> stream = Stream.of(expectedLARTypes);

    if (stream.noneMatch(lt -> lt.equals(larType))) {
        throw new LARTypeException(larType, expectedLARTypes);
    }

    Group group = _groupLocalService.fetchGroup(groupId);

    String layoutsImportMode = MapUtil.getString(parameterMap, PortletDataHandlerKeys.LAYOUTS_IMPORT_MODE);

    if (larType.equals("layout-prototype") && !group.isLayoutPrototype()
            && !layoutsImportMode.equals(PortletDataHandlerKeys.LAYOUTS_IMPORT_MODE_CREATED_FROM_PROTOTYPE)) {

        throw new LARTypeException(LARTypeException.TYPE_LAYOUT_PROTOTYPE);
    }

    if (larType.equals("layout-set")) {
        if (group.isLayoutPrototype() || group.isLayoutSetPrototype()) {
            throw new LARTypeException(LARTypeException.TYPE_LAYOUT_SET);
        }

        long sourceCompanyGroupId = GetterUtil.getLong(headerElement.attributeValue("company-group-id"));
        long sourceGroupId = GetterUtil.getLong(headerElement.attributeValue("group-id"));

        boolean companySourceGroup = false;

        if (sourceCompanyGroupId == sourceGroupId) {
            companySourceGroup = true;
        }

        if (group.isCompany() ^ companySourceGroup) {
            throw new LARTypeException(LARTypeException.TYPE_COMPANY_GROUP);
        }
    }

    if (larType.equals("layout-set-prototype") && !group.isLayoutSetPrototype()
            && !layoutsImportMode.equals(PortletDataHandlerKeys.LAYOUTS_IMPORT_MODE_CREATED_FROM_PROTOTYPE)) {

        throw new LARTypeException(LARTypeException.TYPE_LAYOUT_SET_PROTOTYPE);
    }

    // Portlets compatibility

    List<Element> portletElements = fetchPortletElements(rootElement);

    for (Element portletElement : portletElements) {
        String portletId = GetterUtil.getString(portletElement.attributeValue("portlet-id"));

        if (Validator.isNull(portletId)) {
            continue;
        }

        String schemaVersion = GetterUtil.getString(portletElement.attributeValue("schema-version"));

        PortletDataHandler portletDataHandler = _portletDataHandlerProvider.provide(companyId, portletId);

        if (portletDataHandler == null) {
            continue;
        }

        if (!portletDataHandler.validateSchemaVersion(schemaVersion)) {
            throw new LayoutImportException(LayoutImportException.TYPE_WRONG_PORTLET_SCHEMA_VERSION,
                    new Object[] { schemaVersion, portletId, portletDataHandler.getSchemaVersion() });
        }
    }

    // Available locales

    List<Locale> sourceAvailableLocales = Arrays.asList(
            LocaleUtil.fromLanguageIds(StringUtil.split(headerElement.attributeValue("available-locales"))));

    for (Locale sourceAvailableLocale : sourceAvailableLocales) {
        if (!LanguageUtil.isAvailableLocale(groupId, sourceAvailableLocale)) {

            LocaleException le = new LocaleException(LocaleException.TYPE_EXPORT_IMPORT);

            le.setSourceAvailableLocales(sourceAvailableLocales);
            le.setTargetAvailableLocales(LanguageUtil.getAvailableLocales(groupId));

            throw le;
        }
    }

    // Layout prototypes validity

    Element layoutsElement = rootElement.element(Layout.class.getSimpleName());

    validateLayoutPrototypes(companyId, headerElement, layoutsElement);
}

From source file:com.liferay.exportimport.lar.PermissionImporter.java

License:Open Source License

protected void importPermissions(LayoutCache layoutCache, long companyId, long groupId, long userId,
        Layout layout, String resourceName, String resourcePrimKey, Element permissionsElement)
        throws Exception {

    Map<Long, Set<String>> existingRoleIdsToActionIds = ExportImportPermissionUtil
            .getRoleIdsToActionIds(companyId, resourceName, resourcePrimKey);

    Map<Long, String[]> importedRoleIdsToActionIds = new HashMap<>();

    List<Element> roleElements = permissionsElement.elements("role");

    for (Element roleElement : roleElements) {
        Role role = checkRole(layoutCache, companyId, groupId, userId, roleElement);

        if (role == null) {
            continue;
        }//w w  w .  j  a va  2 s .c  o  m

        Group group = GroupLocalServiceUtil.getGroup(groupId);

        if (!group.isLayoutPrototype() && !group.isLayoutSetPrototype() && layout.isPrivateLayout()) {

            String roleName = role.getName();

            if (roleName.equals(RoleConstants.GUEST)) {
                continue;
            }
        }

        List<String> actions = getActions(roleElement);

        importedRoleIdsToActionIds.put(role.getRoleId(), actions.toArray(new String[actions.size()]));
    }

    Map<Long, String[]> roleIdsToActionIds = ExportImportPermissionUtil
            .mergeImportedPermissionsWithExistingPermissions(existingRoleIdsToActionIds,
                    importedRoleIdsToActionIds);

    ExportImportPermissionUtil.updateResourcePermissions(companyId, groupId, resourceName, resourcePrimKey,
            roleIdsToActionIds);
}

From source file:com.liferay.exportimport.web.internal.portlet.ExportImportControlPanelEntry.java

License:Open Source License

@Override
protected boolean hasAccessPermissionDenied(PermissionChecker permissionChecker, Group group, Portlet portlet)
        throws Exception {

    if (group.isLayoutPrototype()) {
        return true;
    }/*  w w w . ja  v a2s . co m*/

    return super.hasAccessPermissionDenied(permissionChecker, group, portlet);
}