You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ro...@apache.org on 2014/06/19 17:36:02 UTC

svn commit: r1603923 - in /sling/trunk/tooling/ide: api/src/org/apache/sling/ide/transport/ResourceProxy.java impl-vlt/src/org/apache/sling/ide/impl/vlt/AddOrUpdateNodeCommand.java

Author: rombert
Date: Thu Jun 19 15:36:02 2014
New Revision: 1603923

URL: http://svn.apache.org/r1603923
Log:
SLING-3658 - Could not publish to the server.
java.util.NoSuchElementException

Add new methods to ResourceProxy - getCoveredChildren and covers.

Modified:
    sling/trunk/tooling/ide/api/src/org/apache/sling/ide/transport/ResourceProxy.java
    sling/trunk/tooling/ide/impl-vlt/src/org/apache/sling/ide/impl/vlt/AddOrUpdateNodeCommand.java

Modified: sling/trunk/tooling/ide/api/src/org/apache/sling/ide/transport/ResourceProxy.java
URL: http://svn.apache.org/viewvc/sling/trunk/tooling/ide/api/src/org/apache/sling/ide/transport/ResourceProxy.java?rev=1603923&r1=1603922&r2=1603923&view=diff
==============================================================================
--- sling/trunk/tooling/ide/api/src/org/apache/sling/ide/transport/ResourceProxy.java (original)
+++ sling/trunk/tooling/ide/api/src/org/apache/sling/ide/transport/ResourceProxy.java Thu Jun 19 15:36:02 2014
@@ -73,6 +73,30 @@ public class ResourceProxy {
         return res;
     }
 
+    public List<ResourceProxy> getCoveredChildren() {
+
+        List<ResourceProxy> coveredChildren = new ArrayList<ResourceProxy>();
+        for (ResourceProxy child : getChildren()) {
+            if (child.getProperties().isEmpty()) {
+                continue;
+            }
+
+            coveredChildren.add(child);
+        }
+
+        return coveredChildren;
+    }
+
+    public boolean covers(String path) {
+        for (ResourceProxy child : getCoveredChildren()) {
+            if (child.getPath().equals(path)) {
+                return true;
+            }
+        }
+
+        return false;
+    }
+
     @Override
     public String toString() {
         StringBuilder out = new StringBuilder();

Modified: sling/trunk/tooling/ide/impl-vlt/src/org/apache/sling/ide/impl/vlt/AddOrUpdateNodeCommand.java
URL: http://svn.apache.org/viewvc/sling/trunk/tooling/ide/impl-vlt/src/org/apache/sling/ide/impl/vlt/AddOrUpdateNodeCommand.java?rev=1603923&r1=1603922&r2=1603923&view=diff
==============================================================================
--- sling/trunk/tooling/ide/impl-vlt/src/org/apache/sling/ide/impl/vlt/AddOrUpdateNodeCommand.java (original)
+++ sling/trunk/tooling/ide/impl-vlt/src/org/apache/sling/ide/impl/vlt/AddOrUpdateNodeCommand.java Thu Jun 19 15:36:02 2014
@@ -102,7 +102,7 @@ public class AddOrUpdateNodeCommand exte
         updateNode(node, resource);
         processDeletedNodes(node, resource);
 
-        for (ResourceProxy child : getCoveredChildren(resource)) {
+        for (ResourceProxy child : resource.getCoveredChildren()) {
             update(child, session);
         }
 
@@ -126,7 +126,7 @@ public class AddOrUpdateNodeCommand exte
 
         // gather a list of existing paths for all covered children
         // all nodes which are not found in these paths will be deleted
-        List<ResourceProxy> coveredResourceChildren = getCoveredChildren(resource2);
+        List<ResourceProxy> coveredResourceChildren = resource2.getCoveredChildren();
         if (coveredResourceChildren.size() == 0) {
             Activator.getDefault().getPluginLogger()
                     .trace("Resource at {0} has no covered children, skipping deleted nodes processing",
@@ -158,7 +158,7 @@ public class AddOrUpdateNodeCommand exte
 
     private void reorderChildNodes(Node node, ResourceProxy resource2) throws RepositoryException {
 
-        ListIterator<ResourceProxy> coveredResourceChildren = getCoveredChildren(resource2).listIterator();
+        ListIterator<ResourceProxy> coveredResourceChildren = resource2.getCoveredChildren().listIterator();
 
         // do not process
         if (!coveredResourceChildren.hasNext()) {
@@ -209,23 +209,6 @@ public class AddOrUpdateNodeCommand exte
 
     }
 
-    private List<ResourceProxy> getCoveredChildren(ResourceProxy resource) {
-        // TODO - this is a workaround for partial coverage nodes being sent here
-        // when a .content.xml file with partial coverage is added here, the children are listed with no properties
-        // and get all their properties deleted
-
-        List<ResourceProxy> coveredChildren = new ArrayList<ResourceProxy>();
-        for (ResourceProxy child : resource.getChildren()) {
-            if (child.getProperties().isEmpty()) {
-                continue;
-            }
-
-            coveredChildren.add(child);
-        }
-
-        return coveredChildren;
-    }
-
     private Node createNode(ResourceProxy resource, Session session) throws RepositoryException, FileNotFoundException {
 
         String parentLocation = Text.getRelativeParent(resource.getPath(), 1);