@Test public void testSelect_NotFound() throws Exception { when(accessInternalClient.selectUnitLifeCycleById(any(), any())) .thenThrow(new LogbookClientNotFoundException("")); when(accessInternalClient.selectObjectGroupLifeCycleById(any(), any())) .thenThrow(new LogbookClientNotFoundException("")); when(accessInternalClient.selectOperationById(any(), any())) .thenThrow(new LogbookClientNotFoundException("")); when(accessInternalClient.selectOperation(any())) .thenReturn(new RequestResponseOK<>()); given() .contentType(ContentType.JSON) .accept(ContentType.JSON) .header(GlobalDataRest.X_TENANT_ID, TENANT_ID) .body(JsonHandler.getFromString(BODY_TEST_WITH_ID)) .when() .get("/logbookoperations/" + bad_id) .then().statusCode(Status.NOT_FOUND.getStatusCode()); given() .contentType(ContentType.JSON) .accept(ContentType.JSON) .param("id_lc", bad_id) .header(GlobalDataRest.X_TENANT_ID, TENANT_ID) .body(JsonHandler.getFromString(BODY_TEST_WITH_ID)) .when() .get("/logbookunitlifecycles/" + bad_id) .then().statusCode(Status.NOT_FOUND.getStatusCode()); given() .contentType(ContentType.JSON) .accept(ContentType.JSON) .param("id_lc", bad_id) .header(GlobalDataRest.X_TENANT_ID, TENANT_ID) .body(JsonHandler.getFromString(BODY_TEST_WITH_ID)) .when() .get("/logbookobjectgroups/" + bad_id) .then().statusCode(Status.NOT_FOUND.getStatusCode()); }
@GET @Path("/logbookoperations") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) @Secured(permission = "logbookoperations:read", description = "Lister toutes les opérations") public Response selectOperation(@Dsl(value = DslSchema.SELECT_SINGLE) JsonNode query) { Status status; try (AccessInternalClient client = accessInternalClientFactory.getClient()) { SanityChecker.checkJsonAll(query); RequestResponse<JsonNode> result = client.selectOperationSliced(query); int st = result.isOk() ? Status.OK.getStatusCode() : result.getHttpCode(); return Response.status(st).entity(result).build(); } catch (final LogbookClientException e) { LOGGER.error("Client exception while trying to search operations: ", e); status = Status.INTERNAL_SERVER_ERROR; return Response.status(status) .entity(VitamCodeHelper .toVitamError(VitamCode.ACCESS_EXTERNAL_SELECT_OPERATION_ERROR, e.getLocalizedMessage()) .setHttpCode(status.getStatusCode())) .build(); } catch (final InvalidParseOperationException e) { LOGGER.error(INVALID_ARGUMENT, e); status = Status.PRECONDITION_FAILED; return Response.status(status) .entity(VitamCodeHelper .toVitamError(VitamCode.ACCESS_EXTERNAL_SELECT_OPERATION_ERROR, e.getLocalizedMessage()) .setHttpCode(status.getStatusCode())) .build(); } catch (AccessUnauthorizedException e) { LOGGER.error(CONTRACT_ACCESS_DOES_NOT_ALLOW, e); status = Status.UNAUTHORIZED; return Response.status(status) .entity(VitamCodeHelper .toVitamError(VitamCode.ACCESS_EXTERNAL_SELECT_OPERATION_ERROR, e.getLocalizedMessage()) .setHttpCode(status.getStatusCode())) .build(); } }
LogbookExternalResource { @GET @Path("/logbookoperations") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) @Secured(permission = "logbookoperations:read", description = "Lister toutes les opérations") public Response selectOperation(@Dsl(value = DslSchema.SELECT_SINGLE) JsonNode query) { Status status; try (AccessInternalClient client = accessInternalClientFactory.getClient()) { SanityChecker.checkJsonAll(query); RequestResponse<JsonNode> result = client.selectOperationSliced(query); int st = result.isOk() ? Status.OK.getStatusCode() : result.getHttpCode(); return Response.status(st).entity(result).build(); } catch (final LogbookClientException e) { LOGGER.error("Client exception while trying to search operations: ", e); status = Status.INTERNAL_SERVER_ERROR; return Response.status(status) .entity(VitamCodeHelper .toVitamError(VitamCode.ACCESS_EXTERNAL_SELECT_OPERATION_ERROR, e.getLocalizedMessage()) .setHttpCode(status.getStatusCode())) .build(); } catch (final InvalidParseOperationException e) { LOGGER.error(INVALID_ARGUMENT, e); status = Status.PRECONDITION_FAILED; return Response.status(status) .entity(VitamCodeHelper .toVitamError(VitamCode.ACCESS_EXTERNAL_SELECT_OPERATION_ERROR, e.getLocalizedMessage()) .setHttpCode(status.getStatusCode())) .build(); } catch (AccessUnauthorizedException e) { LOGGER.error(CONTRACT_ACCESS_DOES_NOT_ALLOW, e); status = Status.UNAUTHORIZED; return Response.status(status) .entity(VitamCodeHelper .toVitamError(VitamCode.ACCESS_EXTERNAL_SELECT_OPERATION_ERROR, e.getLocalizedMessage()) .setHttpCode(status.getStatusCode())) .build(); } } }
LogbookExternalResource { @GET @Path("/logbookoperations") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) @Secured(permission = "logbookoperations:read", description = "Lister toutes les opérations") public Response selectOperation(@Dsl(value = DslSchema.SELECT_SINGLE) JsonNode query) { Status status; try (AccessInternalClient client = accessInternalClientFactory.getClient()) { SanityChecker.checkJsonAll(query); RequestResponse<JsonNode> result = client.selectOperationSliced(query); int st = result.isOk() ? Status.OK.getStatusCode() : result.getHttpCode(); return Response.status(st).entity(result).build(); } catch (final LogbookClientException e) { LOGGER.error("Client exception while trying to search operations: ", e); status = Status.INTERNAL_SERVER_ERROR; return Response.status(status) .entity(VitamCodeHelper .toVitamError(VitamCode.ACCESS_EXTERNAL_SELECT_OPERATION_ERROR, e.getLocalizedMessage()) .setHttpCode(status.getStatusCode())) .build(); } catch (final InvalidParseOperationException e) { LOGGER.error(INVALID_ARGUMENT, e); status = Status.PRECONDITION_FAILED; return Response.status(status) .entity(VitamCodeHelper .toVitamError(VitamCode.ACCESS_EXTERNAL_SELECT_OPERATION_ERROR, e.getLocalizedMessage()) .setHttpCode(status.getStatusCode())) .build(); } catch (AccessUnauthorizedException e) { LOGGER.error(CONTRACT_ACCESS_DOES_NOT_ALLOW, e); status = Status.UNAUTHORIZED; return Response.status(status) .entity(VitamCodeHelper .toVitamError(VitamCode.ACCESS_EXTERNAL_SELECT_OPERATION_ERROR, e.getLocalizedMessage()) .setHttpCode(status.getStatusCode())) .build(); } } LogbookExternalResource();  LogbookExternalResource(AccessInternalClientFactory accessInternalClientFactory); }
LogbookExternalResource { @GET @Path("/logbookoperations") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) @Secured(permission = "logbookoperations:read", description = "Lister toutes les opérations") public Response selectOperation(@Dsl(value = DslSchema.SELECT_SINGLE) JsonNode query) { Status status; try (AccessInternalClient client = accessInternalClientFactory.getClient()) { SanityChecker.checkJsonAll(query); RequestResponse<JsonNode> result = client.selectOperationSliced(query); int st = result.isOk() ? Status.OK.getStatusCode() : result.getHttpCode(); return Response.status(st).entity(result).build(); } catch (final LogbookClientException e) { LOGGER.error("Client exception while trying to search operations: ", e); status = Status.INTERNAL_SERVER_ERROR; return Response.status(status) .entity(VitamCodeHelper .toVitamError(VitamCode.ACCESS_EXTERNAL_SELECT_OPERATION_ERROR, e.getLocalizedMessage()) .setHttpCode(status.getStatusCode())) .build(); } catch (final InvalidParseOperationException e) { LOGGER.error(INVALID_ARGUMENT, e); status = Status.PRECONDITION_FAILED; return Response.status(status) .entity(VitamCodeHelper .toVitamError(VitamCode.ACCESS_EXTERNAL_SELECT_OPERATION_ERROR, e.getLocalizedMessage()) .setHttpCode(status.getStatusCode())) .build(); } catch (AccessUnauthorizedException e) { LOGGER.error(CONTRACT_ACCESS_DOES_NOT_ALLOW, e); status = Status.UNAUTHORIZED; return Response.status(status) .entity(VitamCodeHelper .toVitamError(VitamCode.ACCESS_EXTERNAL_SELECT_OPERATION_ERROR, e.getLocalizedMessage()) .setHttpCode(status.getStatusCode())) .build(); } } LogbookExternalResource();  LogbookExternalResource(AccessInternalClientFactory accessInternalClientFactory); @GET @Path("/logbookoperations") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) @Secured(permission = "logbookoperations:read", description = "Lister toutes les opérations") Response selectOperation(@Dsl(value = DslSchema.SELECT_SINGLE) JsonNode query); @GET @Path("/logbookoperations/{id_op}") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) @Secured(permission = "logbookoperations:id:read", description = "Récupérer le journal d'une opération donnée") Response getOperationById(@PathParam("id_op") String operationId,
        @Dsl(value = DslSchema.GET_BY_ID) JsonNode queryDsl); @GET @Path("/logbookunitlifecycles/{id_lc}") @Secured(permission = "logbookunitlifecycles:id:read", description = "Récupérer le journal de cycle de vie d'une unité archivistique") @Produces(MediaType.APPLICATION_JSON) Response getUnitLifeCycleById(@PathParam("id_lc") String unitLifeCycleId,
        @Dsl(value = DslSchema.GET_BY_ID) JsonNode queryDsl); @GET @Path("/logbookobjectslifecycles/{id_lc}") @Secured(permission = "logbookobjectslifecycles:id:read", description = "Récupérer le journal de cycle de vie d'un groupe d'objet") @Produces(MediaType.APPLICATION_JSON) Response getObjectGroupLifeCycleById(@PathParam("id_lc") String objectGroupLifeCycleId,
        @Dsl(value = DslSchema.GET_BY_ID) JsonNode queryDsl); }
LogbookExternalResource { @GET @Path("/logbookoperations") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) @Secured(permission = "logbookoperations:read", description = "Lister toutes les opérations") public Response selectOperation(@Dsl(value = DslSchema.SELECT_SINGLE) JsonNode query) { Status status; try (AccessInternalClient client = accessInternalClientFactory.getClient()) { SanityChecker.checkJsonAll(query); RequestResponse<JsonNode> result = client.selectOperationSliced(query); int st = result.isOk() ? Status.OK.getStatusCode() : result.getHttpCode(); return Response.status(st).entity(result).build(); } catch (final LogbookClientException e) { LOGGER.error("Client exception while trying to search operations: ", e); status = Status.INTERNAL_SERVER_ERROR; return Response.status(status) .entity(VitamCodeHelper .toVitamError(VitamCode.ACCESS_EXTERNAL_SELECT_OPERATION_ERROR, e.getLocalizedMessage()) .setHttpCode(status.getStatusCode())) .build(); } catch (final InvalidParseOperationException e) { LOGGER.error(INVALID_ARGUMENT, e); status = Status.PRECONDITION_FAILED; return Response.status(status) .entity(VitamCodeHelper .toVitamError(VitamCode.ACCESS_EXTERNAL_SELECT_OPERATION_ERROR, e.getLocalizedMessage()) .setHttpCode(status.getStatusCode())) .build(); } catch (AccessUnauthorizedException e) { LOGGER.error(CONTRACT_ACCESS_DOES_NOT_ALLOW, e); status = Status.UNAUTHORIZED; return Response.status(status) .entity(VitamCodeHelper .toVitamError(VitamCode.ACCESS_EXTERNAL_SELECT_OPERATION_ERROR, e.getLocalizedMessage()) .setHttpCode(status.getStatusCode())) .build(); } } LogbookExternalResource();  LogbookExternalResource(AccessInternalClientFactory accessInternalClientFactory); @GET @Path("/logbookoperations") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) @Secured(permission = "logbookoperations:read", description = "Lister toutes les opérations") Response selectOperation(@Dsl(value = DslSchema.SELECT_SINGLE) JsonNode query); @GET @Path("/logbookoperations/{id_op}") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) @Secured(permission = "logbookoperations:id:read", description = "Récupérer le journal d'une opération donnée") Response getOperationById(@PathParam("id_op") String operationId,
        @Dsl(value = DslSchema.GET_BY_ID) JsonNode queryDsl); @GET @Path("/logbookunitlifecycles/{id_lc}") @Secured(permission = "logbookunitlifecycles:id:read", description = "Récupérer le journal de cycle de vie d'une unité archivistique") @Produces(MediaType.APPLICATION_JSON) Response getUnitLifeCycleById(@PathParam("id_lc") String unitLifeCycleId,
        @Dsl(value = DslSchema.GET_BY_ID) JsonNode queryDsl); @GET @Path("/logbookobjectslifecycles/{id_lc}") @Secured(permission = "logbookobjectslifecycles:id:read", description = "Récupérer le journal de cycle de vie d'un groupe d'objet") @Produces(MediaType.APPLICATION_JSON) Response getObjectGroupLifeCycleById(@PathParam("id_lc") String objectGroupLifeCycleId,
        @Dsl(value = DslSchema.GET_BY_ID) JsonNode queryDsl);  }