Author: rombert
Date: Wed Oct 1 20:09:25 2014
New Revision: 1628826
URL: http://svn.apache.org/r1628826
Log:
SLING-3990 - Content Navigator does not correctly escape os names for
nodes with special characters
Fix and tests.
Modified:
sling/trunk/tooling/ide/eclipse-test/src/org/apache/sling/ide/test/impl/JcrNodeCreationTest.java
sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/nav/model/JcrNode.java
Modified:
sling/trunk/tooling/ide/eclipse-test/src/org/apache/sling/ide/test/impl/JcrNodeCreationTest.java
URL:
http://svn.apache.org/viewvc/sling/trunk/tooling/ide/eclipse-test/src/org/apache/sling/ide/test/impl/JcrNodeCreationTest.java?rev=1628826&r1=1628825&r2=1628826&view=diff
==============================================================================
---
sling/trunk/tooling/ide/eclipse-test/src/org/apache/sling/ide/test/impl/JcrNodeCreationTest.java
(original)
+++
sling/trunk/tooling/ide/eclipse-test/src/org/apache/sling/ide/test/impl/JcrNodeCreationTest.java
Wed Oct 1 20:09:25 2014
@@ -130,6 +130,33 @@ public class JcrNodeCreationTest {
assertThat(project,
hasFile("/jcr_root/content/test-root/holder/org.apache.sling.SomeComponent.xml"));
}
+ @Test
+ public void createUnstructuredNodeWithSpecialName() throws Exception {
+
+ JcrNode contentNode = syncDirNode.getNode("/content/test-root");
+ contentNode.createChild("sling:stuff", "nt:unstructured");
+
+ assertThat(projectRule.getProject(),
hasFile("/jcr_root/content/test-root/_sling_stuff/.content.xml"));
+ }
+
+ @Test
+ public void createFullCoverageNodeWithSpecialName() throws Exception {
+
+ JcrNode contentNode = syncDirNode.getNode("/content/test-root");
+ contentNode.createChild("sling:stuff", "sling:OsgiConfig");
+
+ assertThat(projectRule.getProject(),
hasFile("/jcr_root/content/test-root/_sling_stuff.xml"));
+ }
+
+ @Test
+ public void createSlingFolderNodeWithSpecialName() throws Exception {
+
+ JcrNode contentNode = syncDirNode.getNode("/content/test-root");
+ contentNode.createChild("sling:stuff", "sling:Folder");
+
+ assertThat(projectRule.getProject(),
hasFile("/jcr_root/content/test-root/_sling_stuff/.content.xml"));
+ }
+
@After
public void cleanup() throws Exception {
new RepositoryAccessor(config).tryDeleteResource("/content/test-root");
Modified:
sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/nav/model/JcrNode.java
URL:
http://svn.apache.org/viewvc/sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/nav/model/JcrNode.java?rev=1628826&r1=1628825&r2=1628826&view=diff
==============================================================================
---
sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/nav/model/JcrNode.java
(original)
+++
sling/trunk/tooling/ide/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/nav/model/JcrNode.java
Wed Oct 1 20:09:25 2014
@@ -49,6 +49,7 @@ import org.apache.sling.ide.filter.Filte
import org.apache.sling.ide.log.Logger;
import org.apache.sling.ide.serialization.SerializationKind;
import org.apache.sling.ide.serialization.SerializationKindManager;
+import org.apache.sling.ide.serialization.SerializationManager;
import org.apache.sling.ide.transport.NodeTypeRegistry;
import org.apache.sling.ide.transport.Repository;
import org.apache.sling.ide.transport.RepositoryException;
@@ -844,6 +845,8 @@ public class JcrNode implements IAdaptab
String thisNodeType = getPrimaryType();
final SerializationKind parentSk =
getSerializationKind(thisNodeType);
final SerializationKind childSk = getSerializationKind(childNodeType);
+
+ final SerializationManager serializationManager =
Activator.getDefault().getSerializationManager();
if (parentSk==SerializationKind.METADATA_FULL) {
createDomChild(childNodeName, childNodeType);
@@ -891,7 +894,7 @@ public class JcrNode implements IAdaptab
}
} else if ((parentSk == SerializationKind.FOLDER || parentSk ==
SerializationKind.METADATA_PARTIAL)
&& childSk == SerializationKind.METADATA_FULL) {
- createVaultFile((IFolder)resource, childNodeName+".xml",
childNodeType);
+ createVaultFile((IFolder) resource,
serializationManager.getOsPath(childNodeName) + ".xml", childNodeType);
} else if (parentSk==SerializationKind.FOLDER &&
childSk==SerializationKind.METADATA_PARTIAL) {
// createVaultFile((IFolder)resource, childNodeName+".xml",
childNodeType);
@@ -901,7 +904,7 @@ public class JcrNode implements IAdaptab
public void run(IProgressMonitor monitor) throws CoreException
{
IFolder f = (IFolder)resource;
IFolder newFolder = null;
- newFolder = f.getFolder(childNodeName);
+ newFolder =
f.getFolder(serializationManager.getOsPath(childNodeName));
newFolder.create(true, true, new NullProgressMonitor());
createVaultFile(newFolder, ".content.xml", childNodeType);
}