01-05-2015 09:32 AM
private Session createSession(String username, String password) {
SessionFactory sessionFactory = SessionFactoryImpl.newInstance();
Map<String, String> parameters = new HashMap<String, String>();
parameters.put(SessionParameter.READ_TIMEOUT, String.valueOf(60000));
//User credentials.
parameters.put(SessionParameter.USER, username);
parameters.put(SessionParameter.PASSWORD, password); //password is "andré"
//CMIS 1.1 browser binding
parameters.put(SessionParameter.BINDING_TYPE, BindingType.BROWSER.value());
parameters.put(SessionParameter.BROWSER_URL, getAlfrescoServerUrl() + "/alfresco/api/-default-/public/cmis/versions/1.1/browser"); // URL to your CMIS server.
parameters.put(SessionParameter.AUTH_HTTP_BASIC, "true");
parameters.put(SessionParameter.COOKIES, "true");
//Set the alfresco object factory
try {
Repository repository = sessionFactory.getRepositories(parameters).get(0);
return repository.createSession();
}catch (CmisUnauthorizedException e){
log.log(Level.WARNING, "createSession(" + username + ").CmisUnauthorizedException.returning NULL-session");
} catch (CmisPermissionDeniedException e) {
log.log(Level.WARNING, "createSession(" + username + ").CmisPermissionDeniedException.returning NULL-session");
}
return null;
}
08-19-2016 10:07 AM
parameters[DotCMIS.SessionParameter.BindingType] = BindingType.AtomPub;
parameters[DotCMIS.SessionParameter.AtomPubUrl] = "http://servername:8080/alfresco/cmisatom";
parameters[DotCMIS.SessionParameter.User] = userName;
parameters[DotCMIS.SessionParameter.Password] = password;
Logging.Debug("Vor SessionFactory.NewInstance()");
SessionFactory factory = SessionFactory.NewInstance();
Logging.Debug("Vor GetRepositories()");
ISession session = factory.GetRepositories(parameters)[0].CreateSession();
Logging.Debug("Vor GetRootFolder()");
IFolder root = session.GetRootFolder();
Logging.Debug("Vor GetChildren()");
IItemEnumerable<ICmisObject> childrens = root.GetChildren();
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.