@POST @Consumes(MediaType.MULTIPART_FORM_DATA) @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) @ApiOperation( value = "Returns a GEO label LML representation", notes = "Requires metadata/feedback documents as data stream") @ApiResponses({@ApiResponse(code = 400, message = "Error in feedback/metadata document")}) public Label getLabelByStream( /* @ApiParam("Metadata document") */ @FormDataParam(Constants.PARAM_METADATA) InputStream metadataInputStream, /* @ApiParam("Feedback document") */ @FormDataParam(Constants.PARAM_FEEDBACK) InputStream feedbackInputStream) throws IOException { MetadataTransformer metadataTransformer = this.transformer.get(); Label label = new Label(); label.setMetadataUrl(new URL("http://not.available.for.direct.upload")); label.setFeedbackUrl(new URL("http://not.available.for.direct.upload")); PushbackInputStream tempStream; boolean hasData = false; if (metadataInputStream != null) { tempStream = new PushbackInputStream(metadataInputStream); int t = tempStream.read(); if (t != -1) { tempStream.unread(t); log.debug("Reading from metadata stream..."); metadataTransformer.updateGeoLabel(tempStream, label); hasData = true; } else tempStream.close(); } if (feedbackInputStream != null) { tempStream = new PushbackInputStream(feedbackInputStream); int t = tempStream.read(); if (t != -1) { tempStream.unread(t); log.debug("Reading from feedback stream..."); metadataTransformer.updateGeoLabel(tempStream, label); hasData = true; } else tempStream.close(); } if (!hasData) throw new WebApplicationException( Response.status(Response.Status.BAD_REQUEST) .type(MediaType.TEXT_PLAIN) .entity("No metadata or feedback file specified") .build()); return label; }
@Override public LineageFacet getAffectedFacet(Label label) { return label.getLineageFacet(); }