Example usage for org.apache.http.client ClientProtocolException printStackTrace

List of usage examples for org.apache.http.client ClientProtocolException printStackTrace

Introduction

In this page you can find the example usage for org.apache.http.client ClientProtocolException printStackTrace.

Prototype

public void printStackTrace() 

Source Link

Document

Prints this throwable and its backtrace to the standard error stream.

Usage

From source file:org.megam.deccanplato.provider.salesforce.crm.handler.ContractImpl.java

/**
 * this method deletes an contract in salesforce.com and returns a success message with deleted contract id.
 * This method gets input from a MAP(contains json data) and returns a MAp.
 * @param outMap //  www. j av a 2 s  .c om
 */
private Map<String, String> delete() {
    Map<String, String> outMap = new HashMap<>();
    final String SALESFORCE_DELETE_CONTACT_URL = args.get(INSTANCE_URL) + SALESFORCE_CONTRACT_URL
            + args.get(ID);
    Map<String, String> header = new HashMap<String, String>();
    header.put(S_AUTHORIZATION, S_OAUTH + args.get(ACCESS_TOKEN));

    TransportTools tst = new TransportTools(SALESFORCE_DELETE_CONTACT_URL, null, header);
    try {
        TransportMachinery.delete(tst);
        outMap.put(OUTPUT, DELETE_STRING + args.get(ID));
    } catch (ClientProtocolException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
    return outMap;
}

From source file:org.megam.deccanplato.provider.salesforce.crm.handler.OpportunitiesImpl.java

/**
 * this method lists all opportunity in salesforce.com and returns a list of all opportunity details.
 * This method gets input from a MAP(contains json data) and returns a MAp.
 * @param outMap //  w  ww  .j  ava 2s .c o  m
 */
private Map<String, String> list() {
    Map<String, String> outMap = new HashMap<>();
    final String SALESFORCE_LIST_OPPORTUNITY_URL = args.get(INSTANCE_URL)
            + "/services/data/v25.0/query/?q=SELECT+CloseDate,Name,Id+FROM+Opportunity";
    Map<String, String> header = new HashMap<String, String>();
    header.put(S_AUTHORIZATION, S_OAUTH + args.get(ACCESS_TOKEN));

    TransportTools tst = new TransportTools(SALESFORCE_LIST_OPPORTUNITY_URL, null, header);
    try {
        String responseBody = TransportMachinery.get(tst).entityToString();
        outMap.put(OUTPUT, responseBody);
    } catch (ClientProtocolException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    } catch (URISyntaxException e) {
        e.printStackTrace();
    }
    return outMap;
}

From source file:org.megam.deccanplato.provider.salesforce.crm.handler.PartnerImpl.java

/**
 * This method updates an account in salesforce.com and returns a success message with updated account id.
 * This method gets input from a MAP(contains json data) and returns a MAp.
 * @param outMap //w w w .jav a2s  .  com
 */
private Map<String, String> update() {
    Map<String, String> outMap = new HashMap<>();
    final String SALESFORCE_UPDATE_PARTNER_URL = args.get(INSTANCE_URL) + SALESFORCE_PARTNER_URL + args.get(ID);
    Map<String, String> header = new HashMap<String, String>();
    header.put(S_AUTHORIZATION, S_OAUTH + args.get(ACCESS_TOKEN));
    Map<String, Object> partnerAttrMap = new HashMap<String, Object>();
    partnerAttrMap.put(S_ACCOUNTFROMIDE, args.get(ACCOUNT_FROM_ID));
    partnerAttrMap.put(S_ACCOUNTTOID, args.get(ACCOUNT_TO_ID));
    partnerAttrMap.put(S_ISPRIMARY, Boolean.parseBoolean(args.get(ISPRIMARY)));
    partnerAttrMap.put(S_OPPORTUNITYID, args.get(OPPORTUNITY_ID));
    partnerAttrMap.put(S_ROLE, args.get(ROLE));

    TransportTools tst = new TransportTools(SALESFORCE_UPDATE_PARTNER_URL, null, header);
    Gson obj = new GsonBuilder().setPrettyPrinting().create();
    tst.setContentType(ContentType.APPLICATION_JSON, obj.toJson(partnerAttrMap));
    try {
        TransportMachinery.patch(tst);
        outMap.put(OUTPUT, UPDATE_STRING + args.get(ID));

    } catch (ClientProtocolException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
    return outMap;
}

From source file:org.megam.deccanplato.provider.salesforce.crm.handler.PartnerImpl.java

/**
 * this method creates an account in salesforce.com and returns that account id.
 * This method gets input from a MAP(contains json data) and returns a MAp.
 * @param outMap //www  .java  2  s .  c  o m
 */
private Map<String, String> create() {
    Map<String, String> outMap = new HashMap<>();
    final String SALESFORCE_CREATE_PARTNER_URL = args.get(INSTANCE_URL) + SALESFORCE_PARTNER_URL;
    Map<String, String> header = new HashMap<String, String>();
    header.put(S_AUTHORIZATION, S_OAUTH + args.get(ACCESS_TOKEN));
    Map<String, Object> partnerAttrMap = new HashMap<String, Object>();
    partnerAttrMap.put(S_ACCOUNTFROMIDE, args.get(ACCOUNT_FROM_ID));
    partnerAttrMap.put(S_ACCOUNTTOID, args.get(ACCOUNT_TO_ID));
    partnerAttrMap.put(S_ISPRIMARY, Boolean.parseBoolean(args.get(ISPRIMARY)));
    partnerAttrMap.put(S_OPPORTUNITYID, args.get(OPPORTUNITY_ID));
    partnerAttrMap.put(S_ROLE, args.get(ROLE));

    TransportTools tst = new TransportTools(SALESFORCE_CREATE_PARTNER_URL, null, header);
    Gson obj = new GsonBuilder().setPrettyPrinting().create();
    tst.setContentType(ContentType.APPLICATION_JSON, obj.toJson(partnerAttrMap));
    try {
        String responseBody = TransportMachinery.post(tst).entityToString();
        outMap.put(OUTPUT, responseBody);

    } catch (ClientProtocolException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
    return outMap;
}

From source file:org.megam.deccanplato.provider.salesforce.crm.handler.PriceBookImpl.java

/**
 * This method updates an account in salesforce.com and returns a success message with updated account id.
 * This method gets input from a MAP(contains json data) and returns a MAp.
 * @param outMap /* w w  w  . j  ava2  s. c o  m*/
 */
private Map<String, String> update() {
    Map<String, String> outMap = new HashMap<>();
    final String SALESFORCE_UPDATE_PRICEBOOK_URL = args.get(INSTANCE_URL) + SALESFORCE_PRICEBOOK_URL
            + args.get(ID);
    Map<String, String> header = new HashMap<String, String>();
    header.put(S_AUTHORIZATION, S_OAUTH + args.get(ACCESS_TOKEN));
    Map<String, Object> priceBookAttrMap = new HashMap<String, Object>();
    priceBookAttrMap.put(S_NAME, args.get(NAME));
    priceBookAttrMap.put(S_DESCRIPTION, args.get(DESCRIPTION));
    priceBookAttrMap.put(S_ISACTIVE, Boolean.parseBoolean(args.get(ISACTIVE)));

    TransportTools tst = new TransportTools(SALESFORCE_UPDATE_PRICEBOOK_URL, null, header);
    Gson obj = new GsonBuilder().setPrettyPrinting().create();
    tst.setContentType(ContentType.APPLICATION_JSON, obj.toJson(priceBookAttrMap));
    try {
        TransportMachinery.patch(tst);
        outMap.put(OUTPUT, UPDATE_STRING + args.get(ID));

    } catch (ClientProtocolException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
    return outMap;
}

From source file:org.megam.deccanplato.provider.salesforce.crm.handler.SolutionImpl.java

/**
 * this method lists all solution in salesforce.com and returns a list of all solution details.
 * This method gets input from a MAP(contains json data) and returns a MAp.
 * @param outMap /* www . java  2s  .com*/
 */
private Map<String, String> list() {
    Map<String, String> outMap = new HashMap<>();
    final String SALESFORCE_LIST_SOLUTION_URL = args.get(INSTANCE_URL)
            + "/services/data/v25.0/query/?q=SELECT+SolutionName,Id+FROM+Solution";
    Map<String, String> header = new HashMap<String, String>();
    header.put(S_AUTHORIZATION, S_OAUTH + args.get(ACCESS_TOKEN));

    TransportTools tst = new TransportTools(SALESFORCE_LIST_SOLUTION_URL, null, header);
    try {
        String response = TransportMachinery.get(tst).entityToString();
        outMap.put(OUTPUT, response);
    } catch (ClientProtocolException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    } catch (URISyntaxException e) {
        e.printStackTrace();
    }
    return outMap;
}

From source file:edu.xiyou.fruits.WebCrawler.net.HttpRequest.java

@Override
public Response getResponse(CrawlDatum datum) throws IllegalArgumentException {
    if (!checkCrawlDatum(datum)) {
        logger.info("datum is null");
        throw new IllegalArgumentException("illegal format");
    }/* w w  w .ja  v  a 2  s  .  co  m*/
    String url = datum.getUrl();

    HttpGet httpGet = new HttpGet(url);
    try {
        Response obj = client.execute(httpGet, handler);
        if (obj != null) {
            ((Html) obj).setUrl(url);
            return obj;
        }
    } catch (ClientProtocolException e) {
        logger.info("ClientProtocolException  ");
        e.printStackTrace();
    } catch (SocketTimeoutException e) {
        logger.error(e.getMessage());
    } catch (IOException e) {
        logger.info("IOException   ");
        e.printStackTrace();
    }

    return null;
}

From source file:org.megam.deccanplato.provider.salesforce.crm.handler.TaskImpl.java

/**
 * this method lists all task in salesforce.com and returns a list of all task details.
 * This method gets input from a MAP(contains json data) and returns a MAp.
 * @param outMap //from   ww w.  j av  a 2  s.c  o m
 */
private Map<String, String> list() {
    Map<String, String> outMap = new HashMap<>();
    final String SALESFORCE_LIST_PRODUCT_URL = args.get(INSTANCE_URL)
            + "/services/data/v25.0/query/?q=SELECT+Id,Subject+FROM+Task";
    Map<String, String> header = new HashMap<String, String>();
    header.put(S_AUTHORIZATION, S_OAUTH + args.get(ACCESS_TOKEN));

    TransportTools tst = new TransportTools(SALESFORCE_LIST_PRODUCT_URL, null, header);
    try {
        String response = TransportMachinery.get(tst).entityToString();
        outMap.put(OUTPUT, response);
    } catch (ClientProtocolException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    } catch (URISyntaxException e) {
        e.printStackTrace();
    }
    return outMap;
}

From source file:com.nagazuka.mobile.android.goedkooptanken.service.impl.GoogleHttpGeocodingService.java

public String download(String url) throws NetworkException {
    String response = "";
    try {/*from  w w w. j a va 2 s . com*/
        HttpClient httpClient = new DefaultHttpClient();
        HttpGet request = new HttpGet(url);
        //Log.d(TAG, "<< HTTP Request: " + request.toString());

        ResponseHandler<String> handler = new BasicResponseHandler();
        response = httpClient.execute(request, handler);
        //Log.d(TAG, "<< HTTP Response: " + response);

        httpClient.getConnectionManager().shutdown();
    } catch (ClientProtocolException c) {
        c.printStackTrace();
        throw new NetworkException("Er zijn netwerkproblemen opgetreden bij het opvragen van de postcode", c);
    } catch (IOException e) {
        e.printStackTrace();
        throw new NetworkException("Er zijn netwerkproblemen opgetreden bij het opvragen van de postcode", e);
    }

    return response;
}

From source file:com.thed.zapi.cloud.sample.CreateCycleAndAddTests.java

public String addTestsToCycle(String uriStr, ZFJCloudRestClient client, String accessKey,
        StringEntity addTestsJSON)//from  w w  w .  j ava2  s .  c o  m
        throws URISyntaxException, JSONException, IllegalStateException, IOException {

    URI uri = new URI(uriStr);
    int expirationInSec = 360;
    JwtGenerator jwtGenerator = client.getJwtGenerator();
    String jwt = jwtGenerator.generateJWT("POST", uri, expirationInSec);
    System.out.println(uri.toString());
    System.out.println(jwt);

    HttpResponse response = null;
    HttpClient restClient = new DefaultHttpClient();

    HttpPost addTestsReq = new HttpPost(uri);
    addTestsReq.addHeader("Content-Type", "application/json");
    addTestsReq.addHeader("Authorization", jwt);
    addTestsReq.addHeader("zapiAccessKey", accessKey);
    addTestsReq.setEntity(addTestsJSON);

    try {
        response = restClient.execute(addTestsReq);
    } catch (ClientProtocolException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }

    int statusCode = response.getStatusLine().getStatusCode();
    System.out.println(statusCode);
    System.out.println(response.toString());
    String string = null;
    if (statusCode >= 200 && statusCode < 300) {
        HttpEntity entity = response.getEntity();
        try {
            string = EntityUtils.toString(entity);
            //System.out.println(string);
            JSONObject cycleObj = new JSONObject(entity);
            //System.out.println(cycleObj.toString());
        } catch (ParseException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }

    } else {
        try {
            throw new ClientProtocolException("Unexpected response status: " + statusCode);
        } catch (ClientProtocolException e) {
            e.printStackTrace();
        }
    }
    return string;
}