Author: rombert
Date: Wed Jul 24 11:27:45 2013
New Revision: 1506501
URL: http://svn.apache.org/r1506501
Log:
SLING-2973 - [Tooling] Align Eclipse tooling to proposed structure
Remove the need to parse JSON when working with the Repository. The
repository implementations are now responsible for parsing the data into
a proper format.
Added:
sling/whiteboard/asanso/plugins/eclipse/api/src/org/apache/sling/ide/transport/ResourceProxy.java
(with props)
sling/whiteboard/asanso/plugins/eclipse/impl-resource-test/
sling/whiteboard/asanso/plugins/eclipse/impl-resource-test/pom.xml (with
props)
sling/whiteboard/asanso/plugins/eclipse/impl-resource-test/src/
sling/whiteboard/asanso/plugins/eclipse/impl-resource-test/src/test/
sling/whiteboard/asanso/plugins/eclipse/impl-resource-test/src/test/java/
sling/whiteboard/asanso/plugins/eclipse/impl-resource-test/src/test/java/org/
sling/whiteboard/asanso/plugins/eclipse/impl-resource-test/src/test/java/org/apache/
sling/whiteboard/asanso/plugins/eclipse/impl-resource-test/src/test/java/org/apache/sling/
sling/whiteboard/asanso/plugins/eclipse/impl-resource-test/src/test/java/org/apache/sling/ide/
sling/whiteboard/asanso/plugins/eclipse/impl-resource-test/src/test/java/org/apache/sling/ide/impl/
sling/whiteboard/asanso/plugins/eclipse/impl-resource-test/src/test/java/org/apache/sling/ide/impl/resource/
sling/whiteboard/asanso/plugins/eclipse/impl-resource-test/src/test/java/org/apache/sling/ide/impl/resource/serialization/
sling/whiteboard/asanso/plugins/eclipse/impl-resource-test/src/test/java/org/apache/sling/ide/impl/resource/serialization/SimpleXmlSerializationManagerTest.java
(with props)
sling/whiteboard/asanso/plugins/eclipse/impl-resource-test/src/test/resources/
sling/whiteboard/asanso/plugins/eclipse/impl-resource-test/src/test/resources/org/
sling/whiteboard/asanso/plugins/eclipse/impl-resource-test/src/test/resources/org/apache/
sling/whiteboard/asanso/plugins/eclipse/impl-resource-test/src/test/resources/org/apache/sling/
sling/whiteboard/asanso/plugins/eclipse/impl-resource-test/src/test/resources/org/apache/sling/ide/
sling/whiteboard/asanso/plugins/eclipse/impl-resource-test/src/test/resources/org/apache/sling/ide/impl/
sling/whiteboard/asanso/plugins/eclipse/impl-resource-test/src/test/resources/org/apache/sling/ide/impl/resource/
sling/whiteboard/asanso/plugins/eclipse/impl-resource-test/src/test/resources/org/apache/sling/ide/impl/resource/serialization/
sling/whiteboard/asanso/plugins/eclipse/impl-resource-test/src/test/resources/org/apache/sling/ide/impl/resource/serialization/SimpleXmlSerializationManagerTest.serializedDataIsEscaped.xml
(with props)
sling/whiteboard/asanso/plugins/eclipse/impl-resource-test/src/test/resources/org/apache/sling/ide/impl/resource/serialization/SimpleXmlSerializationManagerTest.stringSerializedData.xml
(with props)
Removed:
sling/whiteboard/asanso/plugins/eclipse/api/src/org/apache/sling/ide/transport/ResponseType.java
Modified:
sling/whiteboard/asanso/plugins/eclipse/api/src/org/apache/sling/ide/serialization/SerializationManager.java
sling/whiteboard/asanso/plugins/eclipse/api/src/org/apache/sling/ide/transport/Repository.java
sling/whiteboard/asanso/plugins/eclipse/eclipse-core/src/org/apache/sling/ide/eclipse/core/internal/SlingLaunchpadBehaviour.java
sling/whiteboard/asanso/plugins/eclipse/eclipse-ui/META-INF/MANIFEST.MF
sling/whiteboard/asanso/plugins/eclipse/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/internal/ImportWizard.java
sling/whiteboard/asanso/plugins/eclipse/impl-resource/src/org/apache/sling/ide/impl/resource/filer/SimpleFilter.java
sling/whiteboard/asanso/plugins/eclipse/impl-resource/src/org/apache/sling/ide/impl/resource/serialization/SimpleXmlSerializationManager.java
sling/whiteboard/asanso/plugins/eclipse/impl-resource/src/org/apache/sling/ide/impl/resource/transport/RepositoryImpl.java
sling/whiteboard/asanso/plugins/eclipse/pom.xml
Modified:
sling/whiteboard/asanso/plugins/eclipse/api/src/org/apache/sling/ide/serialization/SerializationManager.java
URL:
http://svn.apache.org/viewvc/sling/whiteboard/asanso/plugins/eclipse/api/src/org/apache/sling/ide/serialization/SerializationManager.java?rev=1506501&r1=1506500&r2=1506501&view=diff
==============================================================================
---
sling/whiteboard/asanso/plugins/eclipse/api/src/org/apache/sling/ide/serialization/SerializationManager.java
(original)
+++
sling/whiteboard/asanso/plugins/eclipse/api/src/org/apache/sling/ide/serialization/SerializationManager.java
Wed Jul 24 11:27:45 2013
@@ -18,16 +18,17 @@ package org.apache.sling.ide.serializati
import java.io.IOException;
import java.io.InputStream;
-import java.io.OutputStream;
import java.util.Map;
public interface SerializationManager {
boolean isSerializationFile(String filePath);
+ String getBaseResourcePath(String serializationFilePath);
+
String getSerializationFilePath(String baseFilePath);
- void writeSerializationData(OutputStream destination, Map<String, String>
data) throws IOException;
+ String buildSerializationData(Map<String, Object> content) throws
IOException;
- Map<String, String> readSerializationData(InputStream source) throws
IOException;
+ Map<String, Object> readSerializationData(InputStream source) throws
IOException;
}
Modified:
sling/whiteboard/asanso/plugins/eclipse/api/src/org/apache/sling/ide/transport/Repository.java
URL:
http://svn.apache.org/viewvc/sling/whiteboard/asanso/plugins/eclipse/api/src/org/apache/sling/ide/transport/Repository.java?rev=1506501&r1=1506500&r2=1506501&view=diff
==============================================================================
---
sling/whiteboard/asanso/plugins/eclipse/api/src/org/apache/sling/ide/transport/Repository.java
(original)
+++
sling/whiteboard/asanso/plugins/eclipse/api/src/org/apache/sling/ide/transport/Repository.java
Wed Jul 24 11:27:45 2013
@@ -83,13 +83,13 @@ public interface Repository {
Command<Void> newAddNodeCommand(FileInfo fileInfo);
- Command<Void> newUpdateContentNodeCommand(FileInfo
fileInfo,Map<String,String> properties);
+ Command<Void> newUpdateContentNodeCommand(FileInfo fileInfo, Map<String,
Object> serializationData);
Command<Void> newDeleteNodeCommand(FileInfo fileInfo);
- Command<String> newListChildrenNodeCommand(String path,ResponseType
responseType);
+ Command<ResourceProxy> newListChildrenNodeCommand(String path);
- Command<String> newGetNodeContentCommand(String path,ResponseType
responseType);
+ Command<Map<String, Object>> newGetNodeContentCommand(String path);
Command<byte[]> newGetNodeCommand(String path);
}
Added:
sling/whiteboard/asanso/plugins/eclipse/api/src/org/apache/sling/ide/transport/ResourceProxy.java
URL:
http://svn.apache.org/viewvc/sling/whiteboard/asanso/plugins/eclipse/api/src/org/apache/sling/ide/transport/ResourceProxy.java?rev=1506501&view=auto
==============================================================================
---
sling/whiteboard/asanso/plugins/eclipse/api/src/org/apache/sling/ide/transport/ResourceProxy.java
(added)
+++
sling/whiteboard/asanso/plugins/eclipse/api/src/org/apache/sling/ide/transport/ResourceProxy.java
Wed Jul 24 11:27:45 2013
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sling.ide.transport;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class ResourceProxy {
+
+ private final String path;
+ private final Map<String, Object> properties = new HashMap<String,
Object>();
+ private final List<ResourceProxy> children = new
ArrayList<ResourceProxy>();
+
+ public ResourceProxy(String path) {
+ this.path = path;
+ }
+
+ public void addChild(ResourceProxy child) {
+
+ this.children.add(child);
+ }
+
+ public void addProperty(String name, Object value) {
+
+ this.properties.put(name, value);
+ }
+
+ public String getPath() {
+ return path;
+ }
+
+ public List<ResourceProxy> getChildren() {
+ return children;
+ }
+
+ public Map<String, Object> getProperties() {
+ return properties;
+ }
+
+
+ @Override
+ public String toString() {
+ StringBuilder out = new StringBuilder();
+ out.append('[').append(getClass().getSimpleName()).append(":
path=").append(path).append(", properties=")
+ .append(properties);
+ for (ResourceProxy child : children) {
+ out.append("\n- ").append(child);
+ }
+ out.append("\n]");
+
+ return out.toString();
+ }
+}
Propchange:
sling/whiteboard/asanso/plugins/eclipse/api/src/org/apache/sling/ide/transport/ResourceProxy.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
sling/whiteboard/asanso/plugins/eclipse/api/src/org/apache/sling/ide/transport/ResourceProxy.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision Rev URL
Modified:
sling/whiteboard/asanso/plugins/eclipse/eclipse-core/src/org/apache/sling/ide/eclipse/core/internal/SlingLaunchpadBehaviour.java
URL:
http://svn.apache.org/viewvc/sling/whiteboard/asanso/plugins/eclipse/eclipse-core/src/org/apache/sling/ide/eclipse/core/internal/SlingLaunchpadBehaviour.java?rev=1506501&r1=1506500&r2=1506501&view=diff
==============================================================================
---
sling/whiteboard/asanso/plugins/eclipse/eclipse-core/src/org/apache/sling/ide/eclipse/core/internal/SlingLaunchpadBehaviour.java
(original)
+++
sling/whiteboard/asanso/plugins/eclipse/eclipse-core/src/org/apache/sling/ide/eclipse/core/internal/SlingLaunchpadBehaviour.java
Wed Jul 24 11:27:45 2013
@@ -31,7 +31,7 @@ import org.apache.sling.ide.serializatio
import org.apache.sling.ide.transport.Command;
import org.apache.sling.ide.transport.FileInfo;
import org.apache.sling.ide.transport.Repository;
-import org.apache.sling.ide.transport.ResponseType;
+import org.apache.sling.ide.transport.ResourceProxy;
import org.apache.sling.ide.transport.Result;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
@@ -65,9 +65,8 @@ public class SlingLaunchpadBehaviour ext
boolean success = false;
- Result<String> result = null;
- Command<String> command = ServerUtil.getRepository(getServer(),
monitor).newListChildrenNodeCommand("/", ResponseType.XML);
- result = command.execute();
+ Command<ResourceProxy> command = ServerUtil.getRepository(getServer(),
monitor).newListChildrenNodeCommand("/");
+ Result<ResourceProxy> result = command.execute();
success = result.isSuccess();
if (success) {
@@ -230,7 +229,7 @@ public class SlingLaunchpadBehaviour ext
try {
IFile file = (IFile) resource.getAdapter(IFile.class);
InputStream contents = file.getContents();
- Map<String, String> serializationData =
serializationManager().readSerializationData(contents);
+ Map<String, Object> serializationData =
serializationManager().readSerializationData(contents);
return repository.newUpdateContentNodeCommand(info,
serializationData);
} catch (IOException e) {
// TODO logging
@@ -269,7 +268,7 @@ public class SlingLaunchpadBehaviour ext
}
if (filter != null) {
- FilterResult filterResult =
filter.filter(resource.getModuleRelativePath().toString());
+ FilterResult filterResult = getFilterResult(resource, filter);
if (filterResult == FilterResult.DENY) {
return null;
}
@@ -284,6 +283,18 @@ public class SlingLaunchpadBehaviour ext
return info;
}
+ private FilterResult getFilterResult(IModuleResource resource, Filter
filter) {
+
+ String filePath = resource.getModuleRelativePath().toOSString();
+ if (serializationManager().isSerializationFile(filePath)) {
+ filePath = serializationManager.getBaseResourcePath(filePath);
+ }
+
+ System.out.println("Filtering by " + filePath + " for " + resource);
+
+ return filter.filter(filePath);
+ }
+
private Command<?> removeFileCommand(Repository repository,
IModuleResource resource) {
FileInfo info = createFileInfo(resource);
@@ -320,7 +331,6 @@ public class SlingLaunchpadBehaviour ext
return filter;
}
-
private SerializationManager serializationManager() {
if (serializationManager == null) {
serializationManager =
Activator.getDefault().getSerializationManager();
Modified:
sling/whiteboard/asanso/plugins/eclipse/eclipse-ui/META-INF/MANIFEST.MF
URL:
http://svn.apache.org/viewvc/sling/whiteboard/asanso/plugins/eclipse/eclipse-ui/META-INF/MANIFEST.MF?rev=1506501&r1=1506500&r2=1506501&view=diff
==============================================================================
--- sling/whiteboard/asanso/plugins/eclipse/eclipse-ui/META-INF/MANIFEST.MF
(original)
+++ sling/whiteboard/asanso/plugins/eclipse/eclipse-ui/META-INF/MANIFEST.MF Wed
Jul 24 11:27:45 2013
@@ -46,7 +46,6 @@ Import-Package: org.apache.sling.ide.ecl
org.eclipse.wst.server.core.util,
org.eclipse.wst.server.ui,
org.eclipse.wst.server.ui.editor,
- org.json,
org.osgi.framework,
org.osgi.util.tracker;version="1.5.0"
Bundle-ActivationPolicy: lazy
Modified:
sling/whiteboard/asanso/plugins/eclipse/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/internal/ImportWizard.java
URL:
http://svn.apache.org/viewvc/sling/whiteboard/asanso/plugins/eclipse/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/internal/ImportWizard.java?rev=1506501&r1=1506500&r2=1506501&view=diff
==============================================================================
---
sling/whiteboard/asanso/plugins/eclipse/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/internal/ImportWizard.java
(original)
+++
sling/whiteboard/asanso/plugins/eclipse/eclipse-ui/src/org/apache/sling/ide/eclipse/ui/internal/ImportWizard.java
Wed Jul 24 11:27:45 2013
@@ -20,8 +20,7 @@ import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.InvocationTargetException;
-import java.nio.charset.Charset;
-import java.util.Iterator;
+import java.util.Map;
import org.apache.sling.ide.eclipse.core.ISlingLaunchpadServer;
import org.apache.sling.ide.eclipse.core.ServerUtil;
@@ -32,12 +31,13 @@ import org.apache.sling.ide.serializatio
import org.apache.sling.ide.transport.Command;
import org.apache.sling.ide.transport.Repository;
import org.apache.sling.ide.transport.RepositoryException;
-import org.apache.sling.ide.transport.ResponseType;
+import org.apache.sling.ide.transport.ResourceProxy;
import org.apache.sling.ide.transport.Result;
import org.apache.sling.ide.util.PathUtil;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
@@ -49,9 +49,6 @@ import org.eclipse.jface.wizard.Wizard;
import org.eclipse.ui.IImportWizard;
import org.eclipse.ui.IWorkbench;
import org.eclipse.wst.server.core.IServer;
-import org.json.JSONException;
-import org.json.JSONML;
-import org.json.JSONObject;
/**
* Renders the import wizard container page for the Slingclipse repository
@@ -205,7 +202,7 @@ public class ImportWizard extends Wizard
createFolder(project, rootImportPath.removeLastSegments(i));
}
- /**
+ /**
* Crawls the repository and recursively imports founds resources
*
* @param repository the sling repository to import from
@@ -217,18 +214,17 @@ public class ImportWizard extends Wizard
* @throws JSONException
* @throws RepositoryException
* @throws CoreException
+ * @throws IOException
*/
// TODO: This probably should be pushed into the service layer
private void crawlChildrenAndImport(Repository repository, Filter filter,
String path, IProject project,
- IPath projectRelativePath)
- throws JSONException, RepositoryException, CoreException {
+ IPath projectRelativePath) throws RepositoryException,
CoreException, IOException {
System.out.println("crawlChildrenAndImport(" + repository + ", " +
path + ", " + project + ", "
+ projectRelativePath + ")");
- String children =
executeCommand(repository.newListChildrenNodeCommand(path, ResponseType.JSON));
- JSONObject json = new JSONObject(children);
- String primaryType= json.optString(Repository.JCR_PRIMARY_TYPE);
+ ResourceProxy resource =
executeCommand(repository.newListChildrenNodeCommand(path));
+ String primaryType = (String)
resource.getProperties().get(Repository.JCR_PRIMARY_TYPE);
if (Repository.NT_FILE.equals(primaryType)){
importFile(repository, path, project, projectRelativePath);
@@ -238,26 +234,26 @@ public class ImportWizard extends Wizard
//DO NOTHING
} else {
createFolder(project, projectRelativePath.append(path));
- String content =
executeCommand(repository.newGetNodeContentCommand(path, ResponseType.JSON));
- JSONObject jsonContent = new JSONObject(content);
- jsonContent.put("tagName", Repository.JCR_ROOT); // TODO this is
required by JSONML, not sure why
- String contentXml = JSONML.toString(jsonContent);
- createFile(project,
projectRelativePath.append(serializationManager.getSerializationFilePath(path)),
- contentXml.getBytes(Charset.forName("UTF-8") /* TODO is
this enough? */));
+ Map<String, Object> content =
executeCommand(repository.newGetNodeContentCommand(path));
+
+ String out = serializationManager.buildSerializationData(content);
+ if (out != null) {
+ createFile(project,
projectRelativePath.append(serializationManager.getSerializationFilePath(path)),
+ out.getBytes("UTF-8"));
+ }
}
-
- for (Iterator<?> keys = json.keys(); keys.hasNext();) {
- String key = (String) keys.next();
+
+ for (ResourceProxy child : resource.getChildren()) {
+
if (filter != null) {
- FilterResult filterResult = filter.filter(key);
+ FilterResult filterResult = filter.filter(child.getPath());
if (filterResult == FilterResult.DENY) {
continue;
}
}
- JSONObject innerjson=json.optJSONObject(key);
- if (innerjson!=null){
- crawlChildrenAndImport(repository, filter, PathUtil.join(path,
key), project, projectRelativePath);
- }
+
+ crawlChildrenAndImport(repository, filter, PathUtil.join(path,
child.getPath()), project,
+ projectRelativePath);
}
}
@@ -268,7 +264,7 @@ public class ImportWizard extends Wizard
}
private void importFile(Repository repository, String path, IProject
project, IPath destinationPath)
- throws JSONException, RepositoryException, CoreException {
+ throws RepositoryException, CoreException {
System.out.println("importFile: " + path + " -> " + destinationPath);
@@ -285,12 +281,15 @@ public class ImportWizard extends Wizard
destinationFolder.create(true, true, null /* TODO progress
monitor */);
}
- private void createFile(IProject project, IPath path, byte[] node)
throws CoreException {
+ private void createFile(IProject project, IPath path, byte[] node) throws
CoreException {
IFile destinationFile = project.getFile(path);
- if ( destinationFile.exists() )
- return;
-
- destinationFile.create(new ByteArrayInputStream(node), true,
null /* TODO progress monitor */);
+ if ( destinationFile.exists() ) {
+ /* TODO progress monitor */
+ destinationFile.setContents(new ByteArrayInputStream(node),
IResource.KEEP_HISTORY, null);
+ } else {
+ /* TODO progress monitor */
+ destinationFile.create(new ByteArrayInputStream(node), true, null);
+ }
}
}
Added: sling/whiteboard/asanso/plugins/eclipse/impl-resource-test/pom.xml
URL:
http://svn.apache.org/viewvc/sling/whiteboard/asanso/plugins/eclipse/impl-resource-test/pom.xml?rev=1506501&view=auto
==============================================================================
--- sling/whiteboard/asanso/plugins/eclipse/impl-resource-test/pom.xml (added)
+++ sling/whiteboard/asanso/plugins/eclipse/impl-resource-test/pom.xml Wed Jul
24 11:27:45 2013
@@ -0,0 +1,59 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.sling.ide</groupId>
+ <artifactId>reactor</artifactId>
+ <version>0.0.1-SNAPSHOT</version>
+ </parent>
+ <artifactId>org.apache.sling.ide.impl-resource-test</artifactId>
+ <name>Sling IDE Tools: Resource-based Implementation Tests</name>
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.sling.ide</groupId>
+ <artifactId>org.apache.sling.ide.impl-resource</artifactId>
+ <version>${project.version}</version>
+ <type>eclipse-plugin</type>
+ </dependency>
+ <!--
+ we need to pull in all transitive dependencies of the impl-resource
+ bundle, since they are not exposed by Tycho(?)
+ -->
+ <dependency>
+ <groupId>org.apache.sling.ide</groupId>
+ <artifactId>org.apache.sling.ide.api</artifactId>
+ <version>${project.version}</version>
+ <type>eclipse-plugin</type>
+ </dependency>
+ <dependency>
+ <groupId>org.json</groupId>
+ <artifactId>json</artifactId>
+ <version>20090211</version>
+ </dependency>
+ <dependency>
+ <groupId>xmlunit</groupId>
+ <artifactId>xmlunit</artifactId>
+ <version>1.4</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <!-- Tycho targets 1.6 by default, so we need that as well -->
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
\ No newline at end of file
Propchange: sling/whiteboard/asanso/plugins/eclipse/impl-resource-test/pom.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: sling/whiteboard/asanso/plugins/eclipse/impl-resource-test/pom.xml
------------------------------------------------------------------------------
svn:mime-type = text/xml
Added:
sling/whiteboard/asanso/plugins/eclipse/impl-resource-test/src/test/java/org/apache/sling/ide/impl/resource/serialization/SimpleXmlSerializationManagerTest.java
URL:
http://svn.apache.org/viewvc/sling/whiteboard/asanso/plugins/eclipse/impl-resource-test/src/test/java/org/apache/sling/ide/impl/resource/serialization/SimpleXmlSerializationManagerTest.java?rev=1506501&view=auto
==============================================================================
---
sling/whiteboard/asanso/plugins/eclipse/impl-resource-test/src/test/java/org/apache/sling/ide/impl/resource/serialization/SimpleXmlSerializationManagerTest.java
(added)
+++
sling/whiteboard/asanso/plugins/eclipse/impl-resource-test/src/test/java/org/apache/sling/ide/impl/resource/serialization/SimpleXmlSerializationManagerTest.java
Wed Jul 24 11:27:45 2013
@@ -0,0 +1,143 @@
+package org.apache.sling.ide.impl.resource.serialization;
+
+import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual;
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.nullValue;
+import static org.junit.Assert.assertThat;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.StringReader;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.custommonkey.xmlunit.XMLUnit;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+
+public class SimpleXmlSerializationManagerTest {
+
+ private SimpleXmlSerializationManager sm;
+
+ @BeforeClass
+ public static void configureXmlUnit() {
+ XMLUnit.setIgnoreWhitespace(true);
+ }
+
+ @Before
+ public void prepare() {
+ sm = new SimpleXmlSerializationManager();
+ }
+
+ @Test
+ public void emptySerializedData() throws IOException, SAXException {
+
+ String serializationData = sm.buildSerializationData(new
HashMap<String, Object>());
+
+ assertThat(serializationData, is(nullValue()));
+ }
+
+ @Test
+ public void nullSerializedData() throws IOException, SAXException {
+
+ String serializationData = sm.buildSerializationData(null);
+
+ assertThat(serializationData, is(nullValue()));
+ }
+
+ @Test
+ public void stringSerializedData() throws IOException, SAXException {
+
+ Map<String, Object> data = new HashMap<String, Object>();
+ data.put("jcr:createdBy", "admin");
+ data.put("jcr:lastModifiedBy", "author");
+
+ String serializationData = sm.buildSerializationData(data);
+
+ String methodName = "stringSerializedData";
+
+ assertXmlOutputIsEqualTo(serializationData, methodName);
+ }
+
+ private void assertXmlOutputIsEqualTo(String serializationData, String
methodName) throws SAXException, IOException {
+
+ InputStream doc = readSerializationDataFile(methodName);
+
+ assertXMLEqual(new InputSource(doc), new InputSource(new
StringReader(serializationData)));
+ }
+
+ private InputStream readSerializationDataFile(String methodName) {
+ String name = getClass().getSimpleName() + "." + methodName + ".xml";
+ InputStream doc = getClass().getResourceAsStream(name);
+ if (doc == null)
+ throw new RuntimeException("No test file found for '" + methodName
+ "'");
+ return doc;
+ }
+
+ @Test
+ public void serializedDataIsEscaped() throws IOException, SAXException {
+
+ Map<String, Object> data = new HashMap<String, Object>();
+ data.put("jcr:description", "<p class=\"active\">Welcome</p>");
+
+ String serializationData = sm.buildSerializationData(data);
+
+ String methodName = "serializedDataIsEscaped";
+
+ assertXmlOutputIsEqualTo(serializationData, methodName);
+ }
+
+ @Test
+ public void readSerializedData() throws IOException, SAXException {
+
+ Map<String, Object> serializationData = sm
+
.readSerializationData(readSerializationDataFile("stringSerializedData"));
+
+ Map<String, Object> expected = new HashMap<String, Object>();
+ expected.put("jcr:createdBy", "admin");
+ expected.put("jcr:lastModifiedBy", "author");
+
+ assertThat(serializationData, is(expected));
+ }
+
+ @Test
+ public void serializationFileMatches() {
+
+ assertThat(sm.isSerializationFile(".content.xml"), is(true));
+
+ }
+
+ @Test
+ public void serializationFileDoesNotMatch() {
+
+ assertThat(sm.isSerializationFile("content.json"), is(false));
+
+ }
+
+ @Test
+ public void serializationFileLocation() {
+
+ String serializationFilePath = sm.getSerializationFilePath("jcr_root");
+
+ assertThat(serializationFilePath, is("jcr_root" + File.separatorChar +
".content.xml"));
+ }
+
+ @Test
+ public void baseResourcePath() {
+
+ String basePath = sm.getBaseResourcePath("jcr_root" +
File.separatorChar + ".content.xml");
+ assertThat(basePath, is("jcr_root"));
+ }
+
+ @Test
+ public void baseResourcePathIsEmpty() {
+
+ String basePath = sm.getBaseResourcePath(".content.xml");
+ assertThat(basePath, is(""));
+ }
+
+}
Propchange:
sling/whiteboard/asanso/plugins/eclipse/impl-resource-test/src/test/java/org/apache/sling/ide/impl/resource/serialization/SimpleXmlSerializationManagerTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
sling/whiteboard/asanso/plugins/eclipse/impl-resource-test/src/test/java/org/apache/sling/ide/impl/resource/serialization/SimpleXmlSerializationManagerTest.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision Rev URL
Added:
sling/whiteboard/asanso/plugins/eclipse/impl-resource-test/src/test/resources/org/apache/sling/ide/impl/resource/serialization/SimpleXmlSerializationManagerTest.serializedDataIsEscaped.xml
URL:
http://svn.apache.org/viewvc/sling/whiteboard/asanso/plugins/eclipse/impl-resource-test/src/test/resources/org/apache/sling/ide/impl/resource/serialization/SimpleXmlSerializationManagerTest.serializedDataIsEscaped.xml?rev=1506501&view=auto
==============================================================================
---
sling/whiteboard/asanso/plugins/eclipse/impl-resource-test/src/test/resources/org/apache/sling/ide/impl/resource/serialization/SimpleXmlSerializationManagerTest.serializedDataIsEscaped.xml
(added)
+++
sling/whiteboard/asanso/plugins/eclipse/impl-resource-test/src/test/resources/org/apache/sling/ide/impl/resource/serialization/SimpleXmlSerializationManagerTest.serializedDataIsEscaped.xml
Wed Jul 24 11:27:45 2013
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<resource>
+ <property name="jcr:description"><p
class="active">Welcome</p></property>
+</resource>
Propchange:
sling/whiteboard/asanso/plugins/eclipse/impl-resource-test/src/test/resources/org/apache/sling/ide/impl/resource/serialization/SimpleXmlSerializationManagerTest.serializedDataIsEscaped.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
sling/whiteboard/asanso/plugins/eclipse/impl-resource-test/src/test/resources/org/apache/sling/ide/impl/resource/serialization/SimpleXmlSerializationManagerTest.serializedDataIsEscaped.xml
------------------------------------------------------------------------------
svn:mime-type = text/xml
Added:
sling/whiteboard/asanso/plugins/eclipse/impl-resource-test/src/test/resources/org/apache/sling/ide/impl/resource/serialization/SimpleXmlSerializationManagerTest.stringSerializedData.xml
URL:
http://svn.apache.org/viewvc/sling/whiteboard/asanso/plugins/eclipse/impl-resource-test/src/test/resources/org/apache/sling/ide/impl/resource/serialization/SimpleXmlSerializationManagerTest.stringSerializedData.xml?rev=1506501&view=auto
==============================================================================
---
sling/whiteboard/asanso/plugins/eclipse/impl-resource-test/src/test/resources/org/apache/sling/ide/impl/resource/serialization/SimpleXmlSerializationManagerTest.stringSerializedData.xml
(added)
+++
sling/whiteboard/asanso/plugins/eclipse/impl-resource-test/src/test/resources/org/apache/sling/ide/impl/resource/serialization/SimpleXmlSerializationManagerTest.stringSerializedData.xml
Wed Jul 24 11:27:45 2013
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<resource>
+ <property name="jcr:createdBy">admin</property>
+ <property name="jcr:lastModifiedBy">author</property>
+</resource>
Propchange:
sling/whiteboard/asanso/plugins/eclipse/impl-resource-test/src/test/resources/org/apache/sling/ide/impl/resource/serialization/SimpleXmlSerializationManagerTest.stringSerializedData.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
sling/whiteboard/asanso/plugins/eclipse/impl-resource-test/src/test/resources/org/apache/sling/ide/impl/resource/serialization/SimpleXmlSerializationManagerTest.stringSerializedData.xml
------------------------------------------------------------------------------
svn:mime-type = text/xml
Modified:
sling/whiteboard/asanso/plugins/eclipse/impl-resource/src/org/apache/sling/ide/impl/resource/filer/SimpleFilter.java
URL:
http://svn.apache.org/viewvc/sling/whiteboard/asanso/plugins/eclipse/impl-resource/src/org/apache/sling/ide/impl/resource/filer/SimpleFilter.java?rev=1506501&r1=1506500&r2=1506501&view=diff
==============================================================================
---
sling/whiteboard/asanso/plugins/eclipse/impl-resource/src/org/apache/sling/ide/impl/resource/filer/SimpleFilter.java
(original)
+++
sling/whiteboard/asanso/plugins/eclipse/impl-resource/src/org/apache/sling/ide/impl/resource/filer/SimpleFilter.java
Wed Jul 24 11:27:45 2013
@@ -31,7 +31,7 @@ public class SimpleFilter implements Fil
@Override
public FilterResult filter(String relativeFilePath) {
- if (relativeFilePath.charAt(0) != '/') {
+ if (relativeFilePath.isEmpty() || relativeFilePath.charAt(0) != '/') {
relativeFilePath = '/' + relativeFilePath;
}
System.out.println("SimpleFilter.filter(" + relativeFilePath + ")");
Modified:
sling/whiteboard/asanso/plugins/eclipse/impl-resource/src/org/apache/sling/ide/impl/resource/serialization/SimpleXmlSerializationManager.java
URL:
http://svn.apache.org/viewvc/sling/whiteboard/asanso/plugins/eclipse/impl-resource/src/org/apache/sling/ide/impl/resource/serialization/SimpleXmlSerializationManager.java?rev=1506501&r1=1506500&r2=1506501&view=diff
==============================================================================
---
sling/whiteboard/asanso/plugins/eclipse/impl-resource/src/org/apache/sling/ide/impl/resource/serialization/SimpleXmlSerializationManager.java
(original)
+++
sling/whiteboard/asanso/plugins/eclipse/impl-resource/src/org/apache/sling/ide/impl/resource/serialization/SimpleXmlSerializationManager.java
Wed Jul 24 11:27:45 2013
@@ -16,26 +16,38 @@
*/
package org.apache.sling.ide.impl.resource.serialization;
-import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.OutputStream;
+import java.io.StringWriter;
import java.util.HashMap;
-import java.util.Iterator;
import java.util.Map;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.parsers.SAXParser;
+import javax.xml.parsers.SAXParserFactory;
+import javax.xml.transform.OutputKeys;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerConfigurationException;
+import javax.xml.transform.TransformerFactoryConfigurationError;
+import javax.xml.transform.sax.SAXTransformerFactory;
+import javax.xml.transform.sax.TransformerHandler;
+import javax.xml.transform.stream.StreamResult;
+
import org.apache.sling.ide.serialization.SerializationManager;
-import org.apache.sling.ide.transport.ProtectedNodes;
-import org.json.JSONException;
-import org.json.JSONML;
-import org.json.JSONObject;
+import org.xml.sax.Attributes;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+import org.xml.sax.helpers.AttributesImpl;
+import org.xml.sax.helpers.DefaultHandler;
public class SimpleXmlSerializationManager implements SerializationManager {
+ private static final String TAG_PROPERTY = "property";
+ private static final String ATT_PROPERTY_NAME = "name";
+ private static final String TAG_RESOURCE = "resource";
+
private static final String CONTENT_XML = ".content.xml";
- private static final String TAG_NAME = "tagName";
@Override
public boolean isSerializationFile(String filePath) {
@@ -48,40 +60,138 @@ public class SimpleXmlSerializationManag
}
@Override
- public Map<String, String> readSerializationData(InputStream source)
throws IOException {
+ public String getBaseResourcePath(String serializationFilePath) {
+ if (!serializationFilePath.endsWith(CONTENT_XML)) {
+ throw new IllegalArgumentException("File path " +
serializationFilePath + "does not end with '"
+ + File.separatorChar + CONTENT_XML + "'");
+ }
+
+ if (CONTENT_XML.equals(serializationFilePath)) {
+ return "";
+ }
+
+ return serializationFilePath.substring(0,
serializationFilePath.length() - (CONTENT_XML.length() + 1));
+ }
+
+ @Override
+ public Map<String, Object> readSerializationData(InputStream source)
throws IOException {
try {
- BufferedReader reader = new BufferedReader(new
InputStreamReader(source));
- StringBuilder out = new StringBuilder();
- String line;
- while ((line = reader.readLine()) != null) {
- out.append(line);
- }
+ SAXParserFactory factory = SAXParserFactory.newInstance();
+ SAXParser saxParser = factory.newSAXParser();
+
+ SerializationDataHandler h = new SerializationDataHandler();
+
+ saxParser.parse(new InputSource(source), h);
- return getModifiedProperties(out.toString());
- } catch (JSONException e) {
- // TODO Proper error handling
+ return h.getResult();
+ } catch (ParserConfigurationException e) {
+ // TODO proper exception handling
+ throw new RuntimeException(e);
+ } catch (SAXException e) {
+ // TODO proper exception handling
throw new RuntimeException(e);
}
}
- private Map<String, String> getModifiedProperties(String fileContent)
throws JSONException {
+ @Override
+ public String buildSerializationData(Map<String, Object> content) throws
IOException {
+
+ if (content == null || content.isEmpty()) {
+ return null;
+ }
+
+ try {
+ SAXTransformerFactory f = (SAXTransformerFactory)
SAXTransformerFactory.newInstance();
- Map<String, String> properties = new HashMap<String, String>();
- JSONObject json = JSONML.toJSONObject(fileContent);
- json.remove(TAG_NAME);
- for (Iterator<?> keys = json.keys(); keys.hasNext();) {
- String key = (String) keys.next();
- if (!ProtectedNodes.exists(key) && !key.contains("xmlns")) {
- properties.put(key, json.optString(key));
+ StringWriter sw = new StringWriter();
+ StreamResult sr = new StreamResult(sw);
+
+ TransformerHandler handler = f.newTransformerHandler();
+ Transformer t = handler.getTransformer();
+ t.setOutputProperty(OutputKeys.INDENT, "yes");
+ handler.setResult(sr);
+ handler.startDocument();
+ startElement(handler, TAG_RESOURCE);
+ for (Map.Entry<String, Object> property : content.entrySet()) {
+ Object value = property.getValue();
+ if (value instanceof String) {
+ String tagName = property.getKey();
+ String tagValue = (String) value;
+ AttributesImpl attributes = new AttributesImpl();
+ attributes.addAttribute("", ATT_PROPERTY_NAME,
ATT_PROPERTY_NAME, null, tagName);
+ handler.startElement("", TAG_PROPERTY, TAG_PROPERTY,
attributes);
+ handler.characters(tagValue.toCharArray(), 0,
tagValue.length());
+ handler.endElement("", TAG_PROPERTY, TAG_PROPERTY);
+ } else {
+ // TODO multi-valued properties, other primitives
+ System.err.println("Can't yet handle property " +
property.getKey() + " of type "
+ + value.getClass());
+ }
}
+
+ endElement(handler, TAG_RESOURCE);
+ handler.endDocument();
+
+ return sw.toString();
+ } catch (TransformerConfigurationException e) {
+ // TODO proper exception handling
+ throw new RuntimeException(e);
+ } catch (TransformerFactoryConfigurationError e) {
+ // TODO proper exception handling
+ throw new RuntimeException(e);
+ } catch (SAXException e) {
+ // TODO proper exception handling
+ throw new RuntimeException(e);
}
- return properties;
}
- @Override
- public void writeSerializationData(OutputStream destination, Map<String,
String> data) throws IOException {
+ private void startElement(TransformerHandler handler, String tagName)
throws SAXException {
+
+ handler.startElement("", tagName, tagName, null);
+ }
+
+ private void endElement(TransformerHandler handler, String tagName) throws
SAXException {
+
+ handler.endElement("", tagName, tagName);
}
+ static class SerializationDataHandler extends DefaultHandler {
+ private Map<String, Object> result;
+ private String propertyName;
+
+ @Override
+ public void startDocument() throws SAXException {
+ result = new HashMap<String, Object>();
+ }
+
+ @Override
+ public void startElement(String uri, String localName, String qName,
Attributes attributes) throws SAXException {
+
+ if (TAG_PROPERTY.equals(qName)) {
+ propertyName = attributes.getValue(ATT_PROPERTY_NAME);
+ }
+ }
+
+ @Override
+ public void characters(char[] ch, int start, int length) throws
SAXException {
+
+ if (propertyName != null) {
+ result.put(propertyName, new String(ch, start, length));
+ }
+ }
+
+ @Override
+ public void endElement(String uri, String localName, String qName)
throws SAXException {
+
+ if (TAG_PROPERTY.equals(qName)) {
+ propertyName = null;
+ }
+ }
+
+ public Map<String, Object> getResult() {
+ return result;
+ }
+ }
}
Modified:
sling/whiteboard/asanso/plugins/eclipse/impl-resource/src/org/apache/sling/ide/impl/resource/transport/RepositoryImpl.java
URL:
http://svn.apache.org/viewvc/sling/whiteboard/asanso/plugins/eclipse/impl-resource/src/org/apache/sling/ide/impl/resource/transport/RepositoryImpl.java?rev=1506501&r1=1506500&r2=1506501&view=diff
==============================================================================
---
sling/whiteboard/asanso/plugins/eclipse/impl-resource/src/org/apache/sling/ide/impl/resource/transport/RepositoryImpl.java
(original)
+++
sling/whiteboard/asanso/plugins/eclipse/impl-resource/src/org/apache/sling/ide/impl/resource/transport/RepositoryImpl.java
Wed Jul 24 11:27:45 2013
@@ -17,6 +17,8 @@
package org.apache.sling.ide.impl.resource.transport;
import java.io.File;
+import java.util.HashMap;
+import java.util.Iterator;
import java.util.Map;
import org.apache.commons.httpclient.Credentials;
@@ -32,17 +34,19 @@ import org.apache.commons.httpclient.met
import org.apache.sling.ide.impl.resource.util.Tracer;
import org.apache.sling.ide.transport.Command;
import org.apache.sling.ide.transport.FileInfo;
+import org.apache.sling.ide.transport.Repository;
import org.apache.sling.ide.transport.RepositoryException;
-import org.apache.sling.ide.transport.ResponseType;
+import org.apache.sling.ide.transport.ResourceProxy;
import org.apache.sling.ide.transport.Result;
import org.apache.sling.ide.util.PathUtil;
+import org.json.JSONArray;
+import org.json.JSONObject;
public class RepositoryImpl extends AbstractRepository{
private final HttpClient httpClient = new HttpClient();
private Tracer tracer;
-
/* (non-Javadoc)
* @see
org.apache.sling.slingclipse.api.Repository#newAddNodeCommand(org.apache.sling.slingclipse.api.FileInfo)
*/
@@ -132,25 +136,41 @@ public class RepositoryImpl extends Abst
}
@Override
- public Command<String> newListChildrenNodeCommand(final String
path,final ResponseType responseType) {
- return wrap(new Command<String>() {
+ public Command<ResourceProxy> newListChildrenNodeCommand(final String
path) {
+ return wrap(new Command<ResourceProxy>() {
@Override
- public Result<String> execute() {
- //TODO handle the response type
+ public Result<ResourceProxy> execute() {
GetMethod get = new GetMethod(createFullPath(path +
".1.json"));
try{
httpClient.getParams().setAuthenticationPreemptive(true);
Credentials defaultcreds = new
UsernamePasswordCredentials(repositoryInfo.getUsername(),
repositoryInfo.getPassword());
- //TODO
httpClient.getState().setCredentials(new
AuthScope(repositoryInfo.getHost(),repositoryInfo.getPort(),
AuthScope.ANY_REALM), defaultcreds);
int
responseStatus=httpClient.executeMethod(get);
//TODO change responseAsString with
something like
//return
EncodingUtil.getString(rawdata, m.getResponseCharSet());
- if ( isSuccessStatus(responseStatus) )
- return
AbstractResult.success(get.getResponseBodyAsString());
+ if (!isSuccessStatus(responseStatus))
+ return failureResultForStatusCode(responseStatus);
+
+ ResourceProxy resource = new ResourceProxy(path);
+
+ JSONObject json = new
JSONObject(get.getResponseBodyAsString());
+ String primaryType =
json.optString(Repository.JCR_PRIMARY_TYPE);
+ if (primaryType != null) { // TODO - needed?
+ resource.addProperty(Repository.JCR_PRIMARY_TYPE,
primaryType);
+ }
+
+ for (Iterator<?> keyIterator = json.keys();
keyIterator.hasNext();) {
+
+ String key = (String) keyIterator.next();
+ JSONObject value = json.optJSONObject(key);
+ if (value != null) {
+ ResourceProxy child = new ResourceProxy(key);
+ child.addProperty(Repository.JCR_PRIMARY_TYPE,
value.optString(Repository.JCR_PRIMARY_TYPE));
+ }
+ }
- return
failureResultForStatusCode(responseStatus);
+ return AbstractResult.success(resource);
} catch (Exception e) {
return AbstractResult.failure(new
RepositoryException(e));
}finally{
@@ -161,7 +181,7 @@ public class RepositoryImpl extends Abst
@Override
public String toString() {
- return String.format("%8s %s (%s)", "LISTCH",
path, responseType);
+ return String.format("%8s %s", "LISTCH", path);
}
});
}
@@ -207,10 +227,10 @@ public class RepositoryImpl extends Abst
}
@Override
- public Command<String> newGetNodeContentCommand(final String path,
final ResponseType responseType) {
- return wrap(new Command<String>() {
+ public Command<Map<String, Object>> newGetNodeContentCommand(final String
path) {
+ return wrap(new Command<Map<String, Object>>() {
@Override
- public Result<String> execute() {
+ public Result<Map<String, Object>> execute() {
//TODO handle the response type
GetMethod get = new GetMethod(createFullPath(path + ".json"));
try{
@@ -220,10 +240,25 @@ public class RepositoryImpl extends Abst
int
responseStatus=httpClient.executeMethod(get);
//TODO change responseAsString with
something like
// return
EncodingUtil.getString(rawdata, m.getResponseCharSet());
- if ( isSuccessStatus(responseStatus) )
- return
AbstractResult.success(get.getResponseBodyAsString());
-
- return
failureResultForStatusCode(responseStatus);
+ if (!isSuccessStatus(responseStatus))
+ return failureResultForStatusCode(responseStatus);
+
+ JSONObject result = new
JSONObject(get.getResponseBodyAsString());
+
+ Map<String, Object> properties = new HashMap<String,
Object>();
+ JSONArray names = result.names();
+ for (int i = 0; i < names.length(); i++) {
+ String name = names.getString(i);
+ Object object = result.get(name);
+ if (object instanceof String) {
+ properties.put(name, object);
+ } else {
+ System.out.println("Property '" + name + "' of
type '" + object.getClass().getName()
+ + " is not handled");
+ }
+ }
+
+ return AbstractResult.success(properties);
} catch (Exception e) {
return AbstractResult.failure(new
RepositoryException(e));
}finally{
@@ -234,13 +269,13 @@ public class RepositoryImpl extends Abst
@Override
public String toString() {
- return String.format("%8s %s (%s)", "GETCONT",
path, responseType);
+ return String.format("%8s %s", "GETCONT", path);
}
});
}
@Override
- public Command<Void> newUpdateContentNodeCommand(final FileInfo
fileInfo, final Map<String, String> properties) {
+ public Command<Void> newUpdateContentNodeCommand(final FileInfo fileInfo,
final Map<String, Object> properties) {
return wrap(new Command<Void>() {
@Override
@@ -249,9 +284,16 @@ public class RepositoryImpl extends Abst
try{
Part[] parts = new
Part[properties.size()];
int counter=0;
- for (Map.Entry <String,String>
proerty:properties.entrySet()) {
- parts[counter]=new
StringPart(proerty.getKey(), proerty.getValue());
- counter++;
+ for (Map.Entry<String, Object> proerty :
properties.entrySet()) {
+ Object propValue = proerty.getValue();
+ if (propValue instanceof String) {
+ parts[counter] = new StringPart(proerty.getKey(),
(String) propValue);
+ counter++;
+ } else if (proerty != null) {
+ // TODO handle multi-valued properties
+ System.err.println("Unable to handle property " +
proerty.getKey() + " of type "
+ + proerty.getValue().getClass());
+ }
}
post.setRequestEntity(new
MultipartRequestEntity(parts,post.getParams()));
httpClient.getState().setCredentials(AuthScope.ANY, new
UsernamePasswordCredentials(repositoryInfo.getUsername(),repositoryInfo.getPassword()));
Modified: sling/whiteboard/asanso/plugins/eclipse/pom.xml
URL:
http://svn.apache.org/viewvc/sling/whiteboard/asanso/plugins/eclipse/pom.xml?rev=1506501&r1=1506500&r2=1506501&view=diff
==============================================================================
--- sling/whiteboard/asanso/plugins/eclipse/pom.xml (original)
+++ sling/whiteboard/asanso/plugins/eclipse/pom.xml Wed Jul 24 11:27:45 2013
@@ -12,6 +12,7 @@
<module>target-definition</module>
<module>api</module>
<module>impl-resource</module>
+ <module>impl-resource-test</module>
<module>eclipse-core</module>
<module>eclipse-ui</module>
<module>feature</module>