public void editScope(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { Portlet portlet = ActionUtil.getPortlet(actionRequest); PortletPreferences portletPreferences = ActionUtil.getLayoutPortletSetup(actionRequest, portlet); actionRequest = ActionUtil.getWrappedActionRequest(actionRequest, portletPreferences); updateScope(actionRequest, portlet); if (!SessionErrors.isEmpty(actionRequest)) { return; } String portletResource = ParamUtil.getString(actionRequest, "portletResource"); SessionMessages.add( actionRequest, PortalUtil.getPortletId(actionRequest) + SessionMessages.KEY_SUFFIX_REFRESH_PORTLET, portletResource); SessionMessages.add( actionRequest, PortalUtil.getPortletId(actionRequest) + SessionMessages.KEY_SUFFIX_UPDATED_CONFIGURATION); }
public void editSharing(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { Portlet portlet = ActionUtil.getPortlet(actionRequest); PortletPreferences portletPreferences = ActionUtil.getLayoutPortletSetup(actionRequest, portlet); actionRequest = ActionUtil.getWrappedActionRequest(actionRequest, portletPreferences); updateAnyWebsite(actionRequest, portletPreferences); updateFacebook(actionRequest, portletPreferences); updateFriends(actionRequest, portletPreferences); updateGoogleGadget(actionRequest, portletPreferences); updateNetvibes(actionRequest, portletPreferences); portletPreferences.store(); if (!SessionErrors.isEmpty(actionRequest)) { return; } String portletResource = ParamUtil.getString(actionRequest, "portletResource"); SessionMessages.add( actionRequest, PortalUtil.getPortletId(actionRequest) + SessionMessages.KEY_SUFFIX_REFRESH_PORTLET, portletResource); SessionMessages.add( actionRequest, PortalUtil.getPortletId(actionRequest) + SessionMessages.KEY_SUFFIX_UPDATED_CONFIGURATION); }
@Override protected void doDispatch(RenderRequest renderRequest, RenderResponse renderResponse) throws IOException, PortletException { try { String mvcPath = renderRequest.getParameter("mvcPath"); if (mvcPath.equals("/edit_permissions.jsp")) { checkEditPermissionsJSP(renderRequest); super.doDispatch(renderRequest, renderResponse); return; } Portlet portlet = ActionUtil.getPortlet(renderRequest); if (mvcPath.endsWith("edit_configuration.jsp")) { ThemeDisplay themeDisplay = (ThemeDisplay) renderRequest.getAttribute(WebKeys.THEME_DISPLAY); String settingsScope = renderRequest.getParameter("settingsScope"); PortletPreferences portletPreferences = getPortletPreferences(themeDisplay, portlet.getPortletId(), settingsScope); renderRequest = ActionUtil.getWrappedRenderRequest(renderRequest, portletPreferences); renderEditConfiguration(renderRequest, portlet); } else { PortletPreferences portletPreferences = ActionUtil.getLayoutPortletSetup(renderRequest, portlet); renderRequest = ActionUtil.getWrappedRenderRequest(renderRequest, portletPreferences); if (mvcPath.endsWith("edit_public_render_parameters.jsp")) { renderEditPublicParameters(renderRequest, portlet); } } renderResponse.setTitle(ActionUtil.getTitle(portlet, renderRequest)); super.doDispatch(renderRequest, renderResponse); } catch (Exception e) { _log.error(e.getMessage()); SessionErrors.add(renderRequest, e.getClass()); include("/error.jsp", renderRequest, renderResponse); } }
public void editPublicRenderParameters(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { Portlet portlet = ActionUtil.getPortlet(actionRequest); PortletPreferences portletPreferences = ActionUtil.getLayoutPortletSetup(actionRequest, portlet); actionRequest = ActionUtil.getWrappedActionRequest(actionRequest, portletPreferences); Enumeration<String> enu = portletPreferences.getNames(); while (enu.hasMoreElements()) { String name = enu.nextElement(); if (name.startsWith(PublicRenderParameterConfiguration.IGNORE_PREFIX) || name.startsWith(PublicRenderParameterConfiguration.MAPPING_PREFIX)) { portletPreferences.reset(name); } } for (PublicRenderParameter publicRenderParameter : portlet.getPublicRenderParameters()) { String ignoreKey = PublicRenderParameterConfiguration.getIgnoreKey(publicRenderParameter); boolean ignoreValue = ParamUtil.getBoolean(actionRequest, ignoreKey); if (ignoreValue) { portletPreferences.setValue(ignoreKey, String.valueOf(Boolean.TRUE)); } else { String mappingKey = PublicRenderParameterConfiguration.getMappingKey(publicRenderParameter); String mappingValue = ParamUtil.getString(actionRequest, mappingKey); if (Validator.isNotNull(mappingValue)) { portletPreferences.setValue(mappingKey, mappingValue); } } } if (SessionErrors.isEmpty(actionRequest)) { portletPreferences.store(); } }
public void updateRolePermissions(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); String portletResource = ParamUtil.getString(actionRequest, "portletResource"); String modelResource = ParamUtil.getString(actionRequest, "modelResource"); long[] roleIds = StringUtil.split(ParamUtil.getString(actionRequest, "rolesSearchContainerPrimaryKeys"), 0L); String selResource = PortletConstants.getRootPortletId(portletResource); if (Validator.isNotNull(modelResource)) { selResource = modelResource; } long resourceGroupId = ParamUtil.getLong(actionRequest, "resourceGroupId", themeDisplay.getScopeGroupId()); String resourcePrimKey = ParamUtil.getString(actionRequest, "resourcePrimKey"); Map<Long, String[]> roleIdsToActionIds = new HashMap<>(); if (_resourceBlockLocalService.isSupported(selResource)) { for (long roleId : roleIds) { List<String> actionIds = getActionIdsList(actionRequest, roleId, true); roleIdsToActionIds.put(roleId, actionIds.toArray(new String[actionIds.size()])); } _resourceBlockService.setIndividualScopePermissions( themeDisplay.getCompanyId(), resourceGroupId, selResource, GetterUtil.getLong(resourcePrimKey), roleIdsToActionIds); } else { for (long roleId : roleIds) { String[] actionIds = getActionIds(actionRequest, roleId, false); roleIdsToActionIds.put(roleId, actionIds); } _resourcePermissionService.setIndividualResourcePermissions( resourceGroupId, themeDisplay.getCompanyId(), selResource, resourcePrimKey, roleIdsToActionIds); } if (PropsValues.PERMISSIONS_PROPAGATION_ENABLED) { Portlet portlet = _portletLocalService.getPortletById(themeDisplay.getCompanyId(), portletResource); PermissionPropagator permissionPropagator = portlet.getPermissionPropagatorInstance(); if (permissionPropagator != null) { permissionPropagator.propagateRolePermissions( actionRequest, modelResource, resourcePrimKey, roleIds); } } if (Validator.isNull(modelResource)) { // Force update of layout modified date. See LPS-59246. Portlet portlet = ActionUtil.getPortlet(actionRequest); PortletPreferences portletPreferences = ActionUtil.getLayoutPortletSetup(actionRequest, portlet); portletPreferences.store(); } }