@Override public void processAction(PortletConfig portletConfig, ActionRequest actionRequest, ActionResponse arg2) throws Exception { if (!Constants.UPDATE.equals(actionRequest.getParameter(Constants.CMD))) return; PortletPreferences prefs; String portletResource = ParamUtil.getString(actionRequest, "portletResource"); if (Validator.isNotNull(portletResource)){ prefs = PortletPreferencesFactoryUtil.getPortletSetup(actionRequest, portletResource); } else { prefs = actionRequest.getPreferences(); } prefs.setValue("numerateModules", actionRequest.getParameter("numerateModules")); prefs.store(); SessionMessages.add(actionRequest,portletConfig.getPortletName() + ".doConfigure"); }
@Override public void processAction(PortletConfig portletConfig, ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { String columns = ParamUtil.getString(actionRequest, "columns"); String[] exportFileNames = actionRequest.getParameterValues("exportFileName"); String[] exportNames = actionRequest.getParameterValues("exportName"); String[] exportScripts = actionRequest.getParameterValues("exportScript"); setPreference(actionRequest, "columns", columns.split(",")); setPreference(actionRequest, "exportFileName", exportFileNames); setPreference(actionRequest, "exportName", exportNames); setPreference(actionRequest, "exportScript", exportScripts); super.processAction(portletConfig, actionRequest, actionResponse); }
protected String getSaveAndContinueRedirect( ActionRequest actionRequest, TaskRecord taskRecord, Layout layout, String redirect) throws Exception { PortletConfig portletConfig = (PortletConfig)actionRequest.getAttribute( JavaConstants.JAVAX_PORTLET_CONFIG); LiferayPortletURL portletURL = PortletURLFactoryUtil.create(actionRequest, portletConfig.getPortletName(), layout, PortletRequest.RENDER_PHASE); portletURL.setParameter("mvcRenderCommandName", "editTaskRecord"); portletURL.setParameter(Constants.CMD, Constants.UPDATE, false); portletURL.setParameter("redirect", redirect, false); portletURL.setParameter( "groupId", String.valueOf(taskRecord.getGroupId()), false); portletURL.setParameter( "taskRecordId", String.valueOf(taskRecord.getTaskRecordId()), false); portletURL.setWindowState(actionRequest.getWindowState()); return portletURL.toString(); }
@Override public void init(PortletConfig config) throws PortletException { super.init(config); this.templatesPath = config.getInitParameter(INIT_PARAM_TEMPLATES_PATH); if(this.templatesPath == null) { throw new PortletException("Templates path not specified in init parameters."); } if(!this.templatesPath.endsWith(StringPool.SLASH)) { this.templatesPath = this.templatesPath.concat(StringPool.SLASH); } this.portal = this.getPortal(); this.templateManager = this.getTemplateManager(); try { this.templateResourceLoader = TemplateResourceLoaderUtil.getTemplateResourceLoader(this.templateManager.getName()); } catch(TemplateException e) { throw new PortletException(e); } }
protected String getSaveAndContinueRedirect( ActionRequest actionRequest, Contact contact, Layout layout, String redirect) throws Exception { _log.info("getSaveAndContinueRedirect()"); PortletConfig portletConfig = (PortletConfig)actionRequest.getAttribute( JavaConstants.JAVAX_PORTLET_CONFIG); LiferayPortletURL portletURL = PortletURLFactoryUtil.create(actionRequest, portletConfig.getPortletName(), layout, PortletRequest.RENDER_PHASE); portletURL.setParameter("mvcRenderCommandName", "editContact"); portletURL.setParameter(Constants.CMD, Constants.UPDATE, false); portletURL.setParameter("redirect", redirect, false); portletURL.setParameter( "groupId", String.valueOf(contact.getGroupId()), false); portletURL.setParameter( "contactId", String.valueOf(contact.getContactId()), false); portletURL.setWindowState(actionRequest.getWindowState()); return portletURL.toString(); }
private List<JSONObject> getRegistrationStates(ThemeDisplay themeDisplay) { JSONObject regObject = JSONFactoryUtil.createJSONObject(); List<JSONObject> registrationState = new ArrayList<>(); PortletConfig portletConfig = PortletConfigFactoryUtil.get( themeDisplay.getPortletDisplay().getId()); ResourceBundle resourceBundle = portletConfig.getResourceBundle(themeDisplay.getLocale()); for (int i=0; i<4; i++) { regObject = JSONFactoryUtil.createJSONObject(); regObject.put("value", i); regObject.put("text", LanguageUtil.get(resourceBundle, "registration-state"+i)); registrationState.add(regObject); } return registrationState; }
@Override public void processAction(PortletConfig portletConfig, ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { String linkList = ParamUtil.getString(actionRequest, DummyFactoryConfiguration.CONF_LINKLIST); String urlList = ParamUtil.getString(actionRequest, DummyFactoryConfiguration.CONF_URLLIST); if (_log.isDebugEnabled()) { _log.debug("Link List :" + linkList); _log.debug("URL List :" + urlList); } List<String> errors = Lists.newArrayList(); if (validate(linkList, errors)) { setPreference(actionRequest, DummyFactoryConfiguration.CONF_LINKLIST, linkList); setPreference(actionRequest, DummyFactoryConfiguration.CONF_URLLIST, urlList); SessionMessages.add(actionRequest, "prefs-success"); } super.processAction(portletConfig, actionRequest, actionResponse); }
protected String getSaveAndContinueRedirect( ActionRequest actionRequest, Measurement measurement, Layout layout, String redirect) throws Exception { PortletConfig portletConfig = (PortletConfig)actionRequest.getAttribute( JavaConstants.JAVAX_PORTLET_CONFIG); LiferayPortletURL portletURL = PortletURLFactoryUtil.create(actionRequest, portletConfig.getPortletName(), layout, PortletRequest.RENDER_PHASE); portletURL.setParameter("mvcRenderCommandName", "editMeasurement"); portletURL.setParameter(Constants.CMD, Constants.UPDATE, false); portletURL.setParameter("redirect", redirect, false); portletURL.setParameter( "groupId", String.valueOf(measurement.getGroupId()), false); portletURL.setParameter( "measurementId", String.valueOf(measurement.getMeasurementId()), false); portletURL.setWindowState(actionRequest.getWindowState()); return portletURL.toString(); }
@SuppressWarnings("unchecked") public static List<String> generateCSVOutput( PortletConfig portletConfig, RenderRequest renderRequest) { String title = (String) renderRequest.getAttribute("title"); EnumSet<ExecutionMode> executionMode = (EnumSet<ExecutionMode>)renderRequest.getAttribute("executionMode"); Map<Company, Long> companyProcessTime = (Map<Company, Long>)renderRequest.getAttribute( "companyProcessTime"); Map<Company, Map<Long, List<Comparison>>> companyResultDataMap = (Map<Company, Map<Long, List<Comparison>>>) renderRequest.getAttribute("companyResultDataMap"); Map<Company, String> companyError = (Map<Company, String>) renderRequest.getAttribute("companyError"); if ((executionMode == null)||(companyProcessTime == null)|| (companyResultDataMap == null)) { return null; } return generateCSVOutput( portletConfig, title, renderRequest.getLocale(), true, companyProcessTime, companyResultDataMap, companyError); }
public String getUpdateMessage(PortletConfig portletConfig) { PluginPackage pluginPackage = getPluginPackage(portletConfig); if (pluginPackage == null) { return getUpdateMessageOffline(portletConfig); } @SuppressWarnings("unchecked") Collection<String> lastAvalibleVersion = (Collection<String>)RemoteConfigurationUtil.getConfigurationEntry( "lastAvalibleVersion"); if ((lastAvalibleVersion == null) || lastAvalibleVersion.isEmpty()) { return getUpdateMessageOffline(portletConfig); } String portletVersion = pluginPackage.getVersion(); if (lastAvalibleVersion.contains(portletVersion)) { return null; } return (String)RemoteConfigurationUtil.getConfigurationEntry( "updateMessage"); }
public String getUpdateMessageOffline(PortletConfig portletConfig) { LiferayPortletContext context = (LiferayPortletContext)portletConfig.getPortletContext(); long installationTimestamp = context.getPortlet().getTimestamp(); if (installationTimestamp == 0L) { return null; } long offlineUpdateTimeoutMilis = (Long)ConfigurationUtil.getConfigurationEntry( "offlineUpdateTimeoutMilis"); long offlineUpdateTimestamp = (installationTimestamp + offlineUpdateTimeoutMilis); long currentTimeMillis = System.currentTimeMillis(); if (offlineUpdateTimestamp > currentTimeMillis) { return null; } return (String)ConfigurationUtil.getConfigurationEntry( "offlineUpdateMessage"); }
@Override public void afterPropertiesSet() throws Exception { if (this.portletClass == null) { throw new IllegalArgumentException("portletClass is required"); } if (!Portlet.class.isAssignableFrom(this.portletClass)) { throw new IllegalArgumentException("portletClass [" + this.portletClass.getName() + "] needs to implement interface [javax.portlet.Portlet]"); } if (this.portletName == null) { this.portletName = this.beanName; } PortletConfig config = this.portletConfig; if (config == null || !this.useSharedPortletConfig) { config = new DelegatingPortletConfig(); } this.portletInstance = (Portlet) this.portletClass.newInstance(); this.portletInstance.init(config); }
@Override public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException { if (bean instanceof Portlet) { PortletConfig config = this.portletConfig; if (config == null || !this.useSharedPortletConfig) { config = new DelegatingPortletConfig(beanName, this.portletContext, this.portletConfig); } try { ((Portlet) bean).init(config); } catch (PortletException ex) { throw new BeanInitializationException("Portlet.init threw exception", ex); } } return bean; }
/** * Create new PortletConfigPropertyValues. * @param config PortletConfig we'll use to take PropertyValues from * @param requiredProperties set of property names we need, where * we can't accept default values * @throws PortletException if any required properties are missing */ private PortletConfigPropertyValues(PortletConfig config, Set<String> requiredProperties) throws PortletException { Set<String> missingProps = (requiredProperties != null && !requiredProperties.isEmpty()) ? new HashSet<String>(requiredProperties) : null; Enumeration<String> en = config.getInitParameterNames(); while (en.hasMoreElements()) { String property = en.nextElement(); Object value = config.getInitParameter(property); addPropertyValue(new PropertyValue(property, value)); if (missingProps != null) { missingProps.remove(property); } } // fail if we are still missing properties if (missingProps != null && missingProps.size() > 0) { throw new PortletException( "Initialization from PortletConfig for portlet '" + config.getPortletName() + "' failed; the following required properties were missing: " + StringUtils.collectionToDelimitedString(missingProps, ", ")); } }
@Override public void include( PortletConfig portletConfig, HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception { if (_log.isDebugEnabled()) { _log.debug("Blade Message Portlet configuration include"); } httpServletRequest.setAttribute( MessageDisplayConfiguration.class.getName(), _messageDisplayConfiguration); super.include(portletConfig, httpServletRequest, httpServletResponse); }
@Override public void processAction( PortletConfig portletConfig, ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { String cmd = ParamUtil.getString(actionRequest, Constants.CMD); if (!cmd.equals(Constants.UPDATE)) { return; } // ThemeDisplay themeDisplay = (ThemeDisplay)actionRequest.getAttribute( // WebKeys.THEME_DISPLAY); //ShoppingPreferences preferences = ShoppingPreferences.getInstance( // themeDisplay.getCompanyId(), themeDisplay.getScopeGroupId()); // // String tabs2 = ParamUtil.getString(actionRequest, "tabs2"); // String tabs3 = ParamUtil.getString(actionRequest, "tabs3"); }
@Override public void invokeTaglibDiscussion( ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { //Se parchea porque da error al hacer comentarios con la clase por defecto del portal. PortletConfig portletConfig = getPortletConfig(); PortalClassInvokerPatched.invoke( // Notar el "Patched" true, "com.liferay.portlet.messageboards.action.EditDiscussionAction", "processAction", new String[] { "org.apache.struts.action.ActionMapping", "org.apache.struts.action.ActionForm", PortletConfig.class.getName(), ActionRequest.class.getName(), ActionResponse.class.getName() }, null, null, portletConfig, actionRequest, actionResponse); }
public void processAction( PortletConfig portletConfig, ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { if (!Constants.UPDATE.equals(actionRequest.getParameter(Constants.CMD))){ return; } PortletPreferences prefs; String portletResource = ParamUtil.getString(actionRequest, "portletResource"); if (Validator.isNotNull(portletResource)){ prefs = PortletPreferencesFactoryUtil.getPortletSetup(actionRequest, portletResource); } else { prefs = actionRequest.getPreferences(); } prefs.setValue("showActionSocial", actionRequest.getParameter("showActionSocial")); prefs.setValue("showActionAudit", actionRequest.getParameter("showActionAudit")); prefs.store(); SessionMessages.add( actionRequest, portletConfig.getPortletName() + ".doConfigure"); //SessionMessages.add(actionRequest,"success"); }
@Override public void processAction(PortletConfig portletConfig, ActionRequest actionRequest, ActionResponse arg2) throws Exception { if (!Constants.UPDATE.equals(actionRequest.getParameter(Constants.CMD))) return; PortletPreferences prefs; String portletResource = ParamUtil.getString(actionRequest, "portletResource"); if (Validator.isNotNull(portletResource)){ prefs = PortletPreferencesFactoryUtil.getPortletSetup(actionRequest, portletResource); } else { prefs = actionRequest.getPreferences(); } prefs.setValue("viewAlways", actionRequest.getParameter("viewAlways")); prefs.store(); SessionMessages.add(actionRequest,portletConfig.getPortletName() + ".doConfigure"); }
@Override public void processAction(PortletConfig portletConfig, ActionRequest actionRequest, ActionResponse arg2) throws Exception { if (!Constants.UPDATE.equals(actionRequest.getParameter(Constants.CMD))) return; PortletPreferences prefs; String portletResource = ParamUtil.getString(actionRequest, "portletResource"); if (Validator.isNotNull(portletResource)){ prefs = PortletPreferencesFactoryUtil.getPortletSetup(actionRequest, portletResource); } else { prefs = actionRequest.getPreferences(); } prefs.setValue("viewMode", actionRequest.getParameter("viewMode")); prefs.setValue("numerateModules", actionRequest.getParameter("numerateModules")); prefs.store(); SessionMessages.add(actionRequest,portletConfig.getPortletName() + ".doConfigure"); }
@Override public void processAction(PortletConfig portletConfig, ActionRequest actionRequest, ActionResponse arg2) throws Exception { if (!Constants.UPDATE.equals(actionRequest.getParameter(Constants.CMD))){ return; } PortletPreferences prefs; String portletResource = ParamUtil.getString(actionRequest, "portletResource"); if (Validator.isNotNull(portletResource)){ prefs = PortletPreferencesFactoryUtil.getPortletSetup(actionRequest, portletResource); } else { prefs = actionRequest.getPreferences(); } prefs.setValue("showPreviousModuleButton", actionRequest.getParameter("showPreviousModuleButton")); prefs.store(); SessionMessages.add(actionRequest,portletConfig.getPortletName() + ".doConfigure"); }
public void processAction( PortletConfig portletConfig, ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { PortletPreferences portletPreferences = PortletPreferencesFactoryUtil.getPortletSetup( actionRequest, ParamUtil.getString(actionRequest, "portletResource")); /** * boolean showAllways = preferences.getValue("showAllways", "false").equals("true"); boolean showOnlyWhenFinishDate = preferences.getValue("showOnlyWhenFinishDate", "true").equals("true"); */ portletPreferences.setValue("showCalificationMode",ParamUtil.getString(actionRequest, "showCalificationMode")); portletPreferences.store(); SessionMessages.add( actionRequest, portletConfig.getPortletName() + ".doConfigure"); //SessionMessages.add(actionRequest,"success"); }
public void processAction( PortletConfig portletConfig, ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { PortletPreferences portletPreferences = PortletPreferencesFactoryUtil.getPortletSetup( actionRequest, ParamUtil.getString(actionRequest, "portletResource")); portletPreferences.setValue("myCoursesOrder",Integer.toString(ParamUtil.getInteger(actionRequest, "myCoursesOrder",0))); portletPreferences.store(); SessionMessages.add( actionRequest, portletConfig.getPortletName() + ".doConfigure"); //SessionMessages.add(actionRequest,"success"); }
public void invokeTaglibDiscussion( ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { //Se parchea porque da error al hacer comentarios con la clase por defecto del portal. PortletConfig portletConfig = getPortletConfig(); PortalClassInvokerPatched.invoke( // Notar el "Patched" true, "com.liferay.portlet.messageboards.action.EditDiscussionAction", "processAction", new String[] { "org.apache.struts.action.ActionMapping", "org.apache.struts.action.ActionForm", PortletConfig.class.getName(), ActionRequest.class.getName(), ActionResponse.class.getName() }, null, null, portletConfig, actionRequest, actionResponse); }
@Override public void serveResource(StrutsPortletAction originalStrutsPortletAction, PortletConfig portletConfig, ResourceRequest resourceRequest, ResourceResponse resourceResponse) throws Exception { resourceResponse.setContentType("image/png"); resourceResponse.addProperty(HttpHeaders.CACHE_CONTROL, "max-age=5, must-revalidate"); OutputStream out = resourceResponse.getPortletOutputStream(); InputStream is=getClass().getClassLoader().getResourceAsStream("asposeicon/aspose.png"); byte[] bytes = IOUtils.toByteArray(is); out.write(bytes, 0, bytes.length); out.close(); }
public void init(PortletConfig config) throws PortletException { super.init(config); log.info("Simple RSS Portlet init()"); //pages viewUrl = config.getInitParameter("viewUrl"); editUrl = config.getInitParameter("editUrl"); errorUrl = config.getInitParameter("errorUrl"); noContentUrl = config.getInitParameter("noContentUrl"); //setup cache memoryService = ComponentManager.get(MemoryService.class); feedCache = memoryService.getCache(FEED_CACHE_NAME); mediaCache = memoryService.getCache(MEDIA_CACHE_NAME); }
@Override public void processAction(StrutsPortletAction originalStrutsPortletAction, PortletConfig portletConfig, ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { if(actionRequest.getParameter("add_site") != null) { ServiceContext serviceContext = ServiceContextFactory.getInstance(MySitesCustomAction.class.getName(), actionRequest); ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); SiteRequestLocalServiceUtil.add( themeDisplay.getCompanyGroupId(), themeDisplay.getScopeGroupId(), themeDisplay.getUserId(), actionRequest.getParameter(MicroSiteConstants.SITE_REQUEST_NAME), actionRequest.getParameter(MicroSiteConstants.SITE_REQUEST_DESCRIPTION), serviceContext ); } if(originalStrutsPortletAction != null) { originalStrutsPortletAction.processAction(portletConfig, actionRequest, actionResponse); } else { actionResponse.sendRedirect(actionRequest.getParameter("redirect")); } }
@Override public void include(PortletConfig portletConfig, HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception { httpServletRequest.setAttribute(TimetrackerConfiguration.class.getName(), _timetrackerConfiguration); super.include(portletConfig, httpServletRequest, httpServletResponse); }
@Override public void include(PortletConfig portletConfig, HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception { httpServletRequest.setAttribute(ContactManagerConfiguration.class.getName(), _contactManagerConfiguration); super.include(portletConfig, httpServletRequest, httpServletResponse); }
@Override public void include(PortletConfig portletConfig, HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception { if (_log.isDebugEnabled()) { _log.debug("Dummy Factory Portlet configuration include"); } httpServletRequest.setAttribute(DummyFactoryConfiguration.class.getName(), _DummyFactoryConfiguration); super.include(portletConfig, httpServletRequest, httpServletResponse); }
@Override public void include(PortletConfig portletConfig, HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception { httpServletRequest.setAttribute(DataManagerConfiguration.class.getName(), _dataManagerConfiguration); super.include(portletConfig, httpServletRequest, httpServletResponse); }
public void serveResource( ResourceRequest request, ResourceResponse response) throws IOException, PortletException { PortletConfig portletConfig = (PortletConfig)request.getAttribute( JavaConstants.JAVAX_PORTLET_CONFIG); String resourceId = request.getResourceID(); String portletId = portletConfig.getPortletName(); OutputUtils.servePortletFileEntry(portletId, resourceId, response); }
/** * Create a new PortletContextAwareProcessor for the given context and config. */ public PortletContextAwareProcessor(PortletContext portletContext, PortletConfig portletConfig) { this.portletContext = portletContext; this.portletConfig = portletConfig; if (portletContext == null && portletConfig != null) { this.portletContext = portletConfig.getPortletContext(); } }
@Override public void setPortletConfig(PortletConfig portletConfig) { this.portletConfig = portletConfig; if (portletConfig != null && this.portletContext == null) { this.portletContext = portletConfig.getPortletContext(); } }