// Path: src/main/java/org/audit4j/microservice/core/Ack.java
// public class Ack implements Serializable{
// 
// 	/**
// 	 * 
// 	 */
// 	private static final long serialVersionUID = -8707468501787579530L;
// 
// 	private String message;
// 	
// 	private int code;
// 
// 	public String getMessage() {
// 		return message;
// 	}
// 
// 	public void setMessage(String message) {
// 		this.message = message;
// 	}
// 
// 	public int getCode() {
// 		return code;
// 	}
// 
// 	public void setCode(int code) {
// 		this.code = code;
// 	}
// 
// 	public static Ack SUCCESS(){
// 		Ack ack = new Ack();
// 		ack.setCode(200);
// 		ack.setMessage("success");
// 		return ack;
// 	}
// 	
// 	public static Ack FAIL(){
// 		Ack ack = new Ack();
// 		ack.setCode(500);
// 		ack.setMessage("fail");
// 		return ack;
// 	}
// 	
// 	public static Ack UNAUTHORIZED(){
// 		Ack ack = new Ack();
// 		ack.setCode(401);
// 		ack.setMessage("unauthorized");
// 		return ack;
// 	}
// }
// 
// Path: src/main/java/org/audit4j/microservice/core/EventReceiver.java
// public interface EventReceiver {
// 
// 	Ack receive(AuditEvent event);
// 
// }
// 
// Path: src/main/java/org/audit4j/microservice/core/EventReceiverImpl.java
// public class EventReceiverImpl implements EventReceiver {
// 	@Override
// 	public Ack receive(AuditEvent event) {
// 		/*// Validate Event
// 		if (clientContext.containsClient(event.getMeta().client)) {
// 			AuditManager.getInstance().audit(event);
// 			return Ack.SUCCESS();
// 		} else {
// 			return Ack.UNAUTHORIZED();
// 		}*/
// 		
// 		AuditManager.getInstance().audit(event);
//         return Ack.SUCCESS();
// 	}
// }


import org.audit4j.core.dto.AuditEvent;
import org.audit4j.microservice.core.Ack;
import org.audit4j.microservice.core.EventReceiver;
import org.audit4j.microservice.core.EventReceiverImpl;
import io.vertx.core.http.HttpServerResponse;
import io.vertx.core.json.Json;
import io.vertx.core.json.JsonObject;
import io.vertx.ext.web.RoutingContext;
package org.audit4j.microservice.web.rest;



public class RESTAuditEventHandler  {

    private EventReceiver reciever = new EventReceiverImpl();

    public void handleEvent(RoutingContext routingContext) {
        JsonObject jsonEvent = routingContext.getBodyAsJson();
        AuditEvent event = Json.decodeValue(jsonEvent.encode(), AuditEvent.class);
        reciever.receive(event);

        HttpServerResponse response = routingContext.response();
        response.putHeader("content-type", "application/json")
// Path: src/main/java/org/audit4j/microservice/core/Ack.java
// public class Ack implements Serializable{
// 
// 	/**
// 	 * 
// 	 */
// 	private static final long serialVersionUID = -8707468501787579530L;
// 
// 	private String message;
// 	
// 	private int code;
// 
// 	public String getMessage() {
// 		return message;
// 	}
// 
// 	public void setMessage(String message) {
// 		this.message = message;
// 	}
// 
// 	public int getCode() {
// 		return code;
// 	}
// 
// 	public void setCode(int code) {
// 		this.code = code;
// 	}
// 
// 	public static Ack SUCCESS(){
// 		Ack ack = new Ack();
// 		ack.setCode(200);
// 		ack.setMessage("success");
// 		return ack;
// 	}
// 	
// 	public static Ack FAIL(){
// 		Ack ack = new Ack();
// 		ack.setCode(500);
// 		ack.setMessage("fail");
// 		return ack;
// 	}
// 	
// 	public static Ack UNAUTHORIZED(){
// 		Ack ack = new Ack();
// 		ack.setCode(401);
// 		ack.setMessage("unauthorized");
// 		return ack;
// 	}
// }
// 
// Path: src/main/java/org/audit4j/microservice/core/EventReceiver.java
// public interface EventReceiver {
// 
// 	Ack receive(AuditEvent event);
// 
// }
// 
// Path: src/main/java/org/audit4j/microservice/core/EventReceiverImpl.java
// public class EventReceiverImpl implements EventReceiver {
// 	@Override
// 	public Ack receive(AuditEvent event) {
// 		/*// Validate Event
// 		if (clientContext.containsClient(event.getMeta().client)) {
// 			AuditManager.getInstance().audit(event);
// 			return Ack.SUCCESS();
// 		} else {
// 			return Ack.UNAUTHORIZED();
// 		}*/
// 		
// 		AuditManager.getInstance().audit(event);
//         return Ack.SUCCESS();
// 	}
// }


// Path: src/main/java/org/audit4j/microservice/web/rest/RESTAuditEventHandler.java
import org.audit4j.core.dto.AuditEvent;
import org.audit4j.microservice.core.Ack;
import org.audit4j.microservice.core.EventReceiver;
import org.audit4j.microservice.core.EventReceiverImpl;
import io.vertx.core.http.HttpServerResponse;
import io.vertx.core.json.Json;
import io.vertx.core.json.JsonObject;
import io.vertx.ext.web.RoutingContext;

package org.audit4j.microservice.web.rest;



public class RESTAuditEventHandler  {

    private EventReceiver reciever = new EventReceiverImpl();

    public void handleEvent(RoutingContext routingContext) {
        JsonObject jsonEvent = routingContext.getBodyAsJson();
        AuditEvent event = Json.decodeValue(jsonEvent.encode(), AuditEvent.class);
        reciever.receive(event);

        HttpServerResponse response = routingContext.response();
        response.putHeader("content-type", "application/json")
                .end(new JsonObject(Json.encode(Ack.SUCCESS())).encodePrettily());