Example usage for org.apache.commons.fileupload FileUpload FileUpload

List of usage examples for org.apache.commons.fileupload FileUpload FileUpload

Introduction

In this page you can find the example usage for org.apache.commons.fileupload FileUpload FileUpload.

Prototype

public FileUpload(FileItemFactory fileItemFactory) 

Source Link

Document

Constructs an instance of this class which uses the supplied factory to create FileItem instances.

Usage

From source file:com.kuprowski.mogile.multipart.MojiMultipartResolver.java

@Override
protected FileUpload newFileUpload(FileItemFactory fileItemFactory) {
    return new FileUpload(mojiFileItemFactory);
}

From source file:net.ontopia.topicmaps.classify.ClassifyUtils.java

public static ClassifiableContentIF getFileUploadContent(HttpServletRequest request) {
    // Handle file upload
    String contentType = request.getHeader("content-type");
    // out.write("CT: " + contentType + " " + tm + " " + id);
    if (contentType != null && contentType.startsWith("multipart/form-data")) {
        try {// ww w .j av a2 s . c  om
            FileUpload upload = new FileUpload(new DefaultFileItemFactory());
            for (FileItem item : upload.parseRequest(request)) {
                if (item.getSize() > 0) {
                    // ISSUE: could make use of content type if known
                    byte[] content = item.get();
                    ClassifiableContent cc = new ClassifiableContent();
                    String name = item.getName();
                    if (name != null)
                        cc.setIdentifier("fileupload:name:" + name);
                    else
                        cc.setIdentifier("fileupload:field:" + item.getFieldName());
                    cc.setContent(content);
                    return cc;
                }
            }
        } catch (Exception e) {
            throw new OntopiaRuntimeException(e);
        }
    }
    return null;
}

From source file:juzu.plugin.upload.FileUploadUnmarshaller.java

@Override
public void unmarshall(String mediaType, final ClientContext context,
        Iterable<Map.Entry<ContextualParameter, Object>> contextualArguments,
        Map<String, RequestParameter> parameterArguments) throws IOException {

    org.apache.commons.fileupload.RequestContext ctx = new org.apache.commons.fileupload.RequestContext() {
        public String getCharacterEncoding() {
            return context.getCharacterEncoding();
        }/*from   w  ww.  jav  a2 s . c  o m*/

        public String getContentType() {
            return context.getContentType();
        }

        public int getContentLength() {
            return context.getContentLenth();
        }

        public InputStream getInputStream() throws IOException {
            return context.getInputStream();
        }
    };

    //
    FileUpload upload = new FileUpload(new DiskFileItemFactory());
    try {
        List<FileItem> list = (List<FileItem>) upload.parseRequest(ctx);
        HashMap<String, FileItem> files = new HashMap<String, FileItem>();
        for (FileItem file : list) {
            String name = file.getFieldName();
            if (file.isFormField()) {
                RequestParameter parameterArg = parameterArguments.get(name);
                if (parameterArg == null) {
                    parameterArguments.put(name, RequestParameter.create(name, file.getString()));
                } else {
                    parameterArguments.put(name, parameterArg.append(new String[] { file.getString() }));
                }
            } else {
                files.put(name, file);
            }
        }
        for (Map.Entry<ContextualParameter, Object> argument : contextualArguments) {
            ContextualParameter contextualParam = argument.getKey();
            FileItem file = files.get(contextualParam.getName());
            if (file != null && FileItem.class.isAssignableFrom(contextualParam.getType())) {
                argument.setValue(file);
            }
        }
    } catch (FileUploadException e) {
        throw new IOException(e);
    }
}

From source file:juzu.plugin.upload.impl.UploadPlugin.java

public void invoke(Request request) {

    ///* ww w . j  av a2s . co  m*/
    final ClientContext clientContext = request.getClientContext();

    //
    if (clientContext != null) {
        String contentType = clientContext.getContentType();
        if (contentType != null) {
            if (contentType.startsWith("multipart/")) {

                //
                org.apache.commons.fileupload.RequestContext ctx = new org.apache.commons.fileupload.RequestContext() {
                    public String getCharacterEncoding() {
                        return clientContext.getCharacterEncoding();
                    }

                    public String getContentType() {
                        return clientContext.getContentType();
                    }

                    public int getContentLength() {
                        return clientContext.getContentLenth();
                    }

                    public InputStream getInputStream() throws IOException {
                        return clientContext.getInputStream();
                    }
                };

                //
                FileUpload upload = new FileUpload(new DiskFileItemFactory());

                //
                try {
                    List<FileItem> list = (List<FileItem>) upload.parseRequest(ctx);
                    HashMap<String, RequestParameter> parameters = new HashMap<String, RequestParameter>();
                    for (FileItem file : list) {
                        String name = file.getFieldName();
                        if (file.isFormField()) {
                            RequestParameter parameter = parameters.get(name);
                            if (parameter != null) {
                                parameter = parameter.append(new String[] { file.getString() });
                            } else {
                                parameter = RequestParameter.create(name, file.getString());
                            }
                            parameter.appendTo(parameters);
                        } else {
                            ControlParameter parameter = request.getMethod().getParameter(name);
                            if (parameter instanceof ContextualParameter
                                    && FileItem.class.isAssignableFrom(parameter.getType())) {
                                request.setArgument(parameter, file);
                            }
                        }
                    }

                    // Keep original parameters that may come from the request path
                    for (RequestParameter parameter : request.getParameters().values()) {
                        if (!parameters.containsKey(parameter.getName())) {
                            parameter.appendTo(parameters);
                        }
                    }

                    // Redecode phase arguments from updated request
                    Method<?> method = request.getMethod();
                    Map<ControlParameter, Object> arguments = method.getArguments(parameters);

                    // Update with existing contextual arguments
                    for (Map.Entry<ControlParameter, Object> argument : request.getArguments().entrySet()) {
                        if (argument.getKey() instanceof ContextualParameter) {
                            arguments.put(argument.getKey(), argument.getValue());
                        }
                    }

                    // Replace all arguments
                    request.setArguments(arguments);
                } catch (FileUploadException e) {
                    throw new UndeclaredThrowableException(e);
                }
            }
        }
    }

    //
    request.invoke();
}

From source file:net.ontopia.topicmaps.webed.impl.utils.ReqParamUtils.java

/**
 * INTERNAL: Builds the Parameters object from an HttpServletRequest
 * object.//from  w  w w. ja va2 s  . c om
 * @since 2.0
 */
public static Parameters decodeParameters(HttpServletRequest request, String charenc)
        throws ServletException, IOException {

    String ctype = request.getHeader("content-type");
    log.debug("Content-type: " + ctype);
    Parameters params = new Parameters();

    if (ctype != null && ctype.startsWith("multipart/form-data")) {
        // special file upload request, so use FileUpload to decode
        log.debug("Decoding with FileUpload; charenc=" + charenc);
        try {
            FileUpload upload = new FileUpload(new DefaultFileItemFactory());
            Iterator iterator = upload.parseRequest(request).iterator();
            while (iterator.hasNext()) {
                FileItem item = (FileItem) iterator.next();
                log.debug("Reading: " + item);
                if (item.isFormField()) {
                    if (charenc != null)
                        params.addParameter(item.getFieldName(), item.getString(charenc));
                    else
                        params.addParameter(item.getFieldName(), item.getString());
                } else
                    params.addParameter(item.getFieldName(), new FileParameter(item));
            }
        } catch (FileUploadException e) {
            throw new ServletException(e);
        }

    } else {
        // ordinary web request, so retrieve info and stuff into Parameters object
        log.debug("Normal parameter decode, charenc=" + charenc);
        if (charenc != null)
            request.setCharacterEncoding(charenc);
        Enumeration enumeration = request.getParameterNames();
        while (enumeration.hasMoreElements()) {
            String param = (String) enumeration.nextElement();
            params.addParameter(param, request.getParameterValues(param));
        }
    }

    return params;
}

From source file:com.enonic.cms.web.portal.services.ServicesProcessorBase.java

public ServicesProcessorBase(final String handlerName) {
    this.handlerName = handlerName;
    fileUpload = new FileUpload(new DiskFileItemFactory());
    fileUpload.setHeaderEncoding("UTF-8");
    this.allowedRedirectDomains = ImmutableList.of("*");
}

From source file:ccc.plugins.multipart.apache.MultipartForm.java

/**
 * Parse an HTTP request, extracting the file items.
 *
 * @param context The JAXRS context to parse.
 *
 * @return A list of file items.//from  w w w.ja  v a 2 s .  c  om
 */
@SuppressWarnings("unchecked")
private static List<FileItem> parseFileItems(final JaxrsRequestContext context) {

    DBC.require().notNull(context);

    // Check that we have a file upload request
    final boolean isMultipart = FileUploadBase.isMultipartContent(context);
    if (!isMultipart) {
        throw new RuntimeException("Not a multipart.");
    }

    // Create a factory for disk-based file items
    final DiskFileItemFactory factory = new DiskFileItemFactory();

    // Set factory constraints
    factory.setSizeThreshold(maxInMemorySize());

    // Create a new file upload handler
    final FileUpload upload = new FileUpload(factory);

    // Set overall request size constraint
    upload.setFileSizeMax(maxFileSize());

    try {
        return upload.parseRequest(context);
    } catch (final FileSizeLimitExceededException e) {
        throw handleTooBig(e, e.getPermittedSize());
    } catch (final SizeLimitExceededException e) {
        throw handleTooBig(e, e.getPermittedSize());
    } catch (final FileUploadException e) {
        throw new RuntimeException("Failed to parse multipart request.", e);
    }
}

From source file:com.slamd.admin.RequestInfo.java

/**
 * Creates a new set of request state information using the provided request
 * and response.//  ww  w.  j  av a 2  s .  c  o m
 *
 * @param  request   Information about the HTTP request issued by the client.
 * @param  response  Information about the HTTP response that will be returned
 *                   to the client.
 */
public RequestInfo(HttpServletRequest request, HttpServletResponse response) {
    this.request = request;
    this.response = response;

    generateHTML = true;
    debugInfo = new StringBuilder();
    htmlBody = new StringBuilder();
    infoMessage = new StringBuilder();

    if (request != null) {
        servletBaseURI = request.getRequestURI();
        userIdentifier = request.getRemoteUser();

        if (FileUpload.isMultipartContent(request)) {
            try {
                FileUpload fileUpload = new FileUpload(new DefaultFileItemFactory());
                multipartFieldList = fileUpload.parseRequest(request);
                Iterator iterator = multipartFieldList.iterator();

                while (iterator.hasNext()) {
                    FileItem fileItem = (FileItem) iterator.next();
                    String name = fileItem.getFieldName();
                    if (name.equals(Constants.SERVLET_PARAM_SECTION)) {
                        section = new String(fileItem.get());
                    } else if (name.equals(Constants.SERVLET_PARAM_SUBSECTION)) {
                        subsection = new String(fileItem.get());
                    }
                }
            } catch (FileUploadException fue) {
                fue.printStackTrace();
            }
        } else {
            section = request.getParameter(Constants.SERVLET_PARAM_SECTION);
            subsection = request.getParameter(Constants.SERVLET_PARAM_SUBSECTION);
        }
    }

    if (section == null) {
        section = "";
    }

    if (subsection == null) {
        subsection = "";
    }
}

From source file:cltestgrid.Upload2.java

private List<MyFileItem> parseRequest(HttpServletRequest req) throws RuntimeException {
    try {//from   w w w  .j a  v  a2s  .c o m
        if (isMultipartContent(req)) {
            FileItemFactory factory = new MyFileItemFactory();
            FileUpload upload = new FileUpload(factory);
            return (List<MyFileItem>) upload.parseRequest(req);
        } else {
            log.warning("Non multipart request");
            return Collections.<MyFileItem>emptyList();
        }
    } catch (FileUploadException e) {
        throw new RuntimeException("Error parsing multipart request body", e);
    }
}

From source file:edu.ucsb.eucalyptus.transport.query.WalrusQueryDispatcher.java

public String getOperation(HttpRequest httpRequest, MessageContext messageContext)
        throws EucalyptusCloudException {
    //Figure out if it is an operation on the service, a bucket or an object
    Map operationParams = new HashMap();
    String[] target = null;//from  w  ww . jav a 2  s .c  om
    String path = httpRequest.getOperationPath();
    boolean walrusInternalOperation = false;
    if (path.length() > 0) {
        target = getTarget(path);
    }

    String verb = httpRequest.getHttpMethod();
    Map<String, String> headers = httpRequest.getHeaders();
    CaseInsensitiveMap caseInsensitiveHeaders = new CaseInsensitiveMap(headers);
    String operationKey = "";
    Map<String, String> params = httpRequest.getParameters();
    String operationName = null;
    long contentLength = 0;
    String contentLengthString = (String) messageContext.getProperty(HTTP.CONTENT_LEN);
    if (contentLengthString != null) {
        contentLength = Long.parseLong(contentLengthString);
    }
    if (caseInsensitiveHeaders.containsKey(StorageProperties.EUCALYPTUS_OPERATION)) {
        String value = caseInsensitiveHeaders.get(StorageProperties.EUCALYPTUS_OPERATION);
        for (WalrusProperties.WalrusInternalOperations operation : WalrusProperties.WalrusInternalOperations
                .values()) {
            if (value.toLowerCase().equals(operation.toString().toLowerCase())) {
                operationName = operation.toString();
                walrusInternalOperation = true;
                break;
            }
        }

        if (!walrusInternalOperation) {
            for (WalrusProperties.StorageOperations operation : WalrusProperties.StorageOperations.values()) {
                if (value.toLowerCase().equals(operation.toString().toLowerCase())) {
                    operationName = operation.toString();
                    walrusInternalOperation = true;
                    break;
                }
            }
        }

    }

    if (target == null) {
        //target = service
        operationKey = SERVICE + verb;
    } else if (target.length < 2) {
        //target = bucket
        if (!target[0].equals("")) {
            operationKey = BUCKET + verb;
            operationParams.put("Bucket", target[0]);

            if (verb.equals(HTTPVerb.POST.toString())) {
                InputStream in = (InputStream) messageContext.getProperty("TRANSPORT_IN");
                messageContext.setProperty(WalrusProperties.STREAMING_HTTP_PUT, Boolean.TRUE);
                String contentType = caseInsensitiveHeaders.get(HTTP.CONTENT_TYPE);
                int postContentLength = Integer.parseInt(caseInsensitiveHeaders.get(HTTP.CONTENT_LEN));
                POSTRequestContext postRequestContext = new POSTRequestContext(in, contentType,
                        postContentLength);
                FileUpload fileUpload = new FileUpload(new WalrusFileItemFactory());
                InputStream formDataIn = null;
                String objectKey = null;
                String file = "";
                String key;
                Map<String, String> formFields = new HashMap<String, String>();
                try {
                    List<FileItem> parts = fileUpload.parseRequest(postRequestContext);
                    for (FileItem part : parts) {
                        if (part.isFormField()) {
                            String fieldName = part.getFieldName().toString().toLowerCase();
                            InputStream formFieldIn = part.getInputStream();
                            int bytesRead;
                            String fieldValue = "";
                            byte[] bytes = new byte[512];
                            while ((bytesRead = formFieldIn.read(bytes)) > 0) {
                                fieldValue += new String(bytes, 0, bytesRead);
                            }
                            formFields.put(fieldName, fieldValue);
                        } else {
                            formDataIn = part.getInputStream();
                            if (part.getName() != null)
                                file = part.getName();
                        }
                    }
                } catch (Exception ex) {
                    LOG.warn(ex, ex);
                    throw new EucalyptusCloudException("could not process form request");
                }

                String authenticationHeader = "";
                formFields.put(WalrusProperties.FormField.bucket.toString(), target[0]);
                if (formFields.containsKey(WalrusProperties.FormField.key.toString())) {
                    objectKey = formFields.get(WalrusProperties.FormField.key.toString());
                    objectKey = objectKey.replaceAll("\\$\\{filename\\}", file);
                }
                if (formFields.containsKey(WalrusProperties.FormField.acl.toString())) {
                    String acl = formFields.get(WalrusProperties.FormField.acl.toString());
                    headers.put(WalrusProperties.AMZ_ACL, acl);
                }
                if (formFields.containsKey(WalrusProperties.FormField.success_action_redirect.toString())) {
                    String successActionRedirect = formFields
                            .get(WalrusProperties.FormField.success_action_redirect.toString());
                    operationParams.put("SuccessActionRedirect", successActionRedirect);
                }
                if (formFields.containsKey(WalrusProperties.FormField.success_action_status.toString())) {
                    Integer successActionStatus = Integer.parseInt(
                            formFields.get(WalrusProperties.FormField.success_action_status.toString()));
                    if (successActionStatus == 200 || successActionStatus == 201)
                        operationParams.put("SuccessActionStatus", successActionStatus);
                    else
                        operationParams.put("SuccessActionStatus", 204);
                } else {
                    operationParams.put("SuccessActionStatus", 204);
                }
                if (formFields.containsKey(WalrusProperties.FormField.policy.toString())) {
                    String policy = new String(
                            Base64.decode(formFields.remove(WalrusProperties.FormField.policy.toString())));
                    String policyData;
                    try {
                        policyData = new String(Base64.encode(policy.getBytes()));
                    } catch (Exception ex) {
                        LOG.warn(ex, ex);
                        throw new EucalyptusCloudException("error reading policy data.");
                    }
                    //parse policy
                    try {
                        JSONObject policyObject = new JSONObject(policy);
                        String expiration = (String) policyObject
                                .get(WalrusProperties.PolicyHeaders.expiration.toString());
                        if (expiration != null) {
                            Date expirationDate = DateUtils.parseIso8601DateTimeOrDate(expiration);
                            if ((new Date()).getTime() > expirationDate.getTime()) {
                                LOG.warn("Policy has expired.");
                                //TODO: currently this will be reported as an invalid operation
                                //Fix this to report a security exception
                                throw new EucalyptusCloudException("Policy has expired.");
                            }
                        }
                        List<String> policyItemNames = new ArrayList<String>();

                        JSONArray conditions = (JSONArray) policyObject
                                .get(WalrusProperties.PolicyHeaders.conditions.toString());
                        for (int i = 0; i < conditions.length(); ++i) {
                            Object policyItem = conditions.get(i);
                            if (policyItem instanceof JSONObject) {
                                JSONObject jsonObject = (JSONObject) policyItem;
                                if (!exactMatch(jsonObject, formFields, policyItemNames)) {
                                    LOG.warn("Policy verification failed. ");
                                    throw new EucalyptusCloudException("Policy verification failed.");
                                }
                            } else if (policyItem instanceof JSONArray) {
                                JSONArray jsonArray = (JSONArray) policyItem;
                                if (!partialMatch(jsonArray, formFields, policyItemNames)) {
                                    LOG.warn("Policy verification failed. ");
                                    throw new EucalyptusCloudException("Policy verification failed.");
                                }
                            }
                        }

                        Set<String> formFieldsKeys = formFields.keySet();
                        for (String formKey : formFieldsKeys) {
                            if (formKey.startsWith(WalrusProperties.IGNORE_PREFIX))
                                continue;
                            boolean fieldOkay = false;
                            for (WalrusProperties.IgnoredFields field : WalrusProperties.IgnoredFields
                                    .values()) {
                                if (formKey.equals(field.toString().toLowerCase())) {
                                    fieldOkay = true;
                                    break;
                                }
                            }
                            if (fieldOkay)
                                continue;
                            if (policyItemNames.contains(formKey))
                                continue;
                            LOG.warn("All fields except those marked with x-ignore- should be in policy.");
                            throw new EucalyptusCloudException(
                                    "All fields except those marked with x-ignore- should be in policy.");
                        }
                    } catch (Exception ex) {
                        //rethrow
                        if (ex instanceof EucalyptusCloudException)
                            throw (EucalyptusCloudException) ex;
                        LOG.warn(ex);
                    }
                    //all form uploads without a policy are anonymous
                    if (formFields
                            .containsKey(WalrusProperties.FormField.AWSAccessKeyId.toString().toLowerCase())) {
                        String accessKeyId = formFields
                                .remove(WalrusProperties.FormField.AWSAccessKeyId.toString().toLowerCase());
                        authenticationHeader += "AWS" + " " + accessKeyId + ":";
                    }
                    if (formFields.containsKey(WalrusProperties.FormField.signature.toString())) {
                        String signature = formFields.remove(WalrusProperties.FormField.signature.toString());
                        authenticationHeader += signature;
                        headers.put(HMACQuerySecurityHandler.SecurityParameter.Authorization.toString(),
                                authenticationHeader);
                    }
                    headers.put(WalrusProperties.FormField.FormUploadPolicyData.toString(), policyData);
                }
                operationParams.put("Key", objectKey);
                key = target[0] + "." + objectKey;
                String randomKey = key + "." + Hashes.getRandom(10);
                LinkedBlockingQueue<WalrusDataMessage> putQueue = getWriteMessenger()
                        .interruptAllAndGetQueue(key, randomKey);

                Writer writer = new Writer(formDataIn, postContentLength, putQueue);
                writer.start();

                operationParams.put("ContentLength", (new Long(postContentLength).toString()));
                operationParams.put(WalrusProperties.Headers.RandomKey.toString(), randomKey);
            }

        } else {
            operationKey = SERVICE + verb;
        }
    } else {
        //target = object
        operationKey = OBJECT + verb;
        String objectKey = "";
        String splitOn = "";
        for (int i = 1; i < target.length; ++i) {
            objectKey += splitOn + target[i];
            splitOn = "/";
        }
        operationParams.put("Bucket", target[0]);
        operationParams.put("Key", objectKey);

        if (!params.containsKey(OperationParameter.acl.toString())) {
            if (verb.equals(HTTPVerb.PUT.toString())) {
                if (caseInsensitiveHeaders.containsKey(WalrusProperties.COPY_SOURCE.toString())) {
                    String copySource = caseInsensitiveHeaders.get(WalrusProperties.COPY_SOURCE.toString());
                    String[] sourceTarget = getTarget(copySource);
                    String sourceObjectKey = "";
                    String sourceSplitOn = "";
                    if (sourceTarget.length > 1) {
                        for (int i = 1; i < sourceTarget.length; ++i) {
                            sourceObjectKey += sourceSplitOn + sourceTarget[i];
                            sourceSplitOn = "/";
                        }
                        operationParams.put("SourceBucket", sourceTarget[0]);
                        operationParams.put("SourceObject", sourceObjectKey);
                        operationParams.put("DestinationBucket", operationParams.remove("Bucket"));
                        operationParams.put("DestinationObject", operationParams.remove("Key"));

                        String metaDataDirective = caseInsensitiveHeaders
                                .get(WalrusProperties.METADATA_DIRECTIVE.toString());
                        if (metaDataDirective != null) {
                            operationParams.put("MetadataDirective", metaDataDirective);
                        }
                        AccessControlListType accessControlList;
                        if (contentLength > 0) {
                            InputStream in = (InputStream) messageContext.getProperty("TRANSPORT_IN");
                            accessControlList = getAccessControlList(in);
                        } else {
                            accessControlList = new AccessControlListType();
                        }
                        operationParams.put("AccessControlList", accessControlList);
                        operationKey += WalrusProperties.COPY_SOURCE.toString();
                        Iterator<String> iterator = caseInsensitiveHeaders.keySet().iterator();
                        while (iterator.hasNext()) {
                            String key = iterator.next();
                            for (WalrusProperties.CopyHeaders header : WalrusProperties.CopyHeaders.values()) {
                                if (key.replaceAll("-", "").equals(header.toString().toLowerCase())) {
                                    String value = caseInsensitiveHeaders.get(key);
                                    parseExtendedHeaders(operationParams, header.toString(), value);
                                }
                            }
                        }
                    } else {
                        throw new EucalyptusCloudException("Malformed COPY request");
                    }

                } else {
                    messageContext.setProperty(WalrusProperties.STREAMING_HTTP_PUT, Boolean.TRUE);
                    InputStream in = (InputStream) messageContext.getProperty("TRANSPORT_IN");
                    InputStream inStream = in;
                    if ((!walrusInternalOperation) || (!WalrusProperties.StorageOperations.StoreSnapshot
                            .toString().equals(operationName))) {
                        inStream = new BufferedInputStream(in);
                    } else {
                        try {
                            inStream = new GZIPInputStream(in);
                        } catch (Exception ex) {
                            LOG.warn(ex, ex);
                            throw new EucalyptusCloudException("cannot process input");
                        }
                    }
                    String key = target[0] + "." + objectKey;
                    String randomKey = key + "." + Hashes.getRandom(10);
                    LinkedBlockingQueue<WalrusDataMessage> putQueue = getWriteMessenger()
                            .interruptAllAndGetQueue(key, randomKey);

                    Writer writer = new Writer(inStream, contentLength, putQueue);
                    writer.start();

                    operationParams.put("ContentLength", (new Long(contentLength).toString()));
                    operationParams.put(WalrusProperties.Headers.RandomKey.toString(), randomKey);
                }
            } else if (verb.equals(HTTPVerb.GET.toString())) {
                messageContext.setProperty(WalrusProperties.STREAMING_HTTP_GET, Boolean.TRUE);
                if (!walrusInternalOperation) {

                    operationParams.put("GetData", Boolean.TRUE);
                    operationParams.put("InlineData", Boolean.FALSE);
                    operationParams.put("GetMetaData", Boolean.TRUE);

                    Iterator<String> iterator = caseInsensitiveHeaders.keySet().iterator();
                    boolean isExtendedGet = false;
                    while (iterator.hasNext()) {
                        String key = iterator.next();
                        for (WalrusProperties.ExtendedGetHeaders header : WalrusProperties.ExtendedGetHeaders
                                .values()) {
                            if (key.replaceAll("-", "").equals(header.toString().toLowerCase())) {
                                String value = caseInsensitiveHeaders.get(key);
                                isExtendedGet = true;
                                parseExtendedHeaders(operationParams, header.toString(), value);
                            }
                        }

                    }
                    if (isExtendedGet) {
                        operationKey += "extended";
                        //only supported through SOAP
                        operationParams.put("ReturnCompleteObjectOnConditionFailure", Boolean.FALSE);
                    }
                } else {
                    for (WalrusProperties.InfoOperations operation : WalrusProperties.InfoOperations.values()) {
                        if (operation.toString().equals(operationName)) {
                            messageContext.removeProperty(WalrusProperties.STREAMING_HTTP_GET);
                            break;
                        }
                    }
                }
                if (params.containsKey(WalrusProperties.GetOptionalParameters.IsCompressed.toString())) {
                    Boolean isCompressed = Boolean.parseBoolean(
                            params.remove(WalrusProperties.GetOptionalParameters.IsCompressed.toString()));
                    operationParams.put("IsCompressed", isCompressed);
                }

            } else if (verb.equals(HTTPVerb.HEAD.toString())) {
                messageContext.setProperty(WalrusProperties.STREAMING_HTTP_GET, Boolean.FALSE);
                if (!walrusInternalOperation) {
                    operationParams.put("GetData", Boolean.FALSE);
                    operationParams.put("InlineData", Boolean.FALSE);
                    operationParams.put("GetMetaData", Boolean.TRUE);
                }
            }
        }

    }

    if (verb.equals(HTTPVerb.PUT.toString()) && params.containsKey(OperationParameter.acl.toString())) {
        //read ACL
        InputStream in = (InputStream) messageContext.getProperty("TRANSPORT_IN");
        operationParams.put("AccessControlPolicy", getAccessControlPolicy(in));
    }

    ArrayList paramsToRemove = new ArrayList();

    boolean addMore = true;
    Iterator iterator = params.keySet().iterator();
    while (iterator.hasNext()) {
        Object key = iterator.next();
        String keyString = key.toString().toLowerCase();
        boolean dontIncludeParam = false;
        for (HMACQuerySecurityHandler.SecurityParameter securityParam : HMACQuerySecurityHandler.SecurityParameter
                .values()) {
            if (keyString.equals(securityParam.toString().toLowerCase())) {
                dontIncludeParam = true;
                break;
            }
        }
        if (dontIncludeParam)
            continue;
        String value = params.get(key);
        if (value != null) {
            String[] keyStringParts = keyString.split("-");
            if (keyStringParts.length > 1) {
                keyString = "";
                for (int i = 0; i < keyStringParts.length; ++i) {
                    keyString += toUpperFirst(keyStringParts[i]);
                }
            } else {
                keyString = toUpperFirst(keyString);
            }
            operationParams.put(keyString, value);
        }
        if (addMore) {
            //just add the first one to the key
            operationKey += keyString.toLowerCase();
            addMore = false;
        }
        paramsToRemove.add(key);
    }

    for (Object key : paramsToRemove) {
        params.remove(key);
    }

    if (!walrusInternalOperation) {
        operationName = operationMap.get(operationKey);
    }
    httpRequest.setBindingArguments(operationParams);
    messageContext.setProperty(WalrusProperties.WALRUS_OPERATION, operationName);
    return operationName;
}