Examples of AbderaClient


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

            scaProviderNode = NodeFactory.newInstance().createNode("org/apache/tuscany/sca/binding/atom/Provider.composite", new Contribution("provider", contribution));
            scaProviderNode.start();

            abdera = new Abdera();
            client = new AbderaClient(abdera);
            abderaParser = Abdera.getNewParser();
        } catch(Exception e) {
            e.printStackTrace();
        }
    }
View Full Code Here

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

        scaProviderNode = NodeFactory.newInstance().createNode("org/apache/tuscany/sca/binding/atom/Provider.composite", new Contribution("provider", contribution));
        scaProviderNode.start();

        abdera = new Abdera();
        client = new AbderaClient(abdera);
        abderaParser = Abdera.getNewParser();
    }
View Full Code Here

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

        if (resourcePath == null || "".equals(resourcePath)) {
            resourcePath = "/";
        }

        AbderaClient abderaClient = new AbderaClient(abdera);
        RequestOptions requestOptions = getAuthorization();
        requestOptions.addDateHeader("ToDate", to);
        requestOptions.addDateHeader("FromDate", from);
        requestOptions.addHeader("Action", "" + action);
        requestOptions.addHeader("Author", userName);
        ClientResponse resp = abderaClient.get(baseURI + APPConstants.ATOM +
                encodeURL(resourcePath +
                        RegistryConstants.URL_SEPARATOR +
                        APPConstants.PARAMETER_LOGS),
                requestOptions);
        Document introspection =
                resp.getDocument();
        Feed feed = (Feed) introspection.getRoot();
        List entries = feed.getEntries();
        LogEntry logs[] = null;
        if (entries != null) {
            logs = new LogEntry[entries.size()];
            for (int i = 0; i < entries.size(); i++) {
                Entry entry = (Entry) entries.get(i);
                LogEntry logEntry = new LogEntry();
                logEntry.setDate(entry.getEdited());
                logEntry.setActionData(entry.getContent());
                logEntry.setUserName(entry.getAuthor().getName());
                logEntry.setAction(Integer.parseInt(
                        entry.getSimpleExtension(new QName(APPConstants.NAMESPACE, "action"))));
                String path = entry.getSimpleExtension(new QName(APPConstants.NAMESPACE, "path"));
                logEntry.setResourcePath(path);
                logs[i] = logEntry;
            }
        }
        abderaClient.teardown();
        return logs;
    }
View Full Code Here

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

    public String[] getAvailableAspects() {
        throw new UnsupportedOperationException();
    }

    public void associateAspect(String resourcePath, String aspect) throws RegistryException {
        AbderaClient abderaClient = new AbderaClient(abdera);
        // POST as text to "<resource>;aspects"
        ByteArrayInputStream is = new ByteArrayInputStream(aspect.getBytes());
        ClientResponse resp = abderaClient.post(baseURI + APPConstants.ATOM +
                encodeURL(resourcePath +
                        RegistryConstants.URL_SEPARATOR +
                        APPConstants.ASPECTS),
                is,
                getAuthorization());
        if (resp.getType() == Response.ResponseType.SUCCESS) {
            if (log.isDebugEnabled()) {
                String msg =
                        "Resource associated to aspect " + aspect + " on " + resourcePath + ".";
                log.debug(msg);
            }
            abderaClient.teardown();
        } else {
            String msg = "Resource associated to aspect " + aspect + " on " + resourcePath + ".";
            abderaClient.teardown();
            log.error(msg);
            throw new RegistryException(msg);
        }
    }
View Full Code Here

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

        }
    }

    public void invokeAspect(String resourcePath, String aspectName, String action)
            throws RegistryException {
        AbderaClient abderaClient = new AbderaClient(abdera);

        // The content doesn't really matter here, so this is a placeholder for now.
        // Later on we'll likely want to support parameterized invocations, so we'll likely
        // enable posting form-encoded data.
        ByteArrayInputStream is = new ByteArrayInputStream("invoke".getBytes());
        ClientResponse resp = abderaClient.post(baseURI + APPConstants.ATOM +
                encodeURL(resourcePath +
                        RegistryConstants.URL_SEPARATOR +
                        APPConstants.ASPECT) + "(" + encodeURL(aspectName) + ")" +
                action,
                is,
                getAuthorization());
        if (resp.getType() == Response.ResponseType.SUCCESS) {
            if (log.isDebugEnabled()) {
                String msg = "Succeeded in invoking aspect " + aspectName + " on " + resourcePath +
                        " action " + action + ".";
                log.debug(msg);
            }
            abderaClient.teardown();
        } else {
            String msg = "Couldn't invoke aspect " + aspectName + " on " + resourcePath +
                    " action " + action + ".";
            abderaClient.teardown();
            log.error(msg);
            throw new RegistryException(msg);
        }
    }
View Full Code Here

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

    public void rollbackTransaction() throws RegistryException {
    }

    public String[] getAspectActions(String resourcePath, String aspectName)
            throws RegistryException {
        AbderaClient abderaClient = new AbderaClient(abdera);
        ClientResponse clientResponse =
                abderaClient.get(baseURI + APPConstants.ATOM +
                        encodeURL(resourcePath +
                        RegistryConstants.URL_SEPARATOR +
                        APPConstants.ASPECT) + "(" + encodeURL(aspectName) + ")",
                        getAuthorization());
        Document introspection = clientResponse.getDocument();
        Feed feed = (Feed) introspection.getRoot();
        List entries = feed.getEntries();
        if (entries != null) {
            String[] aspectActions = new String[entries.size()];
            for (int i = 0; i < entries.size(); i++) {
                Entry entry = (Entry) entries.get(i);
                aspectActions[i] = entry.getContent();
            }
            abderaClient.teardown();
            return aspectActions;
        }
        abderaClient.teardown();
        return new String[0];
    }
View Full Code Here

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

    }

    // check in, check out functionality

    public void restore(String path, Reader reader) throws RegistryException {
        AbderaClient abderaClient = new AbderaClient(abdera);
        restore(path, reader, abderaClient);
    }
View Full Code Here

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

        AbderaClient abderaClient = new AbderaClient(abdera);
        restore(path, reader, abderaClient);
    }

    public void dump(String path, Writer writer) throws RegistryException {
        AbderaClient abderaClient = new AbderaClient(abdera);
        dump(path, abderaClient, writer);
    }
View Full Code Here

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

     * @param timeout the time to wait.
     *
     * @throws RegistryException if the operation failed.
     */
    public void restore(String path, Reader reader, int timeout) throws RegistryException {
        AbderaClient abderaClient = new AbderaClient(abdera);
        abderaClient.setSocketTimeout(timeout);
        restore(path, reader, abderaClient);
        abderaClient.teardown();
    }
View Full Code Here

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

     * @param timeout the time to wait.
     *
     * @throws RegistryException if the operation failed.
     */
    public void dump(String path, int timeout, Writer writer) throws RegistryException {
        AbderaClient abderaClient = new AbderaClient(abdera);
        abderaClient.setSocketTimeout(timeout);
        dump(path, abderaClient, writer);
        abderaClient.teardown();
    }
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.