Giter Club home page Giter Club logo

alfresco-rest-client's Introduction

Build Status

About

This library aims to provide some common interfaces / classes that could be used to interact with the Alfresco v1 ReST API. The initial, primary goal of this project is to support simpler integration test code for Alfresco extension projects, by allowing the use of the interfaces / classes in combination with generic ReST client libraries that can map a properly annotated API interface to the underlying service endpoints, e.g. similar to the following code snippet using the JBoss RESTEasy JAX-RS Client and Jackson libraries:

ResteasyJackson2Provider resteasyJacksonProvider = new ResteasyJackson2Provider();
ObjectMapper mapper = new ObjectMapper();
mapper.setSerializationInclusion(Include.NON_EMPTY);
resteasyJacksonProvider.setMapper(mapper);

LocalResteasyProviderFactory resteasyProviderFactory = new LocalResteasyProviderFactory(new ResteasyProviderFactory());
resteasyProviderFactory.register(resteasyJacksonProvider);
RegisterBuiltin.register(resteasyProviderFactory);

String alfrescoBaseUrl = "https://example.com/alfresco";
ResteasyClient client = new ResteasyClientBuilder().providerFactory(resteasyProviderFactory).build();
ResteasyWebTarget target = client.target(UriBuilder.fromPath(alfrescoBaseUrl));

AuthenticationV1 authAPI = target.proxy(AuthenticationV1.class);
TicketEntity ticket = authAPI.createTicket(userName, password);
ClientRequestFilter authFilter = (requestContext) -> {
   String base64Token = Base64.encodeBase64String(ticket.getId().getBytes(StandardCharsets.UTF_8));
   requestContext.getHeaders().add("Authorization", "Basic " + base64Token);
};
target.register(authFilter);

NodesV1 nodesAPI = target.proxy(NodesV1.class);
// load node data for relative path "Data Dictionary" below "-root-" node with "path" and "permissions" included
Node dataDictionaryFolder = nodesAPI.getNodeByPath("-root-", "Data Dictionary", Arrrays.asList("path", "permissions"), Collections.emptyList()); 

// load node data for "-shared-" special node with default data
Node sharedFolder = nodesAPI.getNode("-shared-", Collections.emptyList(), Collections.emptyList());

In future iterations, this library may provide additional classes to provide a working client library out-of-the-box.

alfresco-rest-client's People

Contributors

afaust avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.