use of io.gravitee.rest.api.portal.rest.model.Request in project gravitee-management-rest-api by gravitee-io.
the class LogMapper method convert.
public Log convert(ApplicationRequest applicationRequest) {
final Log logItem = new Log();
logItem.setApi(applicationRequest.getApi());
logItem.setHost(applicationRequest.getHost());
logItem.setId(applicationRequest.getId());
logItem.setMetadata(applicationRequest.getMetadata() == null ? null : new HashMap(applicationRequest.getMetadata()));
logItem.setMethod(HttpMethod.fromValue(applicationRequest.getMethod().name()));
logItem.setPath(applicationRequest.getPath());
logItem.setPlan(applicationRequest.getPlan());
if (applicationRequest.getRequest() != null) {
logItem.setRequest(new Request().body(applicationRequest.getRequest().getBody()).headers(applicationRequest.getRequest().getHeaders()).method(HttpMethod.fromValue(applicationRequest.getRequest().getMethod().name())).uri(applicationRequest.getRequest().getUri()));
}
logItem.setRequestContentLength(applicationRequest.getRequestContentLength());
if (applicationRequest.getResponse() != null) {
logItem.setResponse(new Response().body(applicationRequest.getResponse().getBody()).status(applicationRequest.getResponse().getStatus()).headers(applicationRequest.getResponse().getHeaders()));
}
logItem.setResponseContentLength(applicationRequest.getResponseContentLength());
logItem.setResponseTime(applicationRequest.getResponseTime());
logItem.setSecurityToken(applicationRequest.getSecurityToken());
logItem.setSecurityType(applicationRequest.getSecurityType());
logItem.setStatus(applicationRequest.getStatus());
logItem.setTimestamp(applicationRequest.getTimestamp());
logItem.setTransactionId(applicationRequest.getTransactionId());
logItem.setUser(applicationRequest.getUser());
return logItem;
}
Aggregations