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.

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

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