List of usage examples for com.liferay.portal.kernel.portlet LiferayPortletConfig getPortletId
public String getPortletId();
From source file:com.liferay.portlet.layoutsadmin.action.EditLayoutsAction.java
License:Open Source License
@Override public void processAction(ActionMapping mapping, ActionForm form, PortletConfig portletConfig, ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { try {/*from www . j av a2 s. c om*/ checkPermissions(actionRequest); } catch (PrincipalException pe) { return; } ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); String cmd = ParamUtil.getString(actionRequest, Constants.CMD); //Modification start SessionErrorsUtil.clear(actionRequest); SessionErrors.clear(actionRequest); //Modification end try { String redirect = ParamUtil.getString(actionRequest, "redirect"); String closeRedirect = ParamUtil.getString(actionRequest, "closeRedirect"); Layout layout = null; String oldFriendlyURL = StringPool.BLANK; if (cmd.equals(Constants.ADD) || cmd.equals(Constants.UPDATE)) { Object[] returnValue = updateLayout(actionRequest, actionResponse); layout = (Layout) returnValue[0]; oldFriendlyURL = (String) returnValue[1]; redirect = updateCloseRedirect(redirect, null, layout, oldFriendlyURL); closeRedirect = updateCloseRedirect(closeRedirect, null, layout, oldFriendlyURL); } else if (cmd.equals(Constants.DELETE)) { Object[] returnValue = SitesUtil.deleteLayout(actionRequest, actionResponse); Group group = (Group) returnValue[0]; oldFriendlyURL = (String) returnValue[1]; long newRefererPlid = (Long) returnValue[2]; redirect = updateCloseRedirect(redirect, group, null, oldFriendlyURL); redirect = HttpUtil.setParameter(redirect, "refererPlid", newRefererPlid); // ===================== start of change https://jira.playtech.corp/browse/WPL-2040 redirect = HttpUtil.setParameter(redirect, actionResponse.getNamespace() + "selPlid", newRefererPlid); // ===================== end of change closeRedirect = updateCloseRedirect(closeRedirect, group, null, oldFriendlyURL); } else if (cmd.equals("copy_from_live")) { StagingUtil.copyFromLive(actionRequest); } else if (cmd.equals("display_order")) { updateDisplayOrder(actionRequest); } else if (cmd.equals("delete_layout_revision")) { deleteLayoutRevision(actionRequest); } else if (cmd.equals("enable")) { enableLayout(actionRequest); } else if (cmd.equals("publish_to_live")) { StagingUtil.publishToLive(actionRequest); } else if (cmd.equals("publish_to_remote")) { StagingUtil.publishToRemote(actionRequest); } else if (cmd.equals("reset_customized_view")) { LayoutTypePortlet layoutTypePortlet = themeDisplay.getLayoutTypePortlet(); if ((layoutTypePortlet != null) && layoutTypePortlet.isCustomizable() && layoutTypePortlet.isCustomizedView()) { layoutTypePortlet.resetUserPreferences(); } } else if (cmd.equals("reset_prototype")) { SitesUtil.resetPrototype(themeDisplay.getLayout()); } else if (cmd.equals("schedule_copy_from_live")) { StagingUtil.scheduleCopyFromLive(actionRequest); } else if (cmd.equals("schedule_publish_to_live")) { StagingUtil.schedulePublishToLive(actionRequest); } else if (cmd.equals("schedule_publish_to_remote")) { StagingUtil.schedulePublishToRemote(actionRequest); } else if (cmd.equals("select_layout_set_branch")) { selectLayoutSetBranch(actionRequest); } else if (cmd.equals("select_layout_branch")) { selectLayoutBranch(actionRequest); } else if (cmd.equals("unschedule_copy_from_live")) { StagingUtil.unscheduleCopyFromLive(actionRequest); } else if (cmd.equals("unschedule_publish_to_live")) { StagingUtil.unschedulePublishToLive(actionRequest); } else if (cmd.equals("unschedule_publish_to_remote")) { StagingUtil.unschedulePublishToRemote(actionRequest); } else if (cmd.equals("update_layout_revision")) { updateLayoutRevision(actionRequest, themeDisplay); } if (Validator.isNotNull(closeRedirect)) { LiferayPortletConfig liferayPortletConfig = (LiferayPortletConfig) portletConfig; SessionMessages.add(actionRequest, liferayPortletConfig.getPortletId() + SessionMessages.KEY_SUFFIX_CLOSE_REDIRECT, closeRedirect); } sendRedirect(actionRequest, actionResponse, redirect); } catch (Exception e) { if (e instanceof NoSuchLayoutException || e instanceof PrincipalException) { SessionErrors.add(actionRequest, e.getClass()); setForward(actionRequest, "portlet.layouts_admin.error"); } else if (e instanceof ImageTypeException || e instanceof LayoutFriendlyURLException || e instanceof LayoutHiddenException || e instanceof LayoutNameException || e instanceof LayoutParentLayoutIdException || e instanceof LayoutSetVirtualHostException || e instanceof LayoutTypeException || e instanceof RequiredLayoutException || e instanceof UploadException) { if (e instanceof LayoutFriendlyURLException) { SessionErrors.add(actionRequest, LayoutFriendlyURLException.class.getName(), e); } else { SessionErrors.add(actionRequest, e.getClass(), e); } } else if (e instanceof DuplicateLockException || e instanceof LayoutPrototypeException || e instanceof RemoteExportException || e instanceof RemoteOptionsException || e instanceof SystemException) { SessionErrors.add(actionRequest, e.getClass(), e); String redirect = ParamUtil.getString(actionRequest, "pagesRedirect"); sendRedirect(actionRequest, actionResponse, redirect); } else { throw e; } } finally { SessionErrorsUtil.copyFromSessionErrors(actionRequest); } }
From source file:com.liferay.taglib.portlet.ActionURLTag.java
License:Open Source License
private static String _getPortletName(HttpServletRequest request) { PortletRequest portletRequest = (PortletRequest) request.getAttribute(JavaConstants.JAVAX_PORTLET_REQUEST); if (portletRequest == null) { return null; }//w w w .ja va2 s . c o m LiferayPortletConfig liferayPortletConfig = (LiferayPortletConfig) request .getAttribute(JavaConstants.JAVAX_PORTLET_CONFIG); return liferayPortletConfig.getPortletId(); }
From source file:com.verce.action.ConfigurationActionImpl.java
License:Open Source License
@Override public void processAction(PortletConfig portletConfig, ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { String cmd = ParamUtil.getString(actionRequest, "cmd"); if (cmd.equals("update")) { ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); UnicodeProperties properties = PropertiesParamUtil.getProperties(actionRequest, PREFERENCES_PREFIX); String portletResource = ParamUtil.getString(actionRequest, "portletResource"); PortletPermissionUtil.check(themeDisplay.getPermissionChecker(), themeDisplay.getLayout(), portletResource, ActionKeys.CONFIGURATION); PortletPreferences portletPreferences = PortletPreferencesFactoryUtil.getPortletSetup(actionRequest, portletResource);/*from w ww .j a va 2 s. com*/ for (Map.Entry<String, String> entry : properties.entrySet()) { String name = entry.getKey(); String value = entry.getValue(); portletPreferences.setValue(name, value); } Map<String, String[]> portletPreferencesMap = (Map<String, String[]>) actionRequest .getAttribute(WebKeys.PORTLET_PREFERENCES_MAP); if (portletPreferencesMap != null) { for (Map.Entry<String, String[]> entry : portletPreferencesMap.entrySet()) { String name = entry.getKey(); String[] values = entry.getValue(); portletPreferences.setValues(name, values); } } if (SessionErrors.isEmpty(actionRequest)) { portletPreferences.store(); LiferayPortletConfig liferayPortletConfig = (LiferayPortletConfig) portletConfig; SessionMessages.add(actionRequest, liferayPortletConfig.getPortletId() + ".refreshPortlet", portletResource); SessionMessages.add(actionRequest, liferayPortletConfig.getPortletId() + ".updatedConfiguration"); } } }
From source file:hu.vilmospapp.qrcodedisplay.action.ConfigurationActionImpl.java
License:Open Source License
public void processAction(PortletConfig portletConfig, ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { String portletResource = ParamUtil.getString(actionRequest, "portletResource"); PortletPreferences prefs = PortletPreferencesFactoryUtil.getPortletSetup(actionRequest, portletResource); String backgroundColor = getParameter(actionRequest, "backgroundColor"); String borderColor = getParameter(actionRequest, "borderColor"); String borderEnabled = getParameter(actionRequest, "borderEnabled"); String borderRadius = getParameter(actionRequest, "borderRadius"); String borderStyle = getParameter(actionRequest, "borderStyle"); String borderWidth = getParameter(actionRequest, "borderWidth"); String characterSet = getParameter(actionRequest, "characterSet"); String content = getParameter(actionRequest, "content"); String dimension = getParameter(actionRequest, "dimension"); String displayType = getParameter(actionRequest, "displayType"); String errorCorrection = getParameter(actionRequest, "errorCorrection"); String foregroundColor = getParameter(actionRequest, "foregroundColor"); String imageFormat = getParameter(actionRequest, "imageFormat"); String margin = getParameter(actionRequest, "margin"); String mode = getParameter(actionRequest, "mode"); String shadowAngle = getParameter(actionRequest, "shadowAngle"); String shadowBlur = getParameter(actionRequest, "shadowBlur"); String shadowColor = getParameter(actionRequest, "shadowColor"); String shadowDistance = getParameter(actionRequest, "shadowDistance"); String shadowEnabled = getParameter(actionRequest, "shadowEnabled"); String shadowOpacity = getParameter(actionRequest, "shadowOpacity"); String stripParams = getParameter(actionRequest, "stripParams"); prefs.setValue("backgroundColor", backgroundColor); prefs.setValue("borderColor", borderColor); prefs.setValue("borderEnabled", borderEnabled); prefs.setValue("borderRadius", borderRadius); prefs.setValue("borderStyle", borderStyle); prefs.setValue("borderWidth", borderWidth); prefs.setValue("characterSet", characterSet); prefs.setValue("content", content); prefs.setValue("dimension", dimension); prefs.setValue("displayType", displayType); prefs.setValue("errorCorrection", errorCorrection); prefs.setValue("foregroundColor", foregroundColor); prefs.setValue("imageFormat", imageFormat); prefs.setValue("margin", margin); prefs.setValue("mode", mode); prefs.setValue("shadowAngle", shadowAngle); prefs.setValue("shadowBlur", shadowBlur); prefs.setValue("shadowColor", shadowColor); prefs.setValue("shadowDistance", shadowDistance); prefs.setValue("shadowEnabled", shadowEnabled); prefs.setValue("shadowOpacity", shadowOpacity); prefs.setValue("stripParams", stripParams); prefs.store();/*from w ww. j a v a2 s . c om*/ LiferayPortletConfig liferayPortletConfig = (LiferayPortletConfig) portletConfig; SessionMessages.add(actionRequest, liferayPortletConfig.getPortletId() + SessionMessages.KEY_SUFFIX_REFRESH_PORTLET, portletResource); SessionMessages.add(actionRequest, liferayPortletConfig.getPortletId() + SessionMessages.KEY_SUFFIX_UPDATED_CONFIGURATION); }
From source file:it.dfa.unict.CodeRadePortlet.java
/** * * @param actionRequest//from w w w.j ava 2s .c o m * @param actionResponse * @throws IOException * @throws PortletException */ @ProcessAction(name = "submit") public void submit(ActionRequest actionRequest, ActionResponse actionResponse) throws IOException, PortletException { AppInput appInput = new AppInput(); PortletConfig portletConfig = (PortletConfig) actionRequest .getAttribute(JavaConstants.JAVAX_PORTLET_CONFIG); LiferayPortletConfig liferayPortletConfig = (LiferayPortletConfig) portletConfig; SimpleDateFormat dateFormat = new SimpleDateFormat(TS_FORMAT); String timestamp = dateFormat.format(Calendar.getInstance().getTime()); appInput.setTimestamp(timestamp); ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); User user = themeDisplay.getUser(); String username = user.getScreenName(); appInput.setUsername(username); UploadPortletRequest uploadPortletRequest = PortalUtil.getUploadPortletRequest(actionRequest); String appServerPath = actionRequest.getPortletSession().getPortletContext().getRealPath(File.separator); try { String uploadedModel = processInputFile(uploadPortletRequest, username, timestamp, appInput); appInput.setInputSandbox(uploadedModel); String jobIdentifier = ParamUtil.getString(actionRequest, "jobIdentifier", appInput.getModelName() + "_" + appInput.getTimestamp()); appInput.setJobIdentifier(jobIdentifier); _log.info(appInput); InfrastructureInfo[] enabledInfrastructures = getEnabledInfrastructures( appInfrastructureInfoPreferences); submitJob(appServerPath, appInput, enabledInfrastructures); PortalUtil.copyRequestParameters(actionRequest, actionResponse); actionResponse.setRenderParameter("jobIdentifier", jobIdentifier); actionResponse.setRenderParameter("jspPage", "/jsps/submit.jsp"); } catch (CodeRadePortletException ex) { _log.warn(ex.getMessage()); SessionErrors.add(actionRequest, ex.getMessage()); } SessionMessages.add(actionRequest, liferayPortletConfig.getPortletId() + SessionMessages.KEY_SUFFIX_HIDE_DEFAULT_ERROR_MESSAGE); }
From source file:it.dfa.unict.CodeRadePortlet.java
@ProcessAction(name = "pilotScript") public void pilotScript(ActionRequest actionRequest, ActionResponse actionResponse) throws IOException { _log.debug("pilotScript()"); PortletConfig portletConfig = (PortletConfig) actionRequest .getAttribute(JavaConstants.JAVAX_PORTLET_CONFIG); LiferayPortletConfig liferayPortletConfig = (LiferayPortletConfig) portletConfig; String pilotScript = ParamUtil.getString(actionRequest, "pilotScript"); _log.debug("pilotScript() " + pilotScript); String appServerPath = actionRequest.getPortletSession().getPortletContext().getRealPath(File.separator); PortalUtil.copyRequestParameters(actionRequest, actionResponse); actionResponse.setRenderParameter("jspPage", "/jsps/view-pilot.jsp"); actionRequest.setAttribute("pilotScript", updateString(appServerPath + "WEB-INF/job/" + pilotScript)); SessionMessages.add(actionRequest,/* w ww.j a v a 2 s. c om*/ liferayPortletConfig.getPortletId() + SessionMessages.KEY_SUFFIX_HIDE_DEFAULT_ERROR_MESSAGE); }