List of usage examples for org.apache.http.client ClientProtocolException getMessage
public String getMessage()
From source file:org.apache.ofbiz.accounting.thirdparty.sagepay.SagePayServices.java
public static Map<String, Object> paymentRelease(DispatchContext ctx, Map<String, Object> context) { Debug.logInfo("SagePay - Entered paymentRelease", module); Debug.logInfo("SagePay paymentRelease context : " + context, module); Delegator delegator = ctx.getDelegator(); Map<String, Object> resultMap = new HashMap<String, Object>(); Map<String, String> props = buildSagePayProperties(context, delegator); String vendorTxCode = (String) context.get("vendorTxCode"); String vpsTxId = (String) context.get("vpsTxId"); String securityKey = (String) context.get("securityKey"); String txAuthNo = (String) context.get("txAuthNo"); Locale locale = (Locale) context.get("locale"); HttpHost host = SagePayUtil.getHost(props); //start - release parameters Map<String, String> parameters = new HashMap<String, String>(); String vpsProtocol = props.get("protocolVersion"); String vendor = props.get("vendor"); String txType = props.get("releaseTransType"); parameters.put("VPSProtocol", vpsProtocol); parameters.put("TxType", txType); parameters.put("Vendor", vendor); parameters.put("VendorTxCode", vendorTxCode); parameters.put("VPSTxId", vpsTxId); parameters.put("SecurityKey", securityKey); parameters.put("TxAuthNo", txAuthNo); //end - release parameters try (CloseableHttpClient httpClient = SagePayUtil.getHttpClient()) { String successMessage = null; HttpPost httpPost = SagePayUtil.getHttpPost(props.get("releaseUrl"), parameters); HttpResponse response = httpClient.execute(host, httpPost); Map<String, String> responseData = SagePayUtil.getResponseData(response); String status = responseData.get("Status"); String statusDetail = responseData.get("StatusDetail"); resultMap.put("status", status); resultMap.put("statusDetail", statusDetail); //start - payment released if ("OK".equals(status)) { successMessage = UtilProperties.getMessage(resource, "AccountingSagePayPaymentReleased", locale); }/*from w w w . j a v a 2 s .c om*/ //end - payment released //start - release request not formed properly or parameters missing if ("MALFORMED".equals(status)) { successMessage = UtilProperties.getMessage(resource, "AccountingSagePayPaymentReleaseRequestMalformed", locale); } //end - release request not formed properly or parameters missing //start - invalid information passed in parameters if ("INVALID".equals(status)) { successMessage = UtilProperties.getMessage(resource, "AccountingSagePayPaymentInvalidInformationPassed", locale); } //end - invalid information passed in parameters //start - problem at Sagepay if ("ERROR".equals(status)) { successMessage = UtilProperties.getMessage(resource, "AccountingSagePayPaymentError", locale); } //end - problem at Sagepay resultMap.put(ModelService.RESPONSE_MESSAGE, ModelService.RESPOND_SUCCESS); resultMap.put(ModelService.SUCCESS_MESSAGE, successMessage); } catch (UnsupportedEncodingException uee) { //exception in encoding parameters in httpPost Debug.logError(uee, "Error occurred in encoding parameters for HttpPost (" + uee.getMessage() + ")", module); resultMap = ServiceUtil .returnError(UtilProperties.getMessage(resource, "AccountingSagePayErrorEncodingParameters", UtilMisc.toMap("errorString", uee.getMessage()), locale)); } catch (ClientProtocolException cpe) { //from httpClient execute Debug.logError(cpe, "Error occurred in HttpClient execute(" + cpe.getMessage() + ")", module); resultMap = ServiceUtil .returnError(UtilProperties.getMessage(resource, "AccountingSagePayErrorHttpClientExecute", UtilMisc.toMap("errorString", cpe.getMessage()), locale)); } catch (IOException ioe) { //from httpClient execute or getResponsedata Debug.logError(ioe, "Error occurred in HttpClient execute or getting response (" + ioe.getMessage() + ")", module); resultMap = ServiceUtil.returnError( UtilProperties.getMessage(resource, "AccountingSagePayErrorHttpClientExecuteOrGettingResponse", UtilMisc.toMap("errorString", ioe.getMessage()), locale)); } return resultMap; }
From source file:org.apache.ofbiz.accounting.thirdparty.sagepay.SagePayServices.java
public static Map<String, Object> paymentAuthorisation(DispatchContext ctx, Map<String, Object> context) { Debug.logInfo("SagePay - Entered paymentAuthorisation", module); Debug.logInfo("SagePay paymentAuthorisation context : " + context, module); Delegator delegator = ctx.getDelegator(); Map<String, Object> resultMap = new HashMap<String, Object>(); Map<String, String> props = buildSagePayProperties(context, delegator); String vendorTxCode = (String) context.get("vendorTxCode"); String vpsTxId = (String) context.get("vpsTxId"); String securityKey = (String) context.get("securityKey"); String txAuthNo = (String) context.get("txAuthNo"); String amount = (String) context.get("amount"); Locale locale = (Locale) context.get("locale"); HttpHost host = SagePayUtil.getHost(props); //start - authorization parameters Map<String, String> parameters = new HashMap<String, String>(); String vpsProtocol = props.get("protocolVersion"); String vendor = props.get("vendor"); String txType = props.get("authoriseTransType"); parameters.put("VPSProtocol", vpsProtocol); parameters.put("TxType", txType); parameters.put("Vendor", vendor); parameters.put("VendorTxCode", vendorTxCode); parameters.put("VPSTxId", vpsTxId); parameters.put("SecurityKey", securityKey); parameters.put("TxAuthNo", txAuthNo); parameters.put("ReleaseAmount", amount); Debug.logInfo("authorization parameters -> " + parameters, module); //end - authorization parameters try (CloseableHttpClient httpClient = SagePayUtil.getHttpClient()) { String successMessage = null; HttpPost httpPost = SagePayUtil.getHttpPost(props.get("authoriseUrl"), parameters); HttpResponse response = httpClient.execute(host, httpPost); Map<String, String> responseData = SagePayUtil.getResponseData(response); String status = responseData.get("Status"); String statusDetail = responseData.get("StatusDetail"); resultMap.put("status", status); resultMap.put("statusDetail", statusDetail); //start - payment refunded if ("OK".equals(status)) { successMessage = UtilProperties.getMessage(resource, "AccountingSagePayPaymentReleased", locale); }//from ww w. jav a2 s . c o m //end - payment refunded //start - refund request not formed properly or parameters missing if ("MALFORMED".equals(status)) { successMessage = UtilProperties.getMessage(resource, "AccountingSagePayPaymentReleaseRequestMalformed", locale); } //end - refund request not formed properly or parameters missing //start - invalid information passed in parameters if ("INVALID".equals(status)) { successMessage = UtilProperties.getMessage(resource, "AccountingSagePayPaymentInvalidInformationPassed", locale); } //end - invalid information passed in parameters //start - problem at Sagepay if ("ERROR".equals(status)) { successMessage = UtilProperties.getMessage(resource, "AccountingSagePayPaymentError", locale); } //end - problem at Sagepay resultMap.put(ModelService.RESPONSE_MESSAGE, ModelService.RESPOND_SUCCESS); resultMap.put(ModelService.SUCCESS_MESSAGE, successMessage); } catch (UnsupportedEncodingException uee) { //exception in encoding parameters in httpPost Debug.logError(uee, "Error occurred in encoding parameters for HttpPost (" + uee.getMessage() + ")", module); resultMap = ServiceUtil .returnError(UtilProperties.getMessage(resource, "AccountingSagePayErrorEncodingParameters", UtilMisc.toMap("errorString", uee.getMessage()), locale)); } catch (ClientProtocolException cpe) { //from httpClient execute Debug.logError(cpe, "Error occurred in HttpClient execute(" + cpe.getMessage() + ")", module); resultMap = ServiceUtil .returnError(UtilProperties.getMessage(resource, "AccountingSagePayErrorHttpClientExecute", UtilMisc.toMap("errorString", cpe.getMessage()), locale)); } catch (IOException ioe) { //from httpClient execute or getResponsedata Debug.logError(ioe, "Error occurred in HttpClient execute or getting response (" + ioe.getMessage() + ")", module); resultMap = ServiceUtil.returnError( UtilProperties.getMessage(resource, "AccountingSagePayErrorHttpClientExecuteOrGettingResponse", UtilMisc.toMap("errorString", ioe.getMessage()), locale)); } return resultMap; }
From source file:org.apache.ofbiz.accounting.thirdparty.sagepay.SagePayServices.java
public static Map<String, Object> paymentRefund(DispatchContext ctx, Map<String, Object> context) { Debug.logInfo("SagePay - Entered paymentRefund", module); Debug.logInfo("SagePay paymentRefund context : " + context, module); Delegator delegator = ctx.getDelegator(); Map<String, Object> resultMap = new HashMap<String, Object>(); Map<String, String> props = buildSagePayProperties(context, delegator); String vendorTxCode = (String) context.get("vendorTxCode"); String amount = (String) context.get("amount"); String currency = (String) context.get("currency"); String description = (String) context.get("description"); String relatedVPSTxId = (String) context.get("relatedVPSTxId"); String relatedVendorTxCode = (String) context.get("relatedVendorTxCode"); String relatedSecurityKey = (String) context.get("relatedSecurityKey"); String relatedTxAuthNo = (String) context.get("relatedTxAuthNo"); Locale locale = (Locale) context.get("locale"); HttpHost host = SagePayUtil.getHost(props); //start - refund parameters Map<String, String> parameters = new HashMap<String, String>(); String vpsProtocol = props.get("protocolVersion"); String vendor = props.get("vendor"); parameters.put("VPSProtocol", vpsProtocol); parameters.put("TxType", "REFUND"); parameters.put("Vendor", vendor); parameters.put("VendorTxCode", vendorTxCode); parameters.put("Amount", amount); parameters.put("Currency", currency); parameters.put("Description", description); parameters.put("RelatedVPSTxId", relatedVPSTxId); parameters.put("RelatedVendorTxCode", relatedVendorTxCode); parameters.put("RelatedSecurityKey", relatedSecurityKey); parameters.put("RelatedTxAuthNo", relatedTxAuthNo); //end - refund parameters try (CloseableHttpClient httpClient = SagePayUtil.getHttpClient()) { String successMessage = null; HttpPost httpPost = SagePayUtil.getHttpPost(props.get("refundUrl"), parameters); HttpResponse response = httpClient.execute(host, httpPost); Map<String, String> responseData = SagePayUtil.getResponseData(response); Debug.logInfo("response data -> " + responseData, module); String status = responseData.get("Status"); String statusDetail = responseData.get("StatusDetail"); resultMap.put("status", status); resultMap.put("statusDetail", statusDetail); //start - payment refunded if ("OK".equals(status)) { resultMap.put("vpsTxId", responseData.get("VPSTxId")); resultMap.put("txAuthNo", responseData.get("TxAuthNo")); successMessage = UtilProperties.getMessage(resource, "AccountingSagePayPaymentRefunded", locale); }/*from w w w . j a v a 2 s .c o m*/ //end - payment refunded //start - refund not authorized by the acquiring bank if ("NOTAUTHED".equals(status)) { successMessage = UtilProperties.getMessage(resource, "AccountingSagePayPaymentRefundNotAuthorized", locale); } //end - refund not authorized by the acquiring bank //start - refund request not formed properly or parameters missing if ("MALFORMED".equals(status)) { successMessage = UtilProperties.getMessage(resource, "AccountingSagePayPaymentRefundRequestMalformed", locale); } //end - refund request not formed properly or parameters missing //start - invalid information passed in parameters if ("INVALID".equals(status)) { successMessage = UtilProperties.getMessage(resource, "AccountingSagePayPaymentInvalidInformationPassed", locale); } //end - invalid information passed in parameters //start - problem at Sagepay if ("ERROR".equals(status)) { successMessage = UtilProperties.getMessage(resource, "AccountingSagePayPaymentError", locale); } //end - problem at Sagepay resultMap.put(ModelService.RESPONSE_MESSAGE, ModelService.RESPOND_SUCCESS); resultMap.put(ModelService.SUCCESS_MESSAGE, successMessage); } catch (UnsupportedEncodingException uee) { //exception in encoding parameters in httpPost Debug.logError(uee, "Error occurred in encoding parameters for HttpPost (" + uee.getMessage() + ")", module); resultMap = ServiceUtil .returnError(UtilProperties.getMessage(resource, "AccountingSagePayErrorEncodingParameters", UtilMisc.toMap("errorString", uee.getMessage()), locale)); } catch (ClientProtocolException cpe) { //from httpClient execute Debug.logError(cpe, "Error occurred in HttpClient execute(" + cpe.getMessage() + ")", module); resultMap = ServiceUtil .returnError(UtilProperties.getMessage(resource, "AccountingSagePayErrorHttpClientExecute", UtilMisc.toMap("errorString", cpe.getMessage()), locale)); } catch (IOException ioe) { //from httpClient execute or getResponsedata Debug.logError(ioe, "Error occurred in HttpClient execute or getting response (" + ioe.getMessage() + ")", module); resultMap = ServiceUtil.returnError( UtilProperties.getMessage(resource, "AccountingSagePayErrorHttpClientExecuteOrGettingResponse", UtilMisc.toMap("errorString", ioe.getMessage()), locale)); } return resultMap; }
From source file:org.cloudsimulator.persistence.GenericDAO.java
protected String executeQuery(final String ipAddressOfKB, final String select) { String query = PREFIX_ICR + " " + PREFIX_RDF + " " + PREFIX_XSD + " " + select; String result = null;/*from ww w . j a va2 s.c o m*/ try { ResponseMessageString responseMessage = KBDAO.queryKB(ipAddressOfKB, query); result = responseMessage.getResponseBody(); } catch (ClientProtocolException e) { LOGGER.error(e.getMessage(), e); } catch (IOException e) { LOGGER.error(e.getMessage(), e); } if (result != null) { return result; } else { throw new EmptyQueryResultException(); } }
From source file:com.coroptis.coidi.rp.services.impl.YadisServiceImpl.java
@Override public void readXrdsDocument(String url) { try {//from w w w . j ava2s .c o m HttpClient httpClient = httpService.getHttpClient(); HttpGet httpget = new HttpGet(url); httpget.setHeader("Accept", "application/xrds+xml"); HttpResponse response; response = httpClient.execute(httpget); HttpEntity entity = response.getEntity(); String string = EntityUtils.toString(entity); System.out.println(string); // extract "openid2.provider" } catch (ClientProtocolException e) { logger.error(e.getMessage(), e); throw new CoidiException(e.getMessage(), e); } catch (IOException e) { logger.error(e.getMessage(), e); throw new CoidiException(e.getMessage(), e); } }
From source file:eu.skillpro.ams.pscm.connector.amsservice.ui.CheckConnectionHandler.java
@Override public Object execute(ExecutionEvent event) throws ExecutionException { String message = ""; try {//from w ww. j a v a 2s . c om message = checkConnection(); } catch (ClientProtocolException e) { message += e.getMessage(); e.printStackTrace(); } catch (IOException e) { message += e.getMessage(); e.printStackTrace(); } MessageDialog.open(MessageDialog.INFORMATION, HandlerUtil.getActiveShell(event), "Connection check result", message, SWT.SHEET); return null; }
From source file:com.urucas.raddio.services.RequestTask.java
@Override protected String doInBackground(String... uri) { HttpClient httpclient = new DefaultHttpClient(); HttpResponse response;/*from www.j av a2s . co m*/ String responseString = null; try { response = httpclient.execute(new HttpGet(uri[0])); StatusLine statusLine = response.getStatusLine(); if (statusLine.getStatusCode() == HttpStatus.SC_OK) { ByteArrayOutputStream out = new ByteArrayOutputStream(); response.getEntity().writeTo(out); out.close(); responseString = out.toString(); if (isCancelled()) { rsh.onError("Task cancel"); } } else { //Closes the connection. response.getEntity().getContent().close(); throw new IOException(statusLine.getReasonPhrase()); } } catch (ClientProtocolException e) { rsh.onError(e.getMessage()); } catch (IOException e) { rsh.onError(e.getMessage()); } return responseString; }
From source file:com.normalexception.app.rx8club.task.ProfileTask.java
@Override protected Void doInBackground(Void... params) { try {//from w ww . j a va 2 s . c om HtmlFormUtils.updateProfile(token, customtext, homepage, bio, location, interests, occupation); } catch (ClientProtocolException e) { Log.e(TAG, e.getMessage(), e); } catch (IOException e) { Log.e(TAG, e.getMessage(), e); } return null; }
From source file:it.unicaradio.android.tasks.DownloadCaptchaAsyncTask.java
/** * {@inheritDoc}/*w w w . java2s . co m*/ */ @Override protected Response<String> doInBackground(Void... params) { try { JSONObject request = new JSONObject(); request.put("method", "getCaptcha"); byte[] postData = request.toString().getBytes(); Response<String> response = new Response<String>(); byte[] resultBytes = NetworkUtils.httpPost(WEB_SERVICE, postData, "application/json"); String resultString = new String(resultBytes); Log.d(TAG, "Got CAPTCHA answer: " + resultString); JSONObject resultJSON = new JSONObject(resultString); response.setResult(resultJSON.getString("result")); return response; } catch (ClientProtocolException e) { Log.e(TAG, e.getMessage(), e); return new Response<String>(Error.INTERNAL_GENERIC_ERROR); } catch (IOException e) { Log.e(TAG, e.getMessage(), e); return new Response<String>(Error.INTERNAL_DOWNLOAD_ERROR); } catch (HttpException e) { Log.e(TAG, e.getMessage(), e); return new Response<String>(Error.INTERNAL_GENERIC_ERROR); } catch (JSONException e) { Log.e(TAG, e.getMessage(), e); return new Response<String>(Error.INTERNAL_GENERIC_ERROR); } }
From source file:org.apache.marmotta.client.clients.ContextClient.java
public boolean delete(String uri) { boolean result = false; HttpClient httpClient = HTTPUtil.createClient(config); HttpDelete delete = new HttpDelete(uri); try {//from w w w .ja va 2 s.c o m HttpResponse response = httpClient.execute(delete); switch (response.getStatusLine().getStatusCode()) { case 200: log.debug(uri + "cleanned"); result = true; break; case 404: log.error(uri + " is not a suitable context"); result = false; default: log.error("error cleanning context: {} {}", new Object[] { response.getStatusLine().getStatusCode(), response.getStatusLine().getReasonPhrase() }); } } catch (ClientProtocolException e) { log.error(e.getMessage(), e); result = false; } catch (IOException e) { log.error(e.getMessage(), e); result = false; } finally { delete.releaseConnection(); } return result; }