work on remote Repo issues.
authorBruno Sinou <bsinou@argeo.org>
Wed, 14 May 2014 17:32:30 +0000 (17:32 +0000)
committerBruno Sinou <bsinou@argeo.org>
Wed, 14 May 2014 17:32:30 +0000 (17:32 +0000)
git-svn-id: https://svn.argeo.org/slc/trunk@6982 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc

plugins/org.argeo.slc.client.ui.dist/src/main/java/org/argeo/slc/client/ui/dist/model/WorkspaceElem.java
runtime/org.argeo.slc.repo/src/main/java/org/argeo/slc/repo/RepoSync.java

index e35c66da4515f3f799bb2872bff04282eff1d65d..3be73b5e568fc6ee9f78d87c75e8e7c1dee630a5 100644 (file)
@@ -5,7 +5,10 @@ import javax.jcr.NodeIterator;
 import javax.jcr.RepositoryException;
 import javax.jcr.Session;
 import javax.jcr.query.InvalidQueryException;
-import javax.jcr.query.Query;
+import javax.jcr.query.QueryManager;
+import javax.jcr.query.qom.QueryObjectModel;
+import javax.jcr.query.qom.QueryObjectModelFactory;
+import javax.jcr.query.qom.Selector;
 
 import org.argeo.ArgeoException;
 import org.argeo.jcr.JcrUtils;
@@ -76,16 +79,34 @@ public class WorkspaceElem extends DistParentElem {
                                        login();
 
                                // Retrieve already existing distribution
-                               Query groupQuery = currSession
-                                               .getWorkspace()
-                                               .getQueryManager()
-                                               .createQuery(
-                                                               "select * from ["
-                                                                               + SlcTypes.SLC_MODULAR_DISTRIBUTION
-                                                                               + "]", Query.JCR_SQL2);
+
+                               // Use QOM rather than SQL2 - it seems more robust for remoting
+                               // with JCR 2.2 (might also be some model refresh issue with the
+                               // remoting)
+                               QueryManager queryManager = currSession.getWorkspace()
+                                               .getQueryManager();
+                               QueryObjectModelFactory factory = queryManager.getQOMFactory();
+                               Selector selector = factory.selector(
+                                               SlcTypes.SLC_MODULAR_DISTRIBUTION,
+                                               SlcTypes.SLC_MODULAR_DISTRIBUTION);
+                               // Curiously this works...
+                               // Selector selector = factory.selector(
+                               // SlcTypes.SLC_JAR_FILE,
+                               // SlcTypes.SLC_JAR_FILE);
+
+                               QueryObjectModel query = factory.createQuery(selector, null,
+                                               null, null);
+
+                               // Query groupQuery = currSession
+                               // .getWorkspace()
+                               // .getQueryManager()
+                               // .createQuery(
+                               // "select * from ["
+                               // + SlcTypes.SLC_MODULAR_DISTRIBUTION
+                               // + "]", Query.JCR_SQL2);
                                NodeIterator distributions = null;
                                try {
-                                       distributions = groupQuery.execute().getNodes();
+                                       distributions = query.execute().getNodes();
                                } catch (InvalidQueryException iqe) {
                                        // For legacy only does not throw an exception while
                                        // browsing
@@ -131,4 +152,4 @@ public class WorkspaceElem extends DistParentElem {
                JcrUtils.logoutQuietly(currSession);
                super.dispose();
        }
-}
+}
\ No newline at end of file
index 6ae38bf3a5159894c9980aea473683a78f16ab62..7f1e1e32d2f70b7cd4e4f6424dbaf6f2dc755445 100644 (file)
@@ -206,8 +206,10 @@ public class RepoSync implements Runnable {
                                        .getQueryManager()
                                        .createQuery(
                                                        "select file from ["
-                                                                       + (true ? "nt:file" : "nt:base")
-                                                                       + "] as file", Query.JCR_SQL2);
+                                                                       + (true ? NodeType.NT_FILE
+                                                                                       : NodeType.NT_BASE) + "] as file",
+                                                       Query.JCR_SQL2);
+
                        QueryResult result = countQuery.execute();
                        Long expectedCount = result.getNodes().getSize();
                        return expectedCount;