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

jmluy
Champ in-the-making
Champ in-the-making
Hi,

Can anybody help me? I want to create categories and assign some of my content to that category.
Any pointers on what service i should be using? or better yet, a simple example.
Thanks.

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

klwalker
Champ in-the-making
Champ in-the-making
I'm looking for a way to determine if content is missing for a node programmatically with the RAAR API, for a specific uuid.  I have tried the following but the size is coming back > 0 for nodes which show as missing content when you try to view them from the web client.

————-
NodeRef oNodeRef = new NodeRef(new StoreRef(Constants.WORKSPACE_STORE, "SpacesStore"), p_strGUID);
ContentData contentData = (ContentData)m_oNodeServiceImpl.getProperty(m_oTicket, oNodeRef, ContentModel.PROP_CONTENT);
if (contentData != null && contentData.getSize() > 0)
      // content found…
else
      // content missing…
————-

I read on a different Alfresco forum that you can use
ContentReader contentReader = contentService.getReader(nodeRef, ContentModel.PROP_CONTENT);
if (contentReader.exists())
    // content found

…but how do You get an instance of ContentReader with the RAAR API?  The ContentServiceImpl has no getReader() method.

klwalker
Champ in-the-making
Champ in-the-making
Also, is xpath search supported in the latest version of the RAAR API?  I'm running v1.8.1 now and there is no SearchService.QueryLanguage.xpath variable defined so I assume it's not supported in that version.  The only thing defined is SearchService.QueryLanguage.lucene.

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

I did a quick test using your code snippet and the contentData is null when the node has no content associated with it.
The following is the code that I used.

          ContentData contentData = (ContentData) getNodeService().getProperty(ticket,nodeRef,ContentModel.PROP_CONTENT);
     if (contentData != null && contentData.getSize() > 0) {
                System.out.println("Content data is not null");
     } else {
              System.out.println("Content data is null");
    }

Raar "com.rivetlogic.core.cma.api.ContentService" supports  downlod/upload.  You should be able to read/write a content to/from a file or stream.

Regarding your xpath question, this will be included in the next release.

Best Regards,
Shagul





Best Regards,
Shagul

klwalker
Champ in-the-making
Champ in-the-making
Not in my case.  We have a batch job which ran to upload the documents to Alfresco, and it must have failed at a point where it somehow created the node and add something to the PROP_CONTENT property, but for some reason when I try to open the content from the web client, it says it's missing.  When I run the code snippet I posted, it actually looks like it's returning the correct sizes of the contentData, as reported underneath the node in the web client.

However, I have also tried to get the size with the following code, and this code reports sizes of 314 or 315 for all nodes with missing content, but reports sizes of about 315 more than what is shown in the web client as the size for content that is missing, for example web client shows 13.11 KB and below code reports the size as 13426 (so maybe I can get by with this code and just look at anything under 350 bytes as missing?).

String strCMSFileName = getCMSFileName(p_strGUID);
       
String strDownloadURL = m_strURI + "/download/direct/workspace/SpacesStore/" + p_strGUID + "/"
          + URLEncoder.encode(strCMSFileName, ContentManagementUtil.ENCODING_UTF8) + "?ticket=" + m_oTicket.getTicket();
 
URL url = new URL(strDownloadURL);
URLConnection urlConnection = url.openConnection();
urlConnection.connect();
lFileLength = urlConnection.getContentLength();

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

If you try clicking that link directly you get something like this for the URL.

The node's content is missing:
   node: workspace://SpacesStore/49ad5b5e-fbe3-40a3-bfcd-43b847130b10
   reader: null 
Please contact your system administrator.

Same is happening with your code and this is not null and has size.

One thing to notice is, 13426/1024 is  13.11kb.


Best Regards,
Shagul

klwalker
Champ in-the-making
Champ in-the-making
Good point about the 13.11 kb, you're right.  I was just dividing by 1000.  So do you have any other suggestions for how I can reliably determine whether content is missing or not?  Is there a way to get an instance of the ContentReader with the RAAR API, as mentioned in one of my previous posts?

rivetlogic
Champ on-the-rise
Champ on-the-rise
I would recommend that you investigate/debug this issue further. ContentData returned by RAAr should be null. If you are getting something other than null verify other properties, in particular the contentUrl.

Below are the properties on ContentData.

   org.alfresco.service.cmr.repository.ContentData
   
    private final String contentUrl;
    private final String mimetype;
    private final long size;
    private final String encoding;
    private final Locale locale;

getReader and getRawReader  rely on contentUrl property to determine if there is a content.

RAAr ContentService provides read/write access to the contents.

Reading the entire content to see if it is empty is not an efficient process.

Below is the implementation of ContentService getReader() in  org.alfresco.repo.content.RoutingContentService.

  if (contentData == null)
        {
            PropertyDefinition contentPropDef = dictionaryService.getProperty(propertyQName);
           
            // if no value or a value other content, and a property definition has been provided, ensure that it's CONTENT or ANY           
            if (contentPropDef != null &&
                (!(contentPropDef.getDataType().getName().equals(DataTypeDefinition.CONTENT) ||
                   contentPropDef.getDataType().getName().equals(DataTypeDefinition.ANY))))
            {
                throw new InvalidTypeException("The node property must be of type content: \n" +
                        "   node: " + nodeRef + "\n" +
                        "   property name: " + propertyQName + "\n" +
                        "   property type: " + ((contentPropDef == null) ? "unknown" : contentPropDef.getDataType()),
                        propertyQName);
            }


        // check that the URL is available
        if (contentData == null || contentData.getContentUrl() == null)
        {
            // there is no URL - the interface specifies that this is not an error condition
            return null;                               
        }
 


I hope this helps.

Best Regards,
Shagul

klwalker
Champ in-the-making
Champ in-the-making
I have just looked into the other properties in the contentData object as suggested and none are null for the missing content, not even the contentUrl, and all of the properties are storing what they should be.  However, I verified though that the path returned by getContentUrl() does not exist in the repository for the missing content.