1 Reply Latest reply: Jan 19, 2011 3:12 AM by Sourabh S RSS

    Check for existence of document in Alfresco

    Rob_RH Community Member

      Is there any way to check for the existence of a document in Alfresco?

       

      With the Retrieve Content operation i have an input variable which i fill with: /Company Home/User Homes/Customers/2790/DocumentFolder/Document.txt

       

      Goal of this process is to check for existence and to invoke different processes in case of existence and non existence.

       

      I figured depending of the returned output NodeID (the returned UUD of the content or a null value ) the WF in LiveCycle can follow the scenario needed. The problem here is that LiveCycle directly returns a ALC-CSV-030-002 Unable to locate /Company Home/User Homes/Customers/2790/DocumentFolder/Document.txt in repository.

       

      Any suggestions are appreciated!

      Thanks!

        • 1. Re: Check for existence of document in Alfresco
          Sourabh S Community Member

          You could use Content Services's searchService to ascertain whether the node(document or space) exists in the repository or not.The only issue with this is that searchService is not orchestrable.So, call can be by using DocumentManagementServiceClient in an executeScript operation.

          Here is a sample code used to search for "Company Home->def->def.properties".

           

               import com.adobe.idp.dsc.clientsdk.ServiceClientFactory;
               import com.adobe.livecycle.contentservices.client.Query;
               import com.adobe.livecycle.contentservices.client.ResultSet ;
               import com.adobe.livecycle.contentservices.client.impl.QueryImpl;
               import com.adobe.livecycle.contentservices.client.DocumentManagementServiceClient;
               import com.adobe.livecycle.contentservices.client.impl.DocumentManagementServiceClientImpl;

           

                  DocumentManagementServiceClient docManagementServiceClient =
                  new DocumentManagementServiceClientImpl(ServiceClientFactory.createInstance());
                  String storeName ="SpacesStore";
                  String queryString = "PATH:\"/app:company_home/cm:def/cm:def.pdf\"";// a properly escaped lucene query.

               //the default nodes are preceeded by app prefix where as new user created nodes are prefixed by "cm" prefix

                 
                  Query query = new QueryImpl();
                  query.setQueryString(queryString);
                 
                
                  ResultSet rs = docManagementServiceClient.searchRepository(storeName, "nebulous", true, query, Integer.MAX_VALUE);
                  String nodeId= rs.getMatchingIDs().get(0);// You could use rs.getMatchingIDs().size(). If it is 0, node does not exist.
                  patExecContext.setProcessDataValue("/process_data/outputParam", nodeId);

           

          For userhomes, the query used is this :-  PATH:"/app:company_home/app:user_homes"  (Need to be escaped when used in code)

          Verifying queries :You could go to company home->Administrative Console-> node browser.From there select spacesStore and in the search option drop down, select "lucene". In the text field, type the lucene query and click "search" to verify.

           

          Hope this helps,

          Sourabh