Skip navigation
Currently Being Moderated

Check for existence of document in Alfresco

Jan 19, 2011 12:45 AM

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!


  • Currently Being Moderated
    Jan 19, 2011 3:12 AM   in reply to Rob_RH

    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->".


         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.DocumentManagementServiceC lient;
         import com.adobe.livecycle.contentservices.client.impl.DocumentManagementSer viceClientImpl;


            DocumentManagementServiceClient docManagementServiceClient =
            new DocumentManagementServiceClientImpl(ServiceClientFactory.createInstan ce());
            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();
            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,


    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points