DatasetRest { @POST @Path("{datasetRecordId}/data") @RolesAllowed("user") @ApiOperation("Uploads the data within an RDF file to a specific DatasetRecord in the local Catalog") public Response uploadData(@PathParam("datasetRecordId") String datasetRecordId, @FormDataParam("file") InputStream fileInputStream, @FormDataParam("file") FormDataContentDisposition fileDetail) { if (fileInputStream == null) { throw ErrorUtils.sendError("Must provide a file", Response.Status.BAD_REQUEST); } RDFFormat format = Rio.getParserFormatForFileName(fileDetail.getFileName()).orElseThrow(() -> ErrorUtils.sendError("File is not in a valid RDF format", Response.Status.BAD_REQUEST)); ImportServiceConfig.Builder builder = new ImportServiceConfig.Builder() .dataset(vf.createIRI(datasetRecordId)) .format(format) .logOutput(true); try { importService.importInputStream(builder.build(), fileInputStream); return Response.ok().build(); } catch (IllegalArgumentException | RDFParseException ex) { throw ErrorUtils.sendError(ex, ex.getMessage(), Response.Status.BAD_REQUEST); } catch (Exception ex) { throw ErrorUtils.sendError(ex, ex.getMessage(), Response.Status.INTERNAL_SERVER_ERROR); } }  @GET @Produces(MediaType.APPLICATION_JSON) @RolesAllowed("user") @ApiOperation("Retrieves all DatasetRecords in the local Catalog") Response getDatasetRecords(@Context UriInfo uriInfo,
                               @QueryParam("offset") int offset,
                               @QueryParam("limit") int limit,
                               @QueryParam("sort") String sort,
                               @DefaultValue("true") @QueryParam("ascending") boolean asc,
                               @QueryParam("searchText") String searchText); @POST @Consumes(MediaType.MULTIPART_FORM_DATA) @Produces(MediaType.TEXT_PLAIN) @RolesAllowed("user") @ApiOperation("Creates a new DatasetRecord in the local Catalog and Dataset in the specified repository") Response createDatasetRecord(@Context ContainerRequestContext context,
                                 @FormDataParam("title") String title,
                                 @FormDataParam("repositoryId") String repositoryId,
                                 @FormDataParam("datasetIRI") String datasetIRI,
                                 @FormDataParam("description") String description,
                                 @FormDataParam("markdown") String markdown,
                                 @FormDataParam("keywords") List<FormDataBodyPart> keywords,
                                 @FormDataParam("ontologies") List<FormDataBodyPart> ontologies); @GET @Produces(MediaType.APPLICATION_JSON) @Path("{datasetRecordId}") @RolesAllowed("user") @ApiOperation("Gets a specific DatasetRecord from the local Catalog") Response getDatasetRecord(@PathParam("datasetRecordId") String datasetRecordId); @DELETE @Path("{datasetRecordId}") @RolesAllowed("user") @ApiOperation("Deletes a specific DatasetRecord in the local Catalog") Response deleteDatasetRecord(@Context ContainerRequestContext context,
                                 @PathParam("datasetRecordId") String datasetRecordId,
                                 @DefaultValue("false") @QueryParam("force") boolean force); @DELETE @Path("{datasetRecordId}/data") @RolesAllowed("user") @ApiOperation("Clears the data within a specific DatasetRecord in the local Catalog") Response clearDatasetRecord(@PathParam("datasetRecordId") String datasetRecordId,
                                @DefaultValue("false") @QueryParam("force") boolean force); @POST @Path("{datasetRecordId}/data") @RolesAllowed("user") @ApiOperation("Uploads the data within an RDF file to a specific DatasetRecord in the local Catalog") Response uploadData(@PathParam("datasetRecordId") String datasetRecordId,
                        @FormDataParam("file") InputStream fileInputStream,
                        @FormDataParam("file") FormDataContentDisposition fileDetail);  }
@Test public void uploadDataTest() throws Exception { FormDataMultiPart fd = new FormDataMultiPart(); fd.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("file").fileName("test.ttl").build(), getClass().getResourceAsStream("/test.ttl"), MediaType.APPLICATION_OCTET_STREAM_TYPE)); Response response = target().path("datasets/" + encode(record1.getResource().stringValue()) + "/data") .request().post(Entity.entity(fd, MediaType.MULTIPART_FORM_DATA)); assertEquals(response.getStatus(), 200); verify(importService).importInputStream(any(ImportServiceConfig.class), any(InputStream.class)); }