// Path: src/main/java/net/redborder/cep/rest/exceptions/RestException.java
// public class RestException extends Exception {
//     public RestException(String message) {
//         super(message);
//     }
// 
//     public RestException(String message, Throwable cause) {
//         super(message, cause);
//     }
// }
// 
// Path: src/main/java/net/redborder/cep/rest/exceptions/RestInvalidException.java
// public class RestInvalidException extends RestException {
//     public RestInvalidException(String message) {
//         super(message);
//     }
// 
//     public RestInvalidException(String message, Throwable cause) {
//         super(message, cause);
//     }
// }
// 
// Path: src/main/java/net/redborder/cep/rest/exceptions/RestNotFoundException.java
// public class RestNotFoundException extends RestException {
//     public RestNotFoundException(String message) {
//         super(message);
//     }
// 
//     public RestNotFoundException(String message, Throwable cause) {
//         super(message, cause);
//     }
// }


import net.redborder.cep.rest.exceptions.RestException;
import net.redborder.cep.rest.exceptions.RestInvalidException;
import net.redborder.cep.rest.exceptions.RestNotFoundException;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.codehaus.jackson.map.ObjectMapper;
import javax.inject.Singleton;
import javax.ws.rs.*;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
package net.redborder.cep.rest;



/**
 * This class implements the methods available from the HTTP REST API.
 */

@Singleton
@Path("/v1/")
public class RestRules {
    private final Logger log = LogManager.getLogger(RestRules.class);
    private ObjectMapper mapper = new ObjectMapper();

    /**
     * This method handles HTTP POST requests with JSON data.
     * It sends an add operation to the listener passing it the JSON data.
     *
     * @param json A string in JSON format.
     * @return Response with the appropriate HTTP code.
     */

    @POST
    @Consumes(MediaType.APPLICATION_JSON)
    @Produces(MediaType.APPLICATION_JSON)
    public Response add(String json) {
        RestListener listener = RestManager.getListener();
        Response response;

        try {
            log.info("Add request with json: {}", json);
            listener.add(parseMap(json));
            response = Response.ok().build();
// Path: src/main/java/net/redborder/cep/rest/exceptions/RestException.java
// public class RestException extends Exception {
//     public RestException(String message) {
//         super(message);
//     }
// 
//     public RestException(String message, Throwable cause) {
//         super(message, cause);
//     }
// }
// 
// Path: src/main/java/net/redborder/cep/rest/exceptions/RestInvalidException.java
// public class RestInvalidException extends RestException {
//     public RestInvalidException(String message) {
//         super(message);
//     }
// 
//     public RestInvalidException(String message, Throwable cause) {
//         super(message, cause);
//     }
// }
// 
// Path: src/main/java/net/redborder/cep/rest/exceptions/RestNotFoundException.java
// public class RestNotFoundException extends RestException {
//     public RestNotFoundException(String message) {
//         super(message);
//     }
// 
//     public RestNotFoundException(String message, Throwable cause) {
//         super(message, cause);
//     }
// }


// Path: src/main/java/net/redborder/cep/rest/RestRules.java
import net.redborder.cep.rest.exceptions.RestException;
import net.redborder.cep.rest.exceptions.RestInvalidException;
import net.redborder.cep.rest.exceptions.RestNotFoundException;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.codehaus.jackson.map.ObjectMapper;
import javax.inject.Singleton;
import javax.ws.rs.*;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

package net.redborder.cep.rest;



/**
 * This class implements the methods available from the HTTP REST API.
 */

@Singleton
@Path("/v1/")
public class RestRules {
    private final Logger log = LogManager.getLogger(RestRules.class);
    private ObjectMapper mapper = new ObjectMapper();

    /**
     * This method handles HTTP POST requests with JSON data.
     * It sends an add operation to the listener passing it the JSON data.
     *
     * @param json A string in JSON format.
     * @return Response with the appropriate HTTP code.
     */

    @POST
    @Consumes(MediaType.APPLICATION_JSON)
    @Produces(MediaType.APPLICATION_JSON)
    public Response add(String json) {
        RestListener listener = RestManager.getListener();
        Response response;

        try {
            log.info("Add request with json: {}", json);
            listener.add(parseMap(json));
            response = Response.ok().build();
        } catch (RestInvalidException e) {