@Test public void deleteObjectTest() throws Exception { try (FileInputStream in = new FileInputStream(PropertiesUtils.findFile(ARCHIVE_FILE_TXT))) { assertNotNull(in); with().header(GlobalDataRest.X_TENANT_ID, "1") .header(GlobalDataRest.VITAM_CONTENT_LENGTH, "8766") .header(GlobalDataRest.X_DIGEST_ALGORITHM, DigestType.SHA512.getName()) .contentType(MediaType.APPLICATION_OCTET_STREAM).body(in).when() .put(OBJECTS_URI + OBJECT_TYPE_URI + OBJECT_ID_URI, OBJECT_CODE, "id1"); } final File testFile = PropertiesUtils.findFile(ARCHIVE_FILE_TXT); Digest digest = Digest.digest(testFile, VitamConfiguration.getDefaultDigestType()); given().header(GlobalDataRest.X_TENANT_ID, "1").contentType(MediaType.APPLICATION_JSON).then() .statusCode(Status.OK.getStatusCode()).when() .get(OBJECTS_URI + OBJECT_TYPE_URI + OBJECT_ID_URI, OBJECT_CODE, "id1"); given().header(GlobalDataRest.X_TENANT_ID, "1").contentType(MediaType.APPLICATION_JSON).then() .statusCode(Status.OK.getStatusCode()).when() .get(OBJECTS_URI + OBJECT_TYPE_URI + OBJECT_ID_URI, OBJECT_CODE, "id1"); given().header(GlobalDataRest.X_TENANT_ID, "1").contentType(MediaType.APPLICATION_JSON).then() .statusCode(Status.OK.getStatusCode()).when() .get(OBJECTS_URI + OBJECT_TYPE_URI + OBJECT_ID_URI, OBJECT_CODE, "id1"); String responseAsJson = "{\"id\":\"" + "id1" + "\",\"status\":\"" + Response.Status.OK.toString() + "\"}"; given().header(GlobalDataRest.X_TENANT_ID, "1").header(GlobalDataRest.X_DIGEST, digest.toString()) .header(GlobalDataRest.X_DIGEST_ALGORITHM, VitamConfiguration.getDefaultDigestType().getName()) .delete(OBJECTS_URI + OBJECT_TYPE_URI + OBJECT_ID_URI, OBJECT_CODE, "id1").then().statusCode(200) .body(Matchers.equalTo(responseAsJson)); given().header(GlobalDataRest.X_TENANT_ID, "1").contentType(MediaType.APPLICATION_JSON).then() .statusCode(Status.NOT_FOUND.getStatusCode()).when() .get(OBJECTS_URI + OBJECT_TYPE_URI + OBJECT_ID_URI, OBJECT_CODE, "id1"); }
@DELETE @Path("/objects/{type}/{id:.+}") @Produces(MediaType.APPLICATION_JSON) public Response deleteObject(@HeaderParam(GlobalDataRest.X_TENANT_ID) String xTenantId, @HeaderParam(GlobalDataRest.X_DIGEST_ALGORITHM) String xDigestAlgorithm, @PathParam("type") DataCategory type, @PathParam("id") String idObject) { if (Strings.isNullOrEmpty(xTenantId)) { LOGGER.error(MISSING_THE_TENANT_ID_X_TENANT_ID); return Response.status(Response.Status.BAD_REQUEST).build(); } try { SanityChecker.checkParameter(idObject); VitamThreadUtils.getVitamSession() .setRequestId(GUIDFactory.newRequestIdGUID(Integer.parseInt(xTenantId))); final String containerName = buildContainerName(type, xTenantId); defaultOfferService.deleteObject(containerName, idObject, type); return Response.status(Response.Status.OK) .entity("{\"id\":\"" + idObject + "\",\"status\":\"" + Response.Status.OK.toString() + "\"}") .build(); } catch (ContentAddressableStorageNotFoundException e) { LOGGER.info(e); return Response.status(Response.Status.NOT_FOUND).build(); } catch (ContentAddressableStorageException | InvalidParseOperationException e) { LOGGER.error(e); return Response.status(Status.INTERNAL_SERVER_ERROR).build(); } }
DefaultOfferResource extends ApplicationStatusResource { @DELETE @Path("/objects/{type}/{id:.+}") @Produces(MediaType.APPLICATION_JSON) public Response deleteObject(@HeaderParam(GlobalDataRest.X_TENANT_ID) String xTenantId, @HeaderParam(GlobalDataRest.X_DIGEST_ALGORITHM) String xDigestAlgorithm, @PathParam("type") DataCategory type, @PathParam("id") String idObject) { if (Strings.isNullOrEmpty(xTenantId)) { LOGGER.error(MISSING_THE_TENANT_ID_X_TENANT_ID); return Response.status(Response.Status.BAD_REQUEST).build(); } try { SanityChecker.checkParameter(idObject); VitamThreadUtils.getVitamSession() .setRequestId(GUIDFactory.newRequestIdGUID(Integer.parseInt(xTenantId))); final String containerName = buildContainerName(type, xTenantId); defaultOfferService.deleteObject(containerName, idObject, type); return Response.status(Response.Status.OK) .entity("{\"id\":\"" + idObject + "\",\"status\":\"" + Response.Status.OK.toString() + "\"}") .build(); } catch (ContentAddressableStorageNotFoundException e) { LOGGER.info(e); return Response.status(Response.Status.NOT_FOUND).build(); } catch (ContentAddressableStorageException | InvalidParseOperationException e) { LOGGER.error(e); return Response.status(Status.INTERNAL_SERVER_ERROR).build(); } } }
DefaultOfferResource extends ApplicationStatusResource { @DELETE @Path("/objects/{type}/{id:.+}") @Produces(MediaType.APPLICATION_JSON) public Response deleteObject(@HeaderParam(GlobalDataRest.X_TENANT_ID) String xTenantId, @HeaderParam(GlobalDataRest.X_DIGEST_ALGORITHM) String xDigestAlgorithm, @PathParam("type") DataCategory type, @PathParam("id") String idObject) { if (Strings.isNullOrEmpty(xTenantId)) { LOGGER.error(MISSING_THE_TENANT_ID_X_TENANT_ID); return Response.status(Response.Status.BAD_REQUEST).build(); } try { SanityChecker.checkParameter(idObject); VitamThreadUtils.getVitamSession() .setRequestId(GUIDFactory.newRequestIdGUID(Integer.parseInt(xTenantId))); final String containerName = buildContainerName(type, xTenantId); defaultOfferService.deleteObject(containerName, idObject, type); return Response.status(Response.Status.OK) .entity("{\"id\":\"" + idObject + "\",\"status\":\"" + Response.Status.OK.toString() + "\"}") .build(); } catch (ContentAddressableStorageNotFoundException e) { LOGGER.info(e); return Response.status(Response.Status.NOT_FOUND).build(); } catch (ContentAddressableStorageException | InvalidParseOperationException e) { LOGGER.error(e); return Response.status(Status.INTERNAL_SERVER_ERROR).build(); } } DefaultOfferResource(DefaultOfferService defaultOfferService); }
DefaultOfferResource extends ApplicationStatusResource { @DELETE @Path("/objects/{type}/{id:.+}") @Produces(MediaType.APPLICATION_JSON) public Response deleteObject(@HeaderParam(GlobalDataRest.X_TENANT_ID) String xTenantId, @HeaderParam(GlobalDataRest.X_DIGEST_ALGORITHM) String xDigestAlgorithm, @PathParam("type") DataCategory type, @PathParam("id") String idObject) { if (Strings.isNullOrEmpty(xTenantId)) { LOGGER.error(MISSING_THE_TENANT_ID_X_TENANT_ID); return Response.status(Response.Status.BAD_REQUEST).build(); } try { SanityChecker.checkParameter(idObject); VitamThreadUtils.getVitamSession() .setRequestId(GUIDFactory.newRequestIdGUID(Integer.parseInt(xTenantId))); final String containerName = buildContainerName(type, xTenantId); defaultOfferService.deleteObject(containerName, idObject, type); return Response.status(Response.Status.OK) .entity("{\"id\":\"" + idObject + "\",\"status\":\"" + Response.Status.OK.toString() + "\"}") .build(); } catch (ContentAddressableStorageNotFoundException e) { LOGGER.info(e); return Response.status(Response.Status.NOT_FOUND).build(); } catch (ContentAddressableStorageException | InvalidParseOperationException e) { LOGGER.error(e); return Response.status(Status.INTERNAL_SERVER_ERROR).build(); } } DefaultOfferResource(DefaultOfferService defaultOfferService); @HEAD @Path("/objects/{type}") @Produces(MediaType.APPLICATION_JSON) Response getCapacity(@HeaderParam(GlobalDataRest.X_TENANT_ID) String xTenantId,
        @PathParam("type") DataCategory type); @GET @Path("/objects/{type}") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) Response getContainerList(
        @HeaderParam(GlobalDataRest.X_TENANT_ID) String xTenantId,
        @PathParam("type") DataCategory type); @GET @Path("/objects/{type}/logs") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) Response getOfferLogs(@HeaderParam(GlobalDataRest.X_TENANT_ID) String xTenantId,
        @PathParam("type") DataCategory type, OfferLogRequest offerLogRequest); @GET @Path("/objects/{type}/{id_object}") @Consumes(MediaType.APPLICATION_JSON) @Produces({MediaType.APPLICATION_OCTET_STREAM, CommonMediaType.ZIP}) Response getObject(@PathParam("type") DataCategory type, @NotNull @PathParam("id_object") String objectId,
        @Context HttpHeaders headers); @POST @Path("/readorder/{type}") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) Response createReadOrderRequest(@PathParam("type") DataCategory type, List<String> objectsIds,
        @Context HttpHeaders headers); @GET @Path("/readorder/{readOrderRequestId}") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) Response getReadOrderRequest(@PathParam("readOrderRequestId") String readOrderRequestId,
        @Context HttpHeaders headers); @DELETE @Path("/readorder/{readOrderRequestId}") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) Response removeReadOrderRequest(@PathParam("readOrderRequestId") String readOrderRequestId,
        @Context HttpHeaders headers); @PUT @Path("/objects/{type}/{objectId:.+}") @Consumes(MediaType.APPLICATION_OCTET_STREAM) @Produces(MediaType.APPLICATION_JSON) Response putObject(@PathParam("objectId") String objectId, @PathParam("type") DataCategory type,
        @Context HttpHeaders headers, InputStream input); @PUT @Path("/bulk/objects/{type}") @Consumes(MediaType.APPLICATION_OCTET_STREAM) @Produces(MediaType.APPLICATION_JSON) Response bulkPutObjects(@PathParam("type") DataCategory type,
        @Context HttpHeaders headers, InputStream input); @DELETE @Path("/objects/{type}/{id:.+}") @Produces(MediaType.APPLICATION_JSON) Response deleteObject(@HeaderParam(GlobalDataRest.X_TENANT_ID) String xTenantId,
        @HeaderParam(GlobalDataRest.X_DIGEST_ALGORITHM) String xDigestAlgorithm, @PathParam("type") DataCategory
        type,
        @PathParam("id") String idObject); @HEAD @Path("/objects/{type}/{id:.+}") Response checkObjectExistence(@PathParam("type") DataCategory type, @PathParam("id") String idObject,
        @HeaderParam(GlobalDataRest.X_TENANT_ID) String xTenantId); @GET @Path("/objects/{type}/{id:.+}/metadatas") @Produces(MediaType.APPLICATION_JSON) Response getObjectMetadata(@PathParam("type") DataCategory type, @PathParam("id") String idObject,
        @HeaderParam(GlobalDataRest.X_TENANT_ID) String xTenantId,
        @HeaderParam(GlobalDataRest.X_OFFER_NO_CACHE) Boolean noCache); }
DefaultOfferResource extends ApplicationStatusResource { @DELETE @Path("/objects/{type}/{id:.+}") @Produces(MediaType.APPLICATION_JSON) public Response deleteObject(@HeaderParam(GlobalDataRest.X_TENANT_ID) String xTenantId, @HeaderParam(GlobalDataRest.X_DIGEST_ALGORITHM) String xDigestAlgorithm, @PathParam("type") DataCategory type, @PathParam("id") String idObject) { if (Strings.isNullOrEmpty(xTenantId)) { LOGGER.error(MISSING_THE_TENANT_ID_X_TENANT_ID); return Response.status(Response.Status.BAD_REQUEST).build(); } try { SanityChecker.checkParameter(idObject); VitamThreadUtils.getVitamSession() .setRequestId(GUIDFactory.newRequestIdGUID(Integer.parseInt(xTenantId))); final String containerName = buildContainerName(type, xTenantId); defaultOfferService.deleteObject(containerName, idObject, type); return Response.status(Response.Status.OK) .entity("{\"id\":\"" + idObject + "\",\"status\":\"" + Response.Status.OK.toString() + "\"}") .build(); } catch (ContentAddressableStorageNotFoundException e) { LOGGER.info(e); return Response.status(Response.Status.NOT_FOUND).build(); } catch (ContentAddressableStorageException | InvalidParseOperationException e) { LOGGER.error(e); return Response.status(Status.INTERNAL_SERVER_ERROR).build(); } } DefaultOfferResource(DefaultOfferService defaultOfferService); @HEAD @Path("/objects/{type}") @Produces(MediaType.APPLICATION_JSON) Response getCapacity(@HeaderParam(GlobalDataRest.X_TENANT_ID) String xTenantId,
        @PathParam("type") DataCategory type); @GET @Path("/objects/{type}") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) Response getContainerList(
        @HeaderParam(GlobalDataRest.X_TENANT_ID) String xTenantId,
        @PathParam("type") DataCategory type); @GET @Path("/objects/{type}/logs") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) Response getOfferLogs(@HeaderParam(GlobalDataRest.X_TENANT_ID) String xTenantId,
        @PathParam("type") DataCategory type, OfferLogRequest offerLogRequest); @GET @Path("/objects/{type}/{id_object}") @Consumes(MediaType.APPLICATION_JSON) @Produces({MediaType.APPLICATION_OCTET_STREAM, CommonMediaType.ZIP}) Response getObject(@PathParam("type") DataCategory type, @NotNull @PathParam("id_object") String objectId,
        @Context HttpHeaders headers); @POST @Path("/readorder/{type}") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) Response createReadOrderRequest(@PathParam("type") DataCategory type, List<String> objectsIds,
        @Context HttpHeaders headers); @GET @Path("/readorder/{readOrderRequestId}") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) Response getReadOrderRequest(@PathParam("readOrderRequestId") String readOrderRequestId,
        @Context HttpHeaders headers); @DELETE @Path("/readorder/{readOrderRequestId}") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) Response removeReadOrderRequest(@PathParam("readOrderRequestId") String readOrderRequestId,
        @Context HttpHeaders headers); @PUT @Path("/objects/{type}/{objectId:.+}") @Consumes(MediaType.APPLICATION_OCTET_STREAM) @Produces(MediaType.APPLICATION_JSON) Response putObject(@PathParam("objectId") String objectId, @PathParam("type") DataCategory type,
        @Context HttpHeaders headers, InputStream input); @PUT @Path("/bulk/objects/{type}") @Consumes(MediaType.APPLICATION_OCTET_STREAM) @Produces(MediaType.APPLICATION_JSON) Response bulkPutObjects(@PathParam("type") DataCategory type,
        @Context HttpHeaders headers, InputStream input); @DELETE @Path("/objects/{type}/{id:.+}") @Produces(MediaType.APPLICATION_JSON) Response deleteObject(@HeaderParam(GlobalDataRest.X_TENANT_ID) String xTenantId,
        @HeaderParam(GlobalDataRest.X_DIGEST_ALGORITHM) String xDigestAlgorithm, @PathParam("type") DataCategory
        type,
        @PathParam("id") String idObject); @HEAD @Path("/objects/{type}/{id:.+}") Response checkObjectExistence(@PathParam("type") DataCategory type, @PathParam("id") String idObject,
        @HeaderParam(GlobalDataRest.X_TENANT_ID) String xTenantId); @GET @Path("/objects/{type}/{id:.+}/metadatas") @Produces(MediaType.APPLICATION_JSON) Response getObjectMetadata(@PathParam("type") DataCategory type, @PathParam("id") String idObject,
        @HeaderParam(GlobalDataRest.X_TENANT_ID) String xTenantId,
        @HeaderParam(GlobalDataRest.X_OFFER_NO_CACHE) Boolean noCache); static final String RE_AUTHENTICATION_CALL_STREAM_ALREADY_CONSUMED_BUT_NO_FILE_CREATED; }