All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.dynamicextensionsalfresco.webscripts.messages.AnnotationWebScriptInputMessage Maven / Gradle / Ivy

Go to download

Adds an OSGi container to alfresco repository supporting dynamic code reloading, classpath isolation and a bunch of other useful features

There is a newer version: 3.1.0
Show newest version
package com.github.dynamicextensionsalfresco.webscripts.messages;

import org.springframework.extensions.webscripts.WebScriptRequest;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpInputMessage;

import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.List;

public class AnnotationWebScriptInputMessage implements HttpInputMessage {

    private WebScriptRequest request;

    private final HttpHeadersWrapper headers;

    public AnnotationWebScriptInputMessage(WebScriptRequest request) {
        this.request = request;

        this.headers = new HttpHeadersWrapper(request);
    }

    @Override
    public InputStream getBody() throws IOException {
        return request.getContent().getInputStream();
    }

    @Override
    public HttpHeaders getHeaders() {
        return this.headers;
    }

    class HttpHeadersWrapper extends HttpHeaders {
        private final WebScriptRequest request;

        public HttpHeadersWrapper(WebScriptRequest request) {
            this.request = request;
        }

        @Override
        public List get(Object key) {
            String[] values = request.getHeaderValues(key.toString());

            return Arrays.asList(values);
        }

        @Override
        public String getFirst(String headerName) {
            String[] values = request.getHeaderValues(headerName);

            if (values == null){
                return null;
            } else {
                return values[0];
            }
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy