diff options
author | su622b <sunil.unnava@att.com> | 2018-04-09 14:47:27 -0400 |
---|---|---|
committer | su622b <sunil.unnava@att.com> | 2018-04-09 14:47:42 -0400 |
commit | 20f5a4a523b284437dc7f76d2bc012ebb4cd669b (patch) | |
tree | 23c87130b25ea4322f2c2af584ccbd082d3c30ff /src/main/java/com/att/nsa/mr/client/impl/MRSimplerBatchPublisher.java | |
parent | bc1cad19ab499422b902bf8a2ee2c9900c03e906 (diff) |
Support for post without auth
Issue-ID: DMAAP-399
Change-Id: I0e769c5554a8adf7a606bebe1c23b35fbab9c82c
Signed-off-by: su622b <sunil.unnava@att.com>
Diffstat (limited to 'src/main/java/com/att/nsa/mr/client/impl/MRSimplerBatchPublisher.java')
-rw-r--r-- | src/main/java/com/att/nsa/mr/client/impl/MRSimplerBatchPublisher.java | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/src/main/java/com/att/nsa/mr/client/impl/MRSimplerBatchPublisher.java b/src/main/java/com/att/nsa/mr/client/impl/MRSimplerBatchPublisher.java index 77d47e8..6e1154f 100644 --- a/src/main/java/com/att/nsa/mr/client/impl/MRSimplerBatchPublisher.java +++ b/src/main/java/com/att/nsa/mr/client/impl/MRSimplerBatchPublisher.java @@ -530,6 +530,28 @@ public class MRSimplerBatchPublisher extends MRBaseClient implements MRBatchingP fPending.clear(); return pubResponse; } + + if (ProtocolTypeConstants.HTTPNOAUTH.getValue().equalsIgnoreCase(protocolFlag)) { + getLog().info("sending " + fPending.size() + " msgs to " + httpurl + ". Oldest: " + + (nowMs - fPending.peek().timestamp) + " ms"); + final String result = postNoAuthWithResponse(httpurl, baseStream.toByteArray(), contentType); + + // Here we are checking for error response. If HTTP status + // code is not within the http success response code + // then we consider this as error and return false + pubResponse = createMRPublisherResponse(result, pubResponse); + + if (Integer.valueOf(pubResponse.getResponseCode()) < 200 + || Integer.valueOf(pubResponse.getResponseCode()) > 299) { + + return pubResponse; + } + + final String logLine = String.valueOf((Clock.now() - startMs)); + getLog().info(logLine); + fPending.clear(); + return pubResponse; + } } catch (IllegalArgumentException x) { getLog().warn(x.getMessage(), x); pubResponse.setResponseCode(String.valueOf(HttpStatus.SC_BAD_REQUEST)); @@ -572,7 +594,7 @@ public class MRSimplerBatchPublisher extends MRBaseClient implements MRBatchingP return pubResponse; } - private MRPublisherResponse createMRPublisherResponse(String reply, MRPublisherResponse mrPubResponse) { + public MRPublisherResponse createMRPublisherResponse(String reply, MRPublisherResponse mrPubResponse) { if (reply.isEmpty()) { |