You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@chemistry.apache.org by je...@apache.org on 2010/06/20 16:10:05 UTC

svn commit: r956361 - in /incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src: main/java/org/apache/chemistry/opencmis/inmemory/query/ main/java/org/apache/chemistry/opencmis/inmemory/server/ main/java/or...

Author: jens
Date: Sun Jun 20 14:10:04 2010
New Revision: 956361

URL: http://svn.apache.org/viewvc?rev=956361&view=rev
Log:
CMIS-216
minor bug fixes and some refactoring

Modified:
    incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/query/InMemoryQueryProcessor.java
    incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/query/QueryObject.java
    incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryDiscoveryServiceImpl.java
    incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/api/StoreManager.java
    incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/StoreManagerImpl.java
    incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/DiscoveryServiceTest.java

Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/query/InMemoryQueryProcessor.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/query/InMemoryQueryProcessor.java?rev=956361&r1=956360&r2=956361&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/query/InMemoryQueryProcessor.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/query/InMemoryQueryProcessor.java Sun Jun 20 14:10:04 2010
@@ -18,6 +18,9 @@
  */
 package org.apache.chemistry.opencmis.inmemory.query;
 
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
 import java.math.BigDecimal;
 import java.math.BigInteger;
 import java.util.ArrayList;
@@ -28,6 +31,14 @@ import java.util.List;
 import java.util.Map;
 import java.util.regex.Pattern;
 
+import org.antlr.runtime.ANTLRInputStream;
+import org.antlr.runtime.CharStream;
+import org.antlr.runtime.CommonTokenStream;
+import org.antlr.runtime.RecognitionException;
+import org.antlr.runtime.TokenSource;
+import org.antlr.runtime.TokenStream;
+import org.antlr.runtime.tree.CommonTree;
+import org.antlr.runtime.tree.CommonTreeNodeStream;
 import org.antlr.runtime.tree.Tree;
 import org.apache.chemistry.opencmis.commons.data.ObjectData;
 import org.apache.chemistry.opencmis.commons.data.ObjectList;
@@ -42,7 +53,9 @@ import org.apache.chemistry.opencmis.inm
 import org.apache.chemistry.opencmis.inmemory.query.QueryObject.SortSpec;
 import org.apache.chemistry.opencmis.inmemory.storedobj.api.Filing;
 import org.apache.chemistry.opencmis.inmemory.storedobj.api.Folder;
+import org.apache.chemistry.opencmis.inmemory.storedobj.api.ObjectStore;
 import org.apache.chemistry.opencmis.inmemory.storedobj.api.StoredObject;
+import org.apache.chemistry.opencmis.inmemory.storedobj.impl.ObjectStoreImpl;
 import org.apache.chemistry.opencmis.inmemory.types.PropertyCreationHelper;
 import org.apache.chemistry.opencmis.server.support.query.CalendarHelper;
 import org.apache.commons.logging.Log;
@@ -64,12 +77,72 @@ public class InMemoryQueryProcessor impl
     private List<StoredObject> matches = new ArrayList<StoredObject>();
     private QueryObject queryObj;
     private Tree whereTree;
+    private CommonTree parserTree; // the ANTLR tree after parsing phase
+    private CommonTree walkerTree; // the ANTLR tree after walking phase
     
     public InMemoryQueryProcessor() {
     }
     
-    public void setQueryObject(QueryObject qo) {
-        queryObj = qo;
+    /**
+     * Main entry function to process a query from discovery service
+     */
+    public ObjectList query(TypeManager tm, ObjectStore objectStore, String user, String repositoryId, String statement, Boolean searchAllVersions,
+            Boolean includeAllowableActions, IncludeRelationships includeRelationships, String renditionFilter,
+            BigInteger maxItems, BigInteger skipCount) {
+
+        queryObj = new QueryObject(tm, this);
+        processQueryAndCatchExc(statement); // calls query processor
+
+        // iterate over all the objects and check for each if the query matches
+        for (String objectId : ((ObjectStoreImpl) objectStore).getIds()) {
+            StoredObject so = objectStore.getObjectById(objectId);
+            checkMatch(so);
+        }
+
+        ObjectList objList = buildResultList(tm, user, includeAllowableActions, includeRelationships, renditionFilter,
+                maxItems, skipCount);
+        LOG.debug("Query result, number of matching objects: " + objList.getNumItems());
+        return objList;
+    }        
+
+    private CmisQueryWalker getWalker(String statement) throws UnsupportedEncodingException, IOException, RecognitionException {
+        CharStream input = new ANTLRInputStream(new ByteArrayInputStream(statement.getBytes("UTF-8")));
+        TokenSource lexer = new CMISQLLexerStrict(input);
+        TokenStream tokens = new CommonTokenStream(lexer);
+        CMISQLParserStrict parser = new CMISQLParserStrict(tokens);
+
+        CMISQLParserStrict.query_return parsedStatement = parser.query();
+        if (parser.errorMessage != null) {
+            throw new RuntimeException("Cannot parse query: " + statement + " (" + parser.errorMessage + ")");
+        }
+        parserTree = (CommonTree) parsedStatement.getTree();            
+
+        CommonTreeNodeStream nodes = new CommonTreeNodeStream(parserTree);
+        nodes.setTokenStream(tokens);
+        CmisQueryWalker walker = new CmisQueryWalker(nodes);
+        return walker;
+    }
+
+    public CmisQueryWalker processQuery(String statement) throws UnsupportedEncodingException, IOException, RecognitionException {
+        CmisQueryWalker walker = getWalker(statement);
+        walker.query(queryObj);
+        String errMsg = walker.getErrorMessageString();
+        if (null != errMsg) {
+            throw new RuntimeException("Walking of statement failed with error: \n   " + errMsg + 
+                    "\n   Statement was: " + statement);
+        }
+        walkerTree = (CommonTree) walker.getTreeNodeStream().getTreeSource();
+        return walker;
+    }
+
+    public CmisQueryWalker processQueryAndCatchExc(String statement) {
+        try {
+            return processQuery(statement);
+        } catch (RecognitionException e) {
+            throw new RuntimeException("Walking of statement failed with RecognitionException error: \n   " + e); 
+        } catch (Exception e) {
+            throw new RuntimeException("Walking of statement failed with other exception: \n   " + e); 
+        }
     }
     
     public void onStartProcessing(Tree node) {
@@ -101,6 +174,22 @@ public class InMemoryQueryProcessor impl
         sortMatches();
 
         ObjectListImpl res = new ObjectListImpl();
+        res.setNumItems(BigInteger.valueOf(matches.size()));
+        int start = 0;
+        if (maxItems != null) 
+            start = (int)maxItems.longValue();
+        if (start < 0)
+            start = 0;
+        if (start > matches.size())
+            start = matches.size();
+        int stop = 0;
+        if (skipCount != null) 
+            stop = (int)skipCount.longValue();
+        if (stop <= 0 || stop > matches.size())
+            stop = matches.size();
+        res.setHasMoreItems(stop < matches.size());
+        if (start > 0 || stop > 0)
+            matches = matches.subList(start, stop);
         List<ObjectData> objDataList = new ArrayList<ObjectData>();
         Map<String, String> props = queryObj.getRequestedProperties();
         Map<String, String> funcs = queryObj.getRequestedFuncs();
@@ -112,8 +201,6 @@ public class InMemoryQueryProcessor impl
             objDataList.add(od); 
         }
         res.setObjects(objDataList);
-        res.setNumItems(BigInteger.valueOf(objDataList.size()));
-        res.setHasMoreItems(false);
         return res;
     }
     
@@ -136,6 +223,7 @@ public class InMemoryQueryProcessor impl
             LOG.warn("ORDER BY has more than one sort criterium, all but the first are ignored.");
         class ResultComparator implements Comparator<StoredObject> {
 
+            @SuppressWarnings("unchecked")
             public int compare(StoredObject so1, StoredObject so2) {
                 SortSpec s = orderBy.get(0);
                 CmisSelector sel = s.getSelector();
@@ -286,13 +374,6 @@ public class InMemoryQueryProcessor impl
         
     }
 
-    private void checkRoot(Tree root) {
-        if (root.getType() == CMISQLLexerStrict.WHERE)
-            LOG.debug("Found root with where node.");
-        else
-            LOG.debug("NOT Found root with where node!! " + root.toStringTree());        
-    }
-
     /**
      * For each object check if it matches and append it to match-list if it does.
      * We do here our own walking mechanism so that we can pass additional parameters

Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/query/QueryObject.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/query/QueryObject.java?rev=956361&r1=956360&r2=956361&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/query/QueryObject.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/query/QueryObject.java Sun Jun 20 14:10:04 2010
@@ -173,7 +173,7 @@ public class QueryObject {
         return td;
     }
     
-    Map<String, String> getRequestedProperties() {
+    public Map<String, String> getRequestedProperties() {
         Map<String, String> res = new HashMap<String, String> ();
         for (CmisSelector sel : selectReferences) {
             if (sel instanceof ColumnReference) {
@@ -188,7 +188,7 @@ public class QueryObject {
         return res;
     }
     
-    Map<String, String> getRequestedFuncs() {
+    public Map<String, String> getRequestedFuncs() {
         Map<String, String> res = new HashMap<String, String> ();
         for (CmisSelector sel : selectReferences) {
             if (sel instanceof FunctionReference) {

Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryDiscoveryServiceImpl.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryDiscoveryServiceImpl.java?rev=956361&r1=956360&r2=956361&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryDiscoveryServiceImpl.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryDiscoveryServiceImpl.java Sun Jun 20 14:10:04 2010
@@ -18,23 +18,11 @@
  */
 package org.apache.chemistry.opencmis.inmemory.server;
 
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.UnsupportedEncodingException;
 import java.math.BigInteger;
 import java.util.ArrayList;
 import java.util.GregorianCalendar;
 import java.util.List;
 
-import org.antlr.runtime.ANTLRInputStream;
-import org.antlr.runtime.CharStream;
-import org.antlr.runtime.CommonTokenStream;
-import org.antlr.runtime.RecognitionException;
-import org.antlr.runtime.TokenSource;
-import org.antlr.runtime.TokenStream;
-import org.antlr.runtime.tree.CommonTree;
-import org.antlr.runtime.tree.CommonTreeNodeStream;
-import org.antlr.runtime.tree.Tree;
 import org.apache.chemistry.opencmis.commons.data.ExtensionsData;
 import org.apache.chemistry.opencmis.commons.data.ObjectData;
 import org.apache.chemistry.opencmis.commons.data.ObjectInFolderContainer;
@@ -48,112 +36,13 @@ import org.apache.chemistry.opencmis.com
 import org.apache.chemistry.opencmis.commons.server.CallContext;
 import org.apache.chemistry.opencmis.commons.server.ObjectInfoHandler;
 import org.apache.chemistry.opencmis.commons.spi.Holder;
-import org.apache.chemistry.opencmis.inmemory.TypeManager;
-import org.apache.chemistry.opencmis.inmemory.query.CMISQLLexerStrict;
-import org.apache.chemistry.opencmis.inmemory.query.CMISQLParserStrict;
-import org.apache.chemistry.opencmis.inmemory.query.CmisQueryWalker;
-import org.apache.chemistry.opencmis.inmemory.query.InMemoryQueryProcessor;
-import org.apache.chemistry.opencmis.inmemory.query.QueryObject;
-import org.apache.chemistry.opencmis.inmemory.storedobj.api.ObjectStore;
 import org.apache.chemistry.opencmis.inmemory.storedobj.api.StoreManager;
-import org.apache.chemistry.opencmis.inmemory.storedobj.api.StoredObject;
-import org.apache.chemistry.opencmis.inmemory.storedobj.impl.ObjectStoreImpl;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
 public class InMemoryDiscoveryServiceImpl extends InMemoryAbstractServiceImpl{
     
-    private static Log log = LogFactory.getLog(InMemoryDiscoveryServiceImpl.class);
-    
-     private static class InMemoryQueryContext {
-        
-        public CommonTree parserTree; // the ANTLR tree after parsing phase
-        public CommonTree walkerTree; // the ANTLR tree after walking phase
-        private QueryObject queryObj;
-        
-        /**
-         * Main entry function to process a query from discovery service
-         */
-        public ObjectList query(StoreManager storeMgr, String user, String repositoryId, String statement, Boolean searchAllVersions,
-                Boolean includeAllowableActions, IncludeRelationships includeRelationships, String renditionFilter,
-                BigInteger maxItems, BigInteger skipCount) {
-            
-            TypeManager tm = storeMgr.getTypeManager(repositoryId);
-            ObjectStore objectStore = storeMgr.getObjectStore(repositoryId);
-
-            InMemoryQueryProcessor queryProcessor = new InMemoryQueryProcessor();
-            queryObj = new QueryObject(tm, queryProcessor);
-            queryProcessor.setQueryObject(queryObj);
-            processQueryAndCatchExc(statement); // calls query processor
-
-            // iterate over all the objects and check for each if the query matches
-            for (String objectId : ((ObjectStoreImpl) objectStore).getIds()) {
-                StoredObject so = objectStore.getObjectById(objectId);
-                queryProcessor.checkMatch(so);
-            }
-
-            ObjectList objList = queryProcessor.buildResultList(tm, user, includeAllowableActions, includeRelationships, renditionFilter,
-                    maxItems, skipCount);
-            log.debug("Query result, number of matching objects: " + objList.getNumItems());
-            for (ObjectData od : objList.getObjects())
-                log.debug("Found matching object: " + od);
-            return objList;
-        }        
-        
-        private CmisQueryWalker getWalker(String statement) throws UnsupportedEncodingException, IOException, RecognitionException {
-            CharStream input = new ANTLRInputStream(new ByteArrayInputStream(statement.getBytes("UTF-8")));
-            TokenSource lexer = new CMISQLLexerStrict(input);
-            TokenStream tokens = new CommonTokenStream(lexer);
-            CMISQLParserStrict parser = new CMISQLParserStrict(tokens);
-
-            CMISQLParserStrict.query_return parsedStatement = parser.query();
-            if (parser.errorMessage != null) {
-                throw new RuntimeException("Cannot parse query: " + statement + " (" + parser.errorMessage + ")");
-            }
-            parserTree = (CommonTree) parsedStatement.getTree();            
-        
-            CommonTreeNodeStream nodes = new CommonTreeNodeStream(parserTree);
-            nodes.setTokenStream(tokens);
-            CmisQueryWalker walker = new CmisQueryWalker(nodes);
-            return walker;
-        }
-
-        public CmisQueryWalker processQuery(String statement) throws UnsupportedEncodingException, IOException, RecognitionException {
-            CmisQueryWalker walker = getWalker(statement);
-            walker.query(queryObj);
-            String errMsg = walker.getErrorMessageString();
-            if (null != errMsg) {
-                throw new RuntimeException("Walking of statement failed with error: \n   " + errMsg + 
-                        "\n   Statement was: " + statement);
-            }
-            walkerTree = (CommonTree) walker.getTreeNodeStream().getTreeSource();
-            return walker;
-        }
-
-        public CmisQueryWalker processQueryAndCatchExc(String statement) {
-            try {
-                return processQuery(statement);
-            } catch (RecognitionException e) {
-                throw new RuntimeException("Walking of statement failed with RecognitionException error: \n   " + e); 
-            } catch (Exception e) {
-                throw new RuntimeException("Walking of statement failed with other exception: \n   " + e); 
-            }
-        }
-        
-        private Tree getWhereTree(Tree root) {
-            int count = root.getChildCount();
-            for (int i=0; i<count; i++) {
-                Tree child = root.getChild(i);
-                if (child.getType() == CMISQLLexerStrict.WHERE) {
-                    return child;
-                }
-            }
-            return null;
-        }
-        
-    }
-
-    private static final Log LOG = LogFactory.getLog(InMemoryDiscoveryServiceImpl.class.getName());
+    private static Log LOG = LogFactory.getLog(InMemoryDiscoveryServiceImpl.class);
 
     AtomLinkInfoProvider fAtomLinkProvider;
     InMemoryNavigationServiceImpl fNavigationService; // real implementation of
@@ -217,13 +106,12 @@ public class InMemoryDiscoveryServiceImp
         LOG.debug("start query()");
         checkRepositoryId(repositoryId);
         String user = context.getUsername();
-
-        InMemoryQueryContext queryCtx  = new InMemoryQueryContext();
-        ObjectList objList =  queryCtx.query(fStoreManager, user, repositoryId, statement, searchAllVersions,
-                includeAllowableActions, includeRelationships, renditionFilter, maxItems, skipCount); 
-
+        ObjectList res;
+        
+        res = fStoreManager.query(user, repositoryId, statement, searchAllVersions, includeAllowableActions,
+                includeRelationships, renditionFilter, maxItems, skipCount);
         LOG.debug("stop query()");
-        return objList;
+        return res;
     }
 
 }

Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/api/StoreManager.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/api/StoreManager.java?rev=956361&r1=956360&r2=956361&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/api/StoreManager.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/api/StoreManager.java Sun Jun 20 14:10:04 2010
@@ -18,11 +18,14 @@
  */
 package org.apache.chemistry.opencmis.inmemory.storedobj.api;
 
+import java.math.BigInteger;
 import java.util.Collection;
 import java.util.List;
 
+import org.apache.chemistry.opencmis.commons.data.ObjectList;
 import org.apache.chemistry.opencmis.commons.data.RepositoryInfo;
 import org.apache.chemistry.opencmis.commons.definitions.TypeDefinitionContainer;
+import org.apache.chemistry.opencmis.commons.enums.IncludeRelationships;
 import org.apache.chemistry.opencmis.commons.spi.BindingsObjectFactory;
 import org.apache.chemistry.opencmis.inmemory.TypeManager;
 
@@ -152,5 +155,24 @@ public interface StoreManager {
      *      type manager for this repository or null if repository is unknown
      */
     TypeManager getTypeManager(String repositoryId);
+    
+    /**
+     * Execute a query against the repository (same parameter as the discovery service
+     * query method
+     * 
+     * @param user
+     * @param repositoryId
+     * @param statement
+     * @param searchAllVersions
+     * @param includeAllowableActions
+     * @param includeRelationships
+     * @param renditionFilter
+     * @param maxItems
+     * @param skipCount
+     * @return
+     */
+    ObjectList query(String user, String repositoryId, String statement, Boolean searchAllVersions,
+            Boolean includeAllowableActions, IncludeRelationships includeRelationships, String renditionFilter,
+            BigInteger maxItems, BigInteger skipCount);
 
 }
\ No newline at end of file

Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/StoreManagerImpl.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/StoreManagerImpl.java?rev=956361&r1=956360&r2=956361&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/StoreManagerImpl.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/impl/StoreManagerImpl.java Sun Jun 20 14:10:04 2010
@@ -18,6 +18,7 @@
  */
 package org.apache.chemistry.opencmis.inmemory.storedobj.impl;
 
+import java.math.BigInteger;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.HashMap;
@@ -26,6 +27,7 @@ import java.util.ListIterator;
 import java.util.Map;
 import java.util.Set;
 
+import org.apache.chemistry.opencmis.commons.data.ObjectList;
 import org.apache.chemistry.opencmis.commons.data.RepositoryInfo;
 import org.apache.chemistry.opencmis.commons.definitions.TypeDefinition;
 import org.apache.chemistry.opencmis.commons.definitions.TypeDefinitionContainer;
@@ -35,6 +37,7 @@ import org.apache.chemistry.opencmis.com
 import org.apache.chemistry.opencmis.commons.enums.CapabilityJoin;
 import org.apache.chemistry.opencmis.commons.enums.CapabilityQuery;
 import org.apache.chemistry.opencmis.commons.enums.CapabilityRenditions;
+import org.apache.chemistry.opencmis.commons.enums.IncludeRelationships;
 import org.apache.chemistry.opencmis.commons.exceptions.CmisInvalidArgumentException;
 import org.apache.chemistry.opencmis.commons.impl.dataobjects.AbstractTypeDefinition;
 import org.apache.chemistry.opencmis.commons.impl.dataobjects.BindingsObjectFactoryImpl;
@@ -46,8 +49,11 @@ import org.apache.chemistry.opencmis.inm
 import org.apache.chemistry.opencmis.inmemory.TypeCreator;
 import org.apache.chemistry.opencmis.inmemory.TypeManager;
 import org.apache.chemistry.opencmis.inmemory.TypeManagerImpl;
+import org.apache.chemistry.opencmis.inmemory.query.InMemoryQueryProcessor;
 import org.apache.chemistry.opencmis.inmemory.storedobj.api.ObjectStore;
 import org.apache.chemistry.opencmis.inmemory.storedobj.api.StoreManager;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 
 /**
  * factory to create objects that are stored in the InMemory store
@@ -56,6 +62,8 @@ import org.apache.chemistry.opencmis.inm
  */
 public class StoreManagerImpl implements StoreManager {
 
+    private static Log LOG = LogFactory.getLog(StoreManagerImpl.class);
+    
     protected BindingsObjectFactory fObjectFactory;
     protected RepositoryInfo fRepositoryInfo;
 
@@ -355,4 +363,18 @@ public class StoreManagerImpl implements
         return typeManager;
     }
 
+    public ObjectList query(String user, String repositoryId, String statement, Boolean searchAllVersions,
+            Boolean includeAllowableActions, IncludeRelationships includeRelationships, String renditionFilter,
+            BigInteger maxItems, BigInteger skipCount) {
+        TypeManager tm = getTypeManager(repositoryId);
+        ObjectStore objectStore = getObjectStore(repositoryId);
+
+        InMemoryQueryProcessor queryProcessor = new InMemoryQueryProcessor();
+        ObjectList objList = queryProcessor.query(tm, objectStore, user, repositoryId, statement, searchAllVersions,
+                includeAllowableActions, includeRelationships, renditionFilter, maxItems, skipCount);
+
+        LOG.debug("Query result, number of matching objects: " + objList.getNumItems());
+        return objList;
+    }
+    
 }

Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/DiscoveryServiceTest.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/DiscoveryServiceTest.java?rev=956361&r1=956360&r2=956361&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/DiscoveryServiceTest.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/DiscoveryServiceTest.java Sun Jun 20 14:10:04 2010
@@ -77,19 +77,19 @@ public class DiscoveryServiceTest extend
         String statement = "SELECT * FROM " + TEST_DOCUMENT_TYPE_ID + " WHERE " + TEST_DOCUMENT_STRING_PROP_ID + "='My Doc StringProperty 1'";
         ObjectList res = fDiscSvc.query(fRepositoryId, statement, searchAllVersions, includeAllowableActions,
                 includeRelationships, renditionFilter, maxItems, skipCount, null);
-        assertEquals(BigInteger.valueOf(1), res.getNumItems());
+        assertEquals(1, res.getObjects().size());
         
         statement = "SELECT " + TEST_DOCUMENT_STRING_PROP_ID + " FROM " + TEST_DOCUMENT_TYPE_ID + " WHERE " + TEST_DOCUMENT_STRING_PROP_ID + "='My Doc StringProperty 1'";
         res = fDiscSvc.query(fRepositoryId, statement, searchAllVersions, includeAllowableActions,
                 includeRelationships, renditionFilter, maxItems, skipCount, null);
-        assertEquals(BigInteger.valueOf(1), res.getNumItems());
+        assertEquals(1, res.getObjects().size());
         assertEquals(1, res.getObjects().get(0).getProperties().getProperties().size()); // only one property should be delivered
 
         statement = "SELECT * FROM cmis:folder";
         res = fDiscSvc.query(fRepositoryId, statement, searchAllVersions, includeAllowableActions,
                 includeRelationships, renditionFilter, maxItems, skipCount, null);
         // root + 2 at level 1 + 2*2 at level 2 = 7
-        assertEquals(BigInteger.valueOf(7), res.getNumItems());
+        assertEquals(7, res.getObjects().size());
 
         /*        
         assertEquals(BigInteger.valueOf(9), res.getNumItems());