List of usage examples for com.liferay.portal.kernel.model Layout isTypeControlPanel
public boolean isTypeControlPanel();
From source file:com.liferay.exportimport.controller.PortletExportController.java
License:Open Source License
protected File doExport(PortletDataContext portletDataContext) throws Exception { boolean exportPermissions = MapUtil.getBoolean(portletDataContext.getParameterMap(), PortletDataHandlerKeys.PERMISSIONS); if (_log.isDebugEnabled()) { _log.debug("Export permissions " + exportPermissions); }/*w ww . j av a 2 s . c o m*/ StopWatch stopWatch = new StopWatch(); stopWatch.start(); Layout layout = _layoutLocalService.getLayout(portletDataContext.getPlid()); if (!layout.isTypeControlPanel() && !layout.isTypePanel() && !layout.isTypePortlet()) { StringBundler sb = new StringBundler(4); sb.append("Unable to export layout "); sb.append(layout.getPlid()); sb.append(" because it has an invalid type: "); sb.append(layout.getType()); throw new LayoutImportException(sb.toString()); } ServiceContext serviceContext = ServiceContextThreadLocal.getServiceContext(); if (serviceContext == null) { serviceContext = new ServiceContext(); serviceContext.setCompanyId(layout.getCompanyId()); serviceContext.setSignedIn(false); long defaultUserId = _userLocalService.getDefaultUserId(layout.getCompanyId()); serviceContext.setUserId(defaultUserId); ServiceContextThreadLocal.pushServiceContext(serviceContext); } long layoutSetBranchId = MapUtil.getLong(portletDataContext.getParameterMap(), "layoutSetBranchId"); serviceContext.setAttribute("layoutSetBranchId", layoutSetBranchId); long scopeGroupId = portletDataContext.getGroupId(); javax.portlet.PortletPreferences jxPortletPreferences = PortletPreferencesFactoryUtil .getLayoutPortletSetup(layout, portletDataContext.getPortletId()); String scopeType = GetterUtil.getString(jxPortletPreferences.getValue("lfrScopeType", null)); String scopeLayoutUuid = GetterUtil.getString(jxPortletPreferences.getValue("lfrScopeLayoutUuid", null)); if (Validator.isNotNull(scopeType)) { Group scopeGroup = null; if (scopeType.equals("company")) { scopeGroup = _groupLocalService.getCompanyGroup(layout.getCompanyId()); } else if (Validator.isNotNull(scopeLayoutUuid)) { scopeGroup = layout.getScopeGroup(); } if (scopeGroup != null) { scopeGroupId = scopeGroup.getGroupId(); } } portletDataContext.setScopeType(scopeType); portletDataContext.setScopeLayoutUuid(scopeLayoutUuid); 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(_portal.getSiteGroupId(portletDataContext.getScopeGroupId())))); headerElement.addAttribute("build-number", String.valueOf(ReleaseInfo.getBuildNumber())); 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("type", portletDataContext.getType()); headerElement.addAttribute("company-id", String.valueOf(portletDataContext.getCompanyId())); headerElement.addAttribute("company-group-id", String.valueOf(portletDataContext.getCompanyGroupId())); headerElement.addAttribute("group-id", String.valueOf(scopeGroupId)); headerElement.addAttribute("user-personal-site-group-id", String.valueOf(portletDataContext.getUserPersonalSiteGroupId())); headerElement.addAttribute("private-layout", String.valueOf(layout.isPrivateLayout())); headerElement.addAttribute("root-portlet-id", portletDataContext.getRootPortletId()); headerElement.addAttribute("schema-version", ExportImportConstants.EXPORT_IMPORT_SCHEMA_VERSION); Element missingReferencesElement = rootElement.addElement("missing-references"); portletDataContext.setMissingReferencesElement(missingReferencesElement); Map<String, Boolean> exportPortletControlsMap = _exportImportHelper.getExportPortletControlsMap( layout.getCompanyId(), portletDataContext.getPortletId(), portletDataContext.getParameterMap()); exportPortlet(portletDataContext, layout.getPlid(), rootElement, exportPermissions, exportPortletControlsMap.get(PortletDataHandlerKeys.PORTLET_ARCHIVED_SETUPS), exportPortletControlsMap.get(PortletDataHandlerKeys.PORTLET_DATA), exportPortletControlsMap.get(PortletDataHandlerKeys.PORTLET_SETUP), exportPortletControlsMap.get(PortletDataHandlerKeys.PORTLET_USER_PREFERENCES)); exportService(portletDataContext, rootElement, exportPortletControlsMap.get(PortletDataHandlerKeys.PORTLET_SETUP)); exportAssetLinks(portletDataContext); exportExpandoTables(portletDataContext); exportLocks(portletDataContext); portletDataContext.addDeletionSystemEventStagedModelTypes(new StagedModelType(StagedAssetLink.class)); _deletionSystemEventExporter.exportDeletionSystemEvents(portletDataContext); if (exportPermissions) { _permissionExporter.exportPortletDataPermissions(portletDataContext); } _exportImportHelper.writeManifestSummary(document, portletDataContext.getManifestSummary()); if (_log.isInfoEnabled()) { _log.info("Exporting portlet took " + stopWatch.getTime() + " ms"); } try { portletDataContext.addZipEntry("/manifest.xml", document.formattedString()); } catch (IOException ioe) { throw new SystemException("Unable to create the export LAR manifest file for portlet " + portletDataContext.getPortletId(), ioe); } ZipWriter zipWriter = portletDataContext.getZipWriter(); return zipWriter.getFile(); }
From source file:com.liferay.exportimport.staging.StagingImpl.java
License:Open Source License
protected long publishPortlet(long userId, long scopeGroupId, long plid, String portletId, Map<String, String[]> parameterMap, boolean copyFromLive) throws PortalException { Layout sourceLayout = _layoutLocalService.getLayout(plid); Group scopeGroup = sourceLayout.getScopeGroup(); Group stagingGroup = null;// w w w . j a v a 2 s . c o m Group liveGroup = null; Layout targetLayout = null; if (sourceLayout.isTypeControlPanel()) { stagingGroup = _groupLocalService.fetchGroup(scopeGroupId); liveGroup = stagingGroup.getLiveGroup(); targetLayout = sourceLayout; } else if (sourceLayout.hasScopeGroup() && (scopeGroup.getGroupId() == scopeGroupId)) { stagingGroup = scopeGroup; liveGroup = stagingGroup.getLiveGroup(); targetLayout = _layoutLocalService.getLayout(liveGroup.getClassPK()); } else { stagingGroup = sourceLayout.getGroup(); liveGroup = stagingGroup.getLiveGroup(); targetLayout = _layoutLocalService.fetchLayoutByUuidAndGroupId(sourceLayout.getUuid(), liveGroup.getGroupId(), sourceLayout.isPrivateLayout()); } if (copyFromLive) { return publishPortlet(userId, liveGroup.getGroupId(), stagingGroup.getGroupId(), targetLayout.getPlid(), sourceLayout.getPlid(), portletId, parameterMap); } return publishPortlet(userId, stagingGroup.getGroupId(), liveGroup.getGroupId(), sourceLayout.getPlid(), targetLayout.getPlid(), portletId, parameterMap); }
From source file:com.liferay.grow.linkedpages.LinkedPagesPortletControlMenuEntry.java
License:Open Source License
@Override public boolean isShow(HttpServletRequest request) throws PortalException { ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); Layout layout = themeDisplay.getLayout(); if (layout.isTypeControlPanel()) { return false; }/*from w w w . j a v a 2s . c om*/ if (themeDisplay.isImpersonated()) { return true; } User user = themeDisplay.getUser(); if (themeDisplay.isSignedIn() && user.isSetupComplete()) { return true; } return false; }
From source file:com.liferay.layout.admin.web.internal.control.menu.CustomizationSettingsProductNavigationControlMenuEntry.java
License:Open Source License
private boolean _isShow(HttpServletRequest request) throws PortalException { ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); Layout layout = themeDisplay.getLayout(); if (layout.isTypeControlPanel()) { return false; }/*w ww . ja va 2 s . c o m*/ if (!isCustomizableLayout(themeDisplay)) { return false; } return super.isShow(request); }
From source file:com.liferay.layout.admin.web.internal.control.menu.ManageLayoutProductNavigationControlMenuEntry.java
License:Open Source License
@Override public boolean isShow(HttpServletRequest request) throws PortalException { ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); Layout layout = themeDisplay.getLayout(); if (layout.isTypeControlPanel()) { return false; }/*from www . j a v a 2 s . c o m*/ if (!(themeDisplay.isShowLayoutTemplatesIcon() || themeDisplay.isShowPageSettingsIcon())) { return false; } return super.isShow(request); }
From source file:com.liferay.layout.admin.web.internal.control.menu.ToggleControlsProductNavigationControlMenuEntry.java
License:Open Source License
@Override public boolean isShow(HttpServletRequest request) throws PortalException { ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); Layout layout = themeDisplay.getLayout(); if (layout.isTypeControlPanel()) { return false; }// w w w . j ava2 s.com Group group = layout.getGroup(); if (group.hasStagingGroup() && !group.isStagingGroup() && PropsValues.STAGING_LIVE_GROUP_LOCKING_ENABLED) { return false; } if (!(hasUpdateLayoutPermission(themeDisplay) || hasCustomizePermission(themeDisplay) || hasPortletConfigurationPermission(themeDisplay))) { return false; } return super.isShow(request); }
From source file:com.liferay.layout.admin.web.internal.display.context.LayoutsAdminDisplayContext.java
License:Open Source License
public boolean isPrivateLayout() { if (_privateLayout != null) { return _privateLayout; }//from w ww. j av a 2 s . co m Group selGroup = getSelGroup(); if (selGroup.isLayoutSetPrototype() || selGroup.isLayoutSetPrototype()) { _privateLayout = true; return _privateLayout; } Layout selLayout = getSelLayout(); if (getSelLayout() != null) { _privateLayout = selLayout.isPrivateLayout(); return _privateLayout; } Layout layout = _themeDisplay.getLayout(); if (!layout.isTypeControlPanel()) { _privateLayout = layout.isPrivateLayout(); return _privateLayout; } _privateLayout = ParamUtil.getBoolean(_liferayPortletRequest, "privateLayout"); return _privateLayout; }
From source file:com.liferay.layout.admin.web.internal.product.navigation.control.menu.InformationMessagesProductNavigationControlMenuEntry.java
License:Open Source License
@Override public boolean isShow(HttpServletRequest request) throws PortalException { ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); Layout layout = themeDisplay.getLayout(); if (layout.isTypeControlPanel()) { return false; }/*from www.ja v a 2 s .co m*/ if (!isLinkedLayout(themeDisplay) && !isModifiedLayout(themeDisplay)) { return false; } return super.isShow(request); }
From source file:com.liferay.layout.admin.web.internal.theme.contributor.ToggleControlsTemplateContextContributor.java
License:Open Source License
@Override public void prepare(Map<String, Object> contextObjects, HttpServletRequest request) { String liferayToggleControls = SessionClicks.get(request, "com.liferay.frontend.js.web_toggleControls", "visible"); ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); Layout layout = themeDisplay.getLayout(); if (layout.isTypeControlPanel()) { liferayToggleControls = "visible"; }/*from w w w .j a v a2s . c o m*/ String cssClass = GetterUtil.getString(contextObjects.get("bodyCssClass")); if (Objects.equals(liferayToggleControls, "visible")) { cssClass += " controls-visible"; } else { cssClass += " controls-hidden"; } contextObjects.put("bodyCssClass", cssClass); contextObjects.put("liferay_toggle_controls", liferayToggleControls); contextObjects.put("show_toggle_controls", themeDisplay.isSignedIn()); if (themeDisplay.isSignedIn()) { ResourceBundle resourceBundle = ResourceBundleUtil.getBundle("content.Language", themeDisplay.getLocale(), getClass()); contextObjects.put("toggle_controls_text", LanguageUtil.get(resourceBundle, "toggle-controls")); contextObjects.put("toggle_controls_url", "javascript:;"); } }
From source file:com.liferay.layout.internal.util.LayoutsTreeImpl.java
License:Open Source License
private Layout _fetchCurrentLayout(HttpServletRequest request) { long selPlid = ParamUtil.getLong(request, "selPlid"); if (selPlid > 0) { return _layoutLocalService.fetchLayout(selPlid); }/*www.j a v a 2 s .c o m*/ ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); Layout layout = themeDisplay.getLayout(); if (!layout.isTypeControlPanel()) { return layout; } return null; }