Git Product home page Git Product logo

documentum-rest-client-dotnet's Introduction

Documentum REST .Net Client Reference Implementation

License: Apache 2

This .Net solution contains a reference implementation of Documentum REST Services clients and tests written in C# code. The purpose of this solution is to demonstrate one way to develop a hypermedia driven REST client to consume Documentum REST Services. It does NOT indicate that users could not develop a REST client using other technologies.

OpenText shares the source code of this project for the technology sharing. If users plan to migrate the sample code to their products, they are responsible to maintain this part of the code in their products and should agree with license polices of the referenced libraries used by this sample project.

Overview

This Documentum REST Services client is written with C# code. It uses the JSON media type. It supports HTTP Basic authentication and optionally supports Kerberos. The .Net client's supported features are listed in below tables.

API Spec Description
Supported Servers REST API Version, REST API Version
Supported Formats
  • JSON
Supported Authentications
  • Basic
  • Kerberos
Call Mode
  • Asynchronous
Service Spec Description
Fundamental Services
  • Home document
  • Product information
  • Repositories
  • Batch execution
Folder Services
  • Folder CRUD
  • Folder navigation
  • Copy, move, link, unlink
Document / Sysobject Services
  • Document CRUD
  • Checkout, cancel checkout, checkin
  • Copy, move, link, unlink
  • List checked out objects
Content Services
  • Import contents
  • Export contents
Query and search Services
  • DQL read-only query
  • Full-text search
User and group Services
  • User CRUD
  • Group CRUD
  • Group members
  • Group parent groups
  • User parent groups
  • Add user/group to a group
  • Remove user/group from a group
Relation Services
  • Create relations
  • List relations
Format Services
  • List formats
Network location Services
  • List network locations
Type services
  • List types
  • List relation types

CRUD - Create, Retrieve, Update, Delete

Project Structure

The solution contains four projects.

  • RestClient
  • Tester
  • AspNetWebFormsRestConsumer
  • DroidMamarinTest

The client samples have been verified against Documentum REST Services 7.2 and 7.3. For more information, please visit Documentum REST space in EMC Community Network.

RestClient

This project implements a REST client as a DLL library. It implements all services in Documentum REST 7.2 and partially 7.3. It uses the JSON media type. It supports HTTP Basic authentication and optionally supports Kerberos.

Tester

This project is a console application to show how end to end functions work (the source code here is a great example of how to handle use cases). It has been tested on Windows and Linux and should work on Mac as well.

AspNetWebFormsRestConsumer

This project is an asp.net web forms sample to consume the REST services.

DroidXamarinTest

This project uses Xamarin to show how the DocumentumRestClient dll can be used on mobile platforms. To use this project, you must use Xamarin Studio or have Xamarin for Visual Studio installed. It is definitely nothing fancy, just a basic concept of list cabinets, navigate folders, nothing more.

Use the API

Here is the code to start a Documentum REST services from Home Document.

// new a simple rest client instance
RestController client = new RestController(username, password);
// get home document
HomeDocument home = client.Get<HomeDocument>(RestHomeUri, null);
// get repositories feed
Feed<Repository> repositories = home.GetRepositories<Repository>(new FeedGetOptions { Inline = true, Links = true });

When you get a response from a resource, you get a state of that resource on the client side as well. Then you can perform further operations on that resource according to its available methods. For instance,

public Document ImportDocumentAsNewVersion(Document doc, Stream contentStream, String mimeType, GenericOptions checkinOptions)
{
    // If the document is not already checked out, check it out.
    if (!doc.IsCheckedOut())
    {
        doc = doc.Checkout();
    }
    Document checkinDoc = NewDocument(doc.GetPropertyString("object_name"));
    checkinOptions.SetQuery("format", doc.GetPropertyString("a_content_type"));
    checkinOptions.SetQuery("page", 0);
    checkinOptions.SetQuery("primary", true);
    return doc.CheckinMinor(checkinDoc, contentStream, mimeType, checkinOptions);
}

QuickStart

Step 1

Open the App.Config file and find below XML section:

    <section name="restconfig" type="System.Configuration.NameValueSectionHandler,System"/>

If you are using Visual Studio, it should read this:

    <section name="restconfig" type="System.Configuration.NameValueSectionHandler"/>

Basically, one has a type with a ,System in it and the other doesn't. It is a workaround for Mono for now until they fix it, but having this ,System in the config for Visual Studio causes an exception when loading the configuration file.

Step 2

Go to the <restConfig> section and become familiar with the descriptions and what the parameters do. To get started, all you need do here is set the importFilesDirectory value to a (Windows) [driveletter]:\Path\To\Files directory or (Unix) /Path/To/Files

The path you choose should have a number of files directly under this directory. The Tester will choose a number of files from here at random as samples to upload.

Step 3

You can set the importEmailsDirectory to the same value as importFilesDirectory, this is not currently used with base Rest services, it is only available with extensions enabled. If you need an extension for Rest that imports emails and splits out the attachment files, have your account rep contact [email protected].

Step 4

You can update the defaultReSTHomeUri, defaultUsername, defaultRepositoryName, defaultPassword values to the values for your environment.

Step 5

If you set the useDefault parameter to true, it will not prompt you initially to enter the above information. If you set it to false, when you initially launch the Tester it will prompt you but allow you to hit enter to accept the default values you set in this configuration file.

Kerberos If you Rest service is setup to use Kerberos, you can set the defaultUserName and defaultPassword to "" (blank) and the Tester will use your current Windows credentials to login to the repository.

To run the Tester program, edit the properties in the App.config file. Specifically, the location to get random files from. If you have a directory of hundreds of random files, the tester will choose the number of documents you specify (at runtime) at random from the directory.

You can ignore the random emails directory, this test will not be run unless you have the ReST extensions we have developed for importing email (splitting off attachments like WDK does). If you have TCS installed, the loader can also detect and report duplicate file imports and give you options to deal with them. In some cases, duplication is unavoidable; you need same file in different locations with different security. But having duplicate detection lets you decide what to do, as a programmer, with the duplicate data.

The Tester project is meant to be an example of how one might use the RestClient library. The UseCaseTests.cs class should be very good for mining use case code from for other projects.

Cross-platform Compatability

We did a first round of work exposing the Model and Controller dlls (RestClient project) as COM (for use in Office VBA, Python, or any other COM aware language). The whole project has been tested under Windows and under Linux (using Mono).

The project compatability reports it is also compatible with .NetCore so it should work on Mobile as well. This would include iOS, Droid, and Windows phones.

documentum-rest-client-dotnet's People

Contributors

gentlewind avatar jonathanrobie avatar lili6561 avatar macgydver avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

documentum-rest-client-dotnet's Issues

GetDocumentByQualification not working

First of all I want to say a big thank you for sharing your code.

I added the RestClient to my vs project (with content server and Rest version 7.1), the GetDocumentByQualification or GetObjectByQualification do not work. After adding some debug lines, i found out that the "links" in "feed" is empty, would appreciate if this can be fixed or provide the right way to use it.

I defined the option as the following:

FeedGetOptions DEFAULT_OPTIONS { get { return new FeedGetOptions { Inline = true, Links = true }; } }

And called the GetDocumentByQulification as the following:

RestRepository.GetDocumentByQualification("custom_document where i_latest_flag=1 and i_chronicle_id='" + ChronicleId + "'", DEFAULT_OPTIONS);

In the RepositoryExec.GetObjectByQualification function:

Feed feed = ExecuteDQL(dql, new FeedGetOptions { Inline = true });

The "entries[0]" in the "feed" does not contain any links:

2018-09-12 17:28:51,853 [1] DEBUG Emc.Documentum.Rest.DataModel.Repository -
{
"id": "https://xxx:8899/rest/repositories/myrep",
"title": "DQL query results",
"updated": "2018-09-12T17:28:51.811-04:00",
"total": 0,
"items-per-page": 0,
"page": 0,
"author": [
{
"name": "EMC Documentum"
}
],
"entries": [
{
"id": "https://xxx:8899/rest/repositories/myrep?inline=True&links=True&page=1&include-total=False&dql=select%20r_object_id%20from%20custom_document%20where%20i_latest_flag=1%20and%20i_chronicle_id='09031d4580be05cc'&index=0",
"title": "09031d4580be05cc",
"updated": "2018-09-12T17:28:51.811-04:00",
"author": [],
"content": {
"name": "query-result",
"properties": {
"r_object_id": "09031d4580be05cc"
}
},
"score": 0.0
}
],
"links": [
{
"rel": "self",
"href": "https://xxx:8899/rest/repositories/myrep?inline=True&links=True&page=1&include-total=False&dql=select%20r_object_id%20from%20custom_document%20where%20i_latest_flag=1%20and%20i_chronicle_id='09031d4580be05cc'"
}
]
}

RepositoryExec issue

Hello,
Any help/direction with this is greatly appreciated. I'll get a couple items out of the way here:

  1. Build: 7.2.0000.0081 13 January 2015
  2. DFC Version: 7.2.0000.0054

I'm running into issues with the RestClient in the RepositoryExec.cs file any time ExecuteDQL<t> is used. See code lines below for the exact issue:

string dqlUri = LinkRelations.FindLinkAsString(this.Links, LinkRelations.DQL.Rel);
string dqlUriWithoutTemplateParams = dqlUri.Substring(0, dqlUri.IndexOf("{"));

The problem is that LinkRelations.FindLinkAsString returns a repository URI that is derived from the hreftemplate link relation and is stripped of the template params and stores it in dqlUri. Then the same operation is tried again outside of the Linkrelations.FindLinkAsString function which causes a Sytem.ArgumentOutOfRangeException. Length cannot be less than zero. exception. I get this any time the Feed<T> ExecuteDQL<T>(string dql, FeedOptions options) function is called.

It should also be noted that the MonoReST solution has the same issue when trying to use the REST API in the AspNetWebFormsRestConsumer project. That project determines compatibility with the REST API by calling the D2Repository.isD2Rest() function. If the isD2Rest() function returns false, then the site sets labels to red and says the target repository is not a D2 repository.

I'm pretty new to Documentum so some of this is foreign to me but I assume the RestClient project can be used with my version of Documentum since the overview says the 7.2 and 7.3 REST APIs are supported. I've also been using the RestDotNetFramework.docx documentation and have been able to use the RestClient project to connect and get references to my Repository, a targeted Cabinet.

What I've been able to do with the RestClient project:

  1. Reference the repository
  2. Reference a cabinet
  3. Reference the first folder within a Cabinet

I can provide code if that will help but I am currently at a standstill with this API and cannot move forward unless this is fixed or my mistake is pointed out so I can work around it. Any help is greatly appreciated.

Humbly,
Christopher

Possible RepositoryExec issue

Hello,

I was using the Repository.GetFolderByQualification(string dql, FeedGetOptions) function and getting null reference exceptions instead of what I expected to be a null Folder object. After digging through the code some more I found that the function I am using on Line 292 of RepositoryExec.cs calls the generic GetObjectByQualification<T>(string dql, SingleGetOptions options) function. This function prepends select r_object_id from to the passed in dql statement which, in my case, resulted in dql like the following: select r_object_id from select r_object_id, r_folder_path from .

Is this the expected behavior or should the line on 352 be removed?

Here's the code from RepositoryExec.cs with a comment on the line in the code that is causing a problem:

/// <summary>
/// Get object by dql qualification
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="dql"></param>
/// <param name="options"></param>
/// <returns></returns>
public T GetObjectByQualification<T>(string dql, SingleGetOptions options)
{
    dql = "select r_object_id from " + dql; //THIS LINE IS CAUSING THE PROBLEM
    Feed<PersistentObject> feed = ExecuteDQL<PersistentObject>(dql, new FeedGetOptions { Inline = false });
    if (feed.Entries == null || feed.Entries.Count == 0)
    {
        return default(T);
    }
    if (feed.Entries.Count > 1)
    {
        throw new Exception("The qualification '" + dql + "' has more than one object in repository.");
    }
    return Client.GetSingleton<T>(feed.Entries[0].Links, LinkRelations.EDIT.Rel, options);
}

Update Document Properties using r_object_id

Hi Team,

I am trying to upate the properties of existing documentum using r_object_id. Could you please help me to update which method will help to do this.

For Ex: I have a document custom metadata column like record date and want to update this column using r_object_id.

Contributions

Are you currently taking public contributions? I'm going through some of the code to get a handle on using the RestClient and have noticed some things that are either confusing or could be implemented in a slightly different way.

NuGet package

Is there a plan to release this dot net REST client library as a NuGet package?

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.