public synchronized Map<String, Object[]> getParameterMap() { if (parameterMap == null) { // Two conditions: file upload ("multipart/form-data") or not if (getContentType() != null && getContentType().startsWith("multipart/form-data")) { // Special handling for multipart/form-data // Decode the multipart data parameterMap = Multipart.getParameterMapMultipart( pipelineContext, request, ServletExternalContext.DEFAULT_FORM_CHARSET_DEFAULT); } else if (portletRequest instanceof ResourceRequest) { // We encoded query parameters directly into the resource id in this case final String queryString = NetUtils.getQueryString(((ResourceRequest) portletRequest).getResourceID()); if (queryString != null) parameterMap = Collections.unmodifiableMap( StringConversions.stringArrayMapToObjectArrayMap( NetUtils.decodeQueryString(queryString, false))); else parameterMap = Collections.emptyMap(); } else { // Not a resource request, so just use native request parameters parameterMap = new HashMap<String, Object[]>(portletRequest.getParameterMap()); parameterMap.remove(WSRPURLRewriter.PathParameterName()); parameterMap = Collections.unmodifiableMap(parameterMap); } } return parameterMap; }
/** * Read bytes from an InputStream and generate SAX characters events in Base64 encoding. The * InputStream is closed when done. * * <p>The caller has to close the stream if needed. */ public static void inputStreamToBase64Characters(InputStream is, ContentHandler contentHandler) { try { final OutputStream os = new ContentHandlerOutputStream(contentHandler, false); NetUtils.copyStream(new BufferedInputStream(is), os); os.close(); // necessary with ContentHandlerOutputStream to make sure all extra characters // are written } catch (Exception e) { throw new OXFException(e); } }
public String getPathInfo() { // Use the resource id if we are a ResourceRequest // In that case, remove the query string part of the resource id, that's handled by // getParameterMap() String result = (portletRequest instanceof ResourceRequest) ? NetUtils.removeQueryString(((ResourceRequest) portletRequest).getResourceID()) : portletRequest.getParameter(WSRPURLRewriter.PathParameterName()); if (result == null) result = ""; return (result.startsWith("/")) ? result : "/" + result; }
public static void wrapWithRequestElement(ContentHandlerHelper helper, DebugXML debugXML) { helper.startDocument(); final ExternalContext externalContext = NetUtils.getExternalContext(); final ExternalContext.Request request = (externalContext != null) ? externalContext.getRequest() : null; helper.startElement( "request", new String[] { "request-uri", (request != null) ? request.getRequestURI() : null, "query-string", (request != null) ? request.getQueryString() : null, "method", (request != null) ? request.getMethod() : null }); debugXML.toXML(helper); helper.endElement(); helper.endDocument(); }
public void setContentType(String contentType) { this.contentType = NetUtils.getContentTypeMediaType(contentType); }