cancel
Showing results for 
Search instead for 
Did you mean: 

Remote Alfresco API rivet

rivetlogic
Champ on-the-rise
Champ on-the-rise
RAAr

RAAr is an abstraction layer for remote communication with Alfresco ECM. RAAr provides a simple, Java-based local library that may be used by one or more content rich applications and allows these applications to interface to Alfresco (including multiple Alfresco repositories from the same application). RAAr's lower layers handle communication to remote Alfresco instances over ReSTful calls to Alfresco that get mapped to calls to the Alfresco Foundation Services (AFS) API.

Motivation for RAAr

Certain classes of content rich applications require one or more of the following:

    * Remote full coverage of the AFS API (e.g., version management and version history traversal, dictionary services for model introspection, multi-store access, etc.)
    * Streaming content directly from the application and not from Alfresco (i.e., not using download servlet)
    * SSO support
    * Middle-tier business logic within the application where not all processing is done on Alfresco app server
    * Support for un-marshalling of result sets
RAAr lives here:
http://wiki.rivetlogic.org/display/RAAR/

Feel free to ask questions about RAAr in this thread.

–Sumer
112 REPLIES 112

klwalker
Champ in-the-making
Champ in-the-making
When using RAAR v1.8.1 jars in an applicatin to upload documents to Alfresco, I'm getting the following error in the console.  However, when I modify the job to use v1.7.1, the error does not occur.  However that version is before the change to allow you to configure the http connection pooling.  We're just using the default pool settings so are not overriding with any -D params.

Exception in thread "Thread-5" java.lang.NoSuchFieldError: ANY_HOST_CONFIGURATION
        at org.apache.commons.httpclient.params.HttpConnectionManagerParams.setDefaultMaxConnectionsPerHost(HttpConnectionManagerParams.java:86)
        at com.rivetlogic.core.cma.rest.impl.RestExecuterImpl.init(RestExecuterImpl.java:736)
        at ucs.common.contentmgmt.AlfrescoContentManager.initRaar(AlfrescoContentManager.java:160)
        at ucs.common.contentmgmt.AlfrescoContentManager.<init>(AlfrescoContentManager.java:147)
        at ucs.common.contentmgmt.AlfrescoContentManager.<init>(AlfrescoContentManager.java:140)
        at ucs.common.contentmgmt.ContentManagerFactory.getContentManager(ContentManagerFactory.java:9)
        at ucs.common.contentmgmt.ContentManagementHelper.<init>(ContentManagementHelper.java:40)
        at ucs.itd.ucms.pdf.FileUploadThread.upload(FileUploadThread.java:193)
        at ucs.itd.ucms.pdf.FileUploadThread.run(FileUploadThread.java:86)

klwalker
Champ in-the-making
Champ in-the-making
Ok, I got it working.  The problem was that we were referencing jbossall-client.jar in the classpath as well and that contains httpclient classes of an older version.  I moved common-httpclient-3.1.jar first in the classpath and it works now.

deardooley
Champ in-the-making
Champ in-the-making
I'm using RAAr 1.5 to put together a demo application.  How would one get the size of a content node's content (ie the file size)?  Also, I don't see a rivetlogic implementation of the PermissionService class, however it was used in a code snippet above to specify how to change permissions on folders.  Do I need to upgrade my alfresco and RAAr versions for this feature?

Thanks for your help!!

Rion

rivetlogic
Champ on-the-rise
Champ on-the-rise
Hi Rion,

To get the size, get the content property, cast it to a ContentData and ask that for the size. Example:

  ContentData contentData = (ContentData) node.getProperties.get(ContentModel.PROP_CONTENT);
  long size = 0L;
  if (contentData != null)
  {
    size = contentData.getSize();
  }

Check out the SecurityService for getting/setting permissions.

With regard to compatibility, here is the compatibility matrix:
http://wiki.rivetlogic.com/display/RAAR/Compatibility+Matrix

You might want to consider RAAr 1.8.1 with Alfresco 2.2.1.

Cheers.

–Sumer

rivetlogic
Champ on-the-rise
Champ on-the-rise

rivetlogic
Champ on-the-rise
Champ on-the-rise

deardooley
Champ in-the-making
Champ in-the-making
Quick question.  Are users able to see all permissions on a node?  As a standard user, I've created a node in my personal space and added Consumer permissions for other users to view the that file.  The other users can see the file just fine.  However, I'm querying for the permissions on that node and all I see are my personal permissions, not those I've set for the other users.  Is there a way I can see the other users permissions that I've set.

rivetlogic
Champ on-the-rise
Champ on-the-rise
Hi,

You should be able to use the following RAAr call from the SecurityService  to get all permissions assigned to a node:


java.util.Set<org.alfresco.service.cmr.security.AccessPermission> getAllSetPermissions(Ticket ticket, org.alfresco.service.cmr.repository.NodeRef nodeRef) throws InvalidTicketException, CmaRuntimeException
This call will return a set of permissions assigned to that node. It will include all users and their access level. The only gotcha is that if the user executing this call is a Consumer on that node you will get a org.alfresco.repo.security.permissions.AccessDeniedException exception.

The following is an example of how you can catch that exception:


try {
    Set<AccessPermission> accessPerms = securityService().getAllSetPermissions(ticket, nodeRef);
} catch (CmaRuntimeException e) {
    if (e.getCause() instanceof AccessDeniedException) {
        // This means you are a Consumer on this node
}
Hope this helps,

–Alaaeldin

deardooley
Champ in-the-making
Champ in-the-making
Hey all,

Thanks again for all the help coming up to speed on the RAAr java api.  I'm working with the VersionService and don't quite understand how versioning works through the api.  How does one go about enabling versioning on a node?  I see the version service, but I'm unsure what the steps would be to add versioning support.  Looking at the effect on a node from the alfresco webapp, I see that the following properties were added to a node after versioning:

{http://www.alfresco.org/model/content/1.0}versionLabel   
{http://www.alfresco.org/model/content/1.0}autoVersion   
{http://www.alfresco.org/model/content/1.0}initialVersion   

As well, the following aspect was added:

{http://www.alfresco.org/model/content/1.0}versionable

Is it sufficient to add the aspect and then perform a createVersion, or is there more to it.  Also, to find out if a node is versioned, do we simply look for the versionable aspect, or check for a version history?

Rion

rivetlogic
Champ on-the-rise
Champ on-the-rise
Hi,

You answered your own question Smiley Happy

If you want Alfresco to start versioning a node you should just attach the versionable aspect to it. Any updates to the document will then automatically increment the version number.

If you want to find out if a node is versioned you should just check if the versionable aspect is added using the hasAspect() method of the NodeService.

Hope this helps,

–Alaaeldin