*
*/
package com.packtpub.a3ws.samples.chemistry;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.chemistry.opencmis.client.api.Folder;
import org.apache.chemistry.opencmis.client.api.ObjectId;
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.SessionParameter;
import org.apache.chemistry.opencmis.commons.enums.BindingType;
/**
* @author basanagowda.patil
*
*
*/
public class GettingFolders {
private static Session getSession(String serverUrl, String username, String password) {
SessionFactory sessionFactory = SessionFactoryImpl.newInstance();
Map
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
if (repos.isEmpty()) {
throw new RuntimeException("Server has no repositories!");
}
return repos.get(0).createSession();
}
/**
* @param args
*/
public static void main(String[] args) {
String serverUrl = "http://localhost:8080/alfresco/service/cmis";
String username = "admin";
String password = "admin";
Session session = getSession(serverUrl, username, password);
Folder root = session.getRootFolder();
System.out.println("The root folder is :::"+ root.getId());
//Create the folder(Wiki, inside Wiki images) under CompanyHome
Folder wikiImagesFolder = (Folder) session.getObjectByPath("/Wiki/images");
System.out.println("Illustrating how to construct the CMISObject from the noderef");
System.out.println("The folder ref of the image created is::"+ wikiImagesFolder.getId());
ObjectId parentId = session.createObjectId(wikiImagesFolder.getId());
Folder wikiImagesFolder1 = (Folder) session.getObject(parentId);
System.out.println("Reconstructed the CMisobject from the nodeRef:::"+ wikiImagesFolder1.getId());
}
}
No comments:
Post a Comment