08-05-2013 05:04 AM
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.alfresco.cmis.client.AlfrescoFolder;
import org.apache.chemistry.opencmis.client.api.Folder;
import org.apache.chemistry.opencmis.client.api.Repository;
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;
private Session getSession(String serverUrl, String username, String password)
{
SessionFactory sessionFactory = SessionFactoryImpl.newInstance();
Map<String, String> params = new HashMap<String, String>();
params.put(SessionParameter.USER, username);
params.put(SessionParameter.PASSWORD, password);
params.put(SessionParameter.ATOMPUB_URL, serverUrl);
params.put(SessionParameter.BINDING_TYPE, BindingType.ATOMPUB.value());
List<Repository> repos = sessionFactory.getRepositories(params);
if (repos.isEmpty()) {
throw new RuntimeException("Server has no repositories!");
}
return repos.get(0).createSession();
}
public void createFolder()
{
String servalUrl="http://localhost:8080/alfresco/service/cmis";
String userName="admin";
String password="admin";
Map<String, Object> properties = new HashMap<String, Object>();
properties.put(PropertyIds.OBJECT_TYPE_ID, "cmis:folder,P:cm:titled");
properties.put(PropertyIds.NAME, "TestFolder3");
properties.put(PropertyIds.CREATED_BY, "admin");
properties.put("cm:title", "Title");
properties.put("cm:description", "Desc");
AlfrescoFolder alfFolder=(AlfrescoFolder)getSession(servalUrl, userName,password).getObjectByPath("/");
AlfrescoFolder newFolder=(AlfrescoFolder) alfFolder.createFolder(properties);
System.out.println(newFolder.getName());
}
08-05-2013 07:08 AM
08-05-2013 09:34 PM
08-05-2013 10:46 PM
08-06-2013 11:19 PM
08-07-2013 12:14 AM
10-03-2013 04:32 AM
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.