// 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;
    @GET
    @Produces(MediaType.APPLICATION_JSON)
    public Response list() {
        RestListener listener = RestManager.getListener();
        Response response;

        try {
            List<Map<String, Object>> list = listener.list();
            log.info("List request {}", list);
            response = Response.ok().entity(list).build();
        } catch (Exception e) {
            e.printStackTrace();
            response = Response.serverError()
                    .entity(toMap(e, Response.Status.INTERNAL_SERVER_ERROR))
                    .build();
        }

        return response;
    }

    // Helper methods

    /**
     * This method returns a map from a given json string
     *
     * @param str The JSON string to parse
     * @return A map with the JSON contents
     * @throws RestException If the string does not have a valid JSON format
     */

// 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;

    @GET
    @Produces(MediaType.APPLICATION_JSON)
    public Response list() {
        RestListener listener = RestManager.getListener();
        Response response;

        try {
            List<Map<String, Object>> list = listener.list();
            log.info("List request {}", list);
            response = Response.ok().entity(list).build();
        } catch (Exception e) {
            e.printStackTrace();
            response = Response.serverError()
                    .entity(toMap(e, Response.Status.INTERNAL_SERVER_ERROR))
                    .build();
        }

        return response;
    }

    // Helper methods

    /**
     * This method returns a map from a given json string
     *
     * @param str The JSON string to parse
     * @return A map with the JSON contents
     * @throws RestException If the string does not have a valid JSON format
     */

    private Map<String, Object> parseMap(String str) throws RestException {