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 2013/09/14 23:33:33 UTC
svn commit: r1523331 - in /sling/branches/tooling-ide-vlt/tooling/ide:
api/src/org/apache/sling/ide/serialization/
api/src/org/apache/sling/ide/transport/
eclipse-core/src/org/apache/sling/ide/eclipse/core/internal/
impl-resource-test/src/test/java/org...
Author: rombert
Date: Sat Sep 14 21:33:33 2013
New Revision: 1523331
URL: http://svn.apache.org/r1523331
Log:
SLING-2989 - [Tooling] integrate with vlt once available
The SerializationManager now returns a ResourceProxy instead of a Map
containing the properties. This helps with assigning the correct
repository path and prepares the way in returning all the resources
covered in a docview xml file.
Modified:
sling/branches/tooling-ide-vlt/tooling/ide/api/src/org/apache/sling/ide/serialization/SerializationManager.java
sling/branches/tooling-ide-vlt/tooling/ide/api/src/org/apache/sling/ide/transport/Repository.java
sling/branches/tooling-ide-vlt/tooling/ide/api/src/org/apache/sling/ide/transport/ResourceProxy.java
sling/branches/tooling-ide-vlt/tooling/ide/eclipse-core/src/org/apache/sling/ide/eclipse/core/internal/SlingLaunchpadBehaviour.java
sling/branches/tooling-ide-vlt/tooling/ide/impl-resource-test/src/test/java/org/apache/sling/ide/impl/resource/serialization/SimpleXmlSerializationManagerTest.java
sling/branches/tooling-ide-vlt/tooling/ide/impl-resource/src/org/apache/sling/ide/impl/resource/serialization/SimpleXmlSerializationManager.java
sling/branches/tooling-ide-vlt/tooling/ide/impl-resource/src/org/apache/sling/ide/impl/resource/transport/RepositoryImpl.java
sling/branches/tooling-ide-vlt/tooling/ide/impl-vlt/src/org/apache/sling/ide/impl/vlt/UpdateNodePropertiesCommand.java
sling/branches/tooling-ide-vlt/tooling/ide/impl-vlt/src/org/apache/sling/ide/impl/vlt/VltRepository.java
sling/branches/tooling-ide-vlt/tooling/ide/impl-vlt/src/org/apache/sling/ide/impl/vlt/serialization/VltSerializationManager.java
Modified: sling/branches/tooling-ide-vlt/tooling/ide/api/src/org/apache/sling/ide/serialization/SerializationManager.java
URL: http://svn.apache.org/viewvc/sling/branches/tooling-ide-vlt/tooling/ide/api/src/org/apache/sling/ide/serialization/SerializationManager.java?rev=1523331&r1=1523330&r2=1523331&view=diff
==============================================================================
--- sling/branches/tooling-ide-vlt/tooling/ide/api/src/org/apache/sling/ide/serialization/SerializationManager.java (original)
+++ sling/branches/tooling-ide-vlt/tooling/ide/api/src/org/apache/sling/ide/serialization/SerializationManager.java Sat Sep 14 21:33:33 2013
@@ -19,7 +19,6 @@ package org.apache.sling.ide.serializati
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
-import java.util.Map;
import org.apache.sling.ide.transport.Repository;
import org.apache.sling.ide.transport.RepositoryInfo;
@@ -40,5 +39,5 @@ public interface SerializationManager {
SerializationData buildSerializationData(File contentSyncRoot, ResourceProxy resource, RepositoryInfo repositoryInfo)
throws SerializationException;
- Map<String, Object> readSerializationData(InputStream source) throws IOException;
+ ResourceProxy readSerializationData(String filePath, InputStream source) throws IOException;
}
Modified: sling/branches/tooling-ide-vlt/tooling/ide/api/src/org/apache/sling/ide/transport/Repository.java
URL: http://svn.apache.org/viewvc/sling/branches/tooling-ide-vlt/tooling/ide/api/src/org/apache/sling/ide/transport/Repository.java?rev=1523331&r1=1523330&r2=1523331&view=diff
==============================================================================
--- sling/branches/tooling-ide-vlt/tooling/ide/api/src/org/apache/sling/ide/transport/Repository.java (original)
+++ sling/branches/tooling-ide-vlt/tooling/ide/api/src/org/apache/sling/ide/transport/Repository.java Sat Sep 14 21:33:33 2013
@@ -16,8 +16,6 @@
*/
package org.apache.sling.ide.transport;
-import java.util.Map;
-
public interface Repository {
public static String JCR_PRIMARY_TYPE= "jcr:primaryType";
@@ -85,7 +83,7 @@ public interface Repository {
Command<Void> newAddNodeCommand(FileInfo fileInfo);
- Command<Void> newUpdateContentNodeCommand(FileInfo fileInfo, Map<String, Object> serializationData);
+ Command<Void> newUpdateContentNodeCommand(FileInfo fileInfo, ResourceProxy resourceProxy);
Command<Void> newDeleteNodeCommand(FileInfo fileInfo);
Modified: sling/branches/tooling-ide-vlt/tooling/ide/api/src/org/apache/sling/ide/transport/ResourceProxy.java
URL: http://svn.apache.org/viewvc/sling/branches/tooling-ide-vlt/tooling/ide/api/src/org/apache/sling/ide/transport/ResourceProxy.java?rev=1523331&r1=1523330&r2=1523331&view=diff
==============================================================================
--- sling/branches/tooling-ide-vlt/tooling/ide/api/src/org/apache/sling/ide/transport/ResourceProxy.java (original)
+++ sling/branches/tooling-ide-vlt/tooling/ide/api/src/org/apache/sling/ide/transport/ResourceProxy.java Sat Sep 14 21:33:33 2013
@@ -24,12 +24,17 @@ import java.util.Map;
public class ResourceProxy {
private final String path;
- private final Map<String, Object> properties = new HashMap<String, Object>();
+ private final Map<String, Object> properties;
private final List<ResourceProxy> children = new ArrayList<ResourceProxy>();
private final Map<Class<?>, Object> adapted = new HashMap<Class<?>, Object>(1);
public ResourceProxy(String path) {
+ this(path, new HashMap<String, Object>());
+ }
+
+ public ResourceProxy(String path, Map<String, Object> properties) {
this.path = path;
+ this.properties = properties;
}
public void addChild(ResourceProxy child) {
Modified: sling/branches/tooling-ide-vlt/tooling/ide/eclipse-core/src/org/apache/sling/ide/eclipse/core/internal/SlingLaunchpadBehaviour.java
URL: http://svn.apache.org/viewvc/sling/branches/tooling-ide-vlt/tooling/ide/eclipse-core/src/org/apache/sling/ide/eclipse/core/internal/SlingLaunchpadBehaviour.java?rev=1523331&r1=1523330&r2=1523331&view=diff
==============================================================================
--- sling/branches/tooling-ide-vlt/tooling/ide/eclipse-core/src/org/apache/sling/ide/eclipse/core/internal/SlingLaunchpadBehaviour.java (original)
+++ sling/branches/tooling-ide-vlt/tooling/ide/eclipse-core/src/org/apache/sling/ide/eclipse/core/internal/SlingLaunchpadBehaviour.java Sat Sep 14 21:33:33 2013
@@ -24,8 +24,6 @@ import java.util.Arrays;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
-import java.util.Map;
-
import org.apache.commons.httpclient.Credentials;
import org.apache.commons.httpclient.HttpClient;
@@ -440,9 +438,11 @@ public class SlingLaunchpadBehaviour ext
try {
IFile file = (IFile) resource.getAdapter(IFile.class);
InputStream contents = file.getContents();
- Map<String, Object> serializationData = serializationManager(repository, syncDirectoryAsFile)
- .readSerializationData(contents);
- return repository.newUpdateContentNodeCommand(info, serializationData);
+ IFolder syncDirectory = ProjectUtil.getSyncDirectory(res.getProject());
+ String resourceLocation = file.getFullPath().makeRelativeTo(syncDirectory.getFullPath()).toOSString();
+ ResourceProxy resourceProxy = serializationManager(repository, syncDirectoryAsFile)
+ .readSerializationData(resourceLocation, contents);
+ return repository.newUpdateContentNodeCommand(info, resourceProxy);
} catch (IOException e) {
// TODO logging
e.printStackTrace();
Modified: sling/branches/tooling-ide-vlt/tooling/ide/impl-resource-test/src/test/java/org/apache/sling/ide/impl/resource/serialization/SimpleXmlSerializationManagerTest.java
URL: http://svn.apache.org/viewvc/sling/branches/tooling-ide-vlt/tooling/ide/impl-resource-test/src/test/java/org/apache/sling/ide/impl/resource/serialization/SimpleXmlSerializationManagerTest.java?rev=1523331&r1=1523330&r2=1523331&view=diff
==============================================================================
--- sling/branches/tooling-ide-vlt/tooling/ide/impl-resource-test/src/test/java/org/apache/sling/ide/impl/resource/serialization/SimpleXmlSerializationManagerTest.java (original)
+++ sling/branches/tooling-ide-vlt/tooling/ide/impl-resource-test/src/test/java/org/apache/sling/ide/impl/resource/serialization/SimpleXmlSerializationManagerTest.java Sat Sep 14 21:33:33 2013
@@ -108,7 +108,7 @@ public class SimpleXmlSerializationManag
public void readSerializedData() throws IOException, SAXException {
Map<String, Object> serializationData = sm
- .readSerializationData(readSerializationDataFile("stringSerializedData"));
+ .readSerializationData(null, readSerializationDataFile("stringSerializedData")).getProperties();
Map<String, Object> expected = new HashMap<String, Object>();
expected.put("jcr:createdBy", "admin");
Modified: sling/branches/tooling-ide-vlt/tooling/ide/impl-resource/src/org/apache/sling/ide/impl/resource/serialization/SimpleXmlSerializationManager.java
URL: http://svn.apache.org/viewvc/sling/branches/tooling-ide-vlt/tooling/ide/impl-resource/src/org/apache/sling/ide/impl/resource/serialization/SimpleXmlSerializationManager.java?rev=1523331&r1=1523330&r2=1523331&view=diff
==============================================================================
--- sling/branches/tooling-ide-vlt/tooling/ide/impl-resource/src/org/apache/sling/ide/impl/resource/serialization/SimpleXmlSerializationManager.java (original)
+++ sling/branches/tooling-ide-vlt/tooling/ide/impl-resource/src/org/apache/sling/ide/impl/resource/serialization/SimpleXmlSerializationManager.java Sat Sep 14 21:33:33 2013
@@ -78,7 +78,7 @@ public class SimpleXmlSerializationManag
}
@Override
- public Map<String, Object> readSerializationData(InputStream source) throws IOException {
+ public ResourceProxy readSerializationData(String filePath, InputStream source) throws IOException {
try {
SAXParserFactory factory = SAXParserFactory.newInstance();
@@ -88,7 +88,7 @@ public class SimpleXmlSerializationManag
saxParser.parse(new InputSource(source), h);
- return h.getResult();
+ return new ResourceProxy(filePath, h.getResult());
} catch (ParserConfigurationException e) {
// TODO proper exception handling
throw new RuntimeException(e);
Modified: sling/branches/tooling-ide-vlt/tooling/ide/impl-resource/src/org/apache/sling/ide/impl/resource/transport/RepositoryImpl.java
URL: http://svn.apache.org/viewvc/sling/branches/tooling-ide-vlt/tooling/ide/impl-resource/src/org/apache/sling/ide/impl/resource/transport/RepositoryImpl.java?rev=1523331&r1=1523330&r2=1523331&view=diff
==============================================================================
--- sling/branches/tooling-ide-vlt/tooling/ide/impl-resource/src/org/apache/sling/ide/impl/resource/transport/RepositoryImpl.java (original)
+++ sling/branches/tooling-ide-vlt/tooling/ide/impl-resource/src/org/apache/sling/ide/impl/resource/transport/RepositoryImpl.java Sat Sep 14 21:33:33 2013
@@ -16,8 +16,6 @@
*/
package org.apache.sling.ide.impl.resource.transport;
-import java.util.Map;
-
import org.apache.commons.httpclient.HttpClient;
import org.apache.sling.ide.transport.Command;
import org.apache.sling.ide.transport.FileInfo;
@@ -62,9 +60,10 @@ public class RepositoryImpl extends Abst
}
@Override
- public Command<Void> newUpdateContentNodeCommand(final FileInfo fileInfo, final Map<String, Object> properties) {
+ public Command<Void> newUpdateContentNodeCommand(final FileInfo fileInfo, ResourceProxy resource) {
- return wrap(new UpdateContentCommand(repositoryInfo, httpClient, fileInfo.getRelativeLocation(), properties, fileInfo));
+ return wrap(new UpdateContentCommand(repositoryInfo, httpClient, fileInfo.getRelativeLocation(),
+ resource.getProperties(), fileInfo));
}
public void bindEventAdmin(EventAdmin eventAdmin) {
Modified: sling/branches/tooling-ide-vlt/tooling/ide/impl-vlt/src/org/apache/sling/ide/impl/vlt/UpdateNodePropertiesCommand.java
URL: http://svn.apache.org/viewvc/sling/branches/tooling-ide-vlt/tooling/ide/impl-vlt/src/org/apache/sling/ide/impl/vlt/UpdateNodePropertiesCommand.java?rev=1523331&r1=1523330&r2=1523331&view=diff
==============================================================================
--- sling/branches/tooling-ide-vlt/tooling/ide/impl-vlt/src/org/apache/sling/ide/impl/vlt/UpdateNodePropertiesCommand.java (original)
+++ sling/branches/tooling-ide-vlt/tooling/ide/impl-vlt/src/org/apache/sling/ide/impl/vlt/UpdateNodePropertiesCommand.java Sat Sep 14 21:33:33 2013
@@ -34,22 +34,19 @@ import javax.jcr.Session;
import javax.jcr.Value;
import javax.jcr.ValueFactory;
-import org.apache.jackrabbit.vault.util.PathUtil;
-import org.apache.jackrabbit.vault.util.PlatformNameFormat;
import org.apache.sling.ide.transport.FileInfo;
+import org.apache.sling.ide.transport.ResourceProxy;
public class UpdateNodePropertiesCommand extends JcrCommand<Void> {
private final Map<String, Object> serializationData;
public UpdateNodePropertiesCommand(Repository jcrRepo, Credentials credentials, FileInfo fileInfo,
- Map<String, Object> serializationData) {
+ ResourceProxy resource) {
- // TODO - won't support serialization of full coverage nodes
- super(jcrRepo, credentials, PlatformNameFormat.getRepositoryPath(PathUtil.makePath(
- fileInfo.getRelativeLocation(), "")));
+ super(jcrRepo, credentials, resource.getPath());
- this.serializationData = serializationData;
+ this.serializationData = resource.getProperties();
}
@Override
Modified: sling/branches/tooling-ide-vlt/tooling/ide/impl-vlt/src/org/apache/sling/ide/impl/vlt/VltRepository.java
URL: http://svn.apache.org/viewvc/sling/branches/tooling-ide-vlt/tooling/ide/impl-vlt/src/org/apache/sling/ide/impl/vlt/VltRepository.java?rev=1523331&r1=1523330&r2=1523331&view=diff
==============================================================================
--- sling/branches/tooling-ide-vlt/tooling/ide/impl-vlt/src/org/apache/sling/ide/impl/vlt/VltRepository.java (original)
+++ sling/branches/tooling-ide-vlt/tooling/ide/impl-vlt/src/org/apache/sling/ide/impl/vlt/VltRepository.java Sat Sep 14 21:33:33 2013
@@ -1,7 +1,5 @@
package org.apache.sling.ide.impl.vlt;
-import java.util.Map;
-
import javax.jcr.Credentials;
import javax.jcr.RepositoryException;
@@ -52,9 +50,9 @@ public class VltRepository implements Re
}
@Override
- public Command<Void> newUpdateContentNodeCommand(FileInfo fileInfo, Map<String, Object> serializationData) {
+ public Command<Void> newUpdateContentNodeCommand(FileInfo fileInfo, ResourceProxy resource) {
// TODO implement
- return TracingCommand.wrap(new UpdateNodePropertiesCommand(jcrRepo, credentials, fileInfo, serializationData),
+ return TracingCommand.wrap(new UpdateNodePropertiesCommand(jcrRepo, credentials, fileInfo, resource),
eventAdmin);
}
Modified: sling/branches/tooling-ide-vlt/tooling/ide/impl-vlt/src/org/apache/sling/ide/impl/vlt/serialization/VltSerializationManager.java
URL: http://svn.apache.org/viewvc/sling/branches/tooling-ide-vlt/tooling/ide/impl-vlt/src/org/apache/sling/ide/impl/vlt/serialization/VltSerializationManager.java?rev=1523331&r1=1523330&r2=1523331&view=diff
==============================================================================
--- sling/branches/tooling-ide-vlt/tooling/ide/impl-vlt/src/org/apache/sling/ide/impl/vlt/serialization/VltSerializationManager.java (original)
+++ sling/branches/tooling-ide-vlt/tooling/ide/impl-vlt/src/org/apache/sling/ide/impl/vlt/serialization/VltSerializationManager.java Sat Sep 14 21:33:33 2013
@@ -25,7 +25,6 @@ import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URISyntaxException;
-import java.util.Map;
import javax.jcr.Credentials;
import javax.jcr.Node;
@@ -68,6 +67,8 @@ import org.xml.sax.SAXException;
public class VltSerializationManager implements SerializationManager {
+ private static final String EXTENSION_XML = ".xml";
+
public static void main(String[] args) throws RepositoryException, URISyntaxException, IOException {
RepositoryAddress address = new RepositoryAddress("http://localhost:8080/server/root");
Repository repo = new RepositoryProvider().getRepository(address);
@@ -85,7 +86,7 @@ public class VltSerializationManager imp
for (String attempt : attempts) {
- attempt = PlatformNameFormat.getPlatformPath(attempt) + ".xml";
+ attempt = PlatformNameFormat.getPlatformPath(attempt) + EXTENSION_XML;
VaultFile vaultFile = fs.getFile(attempt);
@@ -123,7 +124,7 @@ public class VltSerializationManager imp
return true;
}
- if (!fileName.endsWith(".xml")) {
+ if (!fileName.endsWith(EXTENSION_XML)) {
return false;
}
@@ -201,7 +202,7 @@ public class VltSerializationManager imp
if (vaultFile == null) {
// TODO - not sure why we need to try both ... not a performance impact but ugly nonetheless
- platformPath = PlatformNameFormat.getPlatformPath(resource.getPath()) + ".xml";
+ platformPath = PlatformNameFormat.getPlatformPath(resource.getPath()) + EXTENSION_XML;
vaultFile = fs.getFile(platformPath);
if (vaultFile == null) {
@@ -288,11 +289,31 @@ public class VltSerializationManager imp
}
@Override
- public Map<String, Object> readSerializationData(InputStream source) throws IOException {
+ public ResourceProxy readSerializationData(String filePath, InputStream source) throws IOException {
if (source == null)
return null;
+ String repositoryPath;
+ File file = new File(filePath);
+ if (file.getName().equals(Constants.DOT_CONTENT_XML)) {
+ repositoryPath = PlatformNameFormat.getRepositoryPath(file.getParent());
+ } 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 = "/";
+ }
+
try {
SAXParserFactory factory = SAXParserFactory.newInstance();
factory.setNamespaceAware(true);
@@ -301,7 +322,7 @@ public class VltSerializationManager imp
ContentXmlHandler handler = new ContentXmlHandler();
parser.parse(source, handler);
- return handler.getProperties();
+ return new ResourceProxy(repositoryPath, handler.getProperties());
} catch (SAXException e) {
// TODO proper error handling
throw new IOException(e);