All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.ingenico.connect.gateway.sdk.java.logging.RequestLogMessageBuilder Maven / Gradle / Ivy

Go to download

SDK to communicate with the Ingenico ePayments platform using the Ingenico Connect Server API

There is a newer version: 6.47.0
Show newest version
package com.ingenico.connect.gateway.sdk.java.logging;

/**
 * A utility class to build request log messages.
 */
public class RequestLogMessageBuilder extends LogMessageBuilder {

	private final String method;
	private final String uri;

	public RequestLogMessageBuilder(String requestId, String method, String uri) {
		super(requestId);

		this.method = method;
		this.uri = uri;
	}

	@Override
	public String getMessage() {

		final String messageTemplateWithoutBody = "Outgoing request (requestId='%s'):%n"
				+ "  method:       '%s'%n"
				+ "  uri:          '%s'%n"
				+ "  headers:      '%s'";

		final String messageTemplateWithBody = messageTemplateWithoutBody + "%n"
				+ "  content-type: '%s'%n"
				+ "  body:         '%s'";

		String body = body();
		if (body == null) {

			return String.format(messageTemplateWithoutBody, requestId(),
					emptyIfNull(method),
					emptyIfNull(uri),
					headers());

		} else {

			return String.format(messageTemplateWithBody, requestId(),
					emptyIfNull(method),
					emptyIfNull(uri),
					headers(),
					emptyIfNull(contentType()),
					body);
		}
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy