@Override public String render(RenderRequest renderRequest, RenderResponse renderResponse) throws PortletException { _log.info("render()"); try { TaskRecord taskRecord = ActionUtil.getTaskRecord(renderRequest); renderRequest.setAttribute(TimetrackerWebKeys.TASK_RECORD, taskRecord); } catch (Exception e) { if (e instanceof NoSuchTaskRecordException || e instanceof PrincipalException) { SessionErrors.add(renderRequest, e.getClass()); return "/error.jsp"; } else { throw new PortletException(e); } } return getPath(); }
/** * Routes between global configuration editing and tab editing * * @param request The request * @param response The response * @throws PortletException If something goes wrong * @throws IOException If something goes wrong */ @Override protected void doEdit(RenderRequest request, RenderResponse response) throws PortletException, IOException { // Very, very simple routing. That's all we need, folks. String editModeParam = ParamUtil.get(request, PortletRequestParameter.EDIT_MODE.getName(), StringPool.BLANK); EditMode editMode = EditMode.getEditMode(editModeParam); switch(editMode) { case TAB: this.doEditTab(request, response); break; case FACET: this.doEditFacet(request, response); break; default: this.doEditGlobal(request, response); break; } }
/** * Saves the global aspect of the configuration * * @param request The request * @param response The response * @throws IOException If something goes wrong * @throws PortletException If something goes wrong */ @ProcessAction(name = ACTION_NAME_SAVE_GLOBAL) public void actionSaveGlobal(ActionRequest request, ActionResponse response) throws IOException, PortletException { String redirectUrl = ParamUtil.get(request, FORM_FIELD_REDIRECT_URL, StringPool.BLANK); String adtUuid = ParamUtil.get(request, FORM_FIELD_ADT_UUID, StringPool.BLANK); boolean doSearchOnStartup = ParamUtil.getBoolean(request, FORM_FIELD_DO_SEARCH_ON_STARTUP, false); if (!PATTERN_UUID.matcher(adtUuid).matches()) { adtUuid = StringPool.BLANK; } String doSearchOnStartupKeywords = ParamUtil.getString(request, FORM_FIELD_DO_SEARCH_ON_STARTUP_KEYWORDS, FlashlightSearchService.CONFIGURATION_DEFAULT_SEARCH_KEYWORDS); this.searchService.saveGlobalSettings(adtUuid, doSearchOnStartup, doSearchOnStartupKeywords, request.getPreferences()); SessionMessages.add(request, SESSION_MESSAGE_CONFIG_SAVED); if (!redirectUrl.isEmpty()) { response.sendRedirect(redirectUrl); } }
/** * This action saves the Liferay facet configuration for a given tab * * @param request The request * @param response The response * @throws PortletException If something goes wrong * @throws IOException If something goes wrong */ @ProcessAction(name = ACTION_NAME_SAVE_FACET_CONFIG) public void actionSaveFacetConfig(ActionRequest request, ActionResponse response) throws PortletException, IOException { String tabId = ParamUtil.get(request, PortletRequestParameter.TAB_ID.getName(), StringPool.BLANK); String facetClassName = ParamUtil.get(request, FORM_FIELD_FACET_CLASS_NAME, StringPool.BLANK); String redirectUrl = ParamUtil.get(request, FORM_FIELD_REDIRECT_URL, StringPool.BLANK); PortletPreferences preferences = request.getPreferences(); FlashlightSearchConfiguration configuration = this.searchService.readConfiguration(preferences); SearchFacet targetFacet = this.getSearchFacetFromRequest(tabId, facetClassName, configuration); if(targetFacet != null) { JSONObject facetConfiguration = targetFacet.getJSONData(request); targetFacet.getFacetConfiguration().setDataJSONObject(facetConfiguration); this.searchService.saveSearchFacetConfig(configuration.getTabs().get(tabId), targetFacet, preferences); SessionMessages.add(request, SESSION_MESSAGE_CONFIG_SAVED); response.sendRedirect(redirectUrl); } }
/** * Deletes a tab from the configuration * * @param request The request * @param response The response * @throws PortletException If something goes wrong * @throws IOException If something goes wrong */ @ProcessAction(name = ACTION_NAME_DELETE_TAB) public void actionDeleteTab(ActionRequest request, ActionResponse response) throws PortletException, IOException { String tabId = ParamUtil.get(request, PortletRequestParameter.TAB_ID.getName(), StringPool.BLANK); String redirectUrl = ParamUtil.get(request, FORM_FIELD_REDIRECT_URL, StringPool.BLANK); if (tabId != null && PATTERN_UUID.matcher(tabId).matches()) { PortletPreferences preferences = request.getPreferences(); Map<String, FlashlightSearchConfigurationTab> tabs = this.searchService.readConfiguration(preferences).getTabs(); if (tabs.containsKey(tabId)) { this.searchService.deleteConfigurationTab(tabId, preferences); } } SessionMessages.add(request, SESSION_MESSAGE_CONFIG_SAVED); if (!redirectUrl.isEmpty()) { response.sendRedirect(redirectUrl); } }
@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); } }
@Override public String render(RenderRequest renderRequest, RenderResponse renderResponse) throws PortletException { _log.info("render()"); try { Contact contact = ActionUtil.getContact(renderRequest); renderRequest.setAttribute(ContactManagerWebKeys.CONTACT, contact); } catch (Exception e) { if (e instanceof NoSuchContactException || e instanceof PrincipalException) { SessionErrors.add(renderRequest, e.getClass()); return "/error.jsp"; } else { throw new PortletException(e); } } return getPath(); }
private void renderFromMobilink( RenderRequest renderRequest, RenderResponse renderResponse) throws IOException, PortletException { renderFrontendWebEmployeePortlet(renderRequest, renderResponse); renderFrontendWebJobposPortlet(renderRequest, renderResponse); renderFrontendWebAdminPortlet(renderRequest, renderResponse); renderFrontendWebWorkingUnitPortlet(renderRequest, renderResponse); renderFrontendWebNotificationPortlet(renderRequest, renderResponse); renderRequest.setAttribute( "url", generateURLCommon(renderRequest, renderResponse)); renderRequest.setAttribute("constants", generalConstantsCommon(renderRequest)); renderRequest.setAttribute("param", generalParamsCommon(renderRequest)); }
@Override public String render(RenderRequest renderRequest, RenderResponse renderResponse) throws PortletException { // Get Mode String mode = ParamUtil.getString( renderRequest, LDFPortletKeys.MODE, LDFPortletKeys.MODE_ORGANIZAION); // Carry around mode renderRequest.setAttribute(LDFPortletKeys.MODE, mode); if(_log.isDebugEnabled()) { _log.debug("mode <" + mode + ">"); _log.debug("jsp <" + _commonUtil .getPageFromMode() .getOrDefault(mode, LDFPortletKeys.JSP_ORGANIZAION) + ">"); } return _commonUtil .getPageFromMode() .getOrDefault(mode, LDFPortletKeys.JSP_ORGANIZAION); }
@Override public String render(RenderRequest renderRequest, RenderResponse renderResponse) throws PortletException { _log.info("render()"); try { Measurement measurement = ActionUtil.getMeasurement(renderRequest); renderRequest.setAttribute(DataManagerWebKeys.MEASUREMENT, measurement); } catch (Exception e) { if (e instanceof NoSuchMeasurementException || e instanceof PrincipalException) { SessionErrors.add(renderRequest, e.getClass()); return "/error.jsp"; } else { throw new PortletException(e); } } return getPath(); }
@Override public void validate(PortletRequest request) throws PortletException { if (!PortletAnnotationMappingUtils.checkHeaders(this.headers, request)) { throw new PortletRequestBindingException("Header conditions \"" + StringUtils.arrayToDelimitedString(this.headers, ", ") + "\" not met for actual request"); } if (!this.methods.isEmpty()) { if (!(request instanceof ClientDataRequest)) { throw new PortletRequestMethodNotSupportedException(StringUtils.toStringArray(this.methods)); } String method = ((ClientDataRequest) request).getMethod(); if (!this.methods.contains(method)) { throw new PortletRequestMethodNotSupportedException(method, StringUtils.toStringArray(this.methods)); } } }
@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, ", ")); } }
/** * Serve the resource as specified in the given request to the given response, * using the PortletContext's request dispatcher. * <p>This is roughly equivalent to Portlet 2.0 GenericPortlet. * @param request the current resource request * @param response the current resource response * @param context the current Portlet's PortletContext * @throws PortletException propagated from Portlet API's forward method * @throws IOException propagated from Portlet API's forward method */ public static void serveResource(ResourceRequest request, ResourceResponse response, PortletContext context) throws PortletException, IOException { String id = request.getResourceID(); if (id != null) { if (!PortletUtils.isProtectedResource(id)) { PortletRequestDispatcher rd = context.getRequestDispatcher(id); if (rd != null) { rd.forward(request, response); return; } } response.setProperty(ResourceResponse.HTTP_STATUS_CODE, "404"); } }
@Test public void unknownRequiredInitParameter() throws Exception { String testParam = "testParam"; String testValue = "testValue"; portletConfig.addInitParameter(testParam, testValue); TestPortletBean portletBean = new TestPortletBean(); portletBean.addRequiredProperty("unknownParam"); assertNull(portletBean.getTestParam()); try { portletBean.init(portletConfig); fail("should have thrown PortletException"); } catch (PortletException ex) { // expected } assertNull(portletBean.getTestParam()); }
@Override public boolean serveResource( ResourceRequest resourceRequest, ResourceResponse resourceResponse) throws PortletException { if (_log.isInfoEnabled()) { _log.info("get captcha resource "); } try { CaptchaUtil.serveImage(resourceRequest, resourceResponse); return false; } catch (Exception e) { _log.error(e, e); return true; } }
@Override public boolean serveResource( ResourceRequest resourceRequest, ResourceResponse resourceResponse) throws PortletException { final String cmd = ParamUtil.getString(resourceRequest, Constants.CMD); if (cmd.equals("BOOKMARK_ORDERABLE")) { serveOlderUserBookmarks(resourceRequest, resourceResponse); } else { _editFolderMVCResourceCommand.serveResource( resourceRequest, resourceResponse); } return true; }
/** * Routes between search results and single asset view * * @param request The request * @param response The response * @throws PortletException If something goes wrong * @throws IOException If something goes wrong */ @Override protected void doView(RenderRequest request, RenderResponse response) throws IOException, PortletException { String viewModeParam = ParamUtil.getString(request, PortletRequestParameter.VIEW_MODE.getName(), StringPool.BLANK); ViewMode viewMode = ViewMode.getViewMode(viewModeParam); switch(viewMode) { case VIEW_JOURNAL: this.doViewJournal(request, response); break; default: this.doViewResults(request, response); break; } }
/** * Routes between portlet resources * * @param request The request * @param response The response * * @throws PortletException If something goes wrong * @throws IOException If something goes wrong */ @Override public void serveResource(ResourceRequest request, ResourceResponse response) throws PortletException, IOException { PortletResource resource = PortletResource.getResource(request); switch(resource) { case LOAD_MORE: this.doLoadMore(request, response); break; default: response.setProperty(ResourceResponse.HTTP_STATUS_CODE, STATUS_CODE_NOT_FOUND); break; } }
@Override protected void doHelp(RenderRequest request, RenderResponse response) throws PortletException, IOException { String lang = request.getLocale().getLanguage(); String templatePath; if(HELP_TEMPLATES.containsKey(lang)) { templatePath = HELP_TEMPLATES.get(lang); } else { templatePath = HELP_TEMPLATES.get(StringPool.BLANK); } Map<String, Object> ctx = Collections.singletonMap("ns", response.getNamespace()); this.renderTemplate(request, response, ctx, templatePath); }
/** * Renders the given template * * @param request The request * @param response The response * @param ctx The template context * @param templatePath The path of the template, relative to the templates path given in the init parameters * * @throws PortletException Thrown if there is an error during template processing * @throws IOException Thrown if there is an error while writing the response */ public void renderTemplate(RenderRequest request, RenderResponse response, Map<String, Object> ctx, String templatePath) throws PortletException, IOException { PortletContext portletCtx = this.getPortletContext(); String templateResourcePath = String.format(TEMPLATE_PATH_FORMAT, portletCtx.getPortletContextName(), this.templatesPath, templatePath); if(this.templateResourceLoader.hasTemplateResource(templateResourcePath)) { try { this.writeTemplate(request, response, ctx, templateResourcePath); } catch(TemplateException e) { throw new PortletException(e); } } else { throw new TemplateNotFoundException(templateResourcePath); } }
@Override public void render( RenderRequest renderRequest, RenderResponse renderResponse) throws IOException, PortletException { ThemeDisplay themeDisplay = (ThemeDisplay) renderRequest.getAttribute(WebKeys.THEME_DISPLAY); PortletDisplay portletDisplay = themeDisplay.getPortletDisplay(); String portletId = portletDisplay.getId(); JSONObject urlObject = JSONFactoryUtil.createJSONObject(); JSONObject apiObject = JSONFactoryUtil.createJSONObject(); // url PortletURL dossierInfoURL = PortletURLFactoryUtil.create( renderRequest, portletId, themeDisplay.getPlid(), PortletRequest.RENDER_PHASE); dossierInfoURL.setPortletMode(PortletMode.VIEW); dossierInfoURL.setWindowState(LiferayWindowState.EXCLUSIVE); dossierInfoURL.setParameter( "mvcPath", "/templates/lookup_dossier/dossierinfo.ftl"); urlObject.put("dossierinfo", dossierInfoURL.toString()); // api apiObject.put("server", themeDisplay.getPortalURL() + "/o/rest/v2"); apiObject.put( "portletNamespace", themeDisplay.getPortletDisplay().getNamespace()); // set varible renderRequest.setAttribute("ajax", urlObject); renderRequest.setAttribute("api", apiObject); super.render(renderRequest, renderResponse); }
@Override public void render( RenderRequest renderRequest, RenderResponse renderResponse) throws IOException, PortletException { ThemeDisplay themeDisplay = (ThemeDisplay) renderRequest.getAttribute(WebKeys.THEME_DISPLAY); PortletDisplay portletDisplay = themeDisplay.getPortletDisplay(); String portletId = portletDisplay.getId(); JSONObject urlObject = JSONFactoryUtil.createJSONObject(); JSONObject apiObject = JSONFactoryUtil.createJSONObject(); // url PortletURL registerResultURL = PortletURLFactoryUtil.create( renderRequest, portletId, themeDisplay.getPlid(), PortletRequest.RENDER_PHASE); registerResultURL.setPortletMode(PortletMode.VIEW); registerResultURL.setWindowState(LiferayWindowState.EXCLUSIVE); registerResultURL.setParameter( "mvcPath", "/templates/applicant/register_result.ftl"); urlObject.put("register_result", registerResultURL.toString()); // api apiObject.put("server", themeDisplay.getPortalURL() + "/o/rest/v2"); apiObject.put( "portletNamespace", themeDisplay.getPortletDisplay().getNamespace()); // set varible renderRequest.setAttribute("ajax", urlObject); renderRequest.setAttribute("api", apiObject); super.render(renderRequest, renderResponse); }
@Override public void render( RenderRequest renderRequest, RenderResponse renderResponse) throws IOException, PortletException { ThemeDisplay themeDisplay = (ThemeDisplay) renderRequest.getAttribute(WebKeys.THEME_DISPLAY); PortletDisplay portletDisplay = themeDisplay.getPortletDisplay(); String portletId = portletDisplay.getId(); JSONObject urlObject = JSONFactoryUtil.createJSONObject(); JSONObject apiObject = JSONFactoryUtil.createJSONObject(); // url PortletURL confirmPasswordURL = PortletURLFactoryUtil.create( renderRequest, portletId, themeDisplay.getPlid(), PortletRequest.RENDER_PHASE); confirmPasswordURL.setPortletMode(PortletMode.VIEW); confirmPasswordURL.setWindowState(LiferayWindowState.EXCLUSIVE); confirmPasswordURL.setParameter( "mvcPath", "/templates/applicant/confirm_password.ftl"); urlObject.put("confirm_password", confirmPasswordURL.toString()); // api apiObject.put("server", themeDisplay.getPortalURL() + "/o/rest/v2"); apiObject.put( "portletNamespace", themeDisplay.getPortletDisplay().getNamespace()); // set varible renderRequest.setAttribute("ajax", urlObject); renderRequest.setAttribute("api", apiObject); super.render(renderRequest, renderResponse); }
@Override public void render( RenderRequest renderRequest, RenderResponse renderResponse) throws IOException, PortletException { ThemeDisplay themeDisplay = (ThemeDisplay) renderRequest.getAttribute(WebKeys.THEME_DISPLAY); PortletDisplay portletDisplay = themeDisplay.getPortletDisplay(); String portletId = portletDisplay.getId(); JSONObject urlObject = JSONFactoryUtil.createJSONObject(); JSONObject apiObject = JSONFactoryUtil.createJSONObject(); // url PortletURL serviceInfoLookupURL = PortletURLFactoryUtil.create( renderRequest, portletId, themeDisplay.getPlid(), PortletRequest.RENDER_PHASE); serviceInfoLookupURL.setPortletMode(PortletMode.VIEW); serviceInfoLookupURL.setWindowState(LiferayWindowState.EXCLUSIVE); serviceInfoLookupURL.setParameter( "mvcPath", "/templates/homepage/serviceinfo_lookup.ftl"); urlObject.put("serviceinfo_lookup", serviceInfoLookupURL.toString()); // api apiObject.put("server", themeDisplay.getPortalURL() + "/o/rest/v2"); apiObject.put( "portletNamespace", themeDisplay.getPortletDisplay().getNamespace()); // set varible renderRequest.setAttribute("ajax", urlObject); renderRequest.setAttribute("api", apiObject); super.render(renderRequest, renderResponse); }
@Override public void render( RenderRequest renderRequest, RenderResponse renderResponse) throws IOException, PortletException { ThemeDisplay themeDisplay = (ThemeDisplay) renderRequest.getAttribute(WebKeys.THEME_DISPLAY); PortletDisplay portletDisplay = themeDisplay.getPortletDisplay(); String portletId = portletDisplay.getId(); JSONObject urlObject = JSONFactoryUtil.createJSONObject(); JSONObject apiObject = JSONFactoryUtil.createJSONObject(); // url PortletURL dossierLookupURL = PortletURLFactoryUtil.create( renderRequest, portletId, themeDisplay.getPlid(), PortletRequest.RENDER_PHASE); dossierLookupURL.setPortletMode(PortletMode.VIEW); dossierLookupURL.setWindowState(LiferayWindowState.EXCLUSIVE); dossierLookupURL.setParameter( "mvcPath", "/templates/homepage/dossier_lookup.ftl"); urlObject.put("dossier_lookup", dossierLookupURL.toString()); // api apiObject.put("server", themeDisplay.getPortalURL() + "/o/rest/v2"); apiObject.put( "portletNamespace", themeDisplay.getPortletDisplay().getNamespace()); // set varible renderRequest.setAttribute("ajax", urlObject); renderRequest.setAttribute("api", apiObject); super.render(renderRequest, renderResponse); }
public void render(RenderRequest renderRequest, RenderResponse renderResponse) throws IOException, PortletException { ThemeDisplay themeDisplay = (ThemeDisplay) renderRequest.getAttribute(WebKeys.THEME_DISPLAY); PortletDisplay portletDisplay = themeDisplay.getPortletDisplay(); String portletId = portletDisplay.getId(); JSONObject urlObject = JSONFactoryUtil.createJSONObject(); JSONObject apiObject = JSONFactoryUtil.createJSONObject(); // url PortletURL dossierLookupURL = PortletURLFactoryUtil.create(renderRequest, portletId, themeDisplay.getPlid(), PortletRequest.RENDER_PHASE); dossierLookupURL.setPortletMode(PortletMode.VIEW); dossierLookupURL.setWindowState(LiferayWindowState.EXCLUSIVE); dossierLookupURL.setParameter("mvcPath", "/templates/homepage/search_serviceinfo.ftl"); urlObject.put("dossier_lookup", dossierLookupURL.toString()); // api apiObject.put("server", themeDisplay.getPortalURL() + "/o/rest/v2"); apiObject.put("portletNamespace", themeDisplay.getPortletDisplay().getNamespace()); // set varible renderRequest.setAttribute("ajax", urlObject); renderRequest.setAttribute("api", apiObject); super.render(renderRequest, renderResponse); }
@Override public void render(RenderRequest renderRequest, RenderResponse renderResponse) throws IOException, PortletException { ThemeDisplay themeDisplay = (ThemeDisplay) renderRequest.getAttribute(WebKeys.THEME_DISPLAY); PortletDisplay portletDisplay = themeDisplay.getPortletDisplay(); String portletId = portletDisplay.getId(); JSONObject urlObject = JSONFactoryUtil.createJSONObject(); JSONObject apiObject = JSONFactoryUtil.createJSONObject(); // url PortletURL dossierLookupURL = PortletURLFactoryUtil.create(renderRequest, portletId, themeDisplay.getPlid(), PortletRequest.RENDER_PHASE); dossierLookupURL.setPortletMode(PortletMode.VIEW); dossierLookupURL.setWindowState(LiferayWindowState.EXCLUSIVE); dossierLookupURL.setParameter("mvcPath", "/templates/homepage/dossier_lookup.ftl"); urlObject.put("dossier_lookup", dossierLookupURL.toString()); // api apiObject.put("server", themeDisplay.getPortalURL() + "/o/rest/v2"); apiObject.put("portletNamespace", themeDisplay.getPortletDisplay().getNamespace()); // set varible renderRequest.setAttribute("ajax", urlObject); renderRequest.setAttribute("api", apiObject); super.render(renderRequest, renderResponse); }
@Override protected void doView( RenderRequest renderRequest, RenderResponse renderResponse) throws IOException, PortletException { PrintWriter printWriter = renderResponse.getWriter(); printWriter.print("opencps-lang Portlet - Hello World!"); }
@Override public void doView(RenderRequest renderRequest, RenderResponse renderResponse) throws IOException, PortletException { renderRequest.setAttribute(DummyFactoryConfiguration.class.getName(), _dummyFactoryConfiguration); super.doView(renderRequest, renderResponse); }
@Override protected void doDispatch( RenderRequest renderRequest, RenderResponse renderResponse) throws IOException, PortletException { renderRequest.setAttribute(DummyFactoryConfiguration.class.getName(), _dummyFactoryConfiguration); super.doDispatch(renderRequest, renderResponse); }
public void doView(RenderRequest request, RenderResponse response) throws PortletException, IOException { response.setContentType("text/html"); PrintWriter writer = response.getWriter(); String user = request.getParameter("user"); writer.println("<h1>Hello "+user+"!</h1>"); }
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); }
public Method resolveHandlerMethod(PortletRequest request) throws PortletException { Map<RequestMappingInfo, Method> targetHandlerMethods = new LinkedHashMap<RequestMappingInfo, Method>(); for (Method handlerMethod : getHandlerMethods()) { RequestMappingInfo mappingInfo = this.mappings.get(handlerMethod); if (mappingInfo.match(request)) { Method oldMappedMethod = targetHandlerMethods.put(mappingInfo, handlerMethod); if (oldMappedMethod != null && oldMappedMethod != handlerMethod) { throw new IllegalStateException("Ambiguous handler methods mapped for portlet mode '" + request.getPortletMode() + "': {" + oldMappedMethod + ", " + handlerMethod + "}. If you intend to handle the same mode in multiple methods, then factor " + "them out into a dedicated handler class with that mode mapped at the type level!"); } } } if (!targetHandlerMethods.isEmpty()) { if (targetHandlerMethods.size() == 1) { return targetHandlerMethods.values().iterator().next(); } else { RequestMappingInfo bestMappingMatch = null; for (RequestMappingInfo mapping : targetHandlerMethods.keySet()) { if (bestMappingMatch == null) { bestMappingMatch = mapping; } else { if (mapping.isBetterMatchThan(bestMappingMatch)) { bestMappingMatch = mapping; } } } return targetHandlerMethods.get(bestMappingMatch); } } else { throw new NoHandlerFoundException("No matching handler method found for portlet request", request); } }
/** * Return the HandlerAdapter for this handler object. * @param handler the handler object to find an adapter for * @throws PortletException if no HandlerAdapter can be found for the handler. * This is a fatal error. */ protected HandlerAdapter getHandlerAdapter(Object handler) throws PortletException { for (HandlerAdapter ha : this.handlerAdapters) { if (logger.isDebugEnabled()) { logger.debug("Testing handler adapter [" + ha + "]"); } if (ha.supports(handler)) { return ha; } } throw new PortletException("No adapter for handler [" + handler + "]: Does your handler implement a supported interface like Controller?"); }
@Override public final boolean preHandle(PortletRequest request, PortletResponse response, Object handler) throws PortletException, IOException { if (this.authorizedRoles != null) { for (String role : this.authorizedRoles) { if (request.isUserInRole(role)) { return true; } } } handleNotAuthorized(request, response, handler); return false; }