mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
. Create node from source (i.e. a templated document) WebScripts to support ALF-9710
. Added selectNodes(xpath) to JavaScript Search API (not sure why I never added it before...!) git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@29789 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -214,6 +214,63 @@ public class Search extends BaseScopableProcessorExtension
|
||||
return Context.getCurrentContext().newArray(getScope(), 0);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute a SelectNodes XPath search
|
||||
*
|
||||
* @param search SelectNodes XPath search string to execute
|
||||
*
|
||||
* @return JavaScript array of Node results from the search - can be empty but not null
|
||||
*/
|
||||
public Scriptable selectNodes(String search)
|
||||
{
|
||||
return selectNodes(null, search);
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute a SelectNodes XPath search
|
||||
*
|
||||
* @param store Store reference to search against i.e. workspace://SpacesStore
|
||||
* @param search SelectNodes XPath search string to execute
|
||||
*
|
||||
* @return JavaScript array of Node results from the search - can be empty but not null
|
||||
*/
|
||||
public Scriptable selectNodes(String store, String search)
|
||||
{
|
||||
if (search != null && search.length() != 0)
|
||||
{
|
||||
Object[] nodeArray = new Object[0];
|
||||
if (store == null)
|
||||
{
|
||||
store = "workspace://SpacesStore";
|
||||
}
|
||||
try
|
||||
{
|
||||
NodeService nodeService = this.services.getNodeService();
|
||||
List<NodeRef> nodes = this.services.getSearchService().selectNodes(
|
||||
nodeService.getRootNode(new StoreRef(store)), search, null, this.services.getNamespaceService(), false);
|
||||
if (nodes.size() != 0)
|
||||
{
|
||||
int index = 0;
|
||||
nodeArray = new Object[nodes.size()];
|
||||
for (NodeRef node: nodes)
|
||||
{
|
||||
nodeArray[index++] = new ScriptNode(node, this.services, getScope());
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Throwable err)
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Failed to execute search: " + search, err);
|
||||
}
|
||||
|
||||
return Context.getCurrentContext().newArray(getScope(), nodeArray);
|
||||
}
|
||||
else
|
||||
{
|
||||
return Context.getCurrentContext().newArray(getScope(), 0);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Validation Xpath query
|
||||
|
Reference in New Issue
Block a user