Author: rombert
Date: Wed Jul 24 11:27:52 2013
New Revision: 1506502
URL: http://svn.apache.org/r1506502
Log:
SLING-2973 - [Tooling] Align Eclipse tooling to proposed structure
Fix recursive imports.
Modified:
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/transport/RepositoryImpl.java
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=1506502&r1=1506501&r2=1506502&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:52 2013
@@ -33,7 +33,6 @@ import org.apache.sling.ide.transport.Re
import org.apache.sling.ide.transport.RepositoryException;
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;
@@ -243,8 +242,14 @@ public class ImportWizard extends Wizard
}
}
+ System.out.println("Children: " + resource.getChildren());
+
for (ResourceProxy child : resource.getChildren()) {
+ if
(Repository.NT_RESOURCE.equals(child.getProperties().get(Repository.JCR_PRIMARY_TYPE)))
{
+ continue;
+ }
+
if (filter != null) {
FilterResult filterResult = filter.filter(child.getPath());
if (filterResult == FilterResult.DENY) {
@@ -252,7 +257,7 @@ public class ImportWizard extends Wizard
}
}
- crawlChildrenAndImport(repository, filter, PathUtil.join(path,
child.getPath()), project,
+ crawlChildrenAndImport(repository, filter, child.getPath(),
project,
projectRelativePath);
}
}
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=1506502&r1=1506501&r2=1506502&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:52 2013
@@ -17,8 +17,10 @@
package org.apache.sling.ide.impl.resource.transport;
import java.io.File;
+import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
+import java.util.List;
import java.util.Map;
import org.apache.commons.httpclient.Credentials;
@@ -34,6 +36,7 @@ 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.ProtectedNodes;
import org.apache.sling.ide.transport.Repository;
import org.apache.sling.ide.transport.RepositoryException;
import org.apache.sling.ide.transport.ResourceProxy;
@@ -160,13 +163,16 @@ public class RepositoryImpl extends Abst
resource.addProperty(Repository.JCR_PRIMARY_TYPE,
primaryType);
}
+ // TODO - populate all properties
+
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);
+ ResourceProxy child = new
ResourceProxy(PathUtil.join(path, key));
child.addProperty(Repository.JCR_PRIMARY_TYPE,
value.optString(Repository.JCR_PRIMARY_TYPE));
+ resource.addChild(child);
}
}
@@ -282,20 +288,24 @@ public class RepositoryImpl extends Abst
public Result<Void> execute() {
PostMethod post = new
PostMethod(createFullPath(fileInfo.getRelativeLocation()));
try{
- Part[] parts = new
Part[properties.size()];
- int counter=0;
- for (Map.Entry<String, Object> proerty :
properties.entrySet()) {
- Object propValue = proerty.getValue();
+ List<Part> parts = new ArrayList<Part>();
+ for (Map.Entry<String, Object> property :
properties.entrySet()) {
+ if (ProtectedNodes.exists(property.getKey())) {
+ continue;
+ }
+
+ Object propValue = property.getValue();
+
if (propValue instanceof String) {
- parts[counter] = new StringPart(proerty.getKey(),
(String) propValue);
- counter++;
- } else if (proerty != null) {
+ parts.add(new StringPart(property.getKey(),
(String) propValue));
+ } else if (property != null) {
// TODO handle multi-valued properties
- System.err.println("Unable to handle property " +
proerty.getKey() + " of type "
- + proerty.getValue().getClass());
+ System.err.println("Unable to handle property " +
property.getKey() + " of type "
+ + property.getValue().getClass());
}
}
- post.setRequestEntity(new
MultipartRequestEntity(parts,post.getParams()));
+ post.setRequestEntity(new
MultipartRequestEntity(parts.toArray(new Part[parts.size()]), post
+ .getParams()));
httpClient.getState().setCredentials(AuthScope.ANY, new
UsernamePasswordCredentials(repositoryInfo.getUsername(),repositoryInfo.getPassword()));
httpClient.getParams().setAuthenticationPreemptive(true);
int
responseStatus=httpClient.executeMethod(post);