03-04-2013 08:07 AM
import java.util.HashMap;
import java.util.Map;
import javax.xml.ws.BindingType;
import org.apache.chemistry.opencmis.client.api.Session;
import org.apache.chemistry.opencmis.client.api.SessionFactory;
import org.apache.chemistry.opencmis.client.runtime.SessionFactoryImpl;
import org.apache.chemistry.opencmis.commons.SessionParameter;
public class Third {
public static void main(String arg[]) throws Exception{
Map<String, String> parameter = new HashMap<String, String>();
// Set the user credentials
parameter.put(SessionParameter.USER, "admin");
parameter.put(SessionParameter.PASSWORD, "admin");
// Specify the connection settings
parameter.put(SessionParameter.ATOMPUB_URL, "http://localhost:8070/alfresco/service/cmis");
parameter.put(SessionParameter.BINDING_TYPE, BindingType.ATOMPUB.value());
// Set the alfresco object factory
parameter.put(SessionParameter.OBJECT_FACTORY_CLASS, "org.alfresco.cmis.client.impl.AlfrescoObjectFactoryImpl");
// Create a session
SessionFactory factory = SessionFactoryImpl.newInstance();
Session session = factory.getRepositories(parameter).get(0).createSession();
System.out.println("Connected to repository:");
}
}
03-04-2013 09:39 AM
import org.apache.chemistry.opencmis.commons.enums.BindingType;
import javax.xml.ws.BindingType;
03-04-2013 11:26 PM
Exception in thread "main" java.lang.IllegalArgumentException: Unable to create object factory: java.lang.ClassNotFoundException: org.alfresco.cmis.client.impl.AlfrescoObjectFactoryImpl
at org.apache.chemistry.opencmis.client.runtime.SessionImpl.createObjectFactory(SessionImpl.java:207)
at org.apache.chemistry.opencmis.client.runtime.SessionImpl.<init>(SessionImpl.java:153)
at org.apache.chemistry.opencmis.client.runtime.SessionFactoryImpl.createSession(SessionFactoryImpl.java:89)
at org.apache.chemistry.opencmis.client.runtime.repository.RepositoryImpl.createSession(RepositoryImpl.java:62)
at Third.main(Third.java:34)
Caused by: java.lang.ClassNotFoundException: org.alfresco.cmis.client.impl.AlfrescoObjectFactoryImpl
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:186)
at org.apache.chemistry.opencmis.client.runtime.SessionImpl.createObjectFactory(SessionImpl.java:195)
… 4 more
03-05-2013 12:33 AM
C:\alfresco_sdk_4_1\lib\server\dependencies\commons\commons-logging-1.1.1.jar
03-05-2013 01:22 AM
03-05-2013 01:48 AM
03-04-2013 10:03 AM
03-04-2013 11:22 PM
03-05-2013 08:07 AM
03-06-2013 08:56 AM
import java.util.HashMap;
import java.util.Map;
import org.apache.chemistry.opencmis.client.api.CmisObject;
import org.apache.chemistry.opencmis.client.api.Folder;
import org.apache.chemistry.opencmis.client.api.ItemIterable;
import org.apache.chemistry.opencmis.client.api.Session;
import org.apache.chemistry.opencmis.client.api.SessionFactory;
import org.apache.chemistry.opencmis.client.runtime.SessionFactoryImpl;
import org.apache.chemistry.opencmis.commons.PropertyIds;
import org.apache.chemistry.opencmis.commons.SessionParameter;
import org.apache.chemistry.opencmis.commons.enums.BindingType;
import org.apache.chemistry.opencmis.client.api.*;
public class First{
private static final String ALFRSCO_ATOMPUB_URL = "http://localhost:8070/alfresco/service/cmis";
//private static final Folder root = null;
//private static Folder root;
public static void main(String arg[]){
Map<String, String> parameter = new HashMap<String, String>();
// Set the user credentials
parameter.put(SessionParameter.USER, "admin");
parameter.put(SessionParameter.PASSWORD, "admin");
// Specify the connection settings
parameter.put(SessionParameter.ATOMPUB_URL, ALFRSCO_ATOMPUB_URL);
parameter.put(SessionParameter.BINDING_TYPE, BindingType.ATOMPUB.value());
//Add repository Id
//parameter.put(SessionParameter.REPOSITORY_ID, REPOSITORY_ID);
// Create a session
SessionFactory factory = SessionFactoryImpl.newInstance();
Session session = factory.getRepositories(parameter).get(0).createSession();
System.out.println("Connected to repository:" + session.getRepositoryInfo().getName());
System.out.println("Repository id:"+session.getRepositoryInfo().getId());
System.out.println("Creating 'SAMPLE1' in the root folder");
Map<String, String> newFolderProps = new HashMap<String, String>();
newFolderProps.put(PropertyIds.OBJECT_TYPE_ID, "cmis:folder");
newFolderProps.put(PropertyIds.NAME, "SAMPLE1");
System.out.println("folder is creating");
Folder newFolder = root.createFolder(newFolderProps);
System.out.println("success:"+newFolder);
}
}
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.