// Path: soap-server/src/main/java/com/cookbook/tutorial/service/DAOCookBookServiceFactory.java
// public class DAOCookBookServiceFactory {
// 
//     private static IDAOCookBookService instance;
// 
//     public static IDAOCookBookService getInstance(){
//         if(instance==null){
//             instance = new CookBookDefaultBackEndImp();
//         }
//         return instance;
//     }
// }


import com.cookbook.tutorial.service.DAOCookBookServiceFactory;
import com.cookbook.tutorial.service.*;
import org.parboiled.common.StringUtils;
import javax.ws.rs.*;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
package com.cookbook.tutorial;


 
@Path("/ingredient")
public class IngredientResource {

	@GET
	@Produces(MediaType.APPLICATION_JSON)
	public Response get(@QueryParam("access_token") String token,@QueryParam("query") String query, @QueryParam("page") Integer page, @QueryParam("pageSize") Integer pageSize) {
		if(!Constants.DEFAULT_TOKEN.equals(token)){
			return Response.status(401).entity(new ErrorResponse("invalid_client","Invalid Token")).build();
		}
		try {
			if(StringUtils.isEmpty(query)){
				query="GET ALL FROM INGREDIENT";
			}
			if(page==null){
				page = 0;
			}
			if(pageSize==null){
				pageSize = 0;
			}
// Path: soap-server/src/main/java/com/cookbook/tutorial/service/DAOCookBookServiceFactory.java
// public class DAOCookBookServiceFactory {
// 
//     private static IDAOCookBookService instance;
// 
//     public static IDAOCookBookService getInstance(){
//         if(instance==null){
//             instance = new CookBookDefaultBackEndImp();
//         }
//         return instance;
//     }
// }


// Path: rest-server/src/main/java/com/cookbook/tutorial/IngredientResource.java
import com.cookbook.tutorial.service.DAOCookBookServiceFactory;
import com.cookbook.tutorial.service.*;
import org.parboiled.common.StringUtils;
import javax.ws.rs.*;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;

package com.cookbook.tutorial;


 
@Path("/ingredient")
public class IngredientResource {

	@GET
	@Produces(MediaType.APPLICATION_JSON)
	public Response get(@QueryParam("access_token") String token,@QueryParam("query") String query, @QueryParam("page") Integer page, @QueryParam("pageSize") Integer pageSize) {
		if(!Constants.DEFAULT_TOKEN.equals(token)){
			return Response.status(401).entity(new ErrorResponse("invalid_client","Invalid Token")).build();
		}
		try {
			if(StringUtils.isEmpty(query)){
				query="GET ALL FROM INGREDIENT";
			}
			if(page==null){
				page = 0;
			}
			if(pageSize==null){
				pageSize = 0;
			}
			return Response.status(200).entity(DAOCookBookServiceFactory.getInstance().searchWithQuery(query,page,pageSize)).build();