AnsweredAssumed Answered

Repository connection using Apache Chemistry APIs

Question asked by zepolar on Jan 23, 2014
Latest reply on Jan 24, 2014 by zepolar
Hi everybody!!!

I have a problem. I am trying to connect Alfresco v3.2 with Apache Chemistry 0.10.

I am using the following code that found in another forum.


System.out.println("Step-1");
SessionFactory factory = SessionFactoryImpl.newInstance();
System.out.println("Step-2");
Map<String, String> parameter = new HashMap<String, String>();
System.out.println("Step-3");
parameter.put(SessionParameter.USER, "username");
System.out.println("Step-4");
parameter.put(SessionParameter.PASSWORD, "password");
System.out.println("Step-5");
parameter.put(SessionParameter.ATOMPUB_URL, "http://localhost/alfresco/s/api/cmis");
System.out.println("Step-6");
parameter.put(SessionParameter.BINDING_TYPE, BindingType.ATOMPUB.value());
System.out.println("Step-7");
parameter.put(SessionParameter.OBJECT_FACTORY_CLASS, "org.alfresco.cmis.client.impl.AlfrescoObjectFactoryImpl");
System.out.println("Step-8");
List<Repository> repositories = factory.getRepositories(parameter);
System.out.println("Step-9");
Session session = repositories.get(0).createSession();
System.out.println("Step-10");
System.out.println("Connected to repository:" + repositories.get(0).getId());
Folder root = session.getRootFolder();
System.out.println("Step-11");
for (Tree<FileableCmisObject> item : root.getDescendants(1)) {
            System.out.println("Itemname=" + item.getItem().getName());
            System.out.println("Itemtype=" + item.getItem().getType().getDisplayName());
}
System.out.println("Reached End");


When I run the project in the console of netbeans show the follow:


session cmis
Step-1
Step-2
Step-3
Step-4
Step-5
Step-6
Step-7
Step-8
Step-9
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 1.745 sec <<< FAILURE!
testSessionCMIS(ec.com.linbrox.alfresco.AlfrescoUtilsV3Test)  Time elapsed: 1.684 sec  <<< ERROR!
java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
   at java.util.ArrayList.rangeCheck(ArrayList.java:635)
   at java.util.ArrayList.get(ArrayList.java:411)


I don't know to do.

Outcomes