List of usage examples for com.liferay.portal.events EventsProcessorUtil process
public static void process(String key, String[] classes, HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws ActionException
From source file:com.liferay.layout.admin.web.internal.portlet.action.DeleteLayoutMVCActionCommand.java
License:Open Source License
protected void deleteLayout(long selPlid, ActionRequest actionRequest, ActionResponse actionResponse) throws PortalException { ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); PermissionChecker permissionChecker = themeDisplay.getPermissionChecker(); Layout layout = _layoutLocalService.getLayout(selPlid); Group group = layout.getGroup(); if (group.isStagingGroup() && !GroupPermissionUtil.contains(permissionChecker, group, ActionKeys.MANAGE_STAGING) && !GroupPermissionUtil.contains(permissionChecker, group, ActionKeys.PUBLISH_STAGING)) { throw new PrincipalException.MustHavePermission(permissionChecker, Group.class.getName(), group.getGroupId(), ActionKeys.MANAGE_STAGING, ActionKeys.PUBLISH_STAGING); }/*from w w w. j a v a 2 s . co m*/ if (LayoutPermissionUtil.contains(permissionChecker, layout, ActionKeys.DELETE)) { LayoutType layoutType = layout.getLayoutType(); EventsProcessorUtil.process(PropsKeys.LAYOUT_CONFIGURATION_ACTION_DELETE, layoutType.getConfigurationActionDelete(), _portal.getHttpServletRequest(actionRequest), _portal.getHttpServletResponse(actionResponse)); } if (group.isGuest() && !layout.isPrivateLayout() && layout.isRootLayout() && (_layoutLocalService .getLayoutsCount(group, false, LayoutConstants.DEFAULT_PARENT_LAYOUT_ID) == 1)) { throw new RequiredLayoutException(RequiredLayoutException.AT_LEAST_ONE); } ServiceContext serviceContext = ServiceContextFactory.getInstance(actionRequest); _layoutService.deleteLayout(selPlid, serviceContext); }
From source file:com.liferay.layout.admin.web.internal.portlet.action.EditLayoutMVCActionCommand.java
License:Open Source License
@Override protected void doProcessAction(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { UploadPortletRequest uploadPortletRequest = _portal.getUploadPortletRequest(actionRequest); ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); long groupId = ParamUtil.getLong(actionRequest, "groupId"); long liveGroupId = ParamUtil.getLong(actionRequest, "liveGroupId"); long stagingGroupId = ParamUtil.getLong(actionRequest, "stagingGroupId"); boolean privateLayout = ParamUtil.getBoolean(actionRequest, "privateLayout"); long layoutId = ParamUtil.getLong(actionRequest, "layoutId"); Map<Locale, String> nameMap = LocalizationUtil.getLocalizationMap(actionRequest, "name"); Map<Locale, String> titleMap = LocalizationUtil.getLocalizationMap(actionRequest, "title"); Map<Locale, String> descriptionMap = LocalizationUtil.getLocalizationMap(actionRequest, "description"); Map<Locale, String> keywordsMap = LocalizationUtil.getLocalizationMap(actionRequest, "keywords"); Map<Locale, String> robotsMap = LocalizationUtil.getLocalizationMap(actionRequest, "robots"); String type = ParamUtil.getString(uploadPortletRequest, "type"); boolean hidden = ParamUtil.getBoolean(uploadPortletRequest, "hidden"); Map<Locale, String> friendlyURLMap = LocalizationUtil.getLocalizationMap(actionRequest, "friendlyURL"); boolean deleteLogo = ParamUtil.getBoolean(actionRequest, "deleteLogo"); byte[] iconBytes = null; long fileEntryId = ParamUtil.getLong(uploadPortletRequest, "fileEntryId"); if (fileEntryId > 0) { FileEntry fileEntry = _dlAppLocalService.getFileEntry(fileEntryId); iconBytes = FileUtil.getBytes(fileEntry.getContentStream()); }//from w ww . ja v a2s .c o m ServiceContext serviceContext = ServiceContextFactory.getInstance(Layout.class.getName(), actionRequest); Layout layout = _layoutLocalService.getLayout(groupId, privateLayout, layoutId); String currentType = layout.getType(); layout = _layoutService.updateLayout(groupId, privateLayout, layoutId, layout.getParentLayoutId(), nameMap, titleMap, descriptionMap, keywordsMap, robotsMap, type, hidden, friendlyURLMap, !deleteLogo, iconBytes, serviceContext); themeDisplay.clearLayoutFriendlyURL(layout); UnicodeProperties layoutTypeSettingsProperties = layout.getTypeSettingsProperties(); UnicodeProperties formTypeSettingsProperties = PropertiesParamUtil.getProperties(actionRequest, "TypeSettingsProperties--"); String linkToLayoutUuid = ParamUtil.getString(actionRequest, "linkToLayoutUuid"); if (Validator.isNotNull(linkToLayoutUuid)) { Layout linkToLayout = _layoutLocalService.getLayoutByUuidAndGroupId(linkToLayoutUuid, groupId, privateLayout); formTypeSettingsProperties.put("linkToLayoutId", String.valueOf(linkToLayout.getLayoutId())); } LayoutTypePortlet layoutTypePortlet = (LayoutTypePortlet) layout.getLayoutType(); if (type.equals(LayoutConstants.TYPE_PORTLET)) { String layoutTemplateId = ParamUtil.getString(uploadPortletRequest, "layoutTemplateId", PropsValues.DEFAULT_LAYOUT_TEMPLATE_ID); layoutTypePortlet.setLayoutTemplateId(themeDisplay.getUserId(), layoutTemplateId); layoutTypeSettingsProperties.putAll(formTypeSettingsProperties); boolean layoutCustomizable = GetterUtil .getBoolean(layoutTypeSettingsProperties.get(LayoutConstants.CUSTOMIZABLE_LAYOUT)); if (!layoutCustomizable) { layoutTypePortlet.removeCustomization(layoutTypeSettingsProperties); } layout = _layoutService.updateLayout(groupId, privateLayout, layoutId, layoutTypeSettingsProperties.toString()); if (!currentType.equals(LayoutConstants.TYPE_PORTLET)) { _portletPreferencesLocalService.deletePortletPreferences(0, PortletKeys.PREFS_OWNER_TYPE_LAYOUT, layout.getPlid()); } } else { layoutTypeSettingsProperties.putAll(formTypeSettingsProperties); layoutTypeSettingsProperties.putAll(layout.getTypeSettingsProperties()); layout = _layoutService.updateLayout(groupId, privateLayout, layoutId, layoutTypeSettingsProperties.toString()); } HttpServletResponse response = _portal.getHttpServletResponse(actionResponse); EventsProcessorUtil.process(PropsKeys.LAYOUT_CONFIGURATION_ACTION_UPDATE, layoutTypePortlet.getConfigurationActionUpdate(), uploadPortletRequest, response); _actionUtil.updateLookAndFeel(actionRequest, themeDisplay.getCompanyId(), liveGroupId, stagingGroupId, privateLayout, layout.getLayoutId(), layout.getTypeSettingsProperties()); String redirect = ParamUtil.getString(actionRequest, "redirect"); if (Validator.isNull(redirect)) { redirect = _portal.getLayoutFullURL(layout, themeDisplay); } String portletResource = ParamUtil.getString(actionRequest, "portletResource"); MultiSessionMessages.add(actionRequest, portletResource + "layoutUpdated", layout); actionRequest.setAttribute(WebKeys.REDIRECT, redirect); }
From source file:com.liferay.portlet.layoutsadmin.action.EditLayoutsAction.java
License:Open Source License
protected Object[] updateLayout(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { UploadPortletRequest uploadPortletRequest = PortalUtil.getUploadPortletRequest(actionRequest); ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); String cmd = ParamUtil.getString(uploadPortletRequest, Constants.CMD); long groupId = ParamUtil.getLong(actionRequest, "groupId"); long liveGroupId = ParamUtil.getLong(actionRequest, "liveGroupId"); long stagingGroupId = ParamUtil.getLong(actionRequest, "stagingGroupId"); boolean privateLayout = ParamUtil.getBoolean(actionRequest, "privateLayout"); long layoutId = ParamUtil.getLong(actionRequest, "layoutId"); long parentLayoutId = ParamUtil.getLong(uploadPortletRequest, "parentLayoutId"); Map<Locale, String> nameMap = LocalizationUtil.getLocalizationMap(actionRequest, "name"); Map<Locale, String> titleMap = LocalizationUtil.getLocalizationMap(actionRequest, "title"); Map<Locale, String> descriptionMap = LocalizationUtil.getLocalizationMap(actionRequest, "description"); Map<Locale, String> keywordsMap = LocalizationUtil.getLocalizationMap(actionRequest, "keywords"); Map<Locale, String> robotsMap = LocalizationUtil.getLocalizationMap(actionRequest, "robots"); String type = ParamUtil.getString(uploadPortletRequest, "type"); boolean hidden = ParamUtil.getBoolean(uploadPortletRequest, "hidden"); String friendlyURL = ParamUtil.getString(uploadPortletRequest, "friendlyURL"); boolean iconImage = ParamUtil.getBoolean(uploadPortletRequest, "iconImage"); byte[] iconBytes = getIconBytes(uploadPortletRequest, "iconFileName"); long layoutPrototypeId = ParamUtil.getLong(uploadPortletRequest, "layoutPrototypeId"); ServiceContext serviceContext = ServiceContextFactory.getInstance(Layout.class.getName(), actionRequest); Layout layout = null;/* w w w.j av a 2s . c o m*/ UnicodeProperties layoutTypeSettingsProperties = null; String oldFriendlyURL = StringPool.BLANK; if (cmd.equals(Constants.ADD)) { // Add layout boolean inheritFromParentLayoutId = ParamUtil.getBoolean(uploadPortletRequest, "inheritFromParentLayoutId"); if (inheritFromParentLayoutId && (parentLayoutId > 0)) { Layout parentLayout = LayoutLocalServiceUtil.getLayout(groupId, privateLayout, parentLayoutId); layout = LayoutServiceUtil.addLayout(groupId, privateLayout, parentLayoutId, nameMap, titleMap, descriptionMap, keywordsMap, robotsMap, parentLayout.getType(), hidden, friendlyURL, serviceContext); LayoutServiceUtil.updateLayout(layout.getGroupId(), layout.isPrivateLayout(), layout.getLayoutId(), parentLayout.getTypeSettings()); if (parentLayout.isTypePortlet()) { ActionUtil.copyPreferences(actionRequest, layout, parentLayout); SitesUtil.copyLookAndFeel(layout, parentLayout); } } else if (layoutPrototypeId > 0) { LayoutPrototype layoutPrototype = LayoutPrototypeServiceUtil.getLayoutPrototype(layoutPrototypeId); String layoutPrototypeLinkEnabled = ParamUtil.getString(uploadPortletRequest, "layoutPrototypeLinkEnabled"); if (Validator.isNotNull(layoutPrototypeLinkEnabled)) { serviceContext.setAttribute("layoutPrototypeLinkEnabled", layoutPrototypeLinkEnabled); } serviceContext.setAttribute("layoutPrototypeUuid", layoutPrototype.getUuid()); layout = LayoutServiceUtil.addLayout(groupId, privateLayout, parentLayoutId, nameMap, titleMap, descriptionMap, keywordsMap, robotsMap, LayoutConstants.TYPE_PORTLET, hidden, friendlyURL, serviceContext); } else { layout = LayoutServiceUtil.addLayout(groupId, privateLayout, parentLayoutId, nameMap, titleMap, descriptionMap, keywordsMap, robotsMap, type, hidden, friendlyURL, serviceContext); } layoutTypeSettingsProperties = layout.getTypeSettingsProperties(); } else { // Update layout layout = LayoutLocalServiceUtil.getLayout(groupId, privateLayout, layoutId); oldFriendlyURL = layout.getFriendlyURL(); layout = LayoutServiceUtil.updateLayout(groupId, privateLayout, layoutId, layout.getParentLayoutId(), nameMap, titleMap, descriptionMap, keywordsMap, robotsMap, type, hidden, friendlyURL, Boolean.valueOf(iconImage), iconBytes, serviceContext); layoutTypeSettingsProperties = layout.getTypeSettingsProperties(); if (oldFriendlyURL.equals(layout.getFriendlyURL())) { oldFriendlyURL = StringPool.BLANK; } UnicodeProperties formTypeSettingsProperties = PropertiesParamUtil.getProperties(actionRequest, "TypeSettingsProperties--"); if (type.equals(LayoutConstants.TYPE_PORTLET)) { LayoutTypePortlet layoutTypePortlet = (LayoutTypePortlet) layout.getLayoutType(); String layoutTemplateId = ParamUtil.getString(uploadPortletRequest, "layoutTemplateId", PropsValues.DEFAULT_LAYOUT_TEMPLATE_ID); layoutTypePortlet.setLayoutTemplateId(themeDisplay.getUserId(), layoutTemplateId); long copyLayoutId = ParamUtil.getLong(uploadPortletRequest, "copyLayoutId"); if ((copyLayoutId > 0) && (copyLayoutId != layout.getLayoutId())) { try { Layout copyLayout = LayoutLocalServiceUtil.getLayout(groupId, privateLayout, copyLayoutId); if (copyLayout.isTypePortlet()) { layoutTypeSettingsProperties = copyLayout.getTypeSettingsProperties(); ActionUtil.copyPreferences(actionRequest, layout, copyLayout); SitesUtil.copyLookAndFeel(layout, copyLayout); } } catch (NoSuchLayoutException nsle) { } } else { layoutTypeSettingsProperties.putAll(formTypeSettingsProperties); LayoutServiceUtil.updateLayout(groupId, privateLayout, layoutId, layout.getTypeSettings()); } } else { layout.setTypeSettingsProperties(formTypeSettingsProperties); layoutTypeSettingsProperties.putAll(layout.getTypeSettingsProperties()); LayoutServiceUtil.updateLayout(groupId, privateLayout, layoutId, layout.getTypeSettings()); } HttpServletResponse response = PortalUtil.getHttpServletResponse(actionResponse); LayoutSettings layoutSettings = LayoutSettings.getInstance(layout); EventsProcessorUtil.process(PropsKeys.LAYOUT_CONFIGURATION_ACTION_UPDATE, layoutSettings.getConfigurationActionUpdate(), uploadPortletRequest, response); } updateLookAndFeel(actionRequest, themeDisplay.getCompanyId(), liveGroupId, stagingGroupId, privateLayout, layout.getLayoutId(), layoutTypeSettingsProperties); updateCustomAttributes(themeDisplay.getCompanyId(), layout, uploadPortletRequest); return new Object[] { layout, oldFriendlyURL }; }
From source file:com.liferay.portlet.layoutsadmin.action.UpdateLayoutAction.java
License:Open Source License
protected String[] addPage(ThemeDisplay themeDisplay, HttpServletRequest request, HttpServletResponse response) throws Exception { String doAsUserId = ParamUtil.getString(request, "doAsUserId"); String doAsUserLanguageId = ParamUtil.getString(request, "doAsUserLanguageId"); long groupId = ParamUtil.getLong(request, "groupId"); boolean privateLayout = ParamUtil.getBoolean(request, "privateLayout"); long parentLayoutId = ParamUtil.getLong(request, "parentLayoutId"); String name = ParamUtil.getString(request, "name", "New Page"); String title = StringPool.BLANK; String description = StringPool.BLANK; String type = LayoutConstants.TYPE_PORTLET; boolean hidden = false; String friendlyURL = StringPool.BLANK; long layoutPrototypeId = ParamUtil.getLong(request, "layoutPrototypeId"); ServiceContext serviceContext = ServiceContextFactory.getInstance(request); Layout layout = null;//ww w . j av a 2 s. co m if (layoutPrototypeId > 0) { LayoutPrototype layoutPrototype = LayoutPrototypeServiceUtil.getLayoutPrototype(layoutPrototypeId); serviceContext.setAttribute("layoutPrototypeLinkEnabled", true); serviceContext.setAttribute("layoutPrototypeUuid", layoutPrototype.getUuid()); layout = LayoutServiceUtil.addLayout(groupId, privateLayout, parentLayoutId, name, title, description, LayoutConstants.TYPE_PORTLET, false, friendlyURL, serviceContext); } else { layout = LayoutServiceUtil.addLayout(groupId, privateLayout, parentLayoutId, name, title, description, type, hidden, friendlyURL, serviceContext); } LayoutSettings layoutSettings = LayoutSettings.getInstance(layout); EventsProcessorUtil.process(PropsKeys.LAYOUT_CONFIGURATION_ACTION_UPDATE, layoutSettings.getConfigurationActionUpdate(), request, response); String layoutURL = PortalUtil.getLayoutURL(layout, themeDisplay); if (Validator.isNotNull(doAsUserId)) { layoutURL = HttpUtil.addParameter(layoutURL, "doAsUserId", themeDisplay.getDoAsUserId()); } if (Validator.isNotNull(doAsUserLanguageId)) { layoutURL = HttpUtil.addParameter(layoutURL, "doAsUserLanguageId", themeDisplay.getDoAsUserLanguageId()); } boolean updateable = SitesUtil.isLayoutUpdateable(layout); boolean deleteable = updateable && LayoutPermissionUtil.contains(themeDisplay.getPermissionChecker(), layout, ActionKeys.DELETE); return new String[] { String.valueOf(layout.getLayoutId()), layoutURL, String.valueOf(deleteable), String.valueOf(updateable) }; }
From source file:com.liferay.portlet.sites.util.SitesUtil.java
License:Open Source License
public static Object[] deleteLayout(HttpServletRequest request, HttpServletResponse response) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); PermissionChecker permissionChecker = themeDisplay.getPermissionChecker(); long plid = ParamUtil.getLong(request, "plid"); long groupId = ParamUtil.getLong(request, "groupId"); boolean privateLayout = ParamUtil.getBoolean(request, "privateLayout"); long layoutId = ParamUtil.getLong(request, "layoutId"); Layout layout = null;//from www . j ava 2 s . c o m if (plid <= 0) { layout = LayoutLocalServiceUtil.getLayout(groupId, privateLayout, layoutId); } else { layout = LayoutLocalServiceUtil.getLayout(plid); groupId = layout.getGroupId(); privateLayout = layout.isPrivateLayout(); layoutId = layout.getLayoutId(); } Group group = layout.getGroup(); String oldFriendlyURL = layout.getFriendlyURL(); if (group.isStagingGroup() && !GroupPermissionUtil.contains(permissionChecker, groupId, ActionKeys.MANAGE_STAGING) && !GroupPermissionUtil.contains(permissionChecker, groupId, ActionKeys.PUBLISH_STAGING)) { throw new PrincipalException(); } if (LayoutPermissionUtil.contains(permissionChecker, layout, ActionKeys.DELETE)) { LayoutSettings layoutSettings = LayoutSettings.getInstance(layout); EventsProcessorUtil.process(PropsKeys.LAYOUT_CONFIGURATION_ACTION_DELETE, layoutSettings.getConfigurationActionDelete(), request, response); } LayoutSet layoutSet = layout.getLayoutSet(); Group layoutSetGroup = layoutSet.getGroup(); ServiceContext serviceContext = ServiceContextFactory.getInstance(request); if (layoutSetGroup.isLayoutSetPrototype()) { LayoutSetPrototype layoutSetPrototype = LayoutSetPrototypeLocalServiceUtil .getLayoutSetPrototype(layoutSetGroup.getClassPK()); List<LayoutSet> linkedLayoutSets = LayoutSetLocalServiceUtil .getLayoutSetsByLayoutSetPrototypeUuid(layoutSetPrototype.getUuid()); for (LayoutSet linkedLayoutSet : linkedLayoutSets) { Layout linkedLayout = LayoutLocalServiceUtil.fetchLayoutByUuidAndGroupId(layout.getUuid(), linkedLayoutSet.getGroupId()); if ((linkedLayout != null) && (!isLayoutUpdateable(linkedLayout) || isLayoutToBeUpdatedFromSourcePrototype(linkedLayout))) { LayoutServiceUtil.deleteLayout(linkedLayout.getPlid(), serviceContext); } } } LayoutServiceUtil.deleteLayout(groupId, privateLayout, layoutId, serviceContext); long newPlid = layout.getParentPlid(); if (newPlid <= 0) { Layout firstLayout = LayoutLocalServiceUtil.fetchFirstLayout(layoutSet.getGroupId(), layoutSet.getPrivateLayout(), LayoutConstants.DEFAULT_PARENT_LAYOUT_ID); if (firstLayout != null) { newPlid = firstLayout.getPlid(); } } return new Object[] { group, oldFriendlyURL, newPlid }; }