// Path: src/main/java/eu/cloudscale/showcase/db/BuyConfirmResult.java
// public class BuyConfirmResult
// {
// 	public IOrders order;
// 	public IShoppingCart cart;
// 	
// 	public BuyConfirmResult(IOrders order2, IShoppingCart sc)
//     {
//         order = order2;
//         cart = sc;
//     }
// 
// 	
//     public IOrders getOrder()
//     {
//     	return order;
//     }
// 
// 	
//     public void setOrder(IOrders order)
//     {
//     	this.order = order;
//     }
// 
// 	
//     public IShoppingCart getCart()
//     {
//     	return cart;
//     }
// 
// 	
//     public void setCart(IShoppingCart cart)
//     {
//     	this.cart = cart;
//     }
// 	
// }
// 
// Path: src/main/java/eu/cloudscale/showcase/servlets/helpers/PaymentService.java
// @Service("paymentService")
// public class PaymentService{
// 	public static final String BASE_URL = "https://arcane-meadow-6418.herokuapp.com/";	
// 	
// 	@Async
// 	public Future<String> callPaymentService(String distribution, String attr1, String attr2, String attr3)
// 	{
// 		try {
// 			ExecutorService executor = Executors.newFixedThreadPool(1);
// 			String url = this.getUrl(distribution, attr1, attr2, attr3);
// 			Future<Response> response = executor.submit(new Request(new URL(url)));
// 			InputStream input = response.get().getBody();
// 			executor.shutdown();
// 		
// 			String body = IOUtils.toString(input, "UTF-8");
// 			return new AsyncResult<String>(body);
// 		} catch (MalformedURLException e) {
// 			e.printStackTrace();
// 		} 
// 		catch (InterruptedException e) {
// 			e.printStackTrace();
// 		} 
// 		catch (ExecutionException e) {
// 			e.printStackTrace();
// 		} catch (IOException e) {
// 			e.printStackTrace();
// 		}
// 		return null;
// 	}
// 	
// 	private String getUrl(String distribution, String attr1, String attr2, String attr3)
// 	{
// 		String url = "";
// 		if (distribution.equals("gauss")) {
//             url = "?mu=" + attr1 + "&sigma=" + attr2 + "&k=0";
//         }
//         if (distribution.equals("expo")) {
//             url = "?lambda=" + attr1 + "&k=" + attr3;
//         }
//         if (distribution.equals("gamma")) {
//             url = "?alpha=" + attr1 + "&beta=" + attr2 + "&k=" + attr3;
//         }
//         if (distribution.equals("log")) {
//             url = "?mu=" + attr1 + "&sigma=" + attr2 + "&k=" + attr3;
//         }
//         if (distribution.equals("pareto")) {
//             url = "?alpha=" + attr1 + "&k=" + attr3;
//         }
//         if (distribution.equals("weibull")) {
//             url = "?alpha=" + attr1 + "&beta=" + attr2 + "&k=" + attr3;
//         }
//         if (distribution.equals("uniform")){
//             url = "?a=" + attr1 + "&b=" + attr2;
//         }
//         if (distribution.equals("constant"))
//         {
//             url = "?c=" + attr1;
//         }
//         return BASE_URL + distribution + url + "&test=false";
// 	}
// }


import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.Future;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
import eu.cloudscale.showcase.db.BuyConfirmResult;
import eu.cloudscale.showcase.servlets.helpers.PaymentService;
		Integer customerId = null;
		if( customerIdString != null && !customerIdString.isEmpty() )
		{
			customerId = Integer.parseInt(  customerIdString );
		}
		
		String ccType = request.getParameter( "CC_TYPE" );
		String ccNumber_str = request.getParameter( "CC_NUMBER" );
		Long ccNumber = null;
		if( !ccNumber_str.isEmpty() )
			ccNumber = Long.parseLong( ccNumber_str );
		
		SimpleDateFormat sdf = new SimpleDateFormat("mm/dd/yyyy");
		String ccName = request.getParameter( "CC_NAME" );
		Date ccExpiry = null;
        try
        {
	        ccExpiry = sdf.parse(request.getParameter( "CC_EXPIRY" ));
        }
        catch ( ParseException e )
        {
	        e.printStackTrace();
        }
		String shipping = request.getParameter( "SHIPPING" );
		String street1 = request.getParameter( "street1" );
		
		
		BuyConfirmResult res = null;
		if( street1 != null && street1.equals( "" ))
		{
// Path: src/main/java/eu/cloudscale/showcase/db/BuyConfirmResult.java
// public class BuyConfirmResult
// {
// 	public IOrders order;
// 	public IShoppingCart cart;
// 	
// 	public BuyConfirmResult(IOrders order2, IShoppingCart sc)
//     {
//         order = order2;
//         cart = sc;
//     }
// 
// 	
//     public IOrders getOrder()
//     {
//     	return order;
//     }
// 
// 	
//     public void setOrder(IOrders order)
//     {
//     	this.order = order;
//     }
// 
// 	
//     public IShoppingCart getCart()
//     {
//     	return cart;
//     }
// 
// 	
//     public void setCart(IShoppingCart cart)
//     {
//     	this.cart = cart;
//     }
// 	
// }
// 
// Path: src/main/java/eu/cloudscale/showcase/servlets/helpers/PaymentService.java
// @Service("paymentService")
// public class PaymentService{
// 	public static final String BASE_URL = "https://arcane-meadow-6418.herokuapp.com/";	
// 	
// 	@Async
// 	public Future<String> callPaymentService(String distribution, String attr1, String attr2, String attr3)
// 	{
// 		try {
// 			ExecutorService executor = Executors.newFixedThreadPool(1);
// 			String url = this.getUrl(distribution, attr1, attr2, attr3);
// 			Future<Response> response = executor.submit(new Request(new URL(url)));
// 			InputStream input = response.get().getBody();
// 			executor.shutdown();
// 		
// 			String body = IOUtils.toString(input, "UTF-8");
// 			return new AsyncResult<String>(body);
// 		} catch (MalformedURLException e) {
// 			e.printStackTrace();
// 		} 
// 		catch (InterruptedException e) {
// 			e.printStackTrace();
// 		} 
// 		catch (ExecutionException e) {
// 			e.printStackTrace();
// 		} catch (IOException e) {
// 			e.printStackTrace();
// 		}
// 		return null;
// 	}
// 	
// 	private String getUrl(String distribution, String attr1, String attr2, String attr3)
// 	{
// 		String url = "";
// 		if (distribution.equals("gauss")) {
//             url = "?mu=" + attr1 + "&sigma=" + attr2 + "&k=0";
//         }
//         if (distribution.equals("expo")) {
//             url = "?lambda=" + attr1 + "&k=" + attr3;
//         }
//         if (distribution.equals("gamma")) {
//             url = "?alpha=" + attr1 + "&beta=" + attr2 + "&k=" + attr3;
//         }
//         if (distribution.equals("log")) {
//             url = "?mu=" + attr1 + "&sigma=" + attr2 + "&k=" + attr3;
//         }
//         if (distribution.equals("pareto")) {
//             url = "?alpha=" + attr1 + "&k=" + attr3;
//         }
//         if (distribution.equals("weibull")) {
//             url = "?alpha=" + attr1 + "&beta=" + attr2 + "&k=" + attr3;
//         }
//         if (distribution.equals("uniform")){
//             url = "?a=" + attr1 + "&b=" + attr2;
//         }
//         if (distribution.equals("constant"))
//         {
//             url = "?c=" + attr1;
//         }
//         return BASE_URL + distribution + url + "&test=false";
// 	}
// }


// Path: src/main/java/eu/cloudscale/showcase/servlets/PaymentController.java
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.Future;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
import eu.cloudscale.showcase.db.BuyConfirmResult;
import eu.cloudscale.showcase.servlets.helpers.PaymentService;

		Integer customerId = null;
		if( customerIdString != null && !customerIdString.isEmpty() )
		{
			customerId = Integer.parseInt(  customerIdString );
		}
		
		String ccType = request.getParameter( "CC_TYPE" );
		String ccNumber_str = request.getParameter( "CC_NUMBER" );
		Long ccNumber = null;
		if( !ccNumber_str.isEmpty() )
			ccNumber = Long.parseLong( ccNumber_str );
		
		SimpleDateFormat sdf = new SimpleDateFormat("mm/dd/yyyy");
		String ccName = request.getParameter( "CC_NAME" );
		Date ccExpiry = null;
        try
        {
	        ccExpiry = sdf.parse(request.getParameter( "CC_EXPIRY" ));
        }
        catch ( ParseException e )
        {
	        e.printStackTrace();
        }
		String shipping = request.getParameter( "SHIPPING" );
		String street1 = request.getParameter( "street1" );
		
		
		BuyConfirmResult res = null;
		if( street1 != null && street1.equals( "" ))
		{
			checkEmptiness(errors, shoppingId, customerId, ccType, ccNumber, ccName, ccExpiry, shipping);