sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From romb...@apache.org
Subject svn commit: r1607681 - in /sling/trunk/tooling/ide: eclipse-core/src/org/apache/sling/ide/eclipse/core/internal/ResourceChangeCommandFactory.java eclipse-test/src/org/apache/sling/ide/test/impl/JcrPartialCoverageAggregatesDeploymentTest.java
Date Thu, 03 Jul 2014 15:38:24 GMT
Author: rombert
Date: Thu Jul  3 15:38:24 2014
New Revision: 1607681

URL: http://svn.apache.org/r1607681
Log:
SLING-3710 - Incorrect handling of nt:hierarchyNode instances nested
within jcr:content nodes of other nt:hieararchyNode node

Enable lookup of serialization files higher in the folder hierarchy if
no serialization hint is found.

Modified:
    sling/trunk/tooling/ide/eclipse-core/src/org/apache/sling/ide/eclipse/core/internal/ResourceChangeCommandFactory.java
    sling/trunk/tooling/ide/eclipse-test/src/org/apache/sling/ide/test/impl/JcrPartialCoverageAggregatesDeploymentTest.java

Modified: sling/trunk/tooling/ide/eclipse-core/src/org/apache/sling/ide/eclipse/core/internal/ResourceChangeCommandFactory.java
URL: http://svn.apache.org/viewvc/sling/trunk/tooling/ide/eclipse-core/src/org/apache/sling/ide/eclipse/core/internal/ResourceChangeCommandFactory.java?rev=1607681&r1=1607680&r2=1607681&view=diff
==============================================================================
--- sling/trunk/tooling/ide/eclipse-core/src/org/apache/sling/ide/eclipse/core/internal/ResourceChangeCommandFactory.java
(original)
+++ sling/trunk/tooling/ide/eclipse-core/src/org/apache/sling/ide/eclipse/core/internal/ResourceChangeCommandFactory.java
Thu Jul  3 15:38:24 2014
@@ -217,9 +217,56 @@ public class ResourceChangeCommandFactor
 
         String resourceLocation = '/' + changedResource.getFullPath().makeRelativeTo(syncDirectory.getFullPath())
                 .toPortableString();
-        String serializationFilePath = serializationManager.getSerializationFilePath(resourceLocation,
-                serializationKind);
+        IPath serializationFilePath = Path.fromPortableString(serializationManager.getSerializationFilePath(
+                resourceLocation,
+                serializationKind));
         IResource serializationResource = syncDirectory.findMember(serializationFilePath);
+
+        // if the serialization resource is null, it's valid to look for a serialization
resource
+        // higher in the filesystem, given that the found serialization resource covers this
resource
+        // TODO - this too should be abstracted in the service layer, rather than in the
Eclipse-specific code
+        if (serializationResource == null && changedResource.getType() == IResource.FOLDER)
{
+            while (!serializationFilePath.isRoot()) {
+                serializationFilePath = serializationFilePath.removeLastSegments(1);
+                IFolder folderWithPossibleSerializationFile = (IFolder) syncDirectory.findMember(serializationFilePath);
+                if (folderWithPossibleSerializationFile == null) {
+                    continue;
+                }
+
+                // it's safe to use a specific SerializationKind since this scenario is only
valid for METADATA_PARTIAL
+                // coverage
+                String possibleSerializationFilePath = serializationManager.getSerializationFilePath(
+                        ((IFolder) folderWithPossibleSerializationFile).getLocation().toOSString(),
+                        SerializationKind.METADATA_PARTIAL);
+
+                if (serializationManager.isSerializationFile(possibleSerializationFilePath))
{
+
+                    IPath parentSerializationFilePath = Path.fromOSString(possibleSerializationFilePath).makeRelativeTo(
+                            syncDirectory.getLocation());
+                    IFile possibleSerializationFile = syncDirectory.getFile(parentSerializationFilePath);
+                    if (!possibleSerializationFile.exists()) {
+                        continue;
+                    }
+
+                    InputStream contents = possibleSerializationFile.getContents();
+                    ResourceProxy serializationData;
+                    try {
+                        serializationData = serializationManager.readSerializationData(
+                                parentSerializationFilePath.toPortableString(), contents);
+                    } finally {
+                        IOUtils.closeQuietly(contents);
+                    }
+
+                    boolean covered = serializationData
+                            .covers(serializationManager.getRepositoryPath(resourceLocation));
+                    if (covered) {
+                        return serializationData.getChild(serializationManager.getRepositoryPath(resourceLocation));
+                    }
+
+                    break;
+                }
+            }
+        }
         return buildResourceProxy(resourceLocation, serializationResource, syncDirectory,
fallbackNodeType);
     }
 
@@ -232,7 +279,8 @@ public class ResourceChangeCommandFactor
                 contents = serializationFile.getContents();
                 String serializationFilePath = serializationResource.getFullPath()
                         .makeRelativeTo(syncDirectory.getFullPath()).toPortableString();
-                return serializationManager.readSerializationData(serializationFilePath,
contents);
+                ResourceProxy resourceProxy = serializationManager.readSerializationData(serializationFilePath,
contents);
+                return resourceProxy;
             } finally {
                 IOUtils.closeQuietly(contents);
             }

Modified: sling/trunk/tooling/ide/eclipse-test/src/org/apache/sling/ide/test/impl/JcrPartialCoverageAggregatesDeploymentTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/tooling/ide/eclipse-test/src/org/apache/sling/ide/test/impl/JcrPartialCoverageAggregatesDeploymentTest.java?rev=1607681&r1=1607680&r2=1607681&view=diff
==============================================================================
--- sling/trunk/tooling/ide/eclipse-test/src/org/apache/sling/ide/test/impl/JcrPartialCoverageAggregatesDeploymentTest.java
(original)
+++ sling/trunk/tooling/ide/eclipse-test/src/org/apache/sling/ide/test/impl/JcrPartialCoverageAggregatesDeploymentTest.java
Thu Jul  3 15:38:24 2014
@@ -44,7 +44,6 @@ import org.eclipse.core.runtime.Path;
 import org.hamcrest.Matcher;
 import org.junit.After;
 import org.junit.Before;
-import org.junit.Ignore;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.RuleChain;
@@ -235,7 +234,6 @@ public class JcrPartialCoverageAggregate
     }
     
     @Test
-    @Ignore("SLING-3170")
     public void deployNodeWithContentXmlInParentFolder() throws Exception {
         
         wstServer.waitForServerToStart();



Mime
View raw message