// Path: src/main/java/org/mockenize/model/LogBean.java
// @Data
// public class LogBean implements Serializable, Cacheable {
// 
// 	private static final long serialVersionUID = 1L;
// 
// 	private String key;
// 
// 	private LogType type;
// 
// 	private String url;
// 
// 	private String path;
// 
// 	private String method;
// 
// 	private RequestLogBean request;
// 
// 	private ResponseLogBean response;
// 
// 	private Date date = new Date();
// 
// 	protected LogBean() {
// 	}
// 
// 	public LogBean(UUID key, LogType type) {
// 		this.key = key.toString();
// 		this.type = type;
// 	}
// 
// }
// 
// Path: src/main/java/org/mockenize/model/LogType.java
// public enum LogType {
//     MOCK,
//     PROXY,
//     NONE
// }
// 
// Path: src/main/java/org/mockenize/model/RequestLogBean.java
// @Data
// public class RequestLogBean implements Serializable {
// 
// 	private static final long serialVersionUID = 1L;
// 
// 	private Map<String, String> headers = new HashMap<>();
// 
// 	private transient JsonNode body;
// }
// 
// Path: src/main/java/org/mockenize/service/LoggingService.java
// @Service
// public class LoggingService {
// 
//     @Autowired
//     private LogRepository logRepository;
// 
//     public void save(LogBean logBean) {
//         logRepository.save(logBean);
//     }
// 
//     public Collection<LogBean> getAll() {
//         return logRepository.findAll();
//     }
// 
//     public LogBean getByKey(UUID key) {
//         return logRepository.findByKey(key.toString());
//     }
// 
// 
//     public LogBean delete(UUID key) {
//         return logRepository.delete(key.toString());
//     }
// 
//     public Collection<LogBean> deleteAll() {
//        return logRepository.deleteAll();
//     }
// 
// 	@SuppressWarnings("unchecked")
// 	public Collection<LogBean> findByFilters(JsonNode jsonNode) {
// 		Iterator<String> fieldNames = jsonNode.fieldNames();
// 		Predicate<String, LogBean> predicate = null;
// 		while(fieldNames.hasNext()) {
// 			String field = fieldNames.next();
// 			String value = jsonNode.get(field).asText();
// 
// 			Predicate<String, LogBean> tmp = Predicates.equal(field, value);
// 			if(predicate == null) {
// 				predicate = tmp;
// 			} else {
// 				predicate = Predicates.and(predicate, tmp);
// 			}
// 		}
// 		return logRepository.findByPredicate(predicate);
// 	}
// }


import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.net.URI;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import javax.annotation.Priority;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.container.ContainerRequestContext;
import javax.ws.rs.container.ContainerRequestFilter;
import javax.ws.rs.core.UriInfo;
import javax.ws.rs.ext.Provider;
import org.glassfish.jersey.message.internal.ReaderWriter;
import org.mockenize.model.LogBean;
import org.mockenize.model.LogType;
import org.mockenize.model.RequestLogBean;
import org.mockenize.service.LoggingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.base.Joiner;
import com.google.common.collect.Maps;
package org.mockenize.provider.filter;





@Provider
@Component
@Priority(Integer.MIN_VALUE)
public class RequestLoggingFilter implements ContainerRequestFilter {

	public static final String KEY = "Mockenize-Id";

	private static final Joiner joiner = Joiner.on(", ");

	@Autowired
	private ObjectMapper objectMapper;

	@Autowired
	private LoggingService loggingService;

	@Autowired
	private HttpServletRequest request;

	@Override
	public void filter(ContainerRequestContext requestContext) throws IOException {
		LogType logType = getRequestType(requestContext.getUriInfo());
		if (LogType.MOCK.equals(logType)) {
			UUID key = UUID.randomUUID();
			request.setAttribute(KEY, key);
			URI requestUri = requestContext.getUriInfo().getRequestUri();
// Path: src/main/java/org/mockenize/model/LogBean.java
// @Data
// public class LogBean implements Serializable, Cacheable {
// 
// 	private static final long serialVersionUID = 1L;
// 
// 	private String key;
// 
// 	private LogType type;
// 
// 	private String url;
// 
// 	private String path;
// 
// 	private String method;
// 
// 	private RequestLogBean request;
// 
// 	private ResponseLogBean response;
// 
// 	private Date date = new Date();
// 
// 	protected LogBean() {
// 	}
// 
// 	public LogBean(UUID key, LogType type) {
// 		this.key = key.toString();
// 		this.type = type;
// 	}
// 
// }
// 
// Path: src/main/java/org/mockenize/model/LogType.java
// public enum LogType {
//     MOCK,
//     PROXY,
//     NONE
// }
// 
// Path: src/main/java/org/mockenize/model/RequestLogBean.java
// @Data
// public class RequestLogBean implements Serializable {
// 
// 	private static final long serialVersionUID = 1L;
// 
// 	private Map<String, String> headers = new HashMap<>();
// 
// 	private transient JsonNode body;
// }
// 
// Path: src/main/java/org/mockenize/service/LoggingService.java
// @Service
// public class LoggingService {
// 
//     @Autowired
//     private LogRepository logRepository;
// 
//     public void save(LogBean logBean) {
//         logRepository.save(logBean);
//     }
// 
//     public Collection<LogBean> getAll() {
//         return logRepository.findAll();
//     }
// 
//     public LogBean getByKey(UUID key) {
//         return logRepository.findByKey(key.toString());
//     }
// 
// 
//     public LogBean delete(UUID key) {
//         return logRepository.delete(key.toString());
//     }
// 
//     public Collection<LogBean> deleteAll() {
//        return logRepository.deleteAll();
//     }
// 
// 	@SuppressWarnings("unchecked")
// 	public Collection<LogBean> findByFilters(JsonNode jsonNode) {
// 		Iterator<String> fieldNames = jsonNode.fieldNames();
// 		Predicate<String, LogBean> predicate = null;
// 		while(fieldNames.hasNext()) {
// 			String field = fieldNames.next();
// 			String value = jsonNode.get(field).asText();
// 
// 			Predicate<String, LogBean> tmp = Predicates.equal(field, value);
// 			if(predicate == null) {
// 				predicate = tmp;
// 			} else {
// 				predicate = Predicates.and(predicate, tmp);
// 			}
// 		}
// 		return logRepository.findByPredicate(predicate);
// 	}
// }


// Path: src/main/java/org/mockenize/provider/filter/RequestLoggingFilter.java
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.net.URI;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import javax.annotation.Priority;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.container.ContainerRequestContext;
import javax.ws.rs.container.ContainerRequestFilter;
import javax.ws.rs.core.UriInfo;
import javax.ws.rs.ext.Provider;
import org.glassfish.jersey.message.internal.ReaderWriter;
import org.mockenize.model.LogBean;
import org.mockenize.model.LogType;
import org.mockenize.model.RequestLogBean;
import org.mockenize.service.LoggingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.base.Joiner;
import com.google.common.collect.Maps;

package org.mockenize.provider.filter;





@Provider
@Component
@Priority(Integer.MIN_VALUE)
public class RequestLoggingFilter implements ContainerRequestFilter {

	public static final String KEY = "Mockenize-Id";

	private static final Joiner joiner = Joiner.on(", ");

	@Autowired
	private ObjectMapper objectMapper;

	@Autowired
	private LoggingService loggingService;

	@Autowired
	private HttpServletRequest request;

	@Override
	public void filter(ContainerRequestContext requestContext) throws IOException {
		LogType logType = getRequestType(requestContext.getUriInfo());
		if (LogType.MOCK.equals(logType)) {
			UUID key = UUID.randomUUID();
			request.setAttribute(KEY, key);
			URI requestUri = requestContext.getUriInfo().getRequestUri();
			LogBean logBean = new LogBean(key, getRequestType(requestContext.getUriInfo()));