// 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;
        } catch (Exception e) {
            e.printStackTrace();
            response = Response.serverError()
                    .entity(toMap(e, Response.Status.INTERNAL_SERVER_ERROR))
                    .build();
        }

        return response;
    }

    /**
     * This methods handles HTTP DELETE requests.
     * It sends an remove operation to the listener passing it an ID.
     *
     * @param id The ID sent by the user on the request
     * @return Response with the appropriate HTTP code.
     */

    @DELETE
    @Path("/{id}")
    @Produces(MediaType.APPLICATION_JSON)
    public Response remove(@PathParam("id") String id) {
        RestListener listener = RestManager.getListener();
        Response response;

        // Check if the listener accepted the operation
        try {
            log.info("Remove request with id: {}", id);
            listener.remove(id);
            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;

        } catch (Exception e) {
            e.printStackTrace();
            response = Response.serverError()
                    .entity(toMap(e, Response.Status.INTERNAL_SERVER_ERROR))
                    .build();
        }

        return response;
    }

    /**
     * This methods handles HTTP DELETE requests.
     * It sends an remove operation to the listener passing it an ID.
     *
     * @param id The ID sent by the user on the request
     * @return Response with the appropriate HTTP code.
     */

    @DELETE
    @Path("/{id}")
    @Produces(MediaType.APPLICATION_JSON)
    public Response remove(@PathParam("id") String id) {
        RestListener listener = RestManager.getListener();
        Response response;

        // Check if the listener accepted the operation
        try {
            log.info("Remove request with id: {}", id);
            listener.remove(id);
            response = Response.ok().build();
        } catch (RestNotFoundException e) {