mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
Big honkin' merge from head. Sheesh!
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/WCM-DEV2/root@3617 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -17,9 +17,6 @@
|
||||
package org.alfresco.repo.jscript;
|
||||
|
||||
import java.io.StringReader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.model.ContentModel;
|
||||
@@ -28,7 +25,6 @@ import org.alfresco.service.cmr.repository.ContentReader;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.StoreRef;
|
||||
import org.alfresco.service.cmr.repository.TemplateImageResolver;
|
||||
import org.alfresco.service.cmr.repository.TemplateNode;
|
||||
import org.alfresco.service.cmr.search.ResultSet;
|
||||
import org.alfresco.service.cmr.search.ResultSetRow;
|
||||
import org.alfresco.service.cmr.search.SearchService;
|
||||
@@ -37,6 +33,7 @@ import org.apache.commons.logging.LogFactory;
|
||||
import org.dom4j.Document;
|
||||
import org.dom4j.Element;
|
||||
import org.dom4j.io.SAXReader;
|
||||
import org.mozilla.javascript.Scriptable;
|
||||
|
||||
/**
|
||||
* Search component for use by the ScriptService.
|
||||
@@ -51,7 +48,7 @@ import org.dom4j.io.SAXReader;
|
||||
*
|
||||
* @author Kevin Roast
|
||||
*/
|
||||
public final class Search
|
||||
public final class Search implements Scopeable
|
||||
{
|
||||
private static Log logger = LogFactory.getLog(Search.class);
|
||||
|
||||
@@ -59,6 +56,9 @@ public final class Search
|
||||
private StoreRef storeRef;
|
||||
private TemplateImageResolver imageResolver;
|
||||
|
||||
/** Root scope for this object */
|
||||
private Scriptable scope;
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
@@ -72,6 +72,48 @@ public final class Search
|
||||
this.imageResolver = imageResolver;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.repo.jscript.Scopeable#setScope(org.mozilla.javascript.Scriptable)
|
||||
*/
|
||||
public void setScope(Scriptable scope)
|
||||
{
|
||||
this.scope = scope;
|
||||
}
|
||||
|
||||
/**
|
||||
* Find a single Node by the Node reference
|
||||
*
|
||||
* @param ref The NodeRef of the Node to find
|
||||
*
|
||||
* @return the Node if found or null if failed to find
|
||||
*/
|
||||
public Node findNode(NodeRef ref)
|
||||
{
|
||||
return findNode(ref.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* Find a single Node by the Node reference
|
||||
*
|
||||
* @param ref The fully qualified NodeRef in String format
|
||||
*
|
||||
* @return the Node if found or null if failed to find
|
||||
*/
|
||||
public Node findNode(String ref)
|
||||
{
|
||||
String query = ref.replace(":", "\\:");
|
||||
query = query.replace("/", "\\/");
|
||||
Node[] result = query("ID:" + query);
|
||||
if (result.length == 1)
|
||||
{
|
||||
return result[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute a Lucene search
|
||||
*
|
||||
@@ -171,7 +213,8 @@ public final class Search
|
||||
for (ResultSetRow row: results)
|
||||
{
|
||||
NodeRef nodeRef = row.getNodeRef();
|
||||
nodes[count++] = new Node(nodeRef, services, this.imageResolver);
|
||||
nodes[count] = new Node(nodeRef, services, this.imageResolver, this.scope);
|
||||
count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user