As we transition to the new Hyland Community, some post links may be temporarily disrupted as we finalize redirects. We apologize for the inconvenience and are working to resolve this as quickly as possible. Details.
You can use getChildByName function
NodeService (Alfresco 5.2-SNAPSHOT API)
Here's a runnable class that leverages OpenCMIS to check for the presence of a folder with a given name.
package com.someco.cmis.examples; import java.util.HashMap; import java.util.List; import java.util.Map; import org.apache.chemistry.opencmis.client.api.ItemIterable; import org.apache.chemistry.opencmis.client.api.QueryResult; import org.apache.chemistry.opencmis.client.api.Repository; import org.apache.chemistry.opencmis.client.api.Session; import org.apache.chemistry.opencmis.client.api.SessionFactory; import org.apache.chemistry.opencmis.client.runtime.SessionFactoryImpl; import org.apache.chemistry.opencmis.commons.SessionParameter; import org.apache.chemistry.opencmis.commons.enums.BindingType; public class FolderChecker { private String serviceUrl = "http://localhost:8080/alfresco/api/-default-/public/cmis/versions/1.1/browser"; private Session session = null; public static void main(String[] args) { if (args.length != 1) { System.out.println("USAGE: java FolderChecker [folder name]"); System.exit(-1); } FolderChecker fc = new FolderChecker(); System.out.println("Does folder: " + args[0] + " exist? " + fc.doesFolderExist(args[0])); } public boolean doesFolderExist(String folderName) { String queryString = "select cmis:objectId from cmis:folder where cmis:name = '" + folderName + "'"; ItemIterable<QueryResult> results = getSession().query(queryString, false); if (results.getTotalNumItems() > 0) { return true; } else { return false; } } public Session getSession() { if (session == null) { // default factory implementation SessionFactory factory = SessionFactoryImpl.newInstance(); Map<String, String> parameter = new HashMap<String, String>(); // user credentials parameter.put(SessionParameter.USER, "admin"); // <-- Replace parameter.put(SessionParameter.PASSWORD, "admin"); // <-- Replace // connection settings parameter.put(SessionParameter.BROWSER_URL, this.serviceUrl); // Uncomment for Atom Pub binding parameter.put(SessionParameter.BINDING_TYPE, BindingType.BROWSER.value()); // Uncomment for Atom Pub binding List<Repository> repositories = factory.getRepositories(parameter); this.session = repositories.get(0).createSession(); } return this.session; } }