use of com.sun.jersey.api.client.ClientHandler in project coprhd-controller by CoprHD.
the class HP3PARApiFactory method getRESTClient.
/**
* Create HP3PAR API client
*
* @param endpoint
* @param username
* @param password
* @return api client
* @throws HP3PARException
*/
public HP3PARApi getRESTClient(URI endpoint, String username, String password) throws HP3PARException {
try {
_log.info("3PARDriver:getRESTClient");
// key=uri+user+pass to make unique, value=HP3PARApi object
HP3PARApi hp3parApi = _clientMap.get(endpoint.toString() + ":" + username + ":" + password);
if (hp3parApi == null) {
_log.info("3PARDriver:getRESTClient1 hp3parApi null");
ClientHandler handler = new URLConnectionClientHandler();
Client connClient = new Client(handler, configureClient());
RESTClient restClient = new RESTClient(connClient);
hp3parApi = new HP3PARApi(endpoint, restClient, username, password);
_clientMap.putIfAbsent(endpoint.toString() + ":" + username + ":" + password, hp3parApi);
}
return hp3parApi;
} catch (Exception e) {
e.printStackTrace();
_log.error("3PARDriver:getRESTClient Error in getting RESTclient");
throw new HP3PARException(e.toString());
}
}
Aggregations