I am trying to connect alfresco using config parameters but i am getting error:
Config: sessionParameters.put(SessionParameter.USER, \"admin\");
sessionParam
try this worked fine for me
private static 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();
}
Use the following method to get session
public Session getSession() {
if (session == null) {
logger.info("Not connected, creating new connection");
// default factory implementation
SessionFactory factory = SessionFactoryImpl.newInstance();
Map<String, String> parameter = new HashMap<String, String>();
// user credentials
parameter.put(SessionParameter.USER, "admin");
parameter.put(SessionParameter.PASSWORD, "admin");
// connection settings
parameter.put(SessionParameter.ATOMPUB_URL, "http://localhost:8080/alfresco/api/-default-/public/cmis/versions/1.0/atom");
parameter.put(SessionParameter.BINDING_TYPE, BindingType.ATOMPUB.value());
List<Repository> repositories = factory.getRepositories(parameter);
if (repositories != null && repositories.size() > 0) {
logger.info("Found (" + repositories.size() + ") Alfresco repositories");
this.session = repositories.get(0).createSession();
} else {
throw new CmisConnectionException("Could not connect to the Alfresco Server,"
+ " no repository found!");
}
}
return this.session;
}