// Path: rahub-composite-service/src/main/java/net/jotorren/microservices/composite/controller/CompositeController.java
// @RestController
// @Path("/")
// @Api(value = "API Services")
// public class CompositeController {
// 
// 	@Autowired
// 	private CompositeService service;
// 	
// 	@POST
// 	@Path("files")
// 	@Produces ( "application/json" )
//     @ApiOperation(
//     		code = 201,
//             value = "Save new content while creating its discussion board",
//             notes = "Both operations (new content and forum) must succeed within a given time interval, otherwise both will be canceled or rolled back. "
//             		+ "The newly created resource(s) can be referenced by the URI(s) returned in the entity of the response, with the URI for the "
//             		+ "distributed transaction given by the Location header field",
//             response = String.class,
//             responseContainer = "List",
//             responseHeaders = {
//     			 @ResponseHeader(name = "Location", description = "The distributed transaction URI", response = String.class)
//     		}
//         )
// 	@ApiResponses(value = {
// 			@ApiResponse(code=500, message="Error processing request", response = ErrorDetails.class)
// 	})
// 	public Response save(@Context UriInfo uriInfo, 
// 			@ApiParam(value = "Data to pass to server", required = true) CompositeData data
// 			) throws CompositeTransactionException {
// 		
// 		Entry<String, List<String>> txEntities = service.saveAllEntities(data);
// 		
// 		URI location = uriInfo.getAbsolutePathBuilder().path("{id}")
// 				.resolveTemplate("id", txEntities.getKey()).build();
// 		
// 		return Response.created(location).entity(txEntities.getValue()).build();
// 	}
// }
// 
// Path: rahub-cross-cutting-concerns/src/main/java/net/jotorren/microservices/rs/ExceptionRestHandler.java
// public class ExceptionRestHandler implements ExceptionMapper<Exception>{
// 
// 	public class ErrorDetails {
// 		private int code;
// 		private String message;
// 		private String stack;
// 		
// 		public ErrorDetails(int code, String message, String stack){
// 			this.code = code;
// 			this.message = message;			
// 			this.stack = stack;
// 		}
// 
// 		public int getCode() {
// 			return code;
// 		}
// 
// 		public String getMessage() {
// 			return message;
// 		}
// 		
// 		public String getStack() {
// 			return stack;
// 		}
// 	}
// 	
// 	@Override
// 	public Response toResponse(Exception exception) {
// 		return toResponse(exception, Response.Status.INTERNAL_SERVER_ERROR);
// 	}
// 		
// 	public Response toResponse(Exception exception, Response.Status status) {
// 		return Response.status(status).entity(
// 				new ErrorDetails(status.getStatusCode(), exception.getMessage(), toString(exception))).build();
// 	}
// 
// 	public String toString(Exception exception) {
// 		StringWriter sw = new StringWriter();
// 		PrintWriter pw = new PrintWriter(sw);
// 		exception.printStackTrace(pw);
// 		String stack = sw.toString();
// 		pw.close();
// 		
// 		return stack;
// 	}
// }


import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import net.jotorren.microservices.composite.controller.CompositeController;
import net.jotorren.microservices.rs.ExceptionRestHandler;
import org.apache.cxf.Bus;
import org.apache.cxf.endpoint.Server;
import org.apache.cxf.feature.LoggingFeature;
import org.apache.cxf.jaxrs.JAXRSServerFactoryBean;
import org.apache.cxf.jaxrs.swagger.Swagger2Feature;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.web.client.RestTemplateBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestTemplate;
import com.atomikos.icatch.tcc.rest.CoordinatorImp;
import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider;

	@Value("${swagger.schemes}")
	private String schemes;

	@Value("${swagger.basePath}")
	private String basePath;

	@Value("${swagger.resourcePackage}")
	private String resourcePackage;

	@Value("${swagger.prettyPrint}")
	private boolean prettyPrint;
	
	@Value("${swagger.scan}")
	private boolean scan;
	
    @Autowired
    private Bus bus;
    
    @Autowired
    private CoordinatorImp tccCoordinatorService;
    
    @Autowired
    private CompositeController compositeController;
    
    @Bean
    public Server rsServer() {
        JAXRSServerFactoryBean endpoint = new JAXRSServerFactoryBean();
        endpoint.setBus(bus);
        endpoint.setAddress("/");
// Path: rahub-composite-service/src/main/java/net/jotorren/microservices/composite/controller/CompositeController.java
// @RestController
// @Path("/")
// @Api(value = "API Services")
// public class CompositeController {
// 
// 	@Autowired
// 	private CompositeService service;
// 	
// 	@POST
// 	@Path("files")
// 	@Produces ( "application/json" )
//     @ApiOperation(
//     		code = 201,
//             value = "Save new content while creating its discussion board",
//             notes = "Both operations (new content and forum) must succeed within a given time interval, otherwise both will be canceled or rolled back. "
//             		+ "The newly created resource(s) can be referenced by the URI(s) returned in the entity of the response, with the URI for the "
//             		+ "distributed transaction given by the Location header field",
//             response = String.class,
//             responseContainer = "List",
//             responseHeaders = {
//     			 @ResponseHeader(name = "Location", description = "The distributed transaction URI", response = String.class)
//     		}
//         )
// 	@ApiResponses(value = {
// 			@ApiResponse(code=500, message="Error processing request", response = ErrorDetails.class)
// 	})
// 	public Response save(@Context UriInfo uriInfo, 
// 			@ApiParam(value = "Data to pass to server", required = true) CompositeData data
// 			) throws CompositeTransactionException {
// 		
// 		Entry<String, List<String>> txEntities = service.saveAllEntities(data);
// 		
// 		URI location = uriInfo.getAbsolutePathBuilder().path("{id}")
// 				.resolveTemplate("id", txEntities.getKey()).build();
// 		
// 		return Response.created(location).entity(txEntities.getValue()).build();
// 	}
// }
// 
// Path: rahub-cross-cutting-concerns/src/main/java/net/jotorren/microservices/rs/ExceptionRestHandler.java
// public class ExceptionRestHandler implements ExceptionMapper<Exception>{
// 
// 	public class ErrorDetails {
// 		private int code;
// 		private String message;
// 		private String stack;
// 		
// 		public ErrorDetails(int code, String message, String stack){
// 			this.code = code;
// 			this.message = message;			
// 			this.stack = stack;
// 		}
// 
// 		public int getCode() {
// 			return code;
// 		}
// 
// 		public String getMessage() {
// 			return message;
// 		}
// 		
// 		public String getStack() {
// 			return stack;
// 		}
// 	}
// 	
// 	@Override
// 	public Response toResponse(Exception exception) {
// 		return toResponse(exception, Response.Status.INTERNAL_SERVER_ERROR);
// 	}
// 		
// 	public Response toResponse(Exception exception, Response.Status status) {
// 		return Response.status(status).entity(
// 				new ErrorDetails(status.getStatusCode(), exception.getMessage(), toString(exception))).build();
// 	}
// 
// 	public String toString(Exception exception) {
// 		StringWriter sw = new StringWriter();
// 		PrintWriter pw = new PrintWriter(sw);
// 		exception.printStackTrace(pw);
// 		String stack = sw.toString();
// 		pw.close();
// 		
// 		return stack;
// 	}
// }


// Path: rahub-composite-service/src/main/java/net/jotorren/microservices/configuration/WebServicesConfiguration.java
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import net.jotorren.microservices.composite.controller.CompositeController;
import net.jotorren.microservices.rs.ExceptionRestHandler;
import org.apache.cxf.Bus;
import org.apache.cxf.endpoint.Server;
import org.apache.cxf.feature.LoggingFeature;
import org.apache.cxf.jaxrs.JAXRSServerFactoryBean;
import org.apache.cxf.jaxrs.swagger.Swagger2Feature;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.web.client.RestTemplateBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestTemplate;
import com.atomikos.icatch.tcc.rest.CoordinatorImp;
import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider;


	@Value("${swagger.schemes}")
	private String schemes;

	@Value("${swagger.basePath}")
	private String basePath;

	@Value("${swagger.resourcePackage}")
	private String resourcePackage;

	@Value("${swagger.prettyPrint}")
	private boolean prettyPrint;
	
	@Value("${swagger.scan}")
	private boolean scan;
	
    @Autowired
    private Bus bus;
    
    @Autowired
    private CoordinatorImp tccCoordinatorService;
    
    @Autowired
    private CompositeController compositeController;
    
    @Bean
    public Server rsServer() {
        JAXRSServerFactoryBean endpoint = new JAXRSServerFactoryBean();
        endpoint.setBus(bus);
        endpoint.setAddress("/");
        endpoint.setProviders(Arrays.asList(new JacksonJsonProvider(), new ExceptionRestHandler()));