Examples of AbderaClient


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

        }
        abderaClient.teardown();
    }

    public String[] getVersions(String path) throws RegistryException {
        AbderaClient abderaClient = new AbderaClient(abdera);
        ClientResponse clientResponse =
                abderaClient.get(baseURI + APPConstants.ATOM +
                        encodeURL(path +
                                RegistryConstants.URL_SEPARATOR +
                                APPConstants.PARAMETER_VERSION),
                        getAuthorization());
        Document introspection = clientResponse.getDocument();
        Feed feed = (Feed) introspection.getRoot();
        List entries = feed.getEntries();
        if (entries != null) {
            String[] versions = new String[entries.size()];
            for (int i = 0; i < entries.size(); i++) {
                Entry entry = (Entry) entries.get(i);
                versions[i] = Utils.getLinkWithRel(entry, "versionLink").getHref().toString();
                //versions[i] = entry.getLink("versionLink").getHref().toString();
            }
            abderaClient.teardown();
            return versions;
        }
        abderaClient.teardown();
        return new String[0];
    }
View Full Code Here

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

        abderaClient.teardown();
        return new String[0];
    }

    public void restoreVersion(String versionPath) throws RegistryException {
        AbderaClient abderaClient = new AbderaClient(abdera);
        Entry entry = abdera.getFactory().newEntry();
        ClientResponse resp = abderaClient.post(baseURI + APPConstants.ATOM +
                encodeURL(versionPath +
                        RegistryConstants.URL_SEPARATOR +
                        APPConstants.PARAMETER_RESTORE),
                entry,
                getAuthorization());
        if (resp.getType() == Response.ResponseType.SUCCESS) {
            if (log.isDebugEnabled()) {
                log.debug("resource restore to " + versionPath + " succeeded" +
                        ", Response Status: " + resp.getStatus() +
                        ", Response Type: " + resp.getType());
            }
            abderaClient.teardown();
        } else {
            String msg = "resource restore " + versionPath + "  failed" +
                    ", Response Status: " + resp.getStatus() +
                    ", Response Type: " + resp.getType();
            abderaClient.teardown();
            log.error(msg);
            throw new RegistryException(msg);
        }
    }
View Full Code Here

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

        }
    }

    public void addAssociation(String sourcePath, String associationPaths, String associationType)
            throws RegistryException {
        AbderaClient abderaClient = new AbderaClient(abdera);
        final Factory factory = abdera.getFactory();
        Element el = factory.newElement(APPConstants.QN_ASSOC);
        el.setAttributeValue(APPConstants.ASSOC_TYPE, associationType);
        el.setText(associationPaths);
        ClientResponse resp = abderaClient.post(baseURI + APPConstants.ATOM +
                encodeURL(sourcePath +
                        RegistryConstants.URL_SEPARATOR +
                        APPConstants.ASSOCIATIONS),
                el,
                getAuthorization());
        if (resp.getType() == Response.ResponseType.SUCCESS) {
            if (log.isDebugEnabled()) {
                log.debug("associating " + sourcePath + " to " + associationPaths +
                        " type " + associationType + " succeeded" +
                        ", Response Status: " + resp.getStatus() +
                        ", Response Type: " + resp.getType());
            }
            abderaClient.teardown();
        } else {
            String msg = "associating " + sourcePath + " to " + associationPaths +
                    " type " + associationType + "failed" +
                    ", Response Status: " + resp.getStatus() +
                    ", Response Type: " + resp.getType();
            abderaClient.teardown();
            log.error(msg);
            throw new RegistryException(msg);
        }
    }
View Full Code Here

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


    public void removeAssociation(String sourcePath, String associationPaths,
                                  String associationType)
            throws RegistryException {
        AbderaClient abderaClient = new AbderaClient(abdera);
        final Factory factory = abdera.getFactory();
        Element el = factory.newElement(APPConstants.QN_ASSOC);
        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

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

            throw new RegistryException(msg);
        }
    }

    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

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

        return associations;
    }

    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()];
            for (int i = 0; i < entries.size(); i++) {
                Entry entry = (Entry) entries.get(i);
                Association association = new Association();
                association.setSourcePath(resourcePath);
                association.setDestinationPath(entry.getContent());
                association.setAssociationType(associationType);
                associations[i] = association;
            }
        }
        abderaClient.teardown();
        return associations;
    }
View Full Code Here

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

        abderaClient.teardown();
        return associations;
    }

    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

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

            throw new RegistryException(msg);
        }
    }

    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()];
            for (int i = 0; i < entries.size(); i++) {
                Entry entry = (Entry) entries.get(i);
                org.wso2.carbon.registry.app.Properties properties =
                        entry.getExtension(PropertyExtensionFactory.TAGS);
                List propertyList = properties.getExtensions(PropertyExtensionFactory.TAG);
                Map<String, String> map = new HashMap<String, String>();
                for (Object aPropertyList : propertyList) {
                    Property property = (Property) aPropertyList;
                    PropertyName pn = property.getExtension(PropertyExtensionFactory.PROPERTY_NAME);
                    PropertyValue pv =
                            property.getExtension(PropertyExtensionFactory.PROPERTY_VALUE);
                    map.put(pn.getText(), pv.getText());
                }
                TaggedResourcePath tagPath = new TaggedResourcePath();
                tagPath.setResourcePath(entry.getTitle());
                tagPath.setTagCount(
                        Long.parseLong(entry.getSimpleExtension(new QName(APPConstants.NAMESPACE,
                                "taggings"))));
                taggedResourcePaths[i] = tagPath;
                tagPath.setTagCounts(map);
            }
        }
        abderaClient.teardown();
        return taggedResourcePaths;
    }
View Full Code Here

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

        abderaClient.teardown();
        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()];
            for (int i = 0; i < entries.size(); i++) {
                Entry entry = (Entry) entries.get(i);
                Tag tag = new Tag();
                tag.setTagCount(Long.parseLong(entry.getSimpleExtension(
                        new QName(APPConstants.NAMESPACE, "taggings"))));
                tag.setTagName(entry.getTitle());
                tags[i] = tag;
            }
        }
        abderaClient.teardown();
        return tags;
    }
View Full Code Here

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

        abderaClient.teardown();
        return tags;
    }

    public void removeTag(String path, String tag) throws RegistryException {
        AbderaClient abderaClient = new AbderaClient(abdera);
        String encodedTag;
        try {
            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
TOP
Copyright © 2018 www.massapi.com. 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.