I want to get the NodeRef of a document (or space) stored in Alfresco.
My code is in Java, running within Alfresco (for instance in an AMP).
How to do?
The easiest way is probably using the NodeLocatorService and the XPath locatorName + an xpath expression
Under the hood, that uses the search service, but it wraps up a lot of the complexity for you!
To use it, get the NodeLocatorService
injected into your bean, then do something like:
Map<String,Serializable> params = new HashMap<>();
params.put("query", "/x:path/to:node/pa:th");
NodeRef nodeRef = nodeLocatorService.getNode("xpath",null,params);
Other NodeLocators exist for other lookups, and it's also available remotely via /alfresco/service/api/nodelocator/{node_locator_name}?params