jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r921296 - in /jackrabbit/sandbox/jackrabbit-spi2cmis: ./ src/main/java/org/apache/jackrabbit/spi2cmis/ src/test/java/org/apache/jackrabbit/spi2cmis/
Date Wed, 10 Mar 2010 10:48:35 GMT
Author: mduerig
Date: Wed Mar 10 10:48:35 2010
New Revision: 921296

URL: http://svn.apache.org/viewvc?rev=921296&view=rev
Log:
updated to recent revisions of jackrabbit and chemistry

Modified:
    jackrabbit/sandbox/jackrabbit-spi2cmis/README.txt
    jackrabbit/sandbox/jackrabbit-spi2cmis/src/main/java/org/apache/jackrabbit/spi2cmis/CmisRepositoryService.java
    jackrabbit/sandbox/jackrabbit-spi2cmis/src/main/java/org/apache/jackrabbit/spi2cmis/Spi2cmisRepositoryServiceFactory.java
    jackrabbit/sandbox/jackrabbit-spi2cmis/src/test/java/org/apache/jackrabbit/spi2cmis/AbstractTestCase.java
    jackrabbit/sandbox/jackrabbit-spi2cmis/src/test/java/org/apache/jackrabbit/spi2cmis/ReadTest.java

Modified: jackrabbit/sandbox/jackrabbit-spi2cmis/README.txt
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-spi2cmis/README.txt?rev=921296&r1=921295&r2=921296&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-spi2cmis/README.txt (original)
+++ jackrabbit/sandbox/jackrabbit-spi2cmis/README.txt Wed Mar 10 10:48:35 2010
@@ -52,9 +52,13 @@ You can build spi2cmis with Maven 2.2.1 
 Please refer to the tests in /src/test for basic usage information
 of the spi2cmis module.  
 
-Patches
--------
-* CMIS-102 (https://issues.apache.org/jira/browse/CMIS-102)
+Patches and dependencies
+------------------------
+* Apache Jackrabbit 2.0 Revision: 919059
+
+* Apache Chemistry Revision: 921293
+
+* CMIS-151 (https://issues.apache.org/jira/browse/CMIS-151)
   This patch is required for some features to work properly
     
  
\ No newline at end of file

Modified: jackrabbit/sandbox/jackrabbit-spi2cmis/src/main/java/org/apache/jackrabbit/spi2cmis/CmisRepositoryService.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-spi2cmis/src/main/java/org/apache/jackrabbit/spi2cmis/CmisRepositoryService.java?rev=921296&r1=921295&r2=921296&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-spi2cmis/src/main/java/org/apache/jackrabbit/spi2cmis/CmisRepositoryService.java
(original)
+++ jackrabbit/sandbox/jackrabbit-spi2cmis/src/main/java/org/apache/jackrabbit/spi2cmis/CmisRepositoryService.java
Wed Mar 10 10:48:35 2010
@@ -21,6 +21,7 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.io.Reader;
+import java.io.Serializable;
 import java.util.Collection;
 import java.util.HashMap;
 import java.util.Iterator;
@@ -28,9 +29,11 @@ import java.util.List;
 import java.util.Map;
 
 import javax.jcr.Credentials;
+import javax.jcr.LoginException;
 import javax.jcr.PathNotFoundException;
 import javax.jcr.PropertyType;
 import javax.jcr.RepositoryException;
+import javax.jcr.SimpleCredentials;
 import javax.jcr.ValueFormatException;
 
 import org.apache.chemistry.BaseType;
@@ -52,6 +55,7 @@ import org.apache.jackrabbit.spi.ChildIn
 import org.apache.jackrabbit.spi.IdFactory;
 import org.apache.jackrabbit.spi.ItemId;
 import org.apache.jackrabbit.spi.ItemInfo;
+import org.apache.jackrabbit.spi.ItemInfoCache;
 import org.apache.jackrabbit.spi.Name;
 import org.apache.jackrabbit.spi.NodeId;
 import org.apache.jackrabbit.spi.NodeInfo;
@@ -66,6 +70,7 @@ import org.apache.jackrabbit.spi.Reposit
 import org.apache.jackrabbit.spi.SessionInfo;
 import org.apache.jackrabbit.spi.commons.AbstractRepositoryService;
 import org.apache.jackrabbit.spi.commons.ChildInfoImpl;
+import org.apache.jackrabbit.spi.commons.ItemInfoCacheImpl;
 import org.apache.jackrabbit.spi.commons.NodeInfoImpl;
 import org.apache.jackrabbit.spi.commons.PropertyInfoImpl;
 import org.apache.jackrabbit.spi.commons.name.NameConstants;
@@ -206,8 +211,23 @@ public class CmisRepositoryService exten
     protected SessionInfo createSessionInfo(Credentials credentials, String workspaceName)
             throws RepositoryException {
 
+        Map<String, Serializable> parameters = new HashMap<String, Serializable>();
+
+        if (credentials instanceof SimpleCredentials) {
+            SimpleCredentials creds = (SimpleCredentials) credentials;
+            String[] keys = creds.getAttributeNames();
+            parameters.put(Repository.PARAM_USERNAME, creds.getUserID());
+            parameters.put(Repository.PARAM_PASSWORD, new String(creds.getPassword()));
+            for (String key : keys) {
+                parameters.put(key, creds.getAttribute(key).toString());
+            }
+        }
+        else if (credentials != null) {
+            throw new LoginException("Invalid credentials: " + credentials);
+        }
+
         SessionInfo sessionInfo = super.createSessionInfo(credentials, workspaceName);
-        cmisConnections.put(sessionInfo, cmisRepository.getConnection(null));
+        cmisConnections.put(sessionInfo, cmisRepository.getConnection(parameters));
         return sessionInfo ;
     }
 
@@ -224,6 +244,12 @@ public class CmisRepositoryService exten
         return TypeTransformer.jcrNodeDef(rootName, root.getType(), namespaces);
     }
 
+    // -----------------------------------------------------< cache >---
+
+    public ItemInfoCache getItemInfoCache(SessionInfo sessionInfo) {
+        return new ItemInfoCacheImpl();
+    }
+
     // -----------------------------------------------------< Workspaces >---
 
     /**
@@ -262,7 +288,7 @@ public class CmisRepositoryService exten
             );
 
             return new NodeInfoImpl(path, nodeId, Path.INDEX_DEFAULT, NameConstants.NT_RESOURCE,
-                    Name.EMPTY_ARRAY, Iterators.<Object> empty(), propertyIds, null);
+                    Name.EMPTY_ARRAY, Iterators.<PropertyId> empty(), propertyIds,
null);
         }
         else {
             CMISObject obj = getCMISObject(conn, nodeId);

Modified: jackrabbit/sandbox/jackrabbit-spi2cmis/src/main/java/org/apache/jackrabbit/spi2cmis/Spi2cmisRepositoryServiceFactory.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-spi2cmis/src/main/java/org/apache/jackrabbit/spi2cmis/Spi2cmisRepositoryServiceFactory.java?rev=921296&r1=921295&r2=921296&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-spi2cmis/src/main/java/org/apache/jackrabbit/spi2cmis/Spi2cmisRepositoryServiceFactory.java
(original)
+++ jackrabbit/sandbox/jackrabbit-spi2cmis/src/main/java/org/apache/jackrabbit/spi2cmis/Spi2cmisRepositoryServiceFactory.java
Wed Mar 10 10:48:35 2010
@@ -16,13 +16,14 @@
  */
 package org.apache.jackrabbit.spi2cmis;
 
+import java.io.Serializable;
+import java.util.HashMap;
 import java.util.Map;
 
 import javax.jcr.RepositoryException;
 
 import org.apache.chemistry.Repository;
-import org.apache.chemistry.atompub.client.APPContentManager;
-import org.apache.chemistry.atompub.client.ContentManager;
+import org.apache.chemistry.atompub.client.APPRepositoryService;
 import org.apache.jackrabbit.spi.RepositoryService;
 import org.apache.jackrabbit.spi.RepositoryServiceFactory;
 import org.slf4j.Logger;
@@ -77,29 +78,25 @@ public class Spi2cmisRepositoryServiceFa
             else if (parameters.containsKey(PARAM_CMIS_REPOSITORY_URL)) {
                 String serverUrl = parameters.get(PARAM_CMIS_REPOSITORY_URL).toString();
                 log.info("Connecting to repository at {}", serverUrl);
-                ContentManager cm = new APPContentManager(serverUrl);
 
-                String username = parameters.containsKey(PARAM_CMIS_USERNAME)
-                    ? parameters.get(PARAM_CMIS_USERNAME).toString()
-                    : null;
-
-                String password = parameters.containsKey(PARAM_CMIS_PASSWORD)
-                    ? parameters.get(PARAM_CMIS_PASSWORD).toString()
-                    : null;
-
-                if (username != null && password != null) {
-                    log.debug("Login in with user {}", username);
-                    cm.login(username, password);
+
+                Map<String, Serializable> cmisParams = new HashMap<String, Serializable>();
+                if (parameters.containsKey(PARAM_CMIS_USERNAME)) {
+                    cmisParams.put(Repository.PARAM_USERNAME, parameters.get(PARAM_CMIS_USERNAME).toString());
+                }
+                if (parameters.containsKey(PARAM_CMIS_PASSWORD)) {
+                    cmisParams.put(Repository.PARAM_PASSWORD, parameters.get(PARAM_CMIS_PASSWORD).toString());
                 }
 
+                APPRepositoryService appRepositoryService = new APPRepositoryService(serverUrl,
cmisParams);
                 if (parameters.containsKey(PARAM_CMIS_REPOSITORY_ID)) {
                     String repositoryId = parameters.get(PARAM_CMIS_REPOSITORY_ID).toString();
                     log.info("Selecting repository \"{}\"", repositoryId);
-                    cmisRepo = cm.getRepository(repositoryId);
+                    cmisRepo = appRepositoryService.getRepository(repositoryId);
                 }
                 else {
                     log.info("Selecting default repository");
-                    cmisRepo = cm.getDefaultRepository();
+                    cmisRepo = appRepositoryService.getDefaultRepository();
                 }
             }
 

Modified: jackrabbit/sandbox/jackrabbit-spi2cmis/src/test/java/org/apache/jackrabbit/spi2cmis/AbstractTestCase.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-spi2cmis/src/test/java/org/apache/jackrabbit/spi2cmis/AbstractTestCase.java?rev=921296&r1=921295&r2=921296&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-spi2cmis/src/test/java/org/apache/jackrabbit/spi2cmis/AbstractTestCase.java
(original)
+++ jackrabbit/sandbox/jackrabbit-spi2cmis/src/test/java/org/apache/jackrabbit/spi2cmis/AbstractTestCase.java
Wed Mar 10 10:48:35 2010
@@ -19,8 +19,11 @@ package org.apache.jackrabbit.spi2cmis;
 import java.util.HashMap;
 import java.util.Map;
 
+import javax.jcr.Credentials;
 import javax.jcr.Repository;
 import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.jcr.SimpleCredentials;
 
 import junit.framework.TestCase;
 
@@ -28,8 +31,8 @@ import org.apache.chemistry.test.BasicHe
 import org.apache.jackrabbit.jcr2spi.Jcr2spiRepositoryFactory;
 
 public abstract class AbstractTestCase extends TestCase {
-
     protected Repository repository;
+    protected Map<String, Object> parameters;
 
     @Override
     protected void setUp() throws Exception {
@@ -39,15 +42,14 @@ public abstract class AbstractTestCase e
 
     protected Repository createJcrRepository() throws RepositoryException {
         try {
-            Map<String, Object> parameters = new HashMap<String, Object>();
+            // TODO fix: get the parameter set from system property
+            parameters = simpleParameters();
+//            parameters = nuxeoParameters();
+//            parameters = alfrescoParameters();
             parameters.put(
                     Jcr2spiRepositoryFactory.PARAM_REPOSITORY_SERVICE_FACTORY,
                     Spi2cmisRepositoryServiceFactory.class.getName());
 
-            simpleParameters(parameters);
-//            nuxeoParameters(parameters);
-//            alfrescoParameters(parameters);
-
             return new Jcr2spiRepositoryFactory().getRepository(parameters);
         }
         catch (Exception e) {
@@ -61,24 +63,52 @@ public abstract class AbstractTestCase e
         return cmisRepo;
     }
 
-    private void simpleParameters(Map<String, Object> parameters) throws Exception
{
+    private Map<String, Object> simpleParameters() throws Exception {
+        Map<String, Object> parameters = new HashMap<String, Object>();
         parameters.put(Spi2cmisRepositoryServiceFactory.PARAM_CMIS_REPOSITORY, createSimpleRepository());
+        parameters.put("paths.node", new String[] { "/folder 1/folder 2" });
+        parameters.put("paths.property", new String[] { "/folder 1/folder 2/title" });
+        parameters.put("paths.binary", new String[] { "/folder 1/folder 2/doc 3/jcr:content/jcr:data"
});
+        return parameters;
     }
 
     @SuppressWarnings("unused")
-    private static void nuxeoParameters(Map<String, Object> parameters) {
+    private static Map<String, Object> nuxeoParameters() {
+        Map<String, Object> parameters = new HashMap<String, Object>();
         parameters.put(Spi2cmisRepositoryServiceFactory.PARAM_CMIS_REPOSITORY_URL,
                 "http://cmis.demo.nuxeo.org/nuxeo/site/cmis/repository");
         parameters.put(Spi2cmisRepositoryServiceFactory.PARAM_CMIS_USERNAME, "Administrator");
         parameters.put(Spi2cmisRepositoryServiceFactory.PARAM_CMIS_PASSWORD, "Administrator");
+        parameters.put("paths.node", new String[] { "/default-domain/workspaces/demo-workspace"
});
+        parameters.put("paths.property", new String[] { "/default-domain/workspaces/demo-workspace/dc:title"
});
+        parameters.put("paths.binary", new String[] { });
+        return parameters;
     }
 
     @SuppressWarnings("unused")
-    private static void alfrescoParameters(Map<String, Object> parameters) {
+    private static Map<String, Object> alfrescoParameters() {
+        Map<String, Object> parameters = new HashMap<String, Object>();
         parameters.put(Spi2cmisRepositoryServiceFactory.PARAM_CMIS_REPOSITORY_URL,
                 "http://cmis.alfresco.com/service/cmis");
         parameters.put(Spi2cmisRepositoryServiceFactory.PARAM_CMIS_USERNAME, "admin");
         parameters.put(Spi2cmisRepositoryServiceFactory.PARAM_CMIS_PASSWORD, "admin");
+        parameters.put("paths.node", new String[] { "/Sites/Franki/d2.txt" });
+        parameters.put("paths.property", new String[] { "/Sites/Franki/d2.txt/cmis:name"
});
+        parameters.put("paths.binary", new String[] { "/Sites/Franki/d2.txt/jcr:content/jcr:data"
});
+        return parameters;
+    }
+
+    protected Session login() throws RepositoryException {
+        Object userName = parameters.get(Spi2cmisRepositoryServiceFactory.PARAM_CMIS_USERNAME);
+        Object password = parameters.get(Spi2cmisRepositoryServiceFactory.PARAM_CMIS_PASSWORD);
+
+        if (userName != null && password != null) {
+            Credentials credentials = new SimpleCredentials(userName.toString(), password.toString().toCharArray());
+            return repository.login(credentials);
+        }
+        else {
+            return repository.login();
+        }
     }
 
 }

Modified: jackrabbit/sandbox/jackrabbit-spi2cmis/src/test/java/org/apache/jackrabbit/spi2cmis/ReadTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/jackrabbit-spi2cmis/src/test/java/org/apache/jackrabbit/spi2cmis/ReadTest.java?rev=921296&r1=921295&r2=921296&view=diff
==============================================================================
--- jackrabbit/sandbox/jackrabbit-spi2cmis/src/test/java/org/apache/jackrabbit/spi2cmis/ReadTest.java
(original)
+++ jackrabbit/sandbox/jackrabbit-spi2cmis/src/test/java/org/apache/jackrabbit/spi2cmis/ReadTest.java
Wed Mar 10 10:48:35 2010
@@ -46,7 +46,7 @@ import org.apache.jackrabbit.spi.commons
 public class ReadTest extends AbstractTestCase {
 
     public void testLogin() throws RepositoryException {
-        Session session = repository.login();
+        Session session = login();
         session.logout();
     }
 
@@ -58,7 +58,7 @@ public class ReadTest extends AbstractTe
     }
 
     public void testGetRoot() throws RepositoryException {
-        Session session = repository.login();
+        Session session = login();
         try {
             Node root = session.getRootNode();
             assertEquals("/", root.getPath());
@@ -69,7 +69,7 @@ public class ReadTest extends AbstractTe
     }
 
     public void testNodeTypes() throws RepositoryException, IOException {
-        Session session = repository.login();
+        Session session = login();
         try {
             NodeTypeManager ntm = session.getWorkspace().getNodeTypeManager();
             NodeTypeIterator nts = ntm.getAllNodeTypes();
@@ -93,13 +93,9 @@ public class ReadTest extends AbstractTe
     }
 
     public void testGetNode() throws RepositoryException {
-        String paths[] = {
-//                "/Sites/Franki/gsrodes/DSC00517.JPG",
-//                "/default-domain/workspaces/demo-workspace",
-                "/folder 1/folder 2",
-        };
+        String paths[] = (String[]) parameters.get("paths.node");
 
-        Session session = repository.login();
+        Session session = login();
         try {
             for (String path : paths) {
                 Node node = session.getNode(path);
@@ -113,13 +109,9 @@ public class ReadTest extends AbstractTe
     }
 
     public void testGetProperty() throws RepositoryException {
-        String paths[] = {
-//                "/Sites/Franki/gsrodes/DSC00517.JPG/cmis:name",
-//                "/default-domain/workspaces/demo-workspace/dc:title",
-                "/folder 1/folder 2/title",
-        };
+        String paths[] = (String[]) parameters.get("paths.property");
 
-        Session session = repository.login();
+        Session session = login();
         try {
             for (String path : paths) {
                 Property property = session.getProperty(path);
@@ -133,13 +125,9 @@ public class ReadTest extends AbstractTe
     }
 
     public void testGetBinaryValue() throws RepositoryException {
-        String paths[] = {
-//                "/Sites/Franki/d2.txt/jcr:content/jcr:data",
-//                "/default-domain/workspaces/demo-workspace/testi/jcr:content/jcr:data",
-                "/folder 1/folder 2/doc 3/jcr:content/jcr:data",
-        };
+        String paths[] = (String[]) parameters.get("paths.binary");
 
-        Session session = repository.login();
+        Session session = login();
         try {
             for (String path : paths) {
                 Property property = session.getProperty(path);
@@ -156,7 +144,7 @@ public class ReadTest extends AbstractTe
     public void testTraverse() throws RepositoryException {
         String paths[] = { "/" };
 
-        Session session = repository.login();
+        Session session = login();
         try {
             for (String path : paths) {
                 Node node = session.getNode(path);



Mime
View raw message