Search in sources :

Example 1 with PortletSecurityException

use of javax.portlet.PortletSecurityException in project struts by apache.

the class PortletUrlHelper method createUrl.

protected Object createUrl(String scheme, String type, Map<String, String[]> portletParams) {
    RenderResponse response = PortletActionContext.getRenderResponse();
    PortletURL url;
    if (URLTYPE_NAME_ACTION.equalsIgnoreCase(type)) {
        if (LOG.isDebugEnabled())
            LOG.debug("Creating action url");
        url = response.createActionURL();
    } else {
        if (LOG.isDebugEnabled())
            LOG.debug("Creating render url");
        url = response.createRenderURL();
    }
    url.setParameters(portletParams);
    if ("HTTPS".equalsIgnoreCase(scheme)) {
        try {
            url.setSecure(true);
        } catch (PortletSecurityException e) {
            LOG.error("Cannot set scheme to https", e);
        }
    }
    return url;
}
Also used : RenderResponse(javax.portlet.RenderResponse) PortletSecurityException(javax.portlet.PortletSecurityException) PortletURL(javax.portlet.PortletURL)

Example 2 with PortletSecurityException

use of javax.portlet.PortletSecurityException in project displaytag by hazendaz.

the class PortletHref method toString.

/**
 * To string.
 *
 * @return the string
 *
 * @see org.displaytag.util.Href#toString()
 */
@Override
public String toString() {
    final PortletURL url;
    if (this.isAction()) {
        url = this.renderResponse.createActionURL();
    } else {
        url = this.renderResponse.createRenderURL();
    }
    if (this.isRequestedSecure()) {
        try {
            url.setSecure(true);
        } catch (final PortletSecurityException pse) {
            throw new RuntimeException("Creating secure PortletURL Failed.", pse);
        }
    }
    if (this.getRequestedMode() != null) {
        try {
            url.setPortletMode(this.getRequestedMode());
        } catch (final PortletModeException pme) {
            final IllegalStateException ise = new IllegalStateException("Requested PortletMode='" + this.getRequestedMode() + "' could not be set.");
            ise.initCause(pme);
            throw ise;
        }
    }
    if (this.getRequestedState() != null) {
        try {
            url.setWindowState(this.getRequestedState());
        } catch (final WindowStateException wse) {
            final IllegalStateException ise = new IllegalStateException("Requested WindowState='" + this.getRequestedState() + "' could not be set.");
            ise.initCause(wse);
            throw ise;
        }
    }
    for (final Entry<String, String[]> entry : this.parameters.entrySet()) {
        final String name = entry.getKey();
        final String[] value = entry.getValue();
        url.setParameter(name, value);
    }
    if (this.getAnchor() == null) {
        return url.toString();
    }
    return url.toString() + "#" + this.getAnchor();
}
Also used : WindowStateException(javax.portlet.WindowStateException) PortletSecurityException(javax.portlet.PortletSecurityException) PortletURL(javax.portlet.PortletURL) PortletModeException(javax.portlet.PortletModeException)

Example 3 with PortletSecurityException

use of javax.portlet.PortletSecurityException in project liferay-faces-bridge-impl by liferay.

the class BaseURLRenderer method encodeEnd.

@Override
public void encodeEnd(FacesContext facesContext, UIComponent uiComponent) throws IOException {
    BaseURL baseURL = createBaseURL(facesContext, uiComponent);
    Boolean secure = getSecure(uiComponent);
    if (secure != null) {
        try {
            baseURL.setSecure(secure);
        } catch (PortletSecurityException e) {
            throw new IOException(e);
        }
    }
    processParamChildren(uiComponent, baseURL);
    processPropertyChildren(uiComponent, baseURL);
    String varName = getVar(uiComponent);
    String url = baseURL.toString();
    if (isEscapeXml(uiComponent)) {
        url = XMLUtil.escapeXML(url);
    }
    // If the user didn't specify a value for the "var" attribute, then write the URL to the response.
    if (varName == null) {
        ResponseWriter responseWriter = facesContext.getResponseWriter();
        responseWriter.write(url);
    } else // Otherwise, place the url into the request scope so that it can be resolved via EL with the name
    // specified in the "var" attribute.
    {
        ExternalContext externalContext = facesContext.getExternalContext();
        Map<String, Object> requestMap = externalContext.getRequestMap();
        requestMap.put(varName, url);
    }
}
Also used : ResponseWriter(javax.faces.context.ResponseWriter) ExternalContext(javax.faces.context.ExternalContext) BaseURL(javax.portlet.BaseURL) IOException(java.io.IOException) PortletSecurityException(javax.portlet.PortletSecurityException)

Example 4 with PortletSecurityException

use of javax.portlet.PortletSecurityException in project struts by apache.

the class PortletUrlHelperJSR286 method createUrl.

protected Object createUrl(String scheme, String type, Map<String, String[]> portletParams) {
    MimeResponse response = (MimeResponse) PortletActionContext.getResponse();
    BaseURL url;
    if (URLTYPE_NAME_ACTION.equalsIgnoreCase(type)) {
        if (LOG.isDebugEnabled())
            LOG.debug("Creating action url");
        url = response.createActionURL();
    } else if (URLTYPE_NAME_RESOURCE.equalsIgnoreCase(type)) {
        if (LOG.isDebugEnabled())
            LOG.debug("Creating resource url");
        url = response.createResourceURL();
    } else {
        if (LOG.isDebugEnabled())
            LOG.debug("Creating render url");
        url = response.createRenderURL();
    }
    url.setParameters(portletParams);
    if ("HTTPS".equalsIgnoreCase(scheme)) {
        try {
            url.setSecure(true);
        } catch (PortletSecurityException e) {
            LOG.error("Cannot set scheme to https", e);
        }
    }
    return url;
}
Also used : MimeResponse(javax.portlet.MimeResponse) BaseURL(javax.portlet.BaseURL) PortletSecurityException(javax.portlet.PortletSecurityException)

Aggregations

PortletSecurityException (javax.portlet.PortletSecurityException)4 BaseURL (javax.portlet.BaseURL)2 PortletURL (javax.portlet.PortletURL)2 IOException (java.io.IOException)1 ExternalContext (javax.faces.context.ExternalContext)1 ResponseWriter (javax.faces.context.ResponseWriter)1 MimeResponse (javax.portlet.MimeResponse)1 PortletModeException (javax.portlet.PortletModeException)1 RenderResponse (javax.portlet.RenderResponse)1 WindowStateException (javax.portlet.WindowStateException)1