Constants.HTTPS_CONNECTION_PREFIX + host
+ Constants.HTTPS_CONNECTION_LOGIN_SUFFIX;
Connect.ConnectType connectType = null;
try {
LoginResponse response = loginClient.login(hostUri, username, password);
//200
if (response.getResponseCode() == HttpStatus.OK.value()) {
if(CommonUtil.isBlank(response.getSessionId())) {
if (isConnected()) {
System.out.println(Constants.CONNECTION_ALREADY_ESTABLISHED);
connectType = Connect.ConnectType.SUCCESS;
} else {
System.out.println(Constants.CONNECT_FAILURE_NO_SESSION_ID);
connectType = Connect.ConnectType.ERROR;
}
} else {
//normal response
updateHostProperty(host);
writeCookieInfo(response.getSessionId());
System.out.println(Constants.CONNECT_SUCCESS);
connectType = Connect.ConnectType.SUCCESS;
}
}
//401
else if(response.getResponseCode() == HttpStatus.UNAUTHORIZED.value()) {
System.out.println(Constants.CONNECT_UNAUTHORIZATION_CONNECT);
//recover old hostUri
hostUri = oldHostUri;
connectType = Connect.ConnectType.UNAUTHORIZATION;
}
//500
else if(response.getResponseCode() == HttpStatus.INTERNAL_SERVER_ERROR.value()) {
System.out.println(HttpStatus.INTERNAL_SERVER_ERROR.getReasonPhrase());
connectType = Connect.ConnectType.ERROR;
} else {
//error
System.out.println(
String.format(
Constants.UNSUPPORTED_HTTP_RESPONSE_CODE, response.getResponseCode()));
//recover old hostUri
hostUri = oldHostUri;
connectType = Connect.ConnectType.ERROR;
}
} catch (Exception e) {