mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-14 17:58:59 +00:00
Merged HEAD-QA to HEAD (4.2) (including moving test classes into separate folders)
51903 to 54309 git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@54310 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -43,6 +43,8 @@ import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.service.cmr.repository.Path;
|
||||
import org.alfresco.service.cmr.repository.StoreRef;
|
||||
import org.alfresco.service.cmr.search.LimitBy;
|
||||
import org.alfresco.service.cmr.search.SearchParameters;
|
||||
import org.alfresco.service.cmr.search.SearchService;
|
||||
import org.alfresco.service.cmr.security.AccessPermission;
|
||||
import org.alfresco.service.cmr.security.AccessStatus;
|
||||
@@ -82,6 +84,8 @@ public class NodeBrowserScript extends DeclarativeWebScript
|
||||
queryLanguages.add(SearchService.LANGUAGE_JCR_XPATH);
|
||||
}
|
||||
|
||||
private Long searchElapsedTime = null;
|
||||
|
||||
// stores and node
|
||||
transient private List<StoreRef> stores = null;
|
||||
|
||||
@@ -471,8 +475,9 @@ public class NodeBrowserScript extends DeclarativeWebScript
|
||||
*
|
||||
* @return next action
|
||||
*/
|
||||
public List<Node> submitSearch(final String store, final String query, final String queryLanguage) throws IOException
|
||||
public List<Node> submitSearch(final String store, final String query, final String queryLanguage, final int maxResults) throws IOException
|
||||
{
|
||||
long start = System.currentTimeMillis();
|
||||
final StoreRef storeRef = new StoreRef(store);
|
||||
RetryingTransactionCallback<List<Node>> searchCallback = new RetryingTransactionCallback<List<Node>>()
|
||||
{
|
||||
@@ -500,9 +505,18 @@ public class NodeBrowserScript extends DeclarativeWebScript
|
||||
searchResults.add(new Node(nodeRef));
|
||||
return searchResults;
|
||||
}
|
||||
SearchParameters sp = new SearchParameters();
|
||||
sp.addStore(storeRef);
|
||||
sp.setLanguage(queryLanguage);
|
||||
sp.setQuery(query);
|
||||
if (maxResults > 0)
|
||||
{
|
||||
sp.setLimit(maxResults);
|
||||
sp.setLimitBy(LimitBy.FINAL_SIZE);
|
||||
}
|
||||
|
||||
// perform search
|
||||
List<NodeRef> nodeRefs = getSearchService().query(storeRef, queryLanguage, query).getNodeRefs();
|
||||
List<NodeRef> nodeRefs = getSearchService().query(sp).getNodeRefs();
|
||||
searchResults = new ArrayList<Node>(nodeRefs.size());
|
||||
for (NodeRef nodeRef : nodeRefs) {
|
||||
searchResults.add(new Node(nodeRef));
|
||||
@@ -513,7 +527,9 @@ public class NodeBrowserScript extends DeclarativeWebScript
|
||||
|
||||
try
|
||||
{
|
||||
return getTransactionService().getRetryingTransactionHelper().doInTransaction(searchCallback, true);
|
||||
List<Node> results = getTransactionService().getRetryingTransactionHelper().doInTransaction(searchCallback, true);
|
||||
this.searchElapsedTime = System.currentTimeMillis() - start;
|
||||
return results;
|
||||
}
|
||||
catch (Throwable e)
|
||||
{
|
||||
@@ -521,6 +537,14 @@ public class NodeBrowserScript extends DeclarativeWebScript
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the searchElapsedTime
|
||||
*/
|
||||
protected Long getSearchElapsedTime()
|
||||
{
|
||||
return this.searchElapsedTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache)
|
||||
{
|
||||
@@ -551,8 +575,19 @@ public class NodeBrowserScript extends DeclarativeWebScript
|
||||
status.setRedirect(true);
|
||||
return null;
|
||||
}
|
||||
nodes = submitSearch(req.getParameter("store"), req.getParameter("q"), req.getParameter("lang"));
|
||||
|
||||
int maxResult = 0;
|
||||
try
|
||||
{
|
||||
maxResult = Integer.parseInt(req.getParameter("maxResults"));
|
||||
}
|
||||
catch (NumberFormatException ex)
|
||||
{
|
||||
}
|
||||
|
||||
nodes = submitSearch(req.getParameter("store"), req.getParameter("q"), req.getParameter("lang"), maxResult);
|
||||
tmplMap.put("results", nodes);
|
||||
tmplMap.put("searchElapsedTime", getSearchElapsedTime());
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
|
Reference in New Issue
Block a user