Search in sources :

Example 1 with Request

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;
}
Also used : Response(io.gravitee.rest.api.portal.rest.model.Response) Log(io.gravitee.rest.api.portal.rest.model.Log) HashMap(java.util.HashMap) Request(io.gravitee.rest.api.portal.rest.model.Request) ApplicationRequest(io.gravitee.rest.api.model.log.ApplicationRequest)

Aggregations

ApplicationRequest (io.gravitee.rest.api.model.log.ApplicationRequest)1 Log (io.gravitee.rest.api.portal.rest.model.Log)1 Request (io.gravitee.rest.api.portal.rest.model.Request)1 Response (io.gravitee.rest.api.portal.rest.model.Response)1 HashMap (java.util.HashMap)1