List of usage examples for com.liferay.portal.kernel.model LayoutConstants DEFAULT_PLID
long DEFAULT_PLID
To view the source code for com.liferay.portal.kernel.model LayoutConstants DEFAULT_PLID.
Click Source Link
From source file:com.liferay.application.list.my.account.permissions.internal.PanelAppMyAccountPermissions.java
License:Open Source License
private void _initPermissions(long companyId, String portletId, String rootPortletId, Role userRole, List<String> actionIds) throws Exception { PortletPreferences portletPreferences = _portletPreferencesFactory.getLayoutPortletSetup(companyId, companyId, PortletKeys.PREFS_OWNER_TYPE_COMPANY, LayoutConstants.DEFAULT_PLID, portletId, PortletConstants.DEFAULT_PREFERENCES); if (_prefsProps.getBoolean(portletPreferences, "myAccountAccessInControlPanelPermissionsInitialized")) { return;/*from www . ja v a 2 s. c o m*/ } if (actionIds.contains(ActionKeys.ACCESS_IN_CONTROL_PANEL)) { _resourcePermissionLocalService.addResourcePermission(companyId, rootPortletId, ResourceConstants.SCOPE_COMPANY, String.valueOf(companyId), userRole.getRoleId(), ActionKeys.ACCESS_IN_CONTROL_PANEL); } portletPreferences.setValue("myAccountAccessInControlPanelPermissionsInitialized", StringPool.TRUE); portletPreferences.store(); }
From source file:com.liferay.application.list.my.account.permissions.test.PanelAppMyAccountPermissionsTest.java
License:Open Source License
@After public void tearDown() throws Exception { for (ServiceRegistration<?> serviceRegistration : _serviceRegistrations) { serviceRegistration.unregister(); }// ww w .j av a 2s . c o m _serviceRegistrations.clear(); PortletPreferencesLocalServiceUtil.deletePortletPreferences(TestPropsValues.getCompanyId(), PortletKeys.PREFS_OWNER_TYPE_COMPANY, LayoutConstants.DEFAULT_PLID, _testPortletId); }
From source file:com.liferay.asset.publisher.web.util.AssetPublisherUtil.java
License:Open Source License
public static long getSubscriptionClassPK(long ownerId, int ownerType, long plid, String portletId) throws PortalException { if (plid != LayoutConstants.DEFAULT_PLID) { Layout layout = _layoutLocalService.fetchLayout(plid); if (layout != null) { long userId = 0; if (PortletIdCodec.hasUserId(portletId)) { userId = PortletIdCodec.decodeUserId(portletId); }/* w w w.jav a2 s .com*/ PortletPreferencesIds portletPreferencesIds = _portletPreferencesFactory .getPortletPreferencesIds(layout.getGroupId(), userId, layout, portletId, false); ownerId = portletPreferencesIds.getOwnerId(); ownerType = portletPreferencesIds.getOwnerType(); plid = portletPreferencesIds.getPlid(); portletId = portletPreferencesIds.getPortletId(); } } if (PortletIdCodec.hasUserId(portletId)) { ownerId = PortletIdCodec.decodeUserId(portletId); ownerType = PortletKeys.PREFS_OWNER_TYPE_USER; } com.liferay.portal.kernel.model.PortletPreferences portletPreferencesModel = _portletPreferencesLocalService .getPortletPreferences(ownerId, ownerType, plid, portletId); return portletPreferencesModel.getPortletPreferencesId(); }
From source file:com.liferay.blogs.internal.trash.BlogsEntryTrashHandler.java
License:Open Source License
protected PortletURL getRestoreURL(PortletRequest portletRequest, long classPK, boolean containerModel) throws PortalException { PortletURL portletURL = null;//from ww w . j a v a 2 s. co m BlogsEntry entry = _blogsEntryLocalService.getEntry(classPK); String portletId = PortletProviderUtil.getPortletId(BlogsEntry.class.getName(), PortletProvider.Action.VIEW); long plid = PortalUtil.getPlidFromPortletId(entry.getGroupId(), portletId); if (plid == LayoutConstants.DEFAULT_PLID) { portletId = PortletProviderUtil.getPortletId(BlogsEntry.class.getName(), PortletProvider.Action.MANAGE); portletURL = PortalUtil.getControlPanelPortletURL(portletRequest, portletId, PortletRequest.RENDER_PHASE); } else { portletURL = PortletURLFactoryUtil.create(portletRequest, portletId, plid, PortletRequest.RENDER_PHASE); } if (!containerModel) { portletURL.setParameter("mvcRenderCommandName", "/blogs/view_entry"); } return portletURL; }
From source file:com.liferay.blogs.web.internal.portlet.action.RSSAction.java
License:Open Source License
@Override protected byte[] getRSS(HttpServletRequest request) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); Layout layout = themeDisplay.getLayout(); long plid = ParamUtil.getLong(request, "p_l_id"); if (plid == LayoutConstants.DEFAULT_PLID) { plid = themeDisplay.getPlid();// www .j a v a 2s . c o m } long companyId = ParamUtil.getLong(request, "companyId"); long groupId = ParamUtil.getLong(request, "groupId"); long organizationId = ParamUtil.getLong(request, "organizationId"); int status = WorkflowConstants.STATUS_APPROVED; int max = ParamUtil.getInteger(request, "max", SearchContainer.DEFAULT_DELTA); String type = ParamUtil.getString(request, "type", RSSUtil.FORMAT_DEFAULT); double version = ParamUtil.getDouble(request, "version", RSSUtil.VERSION_DEFAULT); String displayStyle = ParamUtil.getString(request, "displayStyle", RSSUtil.DISPLAY_STYLE_DEFAULT); String feedURL = themeDisplay.getPortalURL() + themeDisplay.getPathMain() + "/blogs/find_entry?"; String entryURL = feedURL; String rss = StringPool.BLANK; if (companyId > 0) { feedURL = StringPool.BLANK; rss = _blogsEntryService.getCompanyEntriesRSS(companyId, new Date(), status, max, type, version, displayStyle, feedURL, entryURL, themeDisplay); } else if (groupId > 0) { feedURL += "p_l_id=" + plid; entryURL = feedURL; rss = _blogsEntryService.getGroupEntriesRSS(groupId, new Date(), status, max, type, version, displayStyle, feedURL, entryURL, themeDisplay); } else if (organizationId > 0) { feedURL = StringPool.BLANK; rss = _blogsEntryService.getOrganizationEntriesRSS(organizationId, new Date(), status, max, type, version, displayStyle, feedURL, entryURL, themeDisplay); } else if (layout != null) { groupId = themeDisplay.getScopeGroupId(); feedURL = themeDisplay.getPathMain() + "/blogs/rss"; entryURL = feedURL; rss = _blogsEntryService.getGroupEntriesRSS(groupId, new Date(), status, max, type, version, displayStyle, feedURL, entryURL, themeDisplay); } return rss.getBytes(StringPool.UTF8); }
From source file:com.liferay.exportimport.controller.LayoutImportController.java
License:Open Source License
protected void deletePortletData(PortletDataContext portletDataContext) throws Exception { List<Element> portletElements = fetchPortletElements(portletDataContext.getImportDataRootElement()); Map<Long, Layout> layouts = (Map<Long, Layout>) portletDataContext .getNewPrimaryKeysMap(Layout.class + ".layout"); if (_log.isDebugEnabled()) { if (!portletElements.isEmpty()) { _log.debug("Deleting portlet data"); }//from w ww .j a v a 2 s. co m } for (Element portletElement : portletElements) { long layoutId = GetterUtil.getLong(portletElement.attributeValue("layout-id")); long plid = LayoutConstants.DEFAULT_PLID; Layout layout = layouts.get(layoutId); if (layout != null) { plid = layout.getPlid(); } portletDataContext.setPlid(plid); portletDataContext.setPortletId(portletElement.attributeValue("portlet-id")); _portletImportController.deletePortletData(portletDataContext); } }
From source file:com.liferay.exportimport.controller.PortletExportController.java
License:Open Source License
public void exportPortletData(PortletDataContext portletDataContext, Portlet portlet, Layout layout, javax.portlet.PortletPreferences jxPortletPreferences, Element parentElement) throws Exception { if (portlet == null) { return;//from w w w. j a va2 s. co m } PortletDataHandler portletDataHandler = portlet.getPortletDataHandlerInstance(); if ((portletDataHandler == null) || portletDataHandler.isDataPortletInstanceLevel()) { return; } Group group = _groupLocalService.getGroup(portletDataContext.getGroupId()); long plid = LayoutConstants.DEFAULT_PLID; if (layout != null) { group = layout.getGroup(); plid = layout.getPlid(); } if (group.isStagingGroup()) { group = group.getLiveGroup(); } String portletId = portlet.getPortletId(); if (ExportImportThreadLocal.isStagingInProcess() && !group.isStagedPortlet(portletId)) { if (_log.isDebugEnabled()) { _log.debug("Not exporting data for " + portletId + " because it is configured not to be staged"); } return; } if (_log.isDebugEnabled()) { _log.debug("Exporting data for " + portletId); } String path = ExportImportPathUtil.getPortletDataPath(portletDataContext); if (portletDataContext.hasPrimaryKey(String.class, path)) { return; } Date originalStartDate = portletDataContext.getStartDate(); Date portletLastPublishDate = ExportImportDateUtil.getLastPublishDate(portletDataContext, jxPortletPreferences); portletDataContext.setStartDate(portletLastPublishDate); long groupId = portletDataContext.getGroupId(); portletDataContext.setGroupId(portletDataContext.getScopeGroupId()); portletDataContext.clearScopedPrimaryKeys(); String data = null; try { data = portletDataHandler.exportData(portletDataContext, portletId, jxPortletPreferences); } finally { portletDataContext.setGroupId(groupId); portletDataContext.setStartDate(originalStartDate); } if (Validator.isNull(data)) { if (_log.isDebugEnabled()) { _log.debug("Not exporting data for " + portletId + " because null data was returned"); } return; } Element portletDataElement = parentElement.addElement("portlet-data"); portletDataElement.addAttribute("path", path); portletDataContext.addZipEntry(path, data); boolean updateLastPublishDate = MapUtil.getBoolean(portletDataContext.getParameterMap(), PortletDataHandlerKeys.UPDATE_LAST_PUBLISH_DATE); if (ExportImportThreadLocal.isStagingInProcess() && updateLastPublishDate) { DateRange adjustedDateRange = new DateRange(portletLastPublishDate, portletDataContext.getEndDate()); _exportImportProcessCallbackRegistry.registerCallback(portletDataContext.getExportImportProcessId(), new UpdatePortletLastPublishDateCallable(adjustedDateRange, portletDataContext.getEndDate(), portletDataContext.getGroupId(), plid, portletId)); } }
From source file:com.liferay.exportimport.controller.PortletExportController.java
License:Open Source License
protected void exportServicePortletPreferences(PortletDataContext portletDataContext, long ownerId, int ownerType, String serviceName, Element parentElement) throws Exception { PortletPreferences portletPreferences = null; try {/*from w w w . j a va 2s. c o m*/ portletPreferences = getPortletPreferences(ownerId, ownerType, LayoutConstants.DEFAULT_PLID, serviceName); } catch (NoSuchPortletPreferencesException nsppe) { // LPS-52675 if (_log.isDebugEnabled()) { _log.debug(nsppe, nsppe); } return; } exportServicePortletPreference(portletDataContext, ownerId, ownerType, portletPreferences, serviceName, parentElement); }
From source file:com.liferay.exportimport.controller.PortletExportController.java
License:Open Source License
protected PortletPreferences getPortletPreferences(long ownerId, int ownerType, long plid, String portletId) throws PortalException { PortletPreferences portletPreferences = null; if ((ownerType == PortletKeys.PREFS_OWNER_TYPE_ARCHIVED) || (ownerType == PortletKeys.PREFS_OWNER_TYPE_COMPANY) || (ownerType == PortletKeys.PREFS_OWNER_TYPE_GROUP)) { portletPreferences = _portletPreferencesLocalService.getPortletPreferences(ownerId, ownerType, LayoutConstants.DEFAULT_PLID, portletId); } else {/*from ww w . j ava 2s.c om*/ portletPreferences = _portletPreferencesLocalService.getPortletPreferences(ownerId, ownerType, plid, portletId); } return portletPreferences; }
From source file:com.liferay.exportimport.controller.PortletImportController.java
License:Open Source License
public void importPortletPreferences(PortletDataContext portletDataContext, long companyId, long groupId, Layout layout, Element parentElement, boolean preserveScopeLayoutId, boolean importPortletArchivedSetups, boolean importPortletData, boolean importPortletSetup, boolean importPortletUserPreferences) throws Exception { long plid = LayoutConstants.DEFAULT_PLID; String scopeType = StringPool.BLANK; String scopeLayoutUuid = StringPool.BLANK; if (layout != null) { plid = layout.getPlid();//from w ww. ja v a 2 s. c o m if (preserveScopeLayoutId) { javax.portlet.PortletPreferences jxPortletPreferences = PortletPreferencesFactoryUtil .getLayoutPortletSetup(layout, portletDataContext.getPortletId()); scopeType = GetterUtil.getString(jxPortletPreferences.getValue("lfrScopeType", null)); scopeLayoutUuid = GetterUtil.getString(jxPortletPreferences.getValue("lfrScopeLayoutUuid", null)); portletDataContext.setScopeType(scopeType); portletDataContext.setScopeLayoutUuid(scopeLayoutUuid); } } List<Element> portletPreferencesElements = parentElement.elements("portlet-preferences"); for (Element portletPreferencesElement : portletPreferencesElements) { String path = portletPreferencesElement.attributeValue("path"); if (portletDataContext.isPathNotProcessed(path)) { String xml = null; Element element = null; try { xml = portletDataContext.getZipEntryAsString(path); Document preferencesDocument = SAXReaderUtil.read(xml); element = preferencesDocument.getRootElement(); } catch (DocumentException de) { throw new SystemException( "Unable to parse XML portlet preferences for portlet " + portletDataContext.getPortletId() + " while importing portlet preferences", de); } long ownerId = GetterUtil.getLong(element.attributeValue("owner-id")); int ownerType = GetterUtil.getInteger(element.attributeValue("owner-type")); if ((ownerType == PortletKeys.PREFS_OWNER_TYPE_COMPANY) || !importPortletSetup) { continue; } if ((ownerType == PortletKeys.PREFS_OWNER_TYPE_ARCHIVED) && !importPortletArchivedSetups) { continue; } if ((ownerType == PortletKeys.PREFS_OWNER_TYPE_USER) && (ownerId != PortletKeys.PREFS_OWNER_ID_DEFAULT) && !importPortletUserPreferences) { continue; } long curPlid = plid; String curPortletId = portletDataContext.getPortletId(); if (ownerType == PortletKeys.PREFS_OWNER_TYPE_GROUP) { curPlid = PortletKeys.PREFS_PLID_SHARED; curPortletId = portletDataContext.getRootPortletId(); ownerId = portletDataContext.getScopeGroupId(); } long elementPlid = GetterUtil.getLong(element.attributeValue("plid")); if ((ownerType == PortletKeys.PREFS_OWNER_TYPE_LAYOUT) && (ownerId != PortletKeys.PREFS_OWNER_ID_DEFAULT) && (elementPlid == PortletKeys.PREFS_PLID_SHARED)) { curPlid = PortletKeys.PREFS_PLID_SHARED; ownerId = portletDataContext.getScopeGroupId(); } if (ownerType == PortletKeys.PREFS_OWNER_TYPE_ARCHIVED) { String userUuid = element.attributeValue("archive-user-uuid"); long userId = portletDataContext.getUserId(userUuid); String name = element.attributeValue("archive-name"); curPortletId = portletDataContext.getRootPortletId(); PortletItem portletItem = _portletItemLocalService.updatePortletItem(userId, groupId, name, curPortletId, PortletPreferences.class.getName()); curPlid = LayoutConstants.DEFAULT_PLID; ownerId = portletItem.getPortletItemId(); } if (ownerType == PortletKeys.PREFS_OWNER_TYPE_USER) { String userUuid = element.attributeValue("user-uuid"); ownerId = portletDataContext.getUserId(userUuid); } boolean defaultUser = GetterUtil.getBoolean(element.attributeValue("default-user")); if (defaultUser) { ownerId = _userLocalService.getDefaultUserId(companyId); } javax.portlet.PortletPreferences jxPortletPreferences = PortletPreferencesFactoryUtil .fromXML(companyId, ownerId, ownerType, curPlid, curPortletId, xml); Element importDataRootElement = portletDataContext.getImportDataRootElement(); try { Element preferenceDataElement = portletPreferencesElement.element("preference-data"); if (preferenceDataElement != null) { portletDataContext.setImportDataRootElement(preferenceDataElement); } ExportImportPortletPreferencesProcessor exportImportPortletPreferencesProcessor = ExportImportPortletPreferencesProcessorRegistryUtil .getExportImportPortletPreferencesProcessor( PortletIdCodec.decodePortletName(curPortletId)); if (exportImportPortletPreferencesProcessor != null) { List<Capability> importCapabilities = exportImportPortletPreferencesProcessor .getImportCapabilities(); if (ListUtil.isNotEmpty(importCapabilities)) { for (Capability importCapability : importCapabilities) { importCapability.process(portletDataContext, jxPortletPreferences); } } exportImportPortletPreferencesProcessor.processImportPortletPreferences(portletDataContext, jxPortletPreferences); } else { PortletDataHandler portletDataHandler = _portletDataHandlerProvider .provide(portletDataContext.getCompanyId(), curPortletId); if (portletDataHandler != null) { jxPortletPreferences = portletDataHandler.processImportPortletPreferences( portletDataContext, curPortletId, jxPortletPreferences); } } } finally { portletDataContext.setImportDataRootElement(importDataRootElement); } updatePortletPreferences(portletDataContext, ownerId, ownerType, curPlid, curPortletId, PortletPreferencesFactoryUtil.toXML(jxPortletPreferences), importPortletData); } } if (preserveScopeLayoutId && (layout != null)) { javax.portlet.PortletPreferences jxPortletPreferences = PortletPreferencesFactoryUtil .getLayoutPortletSetup(layout, portletDataContext.getPortletId()); try { jxPortletPreferences.setValue("lfrScopeType", scopeType); jxPortletPreferences.setValue("lfrScopeLayoutUuid", scopeLayoutUuid); jxPortletPreferences.store(); } finally { portletDataContext.setScopeType(scopeType); portletDataContext.setScopeLayoutUuid(scopeLayoutUuid); } } }