📄 applicationportletimpl.java
字号:
String encvalue = URLEncoder.encode(aval, "UTF-8"); extraInfo.append(encname); extraInfo.append("="); extraInfo.append(encvalue); } else { extraInfo.append(encname); } } firstParam = false; } } catch (UnsupportedEncodingException e) { log.error("Unsupported encoding!", e); } // before it adds ".1" to real webappName //String realWebAppName = webAppName.substring(0, webAppName.length() - 2); //System.err.println("in getPortletDispatcher of jsr query string " + "/jsr/" + webAppName + extraInfo); // TODO change dangerously hardcoded value!!! RequestDispatcher rd = context.getRequestDispatcher("/jsr/" + webAppName + extraInfo.toString()); //RequestDispatcher rd = context.getNamedDispatcher(servletName); if (rd == null) { String msg = "Unable to create a dispatcher for portlet: " + portletName + "\n"; msg += "Make sure the servlet mapping: /jsr/" + webAppName + " is defined in web.xml"; log.error(msg); } return new PortletDispatcherImpl(rd); } /** * Returns the name of a PortletApplication * * @return name of the PortletApplication */ public String getApplicationPortletName() { return portletName; } public String getApplicationPortletClassName() { return portletClassName; } public PortalContext getPortalContext() { return portalContext; } public String getPortletDescription(Locale locale) { if (locale == null) throw new IllegalArgumentException("supplied locale cannot be null!"); Description[] descs = portletDef.getDescription(); for (int i = 0; i < descs.length; i++) { if (descs[i].getLang().equals(locale.getLanguage())) { return descs[i].getContent(); } } return "Unknown portlet description"; } public String getPortletDisplayName(Locale locale) { if (locale == null) throw new IllegalArgumentException("supplied locale cannot be null!"); DisplayName[] dispNames = portletDef.getDisplayName(); for (int i = 0; i < dispNames.length; i++) { if (dispNames[i].getLang().equals(locale.getLanguage())) { return dispNames[i].getContent(); } } return "Unknown portlet display name"; } public int getExpirationCache() { return portletDef.getExpirationCache().getContent(); } public Locale[] getSupportedLocales() { return supportedLocales; } public SecurityRoleRef[] getSecurityRoleRefs() { return portletDef.getSecurityRoleRef(); } public PortletPreferencesManager getPortletPreferencesManager(String portletId, String userId, boolean isRender) { prefsManager.setPortletId(portletId); prefsManager.setUserId(userId); prefsManager.setRender(isRender); return prefsManager; } public Portlet getPortletInstance() { return portletInstance; } public void setApplicationPortletStatus(PortletStatus status) { this.status = status; } public void setApplicationPortletStatusMessage(String statusMessage) { this.statusMessage = statusMessage; } public PortletStatus getApplicationPortletStatus() { return status; } public String getApplicationPortletStatusMessage() { return statusMessage; } /** * Returns the portlet application name * * @return the portlet application name */ public String getPortletName() { return portletName; } /** * Sets the name of a PortletApplication * * @param portletName name of a PortletApplication */ public void setPortletName(String portletName) { this.portletName = portletName; } /** * Returns the allowed window states supported by this portlet * * @return the <code>List</code> of * <code>WindowState</code> elements allowed for this portlet */ public List<javax.portlet.WindowState> getAllowedWindowStates() { return Collections.unmodifiableList(states); } /** * Returns the supported modes for this portlet * * @return the supported modes for this portlet */ public Set<String> getSupportedModes(String markup) { if (markup == null) throw new IllegalArgumentException("Supplied markup cannot be null!"); for (String mimeType : markupModes.keySet()) { int idx1 = mimeType.indexOf(markup); int idx2 = markup.indexOf(mimeType); if ((idx1 > 0) || (idx2 > 0) || (mimeType.equalsIgnoreCase(markup))) { return markupModes.get(mimeType); } } return new TreeSet<String>(); } public SortedSet<String> getSupportedMimeTypes(javax.portlet.PortletMode mode) { if (mode == null) throw new IllegalArgumentException("Supplied mode cannot be null!"); SortedSet<String> mimeTypes = new TreeSet<String>(); for (String mimeType : markupModes.keySet()) { Set modes = markupModes.get(mimeType); if (modes.contains(mode.toString())) { mimeTypes.add(mimeType); } } return mimeTypes; } /** * returns the amount of time in seconds that a portlet's content should be cached * * @return the amount of time in seconds that a portlet's content should be cached */ public long getCacheExpires() { return expiration; } /** * Returns the concrete portlet id * * @return the concrete portlet id */ public String getConcretePortletID() { return concreteID; } /** * Returns the default/supported locale of a portlet * * @return the default locale of the portlet */ public String getDefaultLocale() { return supportedLocales[0].getLanguage(); } public String getDescription(Locale loc) { String desc = (String) descsMap.get(loc.getLanguage()); if (desc == null) { desc = portletName; } return desc; } public String getDisplayName(Locale loc) { String disp = (String) dispsMap.get(loc.getLanguage()); if (disp == null) { disp = portletName; } return disp; } /** * Returns the required portlet role necessary to access this portlet * * @return the required portlet role necessary to access this portlet */ public String getRequiredRole() { return requiredRole; } /** * Sets the required portlet role necessary to access this portlet * * @param role the required portlet role necessary to access this portlet */ public void setRequiredRole(String role) { this.requiredRole = role; } /** * Saves any concrete portlet changes to the descriptor * * @throws java.io.IOException if an I/O error occurs */ public void save() throws IOException { try { portletDD.save(); } catch (PersistenceManagerException e) { throw new IOException("Unable to save JSR concrete portlet: " + e.getMessage()); } } public String toString() { StringBuffer sb = new StringBuffer(); sb.append("\t JSR Application Portlet:\n"); sb.append("\t JSR Portlet Name: ").append(portletName).append("\n"); sb.append("\t Web app name: ").append(webAppName).append("\n"); sb.append("\t concrete ID: ").append(concreteID).append("\n"); sb.append("\t Status: ").append(status).append("\n"); sb.append("\t Status message: ").append(statusMessage).append("\n"); /* if (portletDispatcher == null) { sb.append("\t Portlet dispatcher: NULL"); } else { sb.append("\t Portlet dispatcher: OK"); } */ return sb.toString(); } public void setCompareLocale(Locale loc) { compareLocale = loc; } public int compareTo(Object o) { ApplicationPortletImpl otherApplicationPortlet = (ApplicationPortletImpl) o; if (compareLocale == null) return (this.getWebApplicationName() + " - " + getDisplayName(new Locale(getDefaultLocale()))). compareToIgnoreCase(otherApplicationPortlet.getWebApplicationName() + " - " + otherApplicationPortlet.getDisplayName(new Locale(getDefaultLocale()))); else return (this.getWebApplicationName() + " - " + getDisplayName(compareLocale)).compareToIgnoreCase( otherApplicationPortlet.getWebApplicationName() + " - " + (otherApplicationPortlet.getDisplayName(compareLocale))); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -