/** * Copies the parameters from map to the BaseURL. * * @param url BaseURL * @return void */ protected void setUrlParameters(BaseURL url) { Set<String> keySet = parametersMap.keySet(); for (String key : keySet) { List<String> valueList = parametersMap.get(key); String[] valueArray = valueList.toArray(new String[0]); url.setParameter(key, valueArray); } }
/** * Sets the secure flag on the URl as required * * @throws JspException */ protected void handleSecureFlag() throws JspException { BaseURL url = getUrl(); if (secure != null && !secure.equalsIgnoreCase("true") && !secure.equalsIgnoreCase("false")) { StringBuilder txt = new StringBuilder(128); txt.append("Invalid secure option: ").append(secure); txt.append(", valid options: true, false"); throw new JspException(txt.toString()); } if(url == null){ throw new IllegalStateException("internal error: url not set"); } if (var != null) { pageContext.removeAttribute(var, PageContext.PAGE_SCOPE); } if (secure != null) { try { url.setSecure(isSecure()); } catch (PortletSecurityException e) { // ignore exception as Pluto doesn't support setSecure // throw new JspException(e); } } }
/** * Copies the properties from map to the BaseURL. * @param url BaseURL * @return void */ protected void setUrlProperties(BaseURL url) { Set<String> keySet = propertiesMap.keySet(); for(String key : keySet){ List<String> valueList = propertiesMap.get(key); for(String value:valueList){ url.addProperty(key, value); } } }
/** * Sets the wrapped object. * * @param wrapped the wrapped object to set. * @throws java.lang.IllegalArgumentException if the BaseURL is null. */ public void setWrapped(BaseURL wrapped) { if (wrapped == null) { throw new java.lang.IllegalArgumentException("BaseURL to wrap is null"); } this.wrapped = wrapped; }
private boolean isURLGenTc(BaseURL url) { boolean ok = false; String[] vals = (String[]) url.getParameterMap().get("tc"); if ((vals != null) && (vals.length > 0) && vals[0].contains("PortletURLGenerationListener")) { ok = true; } return ok; }
private boolean isURLGenTc(BaseURL url) { boolean ok = false; String[] vals = (String[]) url.getParameterMap().get("tc"); if ((vals != null) && (vals.length > 0) && vals[0].contains("PortletURLGenerationListener")) { vals = (String[]) url.getParameterMap().get("PUGL"); if ((vals != null) && (vals.length > 0) && vals[0].matches("^(?:Action|Render|Resource)$")) { ok = true; } } return ok; }
@Override protected void setUrl(BaseURL url) { this.resourceURL = (ResourceURL)url; }
@Override protected BaseURL getUrl() { return portletURL; }
@Override protected void setUrl(BaseURL url) { this.portletURL = (PortletURL) url; }
/** * prevent additional copying */ @Override protected void setUrlParameters(BaseURL url) { }
@Override public int doEndTag() throws JspException{ BaseURL url = getUrl(); if(url == null){ throw new IllegalStateException("internal error: url not set"); } setUrlParameters(url); setUrlProperties(url); HttpServletResponse response = (HttpServletResponse) pageContext.getResponse(); // properly encoding urls to allow non-cookie enabled sessions - PLUTO-252 String urlString = response.encodeURL(url.toString()); if(Boolean.parseBoolean(escapeXml)) { urlString = doEscapeXml(urlString); } if (var == null) { try { JspWriter writer = pageContext.getOut(); writer.print(urlString); } catch (IOException ioe) { throw new JspException( "Portlet/ResourceURL-Tag Exception: cannot write to the output writer."); } } else { pageContext.setAttribute(var, urlString, PageContext.PAGE_SCOPE); } /*cleanup*/ propertiesMap.clear(); parametersMap.clear(); removedParametersList.clear(); setUrl(null); return EVAL_PAGE; }
@Deprecated @Override public void setParameter(String name, String value) { ((BaseURL)wrapped).setParameter(name, value); }
@Deprecated @Override public void setParameter(String name, String... values) { ((BaseURL)wrapped).setParameter(name, values); }
@Deprecated @Override public void setParameters(Map<String, String[]> parameters) { ((BaseURL)wrapped).setParameters(parameters); }
@Override public void setSecure(boolean secure) throws PortletSecurityException { ((BaseURL)wrapped).setSecure(secure); }
@Deprecated @Override public Map<String, String[]> getParameterMap() { return ((BaseURL)wrapped).getParameterMap(); }
@Override public void write(Writer out) throws IOException { ((BaseURL)wrapped).write(out); }
@Override public void write(Writer out, boolean escapeXML) throws IOException { ((BaseURL)wrapped).write(out, escapeXML); }
@Override public Appendable append(Appendable out) throws IOException { return ((BaseURL)wrapped).append(out); }
@Override public Appendable append(Appendable out, boolean escapeXML) throws IOException { return ((BaseURL)wrapped).append(out, escapeXML); }
@Override public void addProperty(String key, String value) { ((BaseURL)wrapped).addProperty(key, value); }
@Override public void setProperty(String key, String value) { ((BaseURL)wrapped).setProperty(key, value); }
/** * Copies the parameters from map to the BaseURL. * @param url BaseURL * @return void */ @SuppressWarnings("deprecation") protected void setUrlParameters(BaseURL url) { Set<String> keySet = parametersMap.keySet(); for(String key : keySet){ List<String> valueList = parametersMap.get(key); String[] valueArray = valueList.toArray(new String[0]); url.setParameter(key, valueArray); } }
/** * @return the url */ protected abstract BaseURL getUrl();
/** * @param url the url to set */ protected abstract void setUrl(BaseURL url);
/** * @param wrapped the wrapped object to set. * @throws java.lang.IllegalArgumentException if the BaseURL is null. */ public BaseURLWrapper(BaseURL wrapped) { super(wrapped); }
/** * Gets the wrapped object. * * @return the wrapped object. */ @Override public BaseURL getWrapped() { return ((BaseURL)wrapped); }