Search in sources :

Example 1 with ClientHandler

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());
    }
}
Also used : HP3PARException(com.emc.storageos.hp3par.impl.HP3PARException) ClientHandler(com.sun.jersey.api.client.ClientHandler) URLConnectionClientHandler(com.sun.jersey.client.urlconnection.URLConnectionClientHandler) ApacheHttpClientHandler(com.sun.jersey.client.apache.ApacheHttpClientHandler) URLConnectionClientHandler(com.sun.jersey.client.urlconnection.URLConnectionClientHandler) HP3PARApi(com.emc.storageos.hp3par.impl.HP3PARApi) ApacheHttpClient(com.sun.jersey.client.apache.ApacheHttpClient) HttpClient(org.apache.commons.httpclient.HttpClient) Client(com.sun.jersey.api.client.Client) HP3PARException(com.emc.storageos.hp3par.impl.HP3PARException) IOException(java.io.IOException) KeyManagementException(java.security.KeyManagementException) CertificateException(java.security.cert.CertificateException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException)

Aggregations

HP3PARApi (com.emc.storageos.hp3par.impl.HP3PARApi)1 HP3PARException (com.emc.storageos.hp3par.impl.HP3PARException)1 Client (com.sun.jersey.api.client.Client)1 ClientHandler (com.sun.jersey.api.client.ClientHandler)1 ApacheHttpClient (com.sun.jersey.client.apache.ApacheHttpClient)1 ApacheHttpClientHandler (com.sun.jersey.client.apache.ApacheHttpClientHandler)1 URLConnectionClientHandler (com.sun.jersey.client.urlconnection.URLConnectionClientHandler)1 IOException (java.io.IOException)1 KeyManagementException (java.security.KeyManagementException)1 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)1 CertificateException (java.security.cert.CertificateException)1 HttpClient (org.apache.commons.httpclient.HttpClient)1