diff options
Diffstat (limited to 'src/main/java/com/att/nsa/mr/client/impl/MRBaseClient.java')
-rw-r--r-- | src/main/java/com/att/nsa/mr/client/impl/MRBaseClient.java | 42 |
1 files changed, 36 insertions, 6 deletions
diff --git a/src/main/java/com/att/nsa/mr/client/impl/MRBaseClient.java b/src/main/java/com/att/nsa/mr/client/impl/MRBaseClient.java index 0cffa7d..c3d1c26 100644 --- a/src/main/java/com/att/nsa/mr/client/impl/MRBaseClient.java +++ b/src/main/java/com/att/nsa/mr/client/impl/MRBaseClient.java @@ -109,6 +109,20 @@ public class MRBaseClient extends HttpClient implements MRClient { "Authentication Failed: Username/password/AuthKey/AuthDate parameter(s) cannot be null or empty."); } } + + public JSONObject postNoAuth(final String path, final byte[] data, String contentType) + throws HttpException, JSONException { + WebTarget target = null; + Response response = null; + if (contentType == null) { + contentType = "text/pain"; + } + target = DmaapClientUtil.getTarget(path); + + response = DmaapClientUtil.postResponsewtNoAuth(target, data, contentType); + + return getResponseDataInJson(response); + } public String postWithResponse(final String path, final byte[] data, final String contentType, final String username, final String password, final String protocolFlag) @@ -122,13 +136,29 @@ public class MRBaseClient extends HttpClient implements MRClient { response = DmaapClientUtil.getResponsewtBasicAuth(target, encoding); - responseData = (String)response.getEntity(); + responseData = (String)response.readEntity(String.class); return responseData; } else { throw new HttpException( "Authentication Failed: Username/password/AuthKey/AuthDate parameter(s) cannot be null or empty."); } } + + public String postNoAuthWithResponse(final String path, final byte[] data, String contentType) + throws HttpException, JSONException { + + String responseData = null; + WebTarget target = null; + Response response = null; + if (contentType == null) { + contentType = "text/pain"; + } + target = DmaapClientUtil.getTarget(path); + + response = DmaapClientUtil.postResponsewtNoAuth(target, data, contentType); + responseData = (String) response.readEntity(String.class); + return responseData; + } public JSONObject postAuth(final String path, final byte[] data, final String contentType, final String authKey, final String authDate, final String username, final String password, final String protocolFlag) @@ -154,7 +184,7 @@ public class MRBaseClient extends HttpClient implements MRClient { Response response=null; target = DmaapClientUtil.getTarget(path, username, password); response = DmaapClientUtil.postResponsewtCambriaAuth(target, authKey, authDate, data, contentType); - responseData = (String)response.getEntity(); + responseData = (String)response.readEntity(String.class); return responseData; } else { @@ -208,7 +238,7 @@ public class MRBaseClient extends HttpClient implements MRClient { fLog.info("TransactionId : " + transactionid); } - responseData = (String)response.getEntity(); + responseData = (String)response.readEntity(String.class); return responseData; } else { throw new HttpException( @@ -262,7 +292,7 @@ public class MRBaseClient extends HttpClient implements MRClient { fLog.info("TransactionId : " + transactionid); } - responseData = (String)response.getEntity(); + responseData = (String)response.readEntity(String.class); return responseData; } else { throw new HttpException( @@ -285,7 +315,7 @@ public class MRBaseClient extends HttpClient implements MRClient { fLog.info("TransactionId : " + transactionid); } - responseData = (String)response.getEntity(); + responseData = (String)response.readEntity(String.class); return responseData; } @@ -325,7 +355,7 @@ public class MRBaseClient extends HttpClient implements MRClient { jsonObject.put("status", response.getStatus()); return jsonObject; } - String responseData = (String)response.getEntity(); + String responseData = (String)response.readEntity(String.class); JSONTokener jsonTokener = new JSONTokener(responseData); JSONObject jsonObject = null; |