AnsweredAssumed Answered

Reproducing a node browser query in Java code.

Question asked by sfoster on Feb 14, 2012
Latest reply on Dec 26, 2014 by krunalpatel

I'm trying to use the SearchService to retrieve all nodes of a certain type. I tested the query in the node browser, which returns a single noderef as expected. However, I can't reproduce this in Java code.

The lucene query is:  TYPE:"{}project"

The Java code I'm using is:

    public List<Project> getProjects() {
        RetryingTransactionCallback<List<NodeRef>> searchCallback = new RetryingTransactionCallback<List<NodeRef>>() {
            public List<NodeRef> execute() throws Throwable {
                List<NodeRef> nodeRefs = serviceRegistry
                                "TYPE:\"" + ProjectManagementModel.TYPE_PROJECT.toString() + "\"")
                return nodeRefs;

        List<Project> projects = new LinkedList<Project>();
        List<NodeRef> nodeRefs = serviceRegistry.getTransactionService()
                .getRetryingTransactionHelper().doInTransaction(searchCallback, true);

        for (NodeRef nodeRef : nodeRefs) {

        return projects;

The code was mainly borrowed from the NodeBrowserScript class.

The alfresco version is 4.0.b.

Any help would be much appreciated.