// Path: src/main/java/org/mockenize/exception/ResourceNotFoundException.java
// public class ResourceNotFoundException extends WebApplicationException {
// 
// 	private static final long serialVersionUID = -1336666303655740602L;
// 
// 	public ResourceNotFoundException(String resource) {
// 		super("Resource not found: " + resource, Response.Status.NOT_FOUND);
// 	}
// }


import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.core.Response;
import org.mockenize.exception.ResourceNotFoundException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.fasterxml.jackson.databind.JsonNode;
package org.mockenize.service;




@Service
public class MockenizeService {

	@Autowired
	private MockService mockService;

	@Autowired
	private ProxyService proxyService;

	public Response getResponse(HttpServletRequest request, JsonNode body) {
		String path = request.getRequestURI();
		String method = request.getMethod();

		if (mockService.exists(method, path)) {
			return mockService.getResponse(request, body);
		} else if (proxyService.exists(path)) {
			return proxyService.getResponse(request, body);
		}

// Path: src/main/java/org/mockenize/exception/ResourceNotFoundException.java
// public class ResourceNotFoundException extends WebApplicationException {
// 
// 	private static final long serialVersionUID = -1336666303655740602L;
// 
// 	public ResourceNotFoundException(String resource) {
// 		super("Resource not found: " + resource, Response.Status.NOT_FOUND);
// 	}
// }


// Path: src/main/java/org/mockenize/service/MockenizeService.java
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.core.Response;
import org.mockenize.exception.ResourceNotFoundException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.fasterxml.jackson.databind.JsonNode;

package org.mockenize.service;




@Service
public class MockenizeService {

	@Autowired
	private MockService mockService;

	@Autowired
	private ProxyService proxyService;

	public Response getResponse(HttpServletRequest request, JsonNode body) {
		String path = request.getRequestURI();
		String method = request.getMethod();

		if (mockService.exists(method, path)) {
			return mockService.getResponse(request, body);
		} else if (proxyService.exists(path)) {
			return proxyService.getResponse(request, body);
		}

		throw new ResourceNotFoundException(path);