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/10/25 00:38:23 UTC
svn commit: r1634147 - in /sling/trunk/tooling/ide:
eclipse-test/src/org/apache/sling/ide/test/impl/ContentDeploymentTest.java
impl-vlt/src/org/apache/sling/ide/impl/vlt/serialization/VltSerializationManager.java
Author: rombert
Date: Fri Oct 24 22:38:23 2014
New Revision: 1634147
URL: http://svn.apache.org/r1634147
Log:
SLING-4098 - Full coverage aggregates nested under a partial coverage
aggregate incorrectly deleted when a sibling resource is published
Unify repository path extraction logic in VltSerializationManager -
getRepositoryPath now hosts the more extensive logic which originally
resided in readSerializationData .
Modified:
sling/trunk/tooling/ide/eclipse-test/src/org/apache/sling/ide/test/impl/ContentDeploymentTest.java
sling/trunk/tooling/ide/impl-vlt/src/org/apache/sling/ide/impl/vlt/serialization/VltSerializationManager.java
Modified: sling/trunk/tooling/ide/eclipse-test/src/org/apache/sling/ide/test/impl/ContentDeploymentTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/tooling/ide/eclipse-test/src/org/apache/sling/ide/test/impl/ContentDeploymentTest.java?rev=1634147&r1=1634146&r2=1634147&view=diff
==============================================================================
--- sling/trunk/tooling/ide/eclipse-test/src/org/apache/sling/ide/test/impl/ContentDeploymentTest.java (original)
+++ sling/trunk/tooling/ide/eclipse-test/src/org/apache/sling/ide/test/impl/ContentDeploymentTest.java Fri Oct 24 22:38:23 2014
@@ -268,6 +268,52 @@ public class ContentDeploymentTest {
}, hasFileContent("hello, world"));
}
+ @Test
+ public void filedDeployedWithFullCoverageSiblingDoesNotCauseSpuriousDeletion() throws Exception {
+
+ wstServer.waitForServerToStart();
+
+ // create faceted project
+ IProject contentProject = projectRule.getProject();
+
+ ProjectAdapter project = new ProjectAdapter(contentProject);
+ project.addNatures(JavaCore.NATURE_ID, "org.eclipse.wst.common.project.facet.core.nature");
+
+ // install bundle facet
+ project.installFacet("sling.content", "1.0");
+
+ ServerAdapter server = new ServerAdapter(wstServer.getServer());
+ server.installModule(contentProject);
+
+ // create sling:Folder at /test/folder
+ project.createOrUpdateFile(Path.fromPortableString("jcr_root/test/folder/.content.xml"), getClass()
+ .getResourceAsStream("sling-folder-nodetype.xml"));
+
+ // create nt:file at /test/folder/hello.esp
+ project.createOrUpdateFile(Path.fromPortableString("jcr_root/test/folder/hello.esp"), new ByteArrayInputStream(
+ "// not really javascript".getBytes()));
+
+ // create sling:OsgiConfig at /test/folder/config.xml
+ project.createOrUpdateFile(Path.fromPortableString("jcr_root/test/folder/config.xml"), getClass()
+ .getResourceAsStream("com.example.some.Component.xml"));
+
+ // verify that config node is created
+ final RepositoryAccessor repo = new RepositoryAccessor(config);
+ Poller poller = new Poller();
+
+ assertThatNode(repo, poller, "/test/folder/config", hasPrimaryType("sling:OsgiConfig"));
+
+ // update file at /test/folder/hello.esp
+ project.createOrUpdateFile(Path.fromPortableString("jcr_root/test/folder/hello.esp"), new ByteArrayInputStream(
+ "// maybe javascript".getBytes()));
+
+ // wait until the file is updated
+ assertThatNode(repo, poller, "/test/folder/hello.esp", hasFileContent("// maybe javascript"));
+
+ // verify that the sling:OsgiConfig node is still present
+ assertThatNode(repo, poller, "/test/folder/config", hasPrimaryType("sling:OsgiConfig"));
+ }
+
private void assertThatNode(final RepositoryAccessor repo, Poller poller, final String nodePath, Matcher<Node> matcher)
throws InterruptedException {
Modified: sling/trunk/tooling/ide/impl-vlt/src/org/apache/sling/ide/impl/vlt/serialization/VltSerializationManager.java
URL: http://svn.apache.org/viewvc/sling/trunk/tooling/ide/impl-vlt/src/org/apache/sling/ide/impl/vlt/serialization/VltSerializationManager.java?rev=1634147&r1=1634146&r2=1634147&view=diff
==============================================================================
--- sling/trunk/tooling/ide/impl-vlt/src/org/apache/sling/ide/impl/vlt/serialization/VltSerializationManager.java (original)
+++ sling/trunk/tooling/ide/impl-vlt/src/org/apache/sling/ide/impl/vlt/serialization/VltSerializationManager.java Fri Oct 24 22:38:23 2014
@@ -174,8 +174,34 @@ public class VltSerializationManager imp
@Override
public String getRepositoryPath(String osPath) {
- // TODO - this is a bit risky, we might clean legitimate directories which contain '.dir'
- return PlatformNameFormat.getRepositoryPath(osPath).replace(".dir/", "/");
+
+ String repositoryPath;
+ String name = Text.getName(osPath);
+ if (name.equals(Constants.DOT_CONTENT_XML)) {
+ // TODO - this is a bit risky, we might clean legitimate directories which contain '.dir'
+ String parentPath = Text.getRelativeParent(osPath, 1);
+ if (parentPath != null && parentPath.endsWith(".dir")) {
+ parentPath = parentPath.substring(0, parentPath.length() - ".dir".length());
+ }
+ repositoryPath = PlatformNameFormat.getRepositoryPath(parentPath);
+ } else {
+ // TODO - we assume here that it's a full coverage aggregate but it might not be
+ if (osPath.endsWith(EXTENSION_XML)) {
+ repositoryPath = PlatformNameFormat.getRepositoryPath(osPath.substring(0, osPath.length()
+ - EXTENSION_XML.length()));
+ } else {
+ repositoryPath = PlatformNameFormat.getRepositoryPath(osPath).replace(".dir/", "/");
+ }
+ }
+
+ // TODO extract into PathUtils
+ if (repositoryPath.length() > 0 && repositoryPath.charAt(0) != '/') {
+ repositoryPath = '/' + repositoryPath;
+ } else if (repositoryPath.length() == 0) {
+ repositoryPath = "/";
+ }
+
+ return repositoryPath;
}
@Override
@@ -215,30 +241,7 @@ public class VltSerializationManager imp
if (source == null)
return null;
- String repositoryPath;
- String name = Text.getName(filePath);
- if (name.equals(Constants.DOT_CONTENT_XML)) {
- // TODO - generalize instead of special-casing the parent name
- String parentPath = Text.getRelativeParent(filePath, 1);
- if (parentPath != null && parentPath.endsWith(".dir")) {
- parentPath = parentPath.substring(0, parentPath.length() - ".dir".length());
- }
- repositoryPath = PlatformNameFormat.getRepositoryPath(parentPath);
- } else {
- if (!filePath.endsWith(EXTENSION_XML)) {
- throw new IllegalArgumentException("Don't know how to extract resource path from file named "
- + filePath);
- }
- repositoryPath = PlatformNameFormat.getRepositoryPath(filePath.substring(0,
- filePath.length() - EXTENSION_XML.length()));
- }
-
- // TODO extract into PathUtils
- if (repositoryPath.length() > 0 && repositoryPath.charAt(0) != '/') {
- repositoryPath = '/' + repositoryPath;
- } else if (repositoryPath.length() == 0) {
- repositoryPath = "/";
- }
+ String repositoryPath = getRepositoryPath(filePath);
try {
SAXParserFactory factory = SAXParserFactory.newInstance();