@Test public void testUpdateMapping() throws Exception { String mappingId = "SampleId2"; WebTarget target = target("/" + MappingOptionListContainer.MAPPINGS + "/" + mappingId); File tempFile = File.createTempFile("example", "xsl"); tempFile.deleteOnExit(); final FileDataBodyPart filePart = new FileDataBodyPart("myFile", tempFile, MediaType.APPLICATION_OCTET_STREAM_TYPE); MetadataTransformation mtdTransformationFake = new MetadataTransformation(); MultiPart multiPartEntity = new MultiPart(); multiPartEntity.bodyPart(new BodyPart(mtdTransformationFake, MediaType.APPLICATION_XML_TYPE)); multiPartEntity.bodyPart(filePart); multiPartEntity.close(); Response response = target.request().put(Entity.entity(multiPartEntity, new MediaType("multipart", "mixed")), Response.class); assertEquals(404, response.getStatus()); }
@PUT @Path("/" + MappingOptionListContainer.MAPPINGID) @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) @Consumes("multipart/mixed") @ApiOperation(value = "Update a mapping.", httpMethod = "PUT", response = String.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "OK (Response containing a String message)"), @ApiResponse(code = 400, message = "InvalidArgumentsException"), @ApiResponse(code = 404, message = "DoesNotExistException"), @ApiResponse(code = 406, message = "MissingArgumentsException"), @ApiResponse(code = 409, message = "AlreadyExistsException"), @ApiResponse(code = 500, message = "InternalServerErrorException") }) public Response updateMapping(@ApiParam(value = "Id of mapping", required = true) @PathParam("mappingId") String mappingId, MultiPart multiPart) throws MissingArgumentsException, InternalServerErrorException, AlreadyExistsException, DoesNotExistException, InvalidArgumentsException { MetadataTransformation mapping; mapping = getMapping(mappingId); oldMappingId = mapping.getId(); createMapping(multiPart); oldMappingId = ""; return Response.status(200).entity(new Result("Mapping with id " + mappingId + " updated!")).build(); }
MappingResource { @PUT @Path("/" + MappingOptionListContainer.MAPPINGID) @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) @Consumes("multipart/mixed") @ApiOperation(value = "Update a mapping.", httpMethod = "PUT", response = String.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "OK (Response containing a String message)"), @ApiResponse(code = 400, message = "InvalidArgumentsException"), @ApiResponse(code = 404, message = "DoesNotExistException"), @ApiResponse(code = 406, message = "MissingArgumentsException"), @ApiResponse(code = 409, message = "AlreadyExistsException"), @ApiResponse(code = 500, message = "InternalServerErrorException") }) public Response updateMapping(@ApiParam(value = "Id of mapping", required = true) @PathParam("mappingId") String mappingId, MultiPart multiPart) throws MissingArgumentsException, InternalServerErrorException, AlreadyExistsException, DoesNotExistException, InvalidArgumentsException { MetadataTransformation mapping; mapping = getMapping(mappingId); oldMappingId = mapping.getId(); createMapping(multiPart); oldMappingId = ""; return Response.status(200).entity(new Result("Mapping with id " + mappingId + " updated!")).build(); } }
MappingResource { @PUT @Path("/" + MappingOptionListContainer.MAPPINGID) @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) @Consumes("multipart/mixed") @ApiOperation(value = "Update a mapping.", httpMethod = "PUT", response = String.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "OK (Response containing a String message)"), @ApiResponse(code = 400, message = "InvalidArgumentsException"), @ApiResponse(code = 404, message = "DoesNotExistException"), @ApiResponse(code = 406, message = "MissingArgumentsException"), @ApiResponse(code = 409, message = "AlreadyExistsException"), @ApiResponse(code = 500, message = "InternalServerErrorException") }) public Response updateMapping(@ApiParam(value = "Id of mapping", required = true) @PathParam("mappingId") String mappingId, MultiPart multiPart) throws MissingArgumentsException, InternalServerErrorException, AlreadyExistsException, DoesNotExistException, InvalidArgumentsException { MetadataTransformation mapping; mapping = getMapping(mappingId); oldMappingId = mapping.getId(); createMapping(multiPart); oldMappingId = ""; return Response.status(200).entity(new Result("Mapping with id " + mappingId + " updated!")).build(); } MappingResource();  MappingResource(DefaultDataManager dataManager, MetadataTransformationManager metadataTransformationManager, MetadataSchemaManager metadataSchemaManager); }
MappingResource { @PUT @Path("/" + MappingOptionListContainer.MAPPINGID) @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) @Consumes("multipart/mixed") @ApiOperation(value = "Update a mapping.", httpMethod = "PUT", response = String.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "OK (Response containing a String message)"), @ApiResponse(code = 400, message = "InvalidArgumentsException"), @ApiResponse(code = 404, message = "DoesNotExistException"), @ApiResponse(code = 406, message = "MissingArgumentsException"), @ApiResponse(code = 409, message = "AlreadyExistsException"), @ApiResponse(code = 500, message = "InternalServerErrorException") }) public Response updateMapping(@ApiParam(value = "Id of mapping", required = true) @PathParam("mappingId") String mappingId, MultiPart multiPart) throws MissingArgumentsException, InternalServerErrorException, AlreadyExistsException, DoesNotExistException, InvalidArgumentsException { MetadataTransformation mapping; mapping = getMapping(mappingId); oldMappingId = mapping.getId(); createMapping(multiPart); oldMappingId = ""; return Response.status(200).entity(new Result("Mapping with id " + mappingId + " updated!")).build(); } MappingResource();  MappingResource(DefaultDataManager dataManager, MetadataTransformationManager metadataTransformationManager, MetadataSchemaManager metadataSchemaManager); @OPTIONS @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) @ApiOperation(value = "Get options over mappings conext.", httpMethod = "OPTIONS", response = MappingOptionListContainer.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "OK (Response containing a list of all available options)") }) MappingOptionListContainer getOptions(); @GET @Path("/" + MappingOptionListContainer.OPTIONS) @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) @ApiOperation(value = "Get options over mappings conext.", httpMethod = "GET", response = MappingOptionListContainer.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "OK (Response containing a list of all available options)") }) MappingOptionListContainer getGETOptions(); @POST @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) @Consumes("multipart/mixed") @ApiOperation(value = "Create a new mapping - XSL file through HTTP POST.", httpMethod = "POST", response = String.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Created (Response containing a String message)"), @ApiResponse(code = 400, message = "InvalidArgumentsException"), @ApiResponse(code = 404, message = "DoesNotExistException"), @ApiResponse(code = 406, message = "MissingArgumentsException"), @ApiResponse(code = 409, message = "AlreadyExistsException"), @ApiResponse(code = 500, message = "InternalServerErrorException") }) Response createMapping(MultiPart multiPart); @GET @Path("/" + MappingOptionListContainer.MAPPINGID) @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) @ApiOperation(value = "Retrieves the specified mapping.", httpMethod = "GET", response = String.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "OK (Response containing an Dataset)"), @ApiResponse(code = 404, message = "DoesNotExistException") }) MetadataTransformation getMapping(@ApiParam(value = "Id of mapping", required = true) @PathParam("mappingId") String mappingId); @DELETE @Path("/" + MappingOptionListContainer.MAPPINGID) @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) @ApiOperation(value = "Delete a mapping.", httpMethod = "DELETE", response = String.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "OK (Response containing a String message)"), @ApiResponse(code = 404, message = "DoesNotExistException"), @ApiResponse(code = 500, message = "InternalServerErrorException") }) Response deleteMapping(@ApiParam(value = "Id of mapping", required = true) @PathParam("mappingId") String mappingId); @PUT @Path("/" + MappingOptionListContainer.MAPPINGID) @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) @Consumes("multipart/mixed") @ApiOperation(value = "Update a mapping.", httpMethod = "PUT", response = String.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "OK (Response containing a String message)"), @ApiResponse(code = 400, message = "InvalidArgumentsException"), @ApiResponse(code = 404, message = "DoesNotExistException"), @ApiResponse(code = 406, message = "MissingArgumentsException"), @ApiResponse(code = 409, message = "AlreadyExistsException"), @ApiResponse(code = 500, message = "InternalServerErrorException") }) Response updateMapping(@ApiParam(value = "Id of mapping", required = true) @PathParam("mappingId") String mappingId,
            MultiPart multiPart); }
MappingResource { @PUT @Path("/" + MappingOptionListContainer.MAPPINGID) @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) @Consumes("multipart/mixed") @ApiOperation(value = "Update a mapping.", httpMethod = "PUT", response = String.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "OK (Response containing a String message)"), @ApiResponse(code = 400, message = "InvalidArgumentsException"), @ApiResponse(code = 404, message = "DoesNotExistException"), @ApiResponse(code = 406, message = "MissingArgumentsException"), @ApiResponse(code = 409, message = "AlreadyExistsException"), @ApiResponse(code = 500, message = "InternalServerErrorException") }) public Response updateMapping(@ApiParam(value = "Id of mapping", required = true) @PathParam("mappingId") String mappingId, MultiPart multiPart) throws MissingArgumentsException, InternalServerErrorException, AlreadyExistsException, DoesNotExistException, InvalidArgumentsException { MetadataTransformation mapping; mapping = getMapping(mappingId); oldMappingId = mapping.getId(); createMapping(multiPart); oldMappingId = ""; return Response.status(200).entity(new Result("Mapping with id " + mappingId + " updated!")).build(); } MappingResource();  MappingResource(DefaultDataManager dataManager, MetadataTransformationManager metadataTransformationManager, MetadataSchemaManager metadataSchemaManager); @OPTIONS @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) @ApiOperation(value = "Get options over mappings conext.", httpMethod = "OPTIONS", response = MappingOptionListContainer.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "OK (Response containing a list of all available options)") }) MappingOptionListContainer getOptions(); @GET @Path("/" + MappingOptionListContainer.OPTIONS) @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) @ApiOperation(value = "Get options over mappings conext.", httpMethod = "GET", response = MappingOptionListContainer.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "OK (Response containing a list of all available options)") }) MappingOptionListContainer getGETOptions(); @POST @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) @Consumes("multipart/mixed") @ApiOperation(value = "Create a new mapping - XSL file through HTTP POST.", httpMethod = "POST", response = String.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Created (Response containing a String message)"), @ApiResponse(code = 400, message = "InvalidArgumentsException"), @ApiResponse(code = 404, message = "DoesNotExistException"), @ApiResponse(code = 406, message = "MissingArgumentsException"), @ApiResponse(code = 409, message = "AlreadyExistsException"), @ApiResponse(code = 500, message = "InternalServerErrorException") }) Response createMapping(MultiPart multiPart); @GET @Path("/" + MappingOptionListContainer.MAPPINGID) @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) @ApiOperation(value = "Retrieves the specified mapping.", httpMethod = "GET", response = String.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "OK (Response containing an Dataset)"), @ApiResponse(code = 404, message = "DoesNotExistException") }) MetadataTransformation getMapping(@ApiParam(value = "Id of mapping", required = true) @PathParam("mappingId") String mappingId); @DELETE @Path("/" + MappingOptionListContainer.MAPPINGID) @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) @ApiOperation(value = "Delete a mapping.", httpMethod = "DELETE", response = String.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "OK (Response containing a String message)"), @ApiResponse(code = 404, message = "DoesNotExistException"), @ApiResponse(code = 500, message = "InternalServerErrorException") }) Response deleteMapping(@ApiParam(value = "Id of mapping", required = true) @PathParam("mappingId") String mappingId); @PUT @Path("/" + MappingOptionListContainer.MAPPINGID) @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) @Consumes("multipart/mixed") @ApiOperation(value = "Update a mapping.", httpMethod = "PUT", response = String.class) @ApiResponses(value = { @ApiResponse(code = 200, message = "OK (Response containing a String message)"), @ApiResponse(code = 400, message = "InvalidArgumentsException"), @ApiResponse(code = 404, message = "DoesNotExistException"), @ApiResponse(code = 406, message = "MissingArgumentsException"), @ApiResponse(code = 409, message = "AlreadyExistsException"), @ApiResponse(code = 500, message = "InternalServerErrorException") }) Response updateMapping(@ApiParam(value = "Id of mapping", required = true) @PathParam("mappingId") String mappingId,
            MultiPart multiPart); public DefaultDataManager dataManager; public MetadataTransformationManager metadataTransformationManager; public MetadataSchemaManager metadataSchemaManager; }