Package org.apache.chemistry.opencmis.client.bindings.spi.http

Examples of org.apache.chemistry.opencmis.client.bindings.spi.http.Response


        // using the content URL and adding a streamId param
        // is not spec-compliant
        url.addParameter(Constants.PARAM_STREAM_ID, streamId);

        // get the content
        Response resp = getHttpInvoker().invokeGET(url, getSession(), offset, length);

        // check response code
        if ((resp.getResponseCode() != 200) && (resp.getResponseCode() != 206)) {
            throw convertStatusCode(resp.getResponseCode(), resp.getResponseMessage(), resp.getErrorContent(), null);
        }

        result.setFileName(null);
        result.setLength(resp.getContentLength());
        result.setMimeType(resp.getContentTypeHeader());
        result.setStream(resp.getStream());

        return result;
    }
View Full Code Here


        // set up object and writer
        final AtomEntryWriter entryWriter = new AtomEntryWriter(createIdObject(objectId.getValue()));

        // post move request
        Response resp = post(url, Constants.MEDIATYPE_ENTRY, new Output() {
            public void write(OutputStream out) throws Exception {
                entryWriter.write(out);
            }
        });

        // parse the response
        AtomEntry entry = parse(resp.getStream(), AtomEntry.class);

        objectId.setValue(entry.getId());
    }
View Full Code Here

                            MimeHelper.encodeContentDisposition(MimeHelper.DISPOSITION_ATTACHMENT,
                                    contentStream.getFileName()));
        }

        // send content
        Response resp = put(url, contentStream.getMimeType(), headers, new Output() {
            public void write(OutputStream out) throws Exception {
                int b;
                byte[] buffer = new byte[4096];

                while ((b = stream.read(buffer)) > -1) {
                    out.write(buffer, 0, b);
                }

                stream.close();
            }
        });

        // check response code further
        if ((resp.getResponseCode() != 200) && (resp.getResponseCode() != 201) && (resp.getResponseCode() != 204)) {
            throw convertStatusCode(resp.getResponseCode(), resp.getResponseMessage(), resp.getErrorContent(), null);
        }

        objectId.setValue(null);
        if (changeToken != null) {
            changeToken.setValue(null);
View Full Code Here

        url.addParameter(Constants.PARAM_POLICY_IDS, includePolicyIds);
        url.addParameter(Constants.PARAM_ACL, includeACL);
        url.addParameter(Constants.PARAM_MAX_ITEMS, maxItems);

        // read and parse
        Response resp = read(url);
        AtomFeed feed = parse(resp.getStream(), AtomFeed.class);

        // handle top level
        for (AtomElement element : feed.getElements()) {
            if (element.getObject() instanceof AtomLink) {
                if (isNextLink(element)) {
View Full Code Here

        queryParameters.put(Constants.PARAM_RENDITION_FILTER, renditionFilter);
        queryParameters.put(Constants.PARAM_MAX_ITEMS, (maxItems == null) ? null : maxItems.toString());
        queryParameters.put(Constants.PARAM_SKIP_COUNT, (skipCount == null) ? null : skipCount.toString());

        // post the query and parse results
        Response resp = post(url, Constants.MEDIATYPE_QUERY, new Output() {
            public void write(OutputStream out) throws Exception {
                AtomEntryWriter.writeQuery(out, queryParameters);
            }
        });
        AtomFeed feed = parse(resp.getStream(), AtomFeed.class);

        // handle top level
        for (AtomElement element : feed.getElements()) {
            if (element.getObject() instanceof AtomLink) {
                if (isNextLink(element)) {
View Full Code Here

        UrlBuilder url = new UrlBuilder(link);
        url.addParameter(Constants.PARAM_FILTER, filter);

        // read and parse
        Response resp = read(url);
        AtomFeed feed = parse(resp.getStream(), AtomFeed.class);

        // get the policies
        if (!feed.getEntries().isEmpty()) {
            for (AtomEntry entry : feed.getEntries()) {
                ObjectData policy = null;
View Full Code Here

        UrlBuilder url = new UrlBuilder(link);
        url.addParameter(Constants.PARAM_FILTER, PropertyIds.OBJECT_ID);

        // read and parse
        Response resp = read(url);
        AtomFeed feed = parse(resp.getStream(), AtomFeed.class);

        // find the policy
        String policyLink = null;
        boolean found = false;
View Full Code Here

        url.addParameter(Constants.PARAM_PROPERTY_DEFINITIONS, includePropertyDefinitions);
        url.addParameter(Constants.PARAM_MAX_ITEMS, maxItems);
        url.addParameter(Constants.PARAM_SKIP_COUNT, skipCount);

        // read and parse
        Response resp = read(url);
        AtomFeed feed = parse(resp.getStream(), AtomFeed.class);

        // handle top level
        for (AtomElement element : feed.getElements()) {
            if (element.getObject() instanceof AtomLink) {
                if (isNextLink(element)) {
View Full Code Here

        url.addParameter(Constants.PARAM_TYPE_ID, typeId);
        url.addParameter(Constants.PARAM_DEPTH, depth);
        url.addParameter(Constants.PARAM_PROPERTY_DEFINITIONS, includePropertyDefinitions);

        // read and parse
        Response resp = read(url);
        AtomFeed feed = parse(resp.getStream(), AtomFeed.class);

        // process tree
        addTypeDescendantsLevel(repositoryId, feed, result);

        return result;
View Full Code Here

     * Performs a GET on an URL, checks the response code and returns the
     * result.
     */
    protected Response read(UrlBuilder url) {
        // make the call
        Response resp = getHttpInvoker().invokeGET(url, session);

        // check response code
        if (resp.getResponseCode() != 200) {
            throw convertStatusCode(resp.getResponseCode(), resp.getResponseMessage(), resp.getErrorContent(), null);
        }

        return resp;
    }
View Full Code Here

TOP

Related Classes of org.apache.chemistry.opencmis.client.bindings.spi.http.Response

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.