1 package info.magnolia.cms.util; 2 3 import info.magnolia.cms.core.Content; 4 import info.magnolia.cms.core.search.Query; 5 import info.magnolia.cms.core.search.QueryManager; 6 import info.magnolia.cms.core.search.QueryResult; 7 8 import java.util.Iterator ; 9 10 import javax.jcr.RepositoryException; 11 12 import org.apache.log4j.Logger; 13 14 15 21 public final class Search { 22 23 26 private static Logger log = Logger.getLogger(Search.class); 27 28 31 private Search() { 32 } 34 35 40 public static Content getContentByUUID(QueryManager queryManager, String uuid) { 41 try { 42 String statement = "SELECT * FROM nt:base where mgnl:uuid like '" + uuid + "'"; Query q = queryManager.createQuery(statement, Query.SQL); 44 QueryResult result = q.execute(); 45 Iterator it = result.getContent().iterator(); 46 while (it.hasNext()) { 47 Content foundObject = (Content) it.next(); 48 return foundObject; 49 } 50 } 51 catch (RepositoryException e) { 52 log.error(e); 53 } 54 return null; 55 } 56 57 } 58 | Popular Tags |