All Downloads are FREE. Search and download functionalities are using the official Maven repository.
Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
com.ingenico.connect.gateway.sdk.java.logging.ResponseLogMessageBuilder Maven / Gradle / Ivy
package com.ingenico.connect.gateway.sdk.java.logging;
/**
* A utility class to build request log messages.
*/
public class ResponseLogMessageBuilder extends LogMessageBuilder {
private final int statusCode;
private final long duration;
/**
* @deprecated Use {@link #ResponseLogMessageBuilder(String, int, BodyObfuscator, HeaderObfuscator)} instead.
*/
@Deprecated
public ResponseLogMessageBuilder(String requestId, int statusCode) {
this(requestId, statusCode, -1);
}
/**
* @deprecated Use {@link #ResponseLogMessageBuilder(String, int, long, BodyObfuscator, HeaderObfuscator)} instead.
*/
@Deprecated
public ResponseLogMessageBuilder(String requestId, int statusCode, long duration) {
super(requestId);
this.statusCode = statusCode;
this.duration = duration;
}
public ResponseLogMessageBuilder(String requestId, int statusCode,
BodyObfuscator bodyObfuscator, HeaderObfuscator headerObfuscator) {
this(requestId, statusCode, -1, bodyObfuscator, headerObfuscator);
}
public ResponseLogMessageBuilder(String requestId, int statusCode, long duration,
BodyObfuscator bodyObfuscator, HeaderObfuscator headerObfuscator) {
super(requestId, bodyObfuscator, headerObfuscator);
this.statusCode = statusCode;
this.duration = duration;
}
@Override
public String getMessage() {
if (duration < 0) {
final String messageTemplate = "Incoming response (requestId='%s'):%n"
+ " status-code: '%d'%n"
+ " headers: '%s'%n"
+ " content-type: '%s'%n"
+ " body: '%s'";
return String.format(messageTemplate, requestId(),
statusCode,
headers(),
emptyIfNull(contentType()),
emptyIfNull(body()));
} else {
final String messageTemplate = "Incoming response (requestId='%s', %d ms):%n"
+ " status-code: '%d'%n"
+ " headers: '%s'%n"
+ " content-type: '%s'%n"
+ " body: '%s'";
return String.format(messageTemplate, requestId(), duration,
statusCode,
headers(),
emptyIfNull(contentType()),
emptyIfNull(body()));
}
}
}