List of usage examples for com.liferay.portal.kernel.model Portlet getRootPortletId
public String getRootPortletId();
From source file:com.liferay.application.list.my.account.permissions.internal.PanelAppMyAccountPermissions.java
License:Open Source License
public void initPermissions(long companyId, List<Portlet> portlets) { Role userRole = _getUserRole(companyId); if (userRole == null) { return;/*from w w w . jav a2 s . c o m*/ } for (Portlet portlet : portlets) { try { List<String> actionIds = ResourceActionsUtil.getPortletResourceActions(portlet.getRootPortletId()); _initPermissions(companyId, portlet.getPortletId(), portlet.getRootPortletId(), userRole, actionIds); } catch (Exception e) { _log.error(StringBundler.concat("Unable to initialize My Account panel permissions ", "for portlet ", portlet.getPortletId(), " in company ", String.valueOf(companyId)), e); } } }
From source file:com.liferay.application.list.user.personal.site.permissions.internal.UserPersonalSitePermissions.java
License:Open Source License
public void initPermissions(List<Company> companies, Portlet portlet) { String rootPortletId = portlet.getRootPortletId(); for (Company company : companies) { long companyId = company.getCompanyId(); Role powerUserRole = getPowerUserRole(companyId); if (powerUserRole == null) { continue; }/*from ww w . j a v a 2 s . c om*/ Group userPersonalSiteGroup = getUserPersonalSiteGroup(companyId); if (userPersonalSiteGroup == null) { continue; } try { initPermissions(companyId, powerUserRole.getRoleId(), rootPortletId, userPersonalSiteGroup.getGroupId()); } catch (PortalException pe) { _log.error(StringBundler.concat("Unable to initialize user personal site permissions ", "for portlet ", portlet.getPortletId(), " in company ", String.valueOf(companyId)), pe); } } }
From source file:com.liferay.application.list.user.personal.site.permissions.internal.UserPersonalSitePermissions.java
License:Open Source License
public void initPermissions(long companyId, List<Portlet> portlets) { Role powerUserRole = getPowerUserRole(companyId); if (powerUserRole == null) { return;//from w ww. ja v a 2 s .c om } Group userPersonalSiteGroup = getUserPersonalSiteGroup(companyId); if (userPersonalSiteGroup == null) { return; } for (Portlet portlet : portlets) { try { initPermissions(companyId, powerUserRole.getRoleId(), portlet.getRootPortletId(), userPersonalSiteGroup.getGroupId()); } catch (PortalException pe) { _log.error(StringBundler.concat("Unable to initialize user personal site permissions ", "for portlet ", portlet.getPortletId(), " in company ", String.valueOf(companyId)), pe); } } }
From source file:com.liferay.asset.internal.util.AssetHelperImpl.java
License:Open Source License
@Override public List<AssetPublisherAddItemHolder> getAssetPublisherAddItemHolders( LiferayPortletRequest liferayPortletRequest, LiferayPortletResponse liferayPortletResponse, long groupId, long[] classNameIds, long[] classTypeIds, long[] allAssetCategoryIds, String[] allAssetTagNames, String redirect) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) liferayPortletRequest.getAttribute(WebKeys.THEME_DISPLAY); Locale locale = themeDisplay.getLocale(); List<AssetPublisherAddItemHolder> assetPublisherAddItemHolders = new ArrayList<>(); for (long classNameId : classNameIds) { String className = _portal.getClassName(classNameId); AssetRendererFactory<?> assetRendererFactory = AssetRendererFactoryRegistryUtil .getAssetRendererFactoryByClassName(className); if (Validator.isNull(assetRendererFactory.getPortletId())) { continue; }//from www . j a v a 2 s .c o m Portlet portlet = _portletLocalService.getPortletById(themeDisplay.getCompanyId(), assetRendererFactory.getPortletId()); if (!portlet.isActive()) { continue; } PortletBag portletBag = PortletBagPool.get(portlet.getRootPortletId()); if (portletBag == null) { continue; } ResourceBundle resourceBundle = portletBag.getResourceBundle(locale); ClassTypeReader classTypeReader = assetRendererFactory.getClassTypeReader(); List<ClassType> classTypes = Collections.emptyList(); if (!(classTypeReader instanceof NullClassTypeReader)) { classTypes = classTypeReader.getAvailableClassTypes( _portal.getCurrentAndAncestorSiteGroupIds(groupId), themeDisplay.getLocale()); } if (classTypes.isEmpty()) { PortletURL addPortletURL = getAddPortletURL(liferayPortletRequest, liferayPortletResponse, groupId, className, 0, allAssetCategoryIds, allAssetTagNames, redirect); if (addPortletURL != null) { assetPublisherAddItemHolders.add(new AssetPublisherAddItemHolder(portlet.getPortletId(), className, resourceBundle, locale, addPortletURL)); } } for (ClassType classType : classTypes) { long classTypeId = classType.getClassTypeId(); if (ArrayUtil.contains(classTypeIds, classTypeId) || (classTypeIds.length == 0)) { PortletURL addPortletURL = getAddPortletURL(liferayPortletRequest, liferayPortletResponse, groupId, className, classTypeId, allAssetCategoryIds, allAssetTagNames, redirect); if (addPortletURL != null) { assetPublisherAddItemHolders.add(new AssetPublisherAddItemHolder(portlet.getPortletId(), classType.getName(), resourceBundle, locale, addPortletURL)); } } } } if (assetPublisherAddItemHolders.size() <= 1) { return assetPublisherAddItemHolders; } assetPublisherAddItemHolders.sort(null); return assetPublisherAddItemHolders; }
From source file:com.liferay.asset.publisher.web.servlet.taglib.ui.OrderingAndGroupingFormNavigatorEntry.java
License:Open Source License
@Override public boolean isVisible(User user, Object object) { if (!isDynamicAssetSelection()) { return false; }//from ww w .j a v a2 s . c o m ServiceContext serviceContext = ServiceContextThreadLocal.getServiceContext(); ThemeDisplay themeDisplay = serviceContext.getThemeDisplay(); PortletDisplay portletDisplay = themeDisplay.getPortletDisplay(); Portlet portlet = _portletLocalService.getPortletById(themeDisplay.getCompanyId(), portletDisplay.getPortletResource()); AssetPublisherCustomizer assetPublisherCustomizer = assetPublisherCustomizerRegistry .getAssetPublisherCustomizer(portlet.getRootPortletId()); if (assetPublisherCustomizer == null) { return true; } return assetPublisherCustomizer.isOrderingAndGroupingEnabled(serviceContext.getRequest()); }
From source file:com.liferay.exportimport.controller.PortletExportController.java
License:Open Source License
public void exportPortlet(PortletDataContext portletDataContext, long plid, Element parentElement, boolean exportPermissions, boolean exportPortletArchivedSetups, boolean exportPortletData, boolean exportPortletSetup, boolean exportPortletUserPreferences) throws Exception { long layoutId = LayoutConstants.DEFAULT_PARENT_LAYOUT_ID; Layout layout = _layoutLocalService.fetchLayout(plid); if (layout != null) { layoutId = layout.getLayoutId(); }/*w w w. ja va 2s . c o m*/ Portlet portlet = _portletLocalService.getPortletById(portletDataContext.getCompanyId(), portletDataContext.getPortletId()); if ((portlet == null) || portlet.isUndeployedPortlet()) { if (_log.isDebugEnabled()) { _log.debug("Do not export portlet " + portletDataContext.getPortletId() + " because the portlet is not deployed"); } return; } if (!portlet.isInstanceable() && !portlet.isPreferencesUniquePerLayout() && portletDataContext.hasNotUniquePerLayout(portletDataContext.getPortletId())) { return; } if (BackgroundTaskThreadLocal.hasBackgroundTask()) { PortletDataContext clonedPortletDataContext = _portletDataContextFactory .clonePortletDataContext(portletDataContext); ManifestSummary manifestSummary = clonedPortletDataContext.getManifestSummary(); manifestSummary.resetCounters(); PortletDataHandler portletDataHandler = portlet.getPortletDataHandlerInstance(); portletDataHandler.prepareManifestSummary(clonedPortletDataContext); _portletDataHandlerStatusMessageSender.sendStatusMessage("portlet", portletDataContext.getPortletId(), manifestSummary); } Document document = SAXReaderUtil.createDocument(); Element portletElement = document.addElement("portlet"); portletElement.addAttribute("portlet-id", portletDataContext.getPortletId()); portletElement.addAttribute("root-portlet-id", portletDataContext.getRootPortletId()); portletElement.addAttribute("old-plid", String.valueOf(plid)); portletElement.addAttribute("scope-group-id", String.valueOf(portletDataContext.getScopeGroupId())); portletElement.addAttribute("scope-layout-type", portletDataContext.getScopeType()); portletElement.addAttribute("scope-layout-uuid", portletDataContext.getScopeLayoutUuid()); portletElement.addAttribute("private-layout", String.valueOf(portletDataContext.isPrivateLayout())); // Data if (exportPortletData) { javax.portlet.PortletPreferences jxPortletPreferences = null; if (ExportImportThreadLocal.isInitialLayoutStagingInProcess()) { if (layout != null) { Group liveGroup = layout.getGroup(); Group stagingGroup = liveGroup.getStagingGroup(); layout.setGroupId(stagingGroup.getGroupId()); jxPortletPreferences = PortletPreferencesFactoryUtil.getStrictPortletSetup(layout, portletDataContext.getPortletId()); layout.setGroupId(liveGroup.getGroupId()); } else { Group liveGroup = _groupLocalService.getGroup(portletDataContext.getGroupId()); Group stagingGroup = liveGroup.getStagingGroup(); jxPortletPreferences = PortletPreferencesFactoryUtil.getStrictPortletSetup( portletDataContext.getCompanyId(), stagingGroup.getGroupId(), portletDataContext.getPortletId()); } } else { if (layout != null) { jxPortletPreferences = PortletPreferencesFactoryUtil.getStrictPortletSetup(layout, portletDataContext.getPortletId()); } else { jxPortletPreferences = PortletPreferencesFactoryUtil.getStrictPortletSetup( portletDataContext.getCompanyId(), portletDataContext.getGroupId(), portletDataContext.getPortletId()); } } if (!portlet.isPreferencesUniquePerLayout()) { StringBundler sb = new StringBundler(5); sb.append(portletDataContext.getPortletId()); sb.append(StringPool.AT); sb.append(portletDataContext.getScopeType()); sb.append(StringPool.AT); sb.append(portletDataContext.getScopeLayoutUuid()); String dataKey = sb.toString(); if (!portletDataContext.hasNotUniquePerLayout(dataKey)) { portletDataContext.putNotUniquePerLayout(dataKey); exportPortletData(portletDataContext, portlet, layout, jxPortletPreferences, portletElement); } } else { exportPortletData(portletDataContext, portlet, layout, jxPortletPreferences, portletElement); } } // Portlet preferences if (exportPortletSetup) { // Company exportPortletPreferences(portletDataContext, portletDataContext.getCompanyId(), PortletKeys.PREFS_OWNER_TYPE_COMPANY, false, layout, plid, portlet.getRootPortletId(), portletElement); // Group exportPortletPreferences(portletDataContext, portletDataContext.getScopeGroupId(), PortletKeys.PREFS_OWNER_TYPE_GROUP, false, layout, PortletKeys.PREFS_PLID_SHARED, portlet.getRootPortletId(), portletElement); // Group embedded portlets exportPortletPreferences(portletDataContext, portletDataContext.getScopeGroupId(), PortletKeys.PREFS_OWNER_TYPE_LAYOUT, false, layout, PortletKeys.PREFS_PLID_SHARED, portlet.getPortletId(), portletElement); // Layout exportPortletPreferences(portletDataContext, PortletKeys.PREFS_OWNER_ID_DEFAULT, PortletKeys.PREFS_OWNER_TYPE_LAYOUT, false, layout, plid, portletDataContext.getPortletId(), portletElement); } // Portlet user preferences if (exportPortletUserPreferences) { List<PortletPreferences> portletPreferencesList = _portletPreferencesLocalService.getPortletPreferences( PortletKeys.PREFS_OWNER_TYPE_USER, plid, portletDataContext.getPortletId()); for (PortletPreferences portletPreferences : portletPreferencesList) { boolean defaultUser = false; if (portletPreferences.getOwnerId() == PortletKeys.PREFS_OWNER_ID_DEFAULT) { defaultUser = true; } exportPortletPreferences(portletDataContext, portletPreferences.getOwnerId(), PortletKeys.PREFS_OWNER_TYPE_USER, defaultUser, layout, plid, portletDataContext.getPortletId(), portletElement); } try { PortletPreferences groupPortletPreferences = _portletPreferencesLocalService.getPortletPreferences( portletDataContext.getScopeGroupId(), PortletKeys.PREFS_OWNER_TYPE_GROUP, PortletKeys.PREFS_PLID_SHARED, portlet.getRootPortletId()); exportPortletPreference(portletDataContext, portletDataContext.getScopeGroupId(), PortletKeys.PREFS_OWNER_TYPE_GROUP, false, groupPortletPreferences, portlet.getRootPortletId(), PortletKeys.PREFS_PLID_SHARED, portletElement); } catch (NoSuchPortletPreferencesException nsppe) { // LPS-52675 if (_log.isDebugEnabled()) { _log.debug(nsppe, nsppe); } } } // Archived setups if (exportPortletArchivedSetups) { List<PortletItem> portletItems = _portletItemLocalService.getPortletItems( portletDataContext.getGroupId(), portletDataContext.getRootPortletId(), PortletPreferences.class.getName()); for (PortletItem portletItem : portletItems) { exportPortletPreferences(portletDataContext, portletItem.getPortletItemId(), PortletKeys.PREFS_OWNER_TYPE_ARCHIVED, false, null, plid, portletItem.getPortletId(), portletElement); } } // Permissions if (exportPermissions) { _permissionExporter.exportPortletPermissions(portletDataContext, portletDataContext.getPortletId(), layout, portletElement); } // Zip StringBundler pathSB = new StringBundler(4); pathSB.append(ExportImportPathUtil.getPortletPath(portletDataContext)); pathSB.append(StringPool.SLASH); pathSB.append(plid); pathSB.append("/portlet.xml"); String path = pathSB.toString(); Element element = parentElement.addElement("portlet"); element.addAttribute("portlet-id", portletDataContext.getPortletId()); element.addAttribute("layout-id", String.valueOf(layoutId)); element.addAttribute("path", path); element.addAttribute("portlet-data", String.valueOf(exportPortletData)); PortletDataHandler portletDataHandler = portlet.getPortletDataHandlerInstance(); element.addAttribute("schema-version", portletDataHandler.getSchemaVersion()); StringBundler configurationOptionsSB = new StringBundler(6); if (exportPortletSetup) { configurationOptionsSB.append("setup"); configurationOptionsSB.append(StringPool.COMMA); } if (exportPortletArchivedSetups) { configurationOptionsSB.append("archived-setups"); configurationOptionsSB.append(StringPool.COMMA); } if (exportPortletUserPreferences) { configurationOptionsSB.append("user-preferences"); configurationOptionsSB.append(StringPool.COMMA); } if (configurationOptionsSB.index() > 0) { configurationOptionsSB.setIndex(configurationOptionsSB.index() - 1); } element.addAttribute("portlet-configuration", configurationOptionsSB.toString()); try { portletDataContext.addZipEntry(path, document.formattedString()); } catch (IOException ioe) { if (_log.isWarnEnabled()) { _log.warn(ioe.getMessage()); } } }
From source file:com.liferay.exportimport.controller.PortletExportController.java
License:Open Source License
protected void exportPortletPreference(PortletDataContext portletDataContext, long ownerId, int ownerType, boolean defaultUser, PortletPreferences portletPreferences, String portletId, long plid, Element parentElement) throws Exception { String preferencesXML = portletPreferences.getPreferences(); if (Validator.isNull(preferencesXML)) { preferencesXML = PortletConstants.DEFAULT_PREFERENCES; }//from ww w . ja v a 2 s . co m javax.portlet.PortletPreferences jxPortletPreferences = PortletPreferencesFactoryUtil .fromDefaultXML(preferencesXML); Portlet portlet = _portletLocalService.getPortletById(portletDataContext.getCompanyId(), portletId); Element portletPreferencesElement = parentElement.addElement("portlet-preferences"); if ((portlet != null) && (portlet.getPortletDataHandlerInstance() != null)) { Element exportDataRootElement = portletDataContext.getExportDataRootElement(); try { portletDataContext.clearScopedPrimaryKeys(); Element preferenceDataElement = portletPreferencesElement.addElement("preference-data"); portletDataContext.setExportDataRootElement(preferenceDataElement); ExportImportPortletPreferencesProcessor exportImportPortletPreferencesProcessor = ExportImportPortletPreferencesProcessorRegistryUtil .getExportImportPortletPreferencesProcessor(portlet.getRootPortletId()); if (exportImportPortletPreferencesProcessor != null) { List<Capability> exportCapabilities = exportImportPortletPreferencesProcessor .getExportCapabilities(); if (ListUtil.isNotEmpty(exportCapabilities)) { for (Capability exportCapability : exportCapabilities) { exportCapability.process(portletDataContext, jxPortletPreferences); } } exportImportPortletPreferencesProcessor.processExportPortletPreferences(portletDataContext, jxPortletPreferences); } else { PortletDataHandler portletDataHandler = portlet.getPortletDataHandlerInstance(); jxPortletPreferences = portletDataHandler.processExportPortletPreferences(portletDataContext, portletId, jxPortletPreferences); } } finally { portletDataContext.setExportDataRootElement(exportDataRootElement); } } Document document = SAXReaderUtil.read(PortletPreferencesFactoryUtil.toXML(jxPortletPreferences)); Element rootElement = document.getRootElement(); rootElement.addAttribute("owner-id", String.valueOf(ownerId)); rootElement.addAttribute("owner-type", String.valueOf(ownerType)); rootElement.addAttribute("default-user", String.valueOf(defaultUser)); rootElement.addAttribute("plid", String.valueOf(plid)); rootElement.addAttribute("portlet-id", portletId); if (ownerType == PortletKeys.PREFS_OWNER_TYPE_ARCHIVED) { PortletItem portletItem = _portletItemLocalService.getPortletItem(ownerId); rootElement.addAttribute("archive-user-uuid", portletItem.getUserUuid()); rootElement.addAttribute("archive-name", portletItem.getName()); } else if (ownerType == PortletKeys.PREFS_OWNER_TYPE_USER) { User user = _userLocalService.fetchUserById(ownerId); if (user == null) { return; } rootElement.addAttribute("user-uuid", user.getUserUuid()); } List<Node> nodes = document .selectNodes("/portlet-preferences/preference[name/text() = " + "'last-publish-date']"); for (Node node : nodes) { node.detach(); } String path = ExportImportPathUtil.getPortletPreferencesPath(portletDataContext, portletId, ownerId, ownerType, plid); portletPreferencesElement.addAttribute("path", path); portletDataContext.addZipEntry(path, document.formattedString(StringPool.TAB, false, false)); }
From source file:com.liferay.exportimport.lar.PortletDataContextImpl.java
License:Open Source License
protected Element doAddReferenceElement(ClassedModel referrerClassedModel, Element element, ClassedModel classedModel, String className, String binPath, String referenceType, boolean missing) { Element referenceElement = null; if (missing) { Element referencesElement = _missingReferencesElement; referenceElement = referencesElement.addElement("missing-reference"); } else {//from w w w . j av a 2 s .c o m Element referencesElement = element.element("references"); if (referencesElement == null) { referencesElement = element.addElement("references"); } referenceElement = referencesElement.addElement("reference"); } referenceElement.addAttribute("class-name", className); referenceElement.addAttribute("class-pk", String.valueOf(classedModel.getPrimaryKeyObj())); populateClassNameAttribute(classedModel, referenceElement); if (missing) { if (classedModel instanceof StagedModel) { referenceElement.addAttribute("display-name", StagedModelDataHandlerUtil.getDisplayName((StagedModel) classedModel)); } else { referenceElement.addAttribute("display-name", String.valueOf(classedModel.getPrimaryKeyObj())); } } if (classedModel instanceof StagedGroupedModel) { StagedGroupedModel stagedGroupedModel = (StagedGroupedModel) classedModel; referenceElement.addAttribute("group-id", String.valueOf(stagedGroupedModel.getGroupId())); try { Group group = GroupLocalServiceUtil.getGroup(stagedGroupedModel.getGroupId()); long liveGroupId = group.getLiveGroupId(); if (group.isStagedRemotely()) { liveGroupId = group.getRemoteLiveGroupId(); } if (liveGroupId == GroupConstants.DEFAULT_LIVE_GROUP_ID) { liveGroupId = group.getGroupId(); } referenceElement.addAttribute("live-group-id", String.valueOf(liveGroupId)); if (group.isLayout()) { try { Layout scopeLayout = LayoutLocalServiceUtil.getLayout(group.getClassPK()); referenceElement.addAttribute("scope-layout-uuid", scopeLayout.getUuid()); } catch (NoSuchLayoutException nsle) { if (_log.isWarnEnabled()) { _log.warn("Unable to find layout " + group.getClassPK(), nsle); } } } } catch (Exception e) { if (_log.isWarnEnabled()) { _log.warn("Unable to find group " + stagedGroupedModel.getGroupId()); } } } if (Validator.isNotNull(binPath)) { referenceElement.addAttribute("path", binPath); } referenceElement.addAttribute("type", referenceType); if (missing) { referenceElement.addAttribute("referrer-class-name", ExportImportClassedModelUtil.getClassName(referrerClassedModel)); if (referrerClassedModel instanceof PortletModel) { Portlet portlet = (Portlet) referrerClassedModel; referenceElement.addAttribute("referrer-display-name", portlet.getRootPortletId()); } else if (referrerClassedModel instanceof StagedModel) { StagedModel referrerStagedModel = (StagedModel) referrerClassedModel; referenceElement.addAttribute("referrer-display-name", StagedModelDataHandlerUtil.getDisplayName(referrerStagedModel)); } } if (classedModel instanceof StagedModel) { StagedModel stagedModel = (StagedModel) classedModel; referenceElement.addAttribute("uuid", stagedModel.getUuid()); referenceElement.addAttribute("company-id", String.valueOf(stagedModel.getCompanyId())); Map<String, String> referenceAttributes = StagedModelDataHandlerUtil.getReferenceAttributes(this, stagedModel); for (Map.Entry<String, String> referenceAttribute : referenceAttributes.entrySet()) { referenceElement.addAttribute(referenceAttribute.getKey(), referenceAttribute.getValue()); } } return referenceElement; }
From source file:com.liferay.faces.portal.context.internal.LiferayPortletHelperImpl.java
License:Open Source License
@Override public String getPortletRootId() { Portlet portlet = getPortlet(); return portlet.getRootPortletId(); }
From source file:com.liferay.portlet.configuration.web.internal.portlet.configuration.icon.PermissionsPortletConfigurationIcon.java
License:Open Source License
@Override public boolean isShow(PortletRequest portletRequest) { ThemeDisplay themeDisplay = (ThemeDisplay) portletRequest.getAttribute(WebKeys.THEME_DISPLAY); PortletDisplay portletDisplay = themeDisplay.getPortletDisplay(); String rootPortletId = portletDisplay.getRootPortletId(); if (Validator.isNotNull(portletDisplay.getPortletResource())) { String portletResource = portletDisplay.getPortletResource(); Portlet portlet = _portletLocalService.getPortletById(themeDisplay.getCompanyId(), portletResource); rootPortletId = portlet.getRootPortletId(); }//from w w w .j a va 2s . c om boolean showPermissionsIcon = false; Layout layout = themeDisplay.getLayout(); Group group = themeDisplay.getScopeGroup(); if (!group.hasStagingGroup() || _STAGING_LIVE_GROUP_LOCKING_ENABLED) { try { if (PortletPermissionUtil.contains(themeDisplay.getPermissionChecker(), layout, rootPortletId, ActionKeys.PERMISSIONS)) { showPermissionsIcon = true; } } catch (PortalException pe) { // LPS-52675 if (_log.isDebugEnabled()) { _log.debug(pe, pe); } showPermissionsIcon = false; } } if (layout.isLayoutPrototypeLinkActive()) { showPermissionsIcon = false; } if (layout.isTypeControlPanel()) { showPermissionsIcon = false; } return showPermissionsIcon; }