Package org.apache.abdera.protocol.client

Examples of org.apache.abdera.protocol.client.ClientResponse


    public void removeComment(String commentPath) throws RegistryException {
        AbderaClient abderaClient = new AbderaClient(abdera);
        String resourcePath = commentPath.substring(0, commentPath.indexOf(";comments:"));
        int commentId = Integer.parseInt(
                commentPath.substring(commentPath.indexOf(";comments:") + ";comments:".length()));
        ClientResponse resp = abderaClient.delete(baseURI + APPConstants.ATOM +
                encodeURL(resourcePath +
                        RegistryConstants.URL_SEPARATOR) +
                        "comment:" + commentId,
                getAuthorization());

        if (resp.getType() == Response.ResponseType.SUCCESS) {
            if (log.isDebugEnabled()) {
                log.debug("Removing comment: " + commentId + " for resourcePath + " + resourcePath +
                        " succeeded." + ", Response Status: " + resp.getStatus() +
                        ", Response Type: " + resp.getType());
            }
            abderaClient.teardown();
        } else {
            String msg = "Removing comment: " + commentId + " for resourcePath + " + resourcePath +
                        " succeeded." + ", Response Status: " + resp.getStatus() +
                    ", Response Type: " + resp.getType();
            abderaClient.teardown();
            log.error(msg);
            throw new RegistryException(msg);
        }
View Full Code Here


    }

    public static String getAnnouncementHtml(String url) {
        Abdera abdera = new Abdera();
        AbderaClient client = new AbderaClient(abdera);
        ClientResponse resp = client.get(url);
        Feed feed;
        if (resp.getType() == Response.ResponseType.SUCCESS) {
            Document<Feed> respDoc = resp.getDocument();
            feed = respDoc.getRoot();
        } else {
            // there was an error
            log.error("The request to the url: " + url + " failed.");
            return "";
View Full Code Here

        try {
            StringRequestEntity stringreq =
                    new StringRequestEntity(getRequest(id, pwd, service));
            RequestOptions options = client.getDefaultRequestOptions();
            options.setContentType("application/x-www-form-urlencoded");
            ClientResponse response = client.post(URI, stringreq, options);
            String auth = read(response.getInputStream());
            response.release();
            return auth.split("\n")[2].replaceAll("Auth=", "auth=");
        } catch (CarbonException e) {
            log.error("Error reading content from Google Client Login for \"" + id + "\"", e);
        } catch (UnsupportedEncodingException e) {
            log.error("Error parsing content from Google Client Login for \"" + id + "\"", e);
View Full Code Here

            throw new CarbonException("Invalid parameter");
        }

        if (arguments[0] instanceof String) {

            ClientResponse clientResponse = hostObject.client.get((String) arguments[0],
                                                                  hostObject.options);
            Scriptable entryHostObject = cx.newObject(hostObject, "AtomEntry", new Object[0]);
            ((AtomEntryHostObject) entryHostObject).setEntry((Entry) clientResponse.getDocument()
                    .getRoot());
            return entryHostObject;

        } else if (arguments[0] instanceof AtomEntryHostObject) {
            AtomEntryHostObject atomEntryHostObject = (AtomEntryHostObject) arguments[0];
            Entry entry = atomEntryHostObject.getEntry();
            if (entry != null) {
                IRI editUri = null;
                try {
                    editUri = getEditURI(entry);
                    ClientResponse clientResponse = hostObject.client.get(editUri.toString());
                    Scriptable entryHostObject = cx.newObject(hostObject, "AtomEntry",
                                                              new Object[0]);
                    ((AtomEntryHostObject) entryHostObject).setEntry((Entry) clientResponse
                            .getDocument().getRoot());
                    return entryHostObject;
                } catch (IRISyntaxException e) {
                    throw new CarbonException(e);
                }
View Full Code Here

            Feed feed = atomFeedHostObject.getFeed();
            if (feed != null) {
                IRI editUri = null;
                try {
                    editUri = getEditURI(feed);
                    ClientResponse clientResponse = hostObject.client.get(editUri.toString());
                    Scriptable feedHostObject = cx.newObject(hostObject, "AtomFeed",
                                                             new Object[0]);
                    ((AtomFeedHostObject) feedHostObject).setFeed((Feed) clientResponse
                            .getDocument().getRoot());
                    return feedHostObject;
                } catch (IRISyntaxException e) {
                    throw new CarbonException(e);
                } catch (MimeTypeParseException e) {
View Full Code Here

            Entry entry = atomEntryHostObject.getEntry();
            if (entry != null) {
                IRI editUri;
                try {
                    editUri = getEditURI(entry);
                    ClientResponse clientResponse = hostObject.client.get(editUri.toString());
                    Scriptable entryHostObject = cx.newObject(hostObject, "AtomEntry",
                                                              new Object[0]);
                    ((AtomEntryHostObject) entryHostObject).setEntry((Entry) clientResponse
                            .getDocument().getRoot());
                    return entryHostObject;
                } catch (IRISyntaxException e) {
                    throw new CarbonException(e);
                }
View Full Code Here

        } else {
            throw new CarbonException("Invalid Number of Parameters");
        }

        performAuthentication(hostObject, url);
        ClientResponse response = hostObject.client.put(url, entry, hostObject.options);

        if (response.getStatus() != 200)
            throw new CarbonException("Put Failed." + response.getStatusText());

    }
View Full Code Here

        }


        performAuthentication(hostObject, url);
        if (url != null) {
            ClientResponse response = hostObject.client.delete(url, hostObject.options);
            if (response.getStatus() != 200)
                throw new CarbonException("Delete Failed." + response.getStatusText());
        } else {
            throw new CarbonException("Entry Cannot be deleted.");
        }
    }
View Full Code Here

        customerEl.setAttributeValue(new QName("name"), "Dan Diephouse");
        entry.setContent(customerEl);

        RequestOptions opts = new RequestOptions();
        opts.setContentType("application/atom+xml;type=entry");
        ClientResponse res = client.post(colUri.toString(), entry, opts);
        assertEquals(201, res.getStatus());

        IRI location = res.getLocation();
        assertEquals(basePath + "/customers/1001-Dan_Diephouse", location.toString());

        // GET the entry
        res = client.get(colUri.resolve(location.toString()).toString());
        assertEquals(200, res.getStatus());

        org.apache.abdera.model.Document<Entry> entry_doc = res.getDocument();
        entry = entry_doc.getRoot();
    }
View Full Code Here

        repository = (Repository) muleContext.getRegistry().lookupObject("jcrRepository");

        Thread.sleep(5000);

        AbderaClient client = new AbderaClient();
        ClientResponse res = client.get("http://localhost:" + getPorts().get(0) + "/events");

        Document<Feed> doc = res.getDocument();
        // see if this helps with intermittent failures
        doc.complete();
        Feed feed = doc.getRoot();
        // see if this helps with intermittent failures
        feed.complete();
View Full Code Here

TOP

Related Classes of org.apache.abdera.protocol.client.ClientResponse

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.