Package com.couchace.core.api.http

Examples of com.couchace.core.api.http.CouchMediaType


                .put(entity);

            CouchStatusCode statusCode = CouchStatusCode.findByCode(response.getStatus());
            String eTag = getETag(response);
            byte[] content = response.readEntity(byte[].class);
            CouchMediaType mediaType = CouchMediaType.fromString(response.getMediaType().toString());
            int contentLength = response.getLength();
            return CouchHttpResponse.builder(CouchMethodType.PUT, webTarget.getUri(), statusCode)
                .setDocumentRevision(eTag)
                .setContent(mediaType, contentLength, content)
                .build();
View Full Code Here


            Response response = webTarget.request().delete();

            CouchStatusCode statusCode = CouchStatusCode.findByCode(response.getStatus());
            String eTag = getETag(response);
            byte[] content = response.readEntity(byte[].class);
            CouchMediaType mediaType = CouchMediaType.fromString(response.getMediaType().toString());
            int contentLength = response.getLength();
            return CouchHttpResponse.builder(CouchMethodType.DELETE, webTarget.getUri(), statusCode)
                .setDocumentRevision(eTag)
                .setContent(mediaType, contentLength, content)
                .build();
View Full Code Here

    }

    protected CouchHttpResponse buildCouchResponse(HttpRequest request, URI uri, Response response, String documentId) {
        CouchStatusCode statusCode = CouchStatusCode.findByCode(response.getStatus());
        String eTag = getETag(response);
        CouchMediaType mediaType = CouchMediaType.fromString(response.getMediaType().toString());

        Object content;
        if (mediaType.isTextType()) {
            content = response.readEntity(String.class);
        } else {
            content = response.readEntity(byte[].class);
        }
View Full Code Here

    }

    public HttpGetRequest newHttpGetRequest(ReadDocumentRequest request) {
        PathAndQuery pathAndQuery = buildPathAndQuery(request);

        CouchMediaType acceptType = CouchMediaType.APPLICATION_JSON;

        if (request instanceof GetAttachmentRequest) {
            // REVIEW - Not sure why I'm doing this but too scared to remove it.
            acceptType = null;
        }
View Full Code Here

        this.jsonStrategy = couch.getJsonStrategy();
        this.metaRepository = couch.getMetaRepository();
    }

    public <T> GetEntityResponse<T> buildEntityResponse(GetEntityRequest<T> request, CouchHttpResponse couchHttpResponse) {
        CouchMediaType contentType = CouchMediaType.APPLICATION_JSON;

        EntityMeta<T> entityMeta = metaRepository.getOrCreateEntityMeta(request.getEntityClass());

        GetEntityResponse<T> entityResponse;
        if (couchHttpResponse.isSuccess()) {
View Full Code Here

        this.jsonStrategy = couch.getJsonStrategy();
        this.metaRepository = couch.getMetaRepository();
    }

    public <T> GetEntityResponse<T> buildEntityResponse(GetEntityRequest<T> request, CouchHttpResponse httpResponse) {
        CouchMediaType contentType = CouchMediaType.APPLICATION_JSON;

        EntityMeta<T> entityMeta = metaRepository.getOrCreateEntityMeta(request.getEntityClass());

        GetEntityResponse<T> entityResponse;
        if (httpResponse.isSuccess()) {
View Full Code Here

    }

    public HttpGetRequest newHttpGetRequest(ReadDocumentRequest request) {
        PathAndQuery pathAndQuery = buildPathAndQuery(request);

        CouchMediaType acceptType = CouchMediaType.APPLICATION_JSON;

        if (request instanceof GetAttachmentRequest) {
            // REVIEW - Not sure why I'm doing this but too scared to remove it.
            acceptType = null;
        }
View Full Code Here

    public <T extends HttpReadRequest> T newHttpReadRequest(Class<T> httpReadRequestClass, ReadRequest request) {

        List<HttpQueryParam> queryParameters = new ArrayList<>();
        String path;
        CouchMediaType acceptType = CouchMediaType.APPLICATION_JSON;
        if (request instanceof GetAttachmentRequest) {
            // Attachment
            GetAttachmentRequest getAttachmentRequest = (GetAttachmentRequest) request;
            path = UriUtil.buildPath(databaseName, request.getDocumentId(), getAttachmentRequest.getAttachmentName());
            acceptType = null;
View Full Code Here

    public <T extends HttpReadRequest> T newHttpReadRequest(Class<T> httpReadRequestClass, ReadRequest request) {

        List<HttpQueryParam> queryParameters = new ArrayList<>();
        String path;
        CouchMediaType acceptType = CouchMediaType.APPLICATION_JSON;
        // TODO - each of these if conditions should be broken out to protected methods so that they may be extended and for readability.
        if (request instanceof GetAttachmentRequest) {
            // Attachment
            GetAttachmentRequest getAttachmentRequest = (GetAttachmentRequest) request;
            path = UriUtil.buildPath(databaseName, request.getDocumentId(), getAttachmentRequest.getAttachmentName());
View Full Code Here

        this.jsonStrategy = couch.getJsonStrategy();
        this.metaRepository = couch.getMetaRepository();
    }

    public <T> GetEntityResponse<T> buildEntityResponse(GetEntityRequest<T> request, CouchHttpResponse couchHttpResponse) {
        CouchMediaType contentType = CouchMediaType.APPLICATION_JSON;

        EntityMeta<T> entityMeta = metaRepository.getOrCreateEntityMeta(request.getEntityClass());

        GetEntityResponse<T> entityResponse;
        if (couchHttpResponse.isSuccess()) {
View Full Code Here

TOP

Related Classes of com.couchace.core.api.http.CouchMediaType

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.