package fr.insee.pogues.webservice.rest;

import fr.insee.pogues.transforms.XmlToDDIService;
import io.swagger.annotations.*;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;

import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.Consumes;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.StreamingOutput;

/**
 * Main WebService class of the PoguesModelToDDI service
 *
 * @author I6VWID
 *
 */
@Path("/PoguesModelToDDI")
@Api(value = "PoguesModelToDDI", authorizations = {
		@Authorization(value="sampleoauth", scopes = {})
})
public class PoguesModelToDDI {

	final static Logger logger = Logger.getLogger(PoguesModelToDDI.class);

	@Autowired
	private XmlToDDIService xmlToDDIService;

	@POST
	@Produces(MediaType.APPLICATION_XML)
	@Consumes(MediaType.APPLICATION_XML)
	@ApiOperation(
			value = "Get DDI From Pogues Model",
			notes = "Get Transformed DDI document from Pogues XML"
	)
	@ApiResponses(value = {
			@ApiResponse(code = 200, message = "OK"),
            @ApiResponse(code = 500, message = "Error")
	})
    @ApiImplicitParams(value={
            @ApiImplicitParam(name="poguesModel", value="XML representation of the Pogues Model", paramType="body", dataType = "string")
    })
	public Response transform(@Context final HttpServletRequest request) {
		try {
			StreamingOutput stream = output -> {
                try {
                    xmlToDDIService.transform(request.getInputStream(), output);
                } catch (Exception e) {
                    logger.error(e.getMessage());
                    throw new PoguesException(500, e.getMessage(), null);
                }
            };
			return Response.ok(stream).build();
		} catch(Exception e) {
			throw e;
		}
	}
}
@@ -70,30 +70,23 @@
 sforms.X
-ml
+ML
 ToDDI
-Service
 ;%0Aimport
@@ -856,30 +856,23 @@
 rivate X
-ml
+ML
 ToDDI
-Service
  xmlToDD
@@ -872,23 +872,16 @@
 xmlToDDI
-Service
 ;%0A%0A%09@POS
@@ -1550,23 +1550,16 @@
 xmlToDDI
-Service
 .transfo

Fix service id in DDI transform controller