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/05/09 21:53:02 UTC

svn commit: r1593605 - in /sling/trunk/tooling/ide/eclipse-test: META-INF/MANIFEST.MF src/org/apache/sling/ide/test/impl/ContentDeploymentTest.java src/org/apache/sling/ide/test/impl/helpers/RepositoryAccessor.java

Author: rombert
Date: Fri May  9 19:53:00 2014
New Revision: 1593605

URL: http://svn.apache.org/r1593605
Log:
SLING-3551 - Content sync does not propagate mixin types

Make the RepositoryAccessor use JCR APIs when needed.

Modified:
    sling/trunk/tooling/ide/eclipse-test/META-INF/MANIFEST.MF
    sling/trunk/tooling/ide/eclipse-test/src/org/apache/sling/ide/test/impl/ContentDeploymentTest.java
    sling/trunk/tooling/ide/eclipse-test/src/org/apache/sling/ide/test/impl/helpers/RepositoryAccessor.java

Modified: sling/trunk/tooling/ide/eclipse-test/META-INF/MANIFEST.MF
URL: http://svn.apache.org/viewvc/sling/trunk/tooling/ide/eclipse-test/META-INF/MANIFEST.MF?rev=1593605&r1=1593604&r2=1593605&view=diff
==============================================================================
--- sling/trunk/tooling/ide/eclipse-test/META-INF/MANIFEST.MF (original)
+++ sling/trunk/tooling/ide/eclipse-test/META-INF/MANIFEST.MF Fri May  9 19:53:00 2014
@@ -20,5 +20,8 @@ Require-Bundle: org.junit,
  org.eclipse.m2e.core,
  org.eclipse.m2e.maven.runtime,
  org.apache.commons.io
+Import-Package: javax.jcr,
+ javax.jcr.nodetype,
+ org.apache.sling.ide.jcr
 Bundle-Activator: org.apache.sling.ide.test.impl.Activator
 Bundle-ActivationPolicy: lazy

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=1593605&r1=1593604&r2=1593605&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 May  9 19:53:00 2014
@@ -120,8 +120,8 @@ public class ContentDeploymentTest {
     }
 
     @After
-    public void cleanUp() throws HttpException, IOException {
+    public void cleanUp() throws Exception {
 
-        new RepositoryAccessor(config).tryDeleteResource("hello.txt");
+        new RepositoryAccessor(config).tryDeleteResource("/hello.txt");
     }
 }

Modified: sling/trunk/tooling/ide/eclipse-test/src/org/apache/sling/ide/test/impl/helpers/RepositoryAccessor.java
URL: http://svn.apache.org/viewvc/sling/trunk/tooling/ide/eclipse-test/src/org/apache/sling/ide/test/impl/helpers/RepositoryAccessor.java?rev=1593605&r1=1593604&r2=1593605&view=diff
==============================================================================
--- sling/trunk/tooling/ide/eclipse-test/src/org/apache/sling/ide/test/impl/helpers/RepositoryAccessor.java (original)
+++ sling/trunk/tooling/ide/eclipse-test/src/org/apache/sling/ide/test/impl/helpers/RepositoryAccessor.java Fri May  9 19:53:00 2014
@@ -20,15 +20,19 @@ import static org.junit.Assert.assertTha
 
 import java.io.IOException;
 
+import javax.jcr.Credentials;
+import javax.jcr.Node;
+import javax.jcr.Repository;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+
 import org.apache.commons.httpclient.HttpClient;
 import org.apache.commons.httpclient.HttpException;
 import org.apache.commons.httpclient.UsernamePasswordCredentials;
 import org.apache.commons.httpclient.auth.AuthScope;
 import org.apache.commons.httpclient.methods.GetMethod;
-import org.apache.commons.httpclient.methods.PostMethod;
-import org.apache.commons.httpclient.methods.multipart.MultipartRequestEntity;
-import org.apache.commons.httpclient.methods.multipart.Part;
-import org.apache.commons.httpclient.methods.multipart.StringPart;
+import org.apache.sling.ide.jcr.RepositoryUtils;
+import org.apache.sling.ide.transport.RepositoryInfo;
 import org.hamcrest.CoreMatchers;
 
 /**
@@ -40,6 +44,8 @@ public class RepositoryAccessor {
 
     private final LaunchpadConfig config;
     private final HttpClient client;
+    private Repository repository;
+    private Credentials credentials;
 
     public RepositoryAccessor(LaunchpadConfig config) {
         this.config = config;
@@ -76,17 +82,43 @@ public class RepositoryAccessor {
         }
     }
 
-    public void tryDeleteResource(String path) throws HttpException, IOException {
+    public void tryDeleteResource(String path) throws RepositoryException {
 
-        PostMethod pm = new PostMethod(config.getUrl() + "hello.txt");
-        Part[] parts = { new StringPart(":operation", "delete") };
-        pm.setRequestEntity(new MultipartRequestEntity(parts, pm.getParams()));
-        try {
-            client.executeMethod(pm);
-        } finally {
-            pm.releaseConnection();
+        // PostMethod pm = new PostMethod(config.getUrl() + "hello.txt");
+        // Part[] parts = { new StringPart(":operation", "delete") };
+        // pm.setRequestEntity(new MultipartRequestEntity(parts, pm.getParams()));
+        // try {
+        // client.executeMethod(pm);
+        // } finally {
+        // pm.releaseConnection();
+        // }
+
+        Session session = login();
+        if (session.nodeExists(path)) {
+            session.removeItem(path);
+            session.save();
+        }
+    }
+
+
+    public Node getNode(String nodePath) throws RepositoryException {
+
+        return login().getNode(nodePath);
+    }
+
+    private Session login() throws RepositoryException {
+        
+        RepositoryInfo repositoryInfo = new RepositoryInfo(config.getUsername(), config.getPassword(), config.getUrl());
+
+        if (repository == null) {
+            repository = RepositoryUtils.getRepository(repositoryInfo);
         }
 
+        if (credentials == null) {
+            credentials = RepositoryUtils.getCredentials(repositoryInfo);
+        }
+        
+        return repository.login(credentials);
     }
 
 }