What is the best way to integrate or migrate users from client app?

cancel
Showing results for 
Search instead for 
Did you mean: 
sepgs2004
Established Member

What is the best way to integrate or migrate users from client app?

From our application, we integrate with Alfresco for document management. There are clients of our application, who has Oracle IP/M, Documentum and other content management systems. So our application has code to integrate with other repositories as well.

Now, our application has its own user management. It is native. Users are stored in the application database. No LDAP or anything. Our application connects with Alfresco through one (alfresco) user for now.

Coming back to Alfresco, we have a custom model defined. It is all working good. 

Recently we were using the Alfresco comments feature using the Rest API. We could have added comments in our own custom model. But we chose to use Alfresco's comments feature. 

1. Now when our application user adds a comment on a document, we want to know which "our application user" added the comment and so on.

2. Also, when an application user updates the metadata properties, then we would like to know which our user updated the properties of the document. 

For 2nd one, we can add two more properties to our custom model (updated by, updated date), and store our application users in there. 

For the 1st one, I do not think we can get away without replicating the users in Alfresco. Or I do not know if we can extend the comments feature, to include another field called application_user. 

Is there a way to make Alfresco call something in our application or database to check for a user? This is along the lines of extending the alfresco users to include external set of users as well.

Gnanasekaran Sakthivel
6 Replies
jpotts
Professional

Re: What is the best way to integrate or migrate users from client app?

How are you adding the comment node? Are you calling the REST API or are you calling a web script that uses the Java API to create the comment?

If it is the latter, you can just add an aspect to your content model that captures the data, then add the aspect to the comment node and set the data. In fact, you've already created two properties to capture updated by and updated date. Those could be defined in an aspect which would allow you to re-use the property definitions for both documents and comments.

Basically, when the application invokes the web script, pass along not only the comment but also the application username. The web script can then add the aspect to the comment node.

sepgs2004
Established Member

Re: What is the best way to integrate or migrate users from client app?

For now, we are invoking the existing built in webscripts, that correspond to add/delete comments, through Rest API.

When you say the "latter", do you mean we should write our own webscript with JAVA.

I will explore along the lines of having aspects for the comments.

When you say "when the application invokes the web script"... what is this web script you are talking about.

I am using the ones that are built in...

Get all the comments
GET /alfresco/s/api/node/{store_type}/{store_id}/{id}/comments?reverse={reverse?}&startIndex={startIndex?}&pageSize={pageSize?}

Add comment
POST /alfresco/s/api/node/{store_type}/{store_id}/{id}/comments

Delete comment
DELETE /alfresco/s/api/comment/node/{store_type}/{store_id}/{id}

Please give me some more tips to follow your recommendation.

Gnanasekaran Sakthivel
cesarista
Customer

Re: What is the best way to integrate or migrate users from client app?

Hi:

Jeff mentions that if you created a custom aspect with a property called "updated by", you may add this aspect to your comment (not only to the document). Even, you can add the user in the text of the comment for having a visual reference of the application user.

Other aprox. could be for example to integrate users in Alfresco, with a custom JDBC authentication subsystem, that enables to login in Alfresco from a database table. Then, users (with contributor role) could create their own comments via webscript. Although this probably will change a lot your document structure permissions on the repo.

Regards.

--C.

sepgs2004
Established Member

Re: What is the best way to integrate or migrate users from client app?

If we go with having a custom aspect with updated_by property, you mentioned that we can add this aspect to the comment.

Can I still use the REST API (and version 5.1.0) to accomplish this (like described below)?

For the REST API that I use with version 5.1.0, to add a comment, I am using the following call.

It has a JSON argument. Are you saying we can add the aspect property into the JSON argument?

It's details are here.

<url>/api/comment/node/{store_type}/{store_id}/{id}</url>
<format default="json">argument</format>
My code looks like this. I wonder how to pass the aspect value in here in this REST API call!
JsonObject jobject = new JsonObject();
jobject.addProperty("content", commentContent);
StringEntity entity = new StringEntity(jobject.toString());
callFunction.setEntity(entity);
callFunction.setHeader("Accept", "application/json");
callFunction.setHeader("Content-type", "application/json");
response = httpClient.execute(callFunction);
Or should I use the Alfresco SDK API with features available in Alfresco 5.2 onward?
Gnanasekaran Sakthivel
cesarista
Customer

Re: What is the best way to integrate or migrate users from client app?

Maybe with additional GET and PUT calls to /api/nodes/{nodeId} , where your nodeId is your comment id (check the notes about adding or removing aspects).

Alfresco Content Services REST API Explorer 

Regards.

--C.

jpotts
Professional

Re: What is the best way to integrate or migrate users from client app?

To clarify, I meant that if you were already calling a custom web script, just modify it to add an aspect and set the property.

If you are not using a custom web script, why not write one? That way you can get this done in one REST call instead of multiple.