protected void getSession() throws ManifoldCFException, ServiceInterruption {
if (session == null) {
// Check for parameter validity
if (StringUtils.isEmpty(username))
throw new ManifoldCFException("Parameter " + AlfrescoConfig.USERNAME_PARAM
+ " required but not set");
if (Logging.connectors.isDebugEnabled())
Logging.connectors.debug("Alfresco: Username = '" + username + "'");
if (StringUtils.isEmpty(password))
throw new ManifoldCFException("Parameter " + AlfrescoConfig.PASSWORD_PARAM
+ " required but not set");
Logging.connectors.debug("Alfresco: Password exists");
if (StringUtils.isEmpty(protocol))
throw new ManifoldCFException("Parameter " + AlfrescoConfig.PROTOCOL_PARAM
+ " required but not set");
if (StringUtils.isEmpty(server))
throw new ManifoldCFException("Parameter " + AlfrescoConfig.SERVER_PARAM
+ " required but not set");
if (StringUtils.isEmpty(port))
throw new ManifoldCFException("Parameter " + AlfrescoConfig.PORT_PARAM
+ " required but not set");
if (StringUtils.isEmpty(path))
throw new ManifoldCFException("Parameter " + AlfrescoConfig.PATH_PARAM
+ " required but not set");
endpoint = protocol+"://"+server+":"+port+path;
try {
WebServiceFactory.setEndpointAddress(endpoint);
WebServiceFactory.setTimeoutMilliseconds(socketTimeout);
AuthenticationUtils.startSession(username, password);
session = AuthenticationUtils.getAuthenticationDetails();
}catch (AuthenticationFault e) {
Logging.connectors.warn(
"Alfresco: Error during authentication. Username: "+username + ", endpoint: "+endpoint+". "
+ e.getMessage(), e);
handleIOException(e);
} catch (WebServiceException e){
Logging.connectors.warn(
"Alfresco: Error during trying to authenticate the user. Username: "+username + ", endpoint: "+endpoint
+". Please check the connector parameters. "
+ e.getMessage(), e);
throw new ManifoldCFException("Alfresco: Error during trying to authenticate the user. Username: "+username + ", endpoint: "+endpoint
+". Please check the connector parameters. "
+ e.getMessage(), e);
}
lastSessionFetch = System.currentTimeMillis();