]> git.argeo.org Git - lgpl/argeo-commons.git/blobdiff - server/runtime/org.argeo.server.jcr/src/main/java/org/argeo/jcr/JcrUtils.java
Start working on JCR url stream handler
[lgpl/argeo-commons.git] / server / runtime / org.argeo.server.jcr / src / main / java / org / argeo / jcr / JcrUtils.java
index a579392dd50e97c7d13d06382f0c3904daf36978..554e9f34c6e8ff2118699a16cd172760238a9ab4 100644 (file)
@@ -35,6 +35,7 @@ import javax.jcr.PropertyIterator;
 import javax.jcr.RepositoryException;
 import javax.jcr.Session;
 import javax.jcr.Value;
+import javax.jcr.nodetype.NodeType;
 import javax.jcr.query.Query;
 import javax.jcr.query.QueryResult;
 
@@ -201,7 +202,7 @@ public class JcrUtils {
                                        else
                                                currentNode = currentNode.addNode(part);
                                        if (versioning)
-                                               currentNode.addMixin(ArgeoJcrConstants.MIX_VERSIONABLE);
+                                               currentNode.addMixin(NodeType.MIX_VERSIONABLE);
                                        if (log.isTraceEnabled())
                                                log.debug("Added folder " + part + " as " + current);
                                } else {
@@ -262,7 +263,7 @@ public class JcrUtils {
                        // First output the node path
                        log.debug(node.getPath());
                        // Skip the virtual (and large!) jcr:system subtree
-                       if (node.getName().equals(ArgeoJcrConstants.JCR_SYSTEM)) {
+                       if (node.getName().equals("jcr:system")) {
                                return;
                        }
 
@@ -438,16 +439,26 @@ public class JcrUtils {
                try {
                        Iterator<String> pit = properties.iterator();
 
-                       while (pit.hasNext()) {
+                       props: while (pit.hasNext()) {
                                String name = pit.next();
-                               if (!observed.hasProperty(name)) {
+                               if (!reference.hasProperty(name)) {
+                                       if (!observed.hasProperty(name))
+                                               continue props;
+                                       Value val = observed.getProperty(name).getValue();
+                                       try {
+                                               // empty String but not null
+                                               if ("".equals(val.getString()))
+                                                       continue props;
+                                       } catch (Exception e) {
+                                               // not parseable as String, silent
+                                       }
+                                       PropertyDiff pDiff = new PropertyDiff(PropertyDiff.ADDED,
+                                                       name, null, val);
+                                       diffs.put(name, pDiff);
+                               } else if (!observed.hasProperty(name)) {
                                        PropertyDiff pDiff = new PropertyDiff(PropertyDiff.REMOVED,
                                                        name, reference.getProperty(name).getValue(), null);
                                        diffs.put(name, pDiff);
-                               } else if (!reference.hasProperty(name)) {
-                                       PropertyDiff pDiff = new PropertyDiff(PropertyDiff.ADDED,
-                                                       name, null, observed.getProperty(name).getValue());
-                                       diffs.put(name, pDiff);
                                } else {
                                        Value referenceValue = reference.getProperty(name)
                                                        .getValue();