Package org.apache.abdera.protocol.client

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


        el.setAttributeValue(APPConstants.ASSOC_TYPE, associationType);
        el.setText(associationPaths);
        RequestOptions requestOptions = getAuthorization();
        requestOptions.setHeader("Destination", associationPaths);
        requestOptions.setHeader("AssociationType", associationType);
        ClientResponse resp = abderaClient.delete(baseURI + APPConstants.ATOM +
                encodeURL(sourcePath +
                        RegistryConstants.URL_SEPARATOR +
                        APPConstants.ASSOCIATIONS),
                requestOptions);
        if (resp.getType() == Response.ResponseType.SUCCESS) {
            if (log.isDebugEnabled()) {
                log.debug("remove association " + sourcePath + " to " + associationPaths +
                        " type " + associationType + " succeeded" +
                        ", Response Status: " + resp.getStatus() +
                        ", Response Type: " + resp.getType());
            }
            abderaClient.teardown();
        } else {
            String msg = "remove association " + sourcePath + " to " + associationPaths +
                    " type " + associationType + "failed" +
                    ", Response Status: " + resp.getStatus() +
                    ", Response Type: " + resp.getType();
            log.error(msg);
            abderaClient.teardown();
            throw new RegistryException(msg);
        }
    }
View Full Code Here


        }
    }

    public Association[] getAllAssociations(String resourcePath) throws RegistryException {
        AbderaClient abderaClient = new AbderaClient(abdera);
        ClientResponse resp = abderaClient.get(baseURI + APPConstants.ATOM +
                encodeURL(resourcePath +
                        RegistryConstants.URL_SEPARATOR +
                        APPConstants.ASSOCIATIONS),
                getAuthorization());
        if (resp.getType() == Response.ResponseType.SUCCESS) {
            Document introspection = resp.getDocument();
            Feed feed = (Feed) introspection.getRoot();
            Association[] associations = getAssociationsFromFeed(feed, resourcePath);
            abderaClient.teardown();
            return associations;
        } else {
            String msg = "uanble to get all associations for path " + resourcePath +
                    ", Response Status: " + resp.getStatus() +
                    ", Response Type: " + resp.getType();
            log.error(msg);
            abderaClient.teardown();
            throw new RegistryException(msg);
        }
    }
View Full Code Here

    }

    public Association[] getAssociations(String resourcePath, String associationType)
            throws RegistryException {
        AbderaClient abderaClient = new AbderaClient(abdera);
        ClientResponse clientResponse =
                abderaClient.get(baseURI + APPConstants.ATOM +
                        encodeURL(resourcePath + RegistryConstants.URL_SEPARATOR +
                                APPConstants.ASSOCIATIONS + ":" +
                                associationType),
                        getAuthorization());
        Document introspection = clientResponse.getDocument();
        Feed feed = (Feed) introspection.getRoot();
        List entries = feed.getEntries();
        Association associations[] = null;
        if (entries != null) {
            associations = new Association[entries.size()];
View Full Code Here

    public void applyTag(String resourcePath, String tag) throws RegistryException {
        AbderaClient abderaClient = new AbderaClient(abdera);
        Entry entry = abdera.getFactory().newEntry();
        entry.setContent(tag);
        ClientResponse resp = abderaClient.post(baseURI + APPConstants.ATOM +
                encodeURL(resourcePath +
                        RegistryConstants.URL_SEPARATOR +
                        APPConstants.PARAMETER_TAGS),
                entry,
                getAuthorization());

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

        }
    }

    public TaggedResourcePath[] getResourcePathsWithTag(String tag) throws RegistryException {
        AbderaClient abderaClient = new AbderaClient(abdera);
        ClientResponse clientResponse = abderaClient.get(baseURI + "/tags/" + tag,
                getAuthorization());

        Document introspection =
                clientResponse.getDocument();
        Feed feed = (Feed) introspection.getRoot();
        List entries = feed.getEntries();
        TaggedResourcePath taggedResourcePaths[] = null;
        if (entries != null) {
            taggedResourcePaths = new TaggedResourcePath[entries.size()];
View Full Code Here

        return taggedResourcePaths;
    }

    public Tag[] getTags(String resourcePath) throws RegistryException {
        AbderaClient abderaClient = new AbderaClient(abdera);
        ClientResponse clientResponse = abderaClient.get(baseURI + APPConstants.ATOM +
                encodeURL(resourcePath +
                        RegistryConstants.URL_SEPARATOR +
                        APPConstants.PARAMETER_TAGS),
                getAuthorization());

        Document introspection =
                clientResponse.getDocument();
        Feed feed = (Feed) introspection.getRoot();
        List entries = feed.getEntries();
        Tag tags[] = null;
        if (entries != null) {
            tags = new Tag[entries.size()];
View Full Code Here

            encodedTag = URLEncoder.encode(tag, "UTF-8");
        } catch (Exception e) {
            log.error("An exception occurred while processing removeTag request", e);
            return;
        }
        ClientResponse resp = abderaClient.delete(baseURI + APPConstants.ATOM +
                encodeURL(path +
                        RegistryConstants.URL_SEPARATOR) +
                        "tag:" + encodedTag,
                getAuthorization());

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

        entry.setId("tag:commentID"); // TODO - generate real ID
        entry.setTitle("Comment");
        entry.setUpdated(comment.getCreatedTime());
        entry.addAuthor(comment.getUser());
        entry.setContent(comment.getText());
        ClientResponse resp =
                abderaClient.post(baseURI + APPConstants.ATOM +
                        encodeURL(resourcePath +
                                RegistryConstants.URL_SEPARATOR +
                                APPConstants.PARAMETER_COMMENTS),
                        entry,
                        getAuthorization());
        if (resp.getType() == Response.ResponseType.SUCCESS) {
            if (log.isDebugEnabled()) {
                log.debug("Adding comment for resourcePath + " + resourcePath + " succeeded." +
                        ", Response Status: " + resp.getStatus() +
                        ", Response Type: " + resp.getType());
            }
            abderaClient.teardown();
            return resp.getLocation().toString().substring(baseURI.length());
        } else {
            String msg = "Adding comment for resourcePath + " + resourcePath + " failed." +
                    ", Response Status: " + resp.getStatus() +
                    ", Response Type: " + resp.getType();
            abderaClient.teardown();
            log.error(msg);
            throw new RegistryException(msg);
        }
    }
View Full Code Here

    public void editComment(String commentPath, String text) throws RegistryException {
        AbderaClient abderaClient = new AbderaClient(abdera);
        Entry entry = abdera.getFactory().newEntry();
        entry.setContent(text);
        ClientResponse resp = abderaClient.put(baseURI + APPConstants.ATOM +
                encodeURL(commentPath),
                entry,
                getAuthorization());

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

            resourcePath = resourcePath.substring(0, index).replace(":", "%3A") +
                    resourcePath.substring(index);
        } else {
            resourcePath = resourcePath.replace(":", "%3A");
        }
        ClientResponse clientResponse =
                abderaClient.get(baseURI + APPConstants.ATOM +
                        resourcePath + RegistryConstants.URL_SEPARATOR +
                        APPConstants.PARAMETER_COMMENTS,
                        getAuthorization());
        Document introspection = clientResponse.getDocument();
        Element element = introspection.getRoot();
        Feed feed = (Feed) element;
        org.wso2.carbon.registry.core.Comment[] comments = getCommentsFromFeed(feed);
        abderaClient.teardown();
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.