GithubHelp home page GithubHelp logo

nuxeo-sdk-ios's Introduction

Nuxeo SDK iOS

Toolbox to provides a library to start building your iOS application connected to Nuxeo through our REST API.

How to build

You need to install cocoapods:

    # Adding our cocoapods specs repository
    $ pod repo add nuxeo https://github.com/nuxeo/cocoapods-specs
    
    # Executing `pod` to fetch dependencies
    $ cd NuxeoSDK
    $ pod
    $ open NuxeoSDK.xcworkspace
    

API Provided

You can find the whole documentation about what you can do with this library and access your server with the REST API in the documentation center in the iOS Client part.

REST / Automation API

Documentation about REST / Automation API

A simple example how to fetch default-domain from your server using REST API:

    NSURL *url = [[NSURL alloc] initWithString:@"http://localhost:8080/nuxeo"];
    
    NUXBasicAuthenticator *auth = [[NUXBasicAuthenticator alloc] initWithUsername:@"Administrator" password:@"Administrator"];
    NUXSession *session = [[NUXSession alloc] initWithServerURL:url authenticator:auth];
    [session addDefaultSchemas:@[@"dublincore"]];
    
    NUXRequest *request = [session requestDocument:@"default-domain"];
    
    [request setCompletionBlock:^(NUXRequest *request) {
      NSError *error; 
      NUXDocument *doc = [request responseEntityWithError:&error];
      
      [self doSomethingGreatWith:doc]; 
    }];
    [request start];
    

Authenticators

For now we provide two way to authenticate through Nuxeo; you can add your own using NUXAuthenticator protocol. Authenticator must be set in your session object, and it handles request modification to authenticate on destination server.

  • Basic authentication

The default one, you can also set it with a global file.

    NUXBasicAuthenticator *authenticator = [[NUXBasicAuthenticator alloc] initWithUsername:@"Administrator" password:@"Administrator"];
  • Token based authentication

When using token authentication, you should check softAuthentication to know if you already have a token, or not. If not, you should request server to ask for a new one.

    NUXTokenAuthenticator *auth = [[NUXTokenAuthenticator alloc] init];
    // Those fields are mandatory
    auth.applicationName = @"MyOwnAppName";
    auth.permission = @"rw";
    
    session.authenticator = auth;
    if (![auth softAuthentication]) {
      NUXRequest *request = [session requestTokenAuthentication];
      
      // We use the request built-in basic authentication challenge
      request.username = @"Administrator";
      request.password = @"Administrator";
      
      // Beware, request execution is asychronously.
      [auth setTokenFromRequest:nil withCompletionBlock:^(BOOL success) {
        // if success, token saved !
      }];
    } else {
      // Otherwise; you might be authenticated, but do not forget that a token could be revoked.
    }

Entity Mapping

Documentation about entity mapping

We provide a simple way to register entities and map them to query results. To register a new entity type, just do as follow:

    [[NUXJSONMApper sharedMapper] registerEntityClass:[OWNEntity class]];

Then to map request response to an existing entity, resoluton is based on response entity-type JSON field:

    NSError *error;
    OWNEntity *doc = [request responseEntityWithError:&error];

Hiearchical cache

Documentation about hiearchical cache

Blob store

Documentation about LRU blob cache

Blob store do not handles directly blob download, you have to do it with a specific request. But, as soon as the blob is downloaded you can save it inside the blob store like this:

    NSError* error;
    [bs saveBlobFromPath:filePath withDocument:doc metadataXPath:@"file:content" error:&error];

And retrieve it with:

  
    NSString* blobPath = [bs blobFromDocument:doc metadataXPath:@"file:content"];
    

Document, Document listing cache

To cache document response based on their entity type, you can use:

    NUXEntityCache *cache = [NUXEntityCache instance];
    // Write entity in cache
    [cache writeEntity:doc];
    
    // Read entity from the cache
    [cache hasEntityWithId:@"4242-4242-4342" class:[NUXDocument class]]);
    NUXDocument *ent = [[cache entityWithId:@"4242-4242-4342" class:[NUXDocument class]]);
    

To manipulate document listing, there is the same kind of API:

    // Save
    [cache saveEntities:entitiesArray withListName:@"myListName" error:nil];
    NSArray *cached = [cache entitiesFromList:@"myListName"];

QA Scripts

There are two scripts to help to automaticly testing the project

build-and-test.sh

This script is based on Nuxeo integration scripts. It downloads, start the latest built nuxeo-distribution and execute the test suite using xctool, a Facebook's script to prettify XCode output.

prepare-pod.sh

Just a few commands to install pods dependencies

About Nuxeo

Nuxeo provides a modular, extensible Java-based open source software platform for enterprise content management and packaged applications for document management, digital asset management and case management. Designed by developers for developers, the Nuxeo platform offers a modern architecture, a powerful plug-in model and extensive packaging capabilities for building content applications.

More information on: http://www.nuxeo.com/

nuxeo-sdk-ios's People

Contributors

akervern avatar lifely avatar thibarg avatar zuzoovn avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  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.