@RunWithCustomExecutor @Test public void givenQueryCorrectWhenGetObjectAsInputStreamThenRaisePreconditionFailed() throws Exception { VitamThreadUtils.getVitamSession().setRequestId(DUMMY_REQUEST_ID); when(mock.get()).thenReturn(Response.status(Status.PRECONDITION_FAILED).build()); assertThatThrownBy(() -> client.getObject(ID, USAGE, VERSION, UNIT_ID)) .isInstanceOf(IllegalArgumentException.class); }
@Override public Response getObject(String objectGroupId, String usage, int version, String unitId) throws InvalidParseOperationException, AccessInternalClientServerException, AccessInternalClientNotFoundException, AccessUnauthorizedException { ParametersChecker.checkParameter(BLANK_OBJECT_GROUP_ID, objectGroupId); ParametersChecker.checkParameter(BLANK_UNIT_ID, unitId); try { VitamRequestBuilder request = get().withPath(OBJECTS + objectGroupId + "/" + unitId) .withHeader(X_QUALIFIER, usage) .withHeader(X_VERSION, version) .withJsonOctet() .withBefore(CHECK_REQUEST_ID); Response response = make(request); check(response); return response; } catch (PreconditionFailedClientException e) { throw new IllegalArgumentException(e); } catch (VitamClientInternalException | NoWritingPermissionException | ForbiddenClientException | ExpectationFailedClientException e) { throw new AccessInternalClientServerException(e); } catch (BadRequestException e) { throw new InvalidParseOperationException(e); } }
AccessInternalClientRest extends DefaultClient implements AccessInternalClient { @Override public Response getObject(String objectGroupId, String usage, int version, String unitId) throws InvalidParseOperationException, AccessInternalClientServerException, AccessInternalClientNotFoundException, AccessUnauthorizedException { ParametersChecker.checkParameter(BLANK_OBJECT_GROUP_ID, objectGroupId); ParametersChecker.checkParameter(BLANK_UNIT_ID, unitId); try { VitamRequestBuilder request = get().withPath(OBJECTS + objectGroupId + "/" + unitId) .withHeader(X_QUALIFIER, usage) .withHeader(X_VERSION, version) .withJsonOctet() .withBefore(CHECK_REQUEST_ID); Response response = make(request); check(response); return response; } catch (PreconditionFailedClientException e) { throw new IllegalArgumentException(e); } catch (VitamClientInternalException | NoWritingPermissionException | ForbiddenClientException | ExpectationFailedClientException e) { throw new AccessInternalClientServerException(e); } catch (BadRequestException e) { throw new InvalidParseOperationException(e); } } }
AccessInternalClientRest extends DefaultClient implements AccessInternalClient { @Override public Response getObject(String objectGroupId, String usage, int version, String unitId) throws InvalidParseOperationException, AccessInternalClientServerException, AccessInternalClientNotFoundException, AccessUnauthorizedException { ParametersChecker.checkParameter(BLANK_OBJECT_GROUP_ID, objectGroupId); ParametersChecker.checkParameter(BLANK_UNIT_ID, unitId); try { VitamRequestBuilder request = get().withPath(OBJECTS + objectGroupId + "/" + unitId) .withHeader(X_QUALIFIER, usage) .withHeader(X_VERSION, version) .withJsonOctet() .withBefore(CHECK_REQUEST_ID); Response response = make(request); check(response); return response; } catch (PreconditionFailedClientException e) { throw new IllegalArgumentException(e); } catch (VitamClientInternalException | NoWritingPermissionException | ForbiddenClientException | ExpectationFailedClientException e) { throw new AccessInternalClientServerException(e); } catch (BadRequestException e) { throw new InvalidParseOperationException(e); } } AccessInternalClientRest(AccessInternalClientFactory factory); }
AccessInternalClientRest extends DefaultClient implements AccessInternalClient { @Override public Response getObject(String objectGroupId, String usage, int version, String unitId) throws InvalidParseOperationException, AccessInternalClientServerException, AccessInternalClientNotFoundException, AccessUnauthorizedException { ParametersChecker.checkParameter(BLANK_OBJECT_GROUP_ID, objectGroupId); ParametersChecker.checkParameter(BLANK_UNIT_ID, unitId); try { VitamRequestBuilder request = get().withPath(OBJECTS + objectGroupId + "/" + unitId) .withHeader(X_QUALIFIER, usage) .withHeader(X_VERSION, version) .withJsonOctet() .withBefore(CHECK_REQUEST_ID); Response response = make(request); check(response); return response; } catch (PreconditionFailedClientException e) { throw new IllegalArgumentException(e); } catch (VitamClientInternalException | NoWritingPermissionException | ForbiddenClientException | ExpectationFailedClientException e) { throw new AccessInternalClientServerException(e); } catch (BadRequestException e) { throw new InvalidParseOperationException(e); } } AccessInternalClientRest(AccessInternalClientFactory factory); @Override RequestResponse<JsonNode> selectUnits(JsonNode selectQuery); @Override RequestResponse<JsonNode> selectUnitbyId(JsonNode selectQuery, String idUnit); @Override RequestResponse<JsonNode> updateUnitbyId(JsonNode updateQuery, String unitId); @Override RequestResponse<JsonNode> updateUnits(JsonNode updateQuery); @Override RequestResponse<JsonNode> updateUnitsRules(MassUpdateUnitRuleRequest massUpdateUnitRuleRequest); @Override RequestResponse<JsonNode> selectObjectbyId(JsonNode selectObjectQuery, String objectId); @Override Response getObject(String objectGroupId, String usage, int version, String unitId); @Override RequestResponse<JsonNode> selectOperation(JsonNode select); @Override RequestResponse<JsonNode> selectOperationSliced(JsonNode select); @Override RequestResponse<JsonNode> selectOperationById(String processId, JsonNode select); @Override RequestResponse<JsonNode> selectUnitLifeCycleById(String idUnit, JsonNode queryDsl); @Override RequestResponse<JsonNode> selectObjectGroupLifeCycleById(String idObject, JsonNode queryDsl); @Override RequestResponse<JsonNode> checkTraceabilityOperation(JsonNode query); @Override Response downloadTraceabilityFile(String operationId); @Override RequestResponse<JsonNode> exportDIP(JsonNode dslRequest); @Override RequestResponse<JsonNode> exportByUsageFilter(ExportRequest exportRequest); @Override Response findExportByID(String id); @Override Response findTransferSIPByID(String id); @Override RequestResponse<JsonNode> reclassification(JsonNode reclassificationRequest); @Override RequestResponse<JsonNode> selectObjects(JsonNode selectQuery); @Override RequestResponse<JsonNode> selectUnitsWithInheritedRules(JsonNode selectQuery); @Override Response downloadAccessLogFile(JsonNode params); @Override RequestResponse<JsonNode> startEliminationAnalysis(EliminationRequestBody eliminationRequestBody); @Override RequestResponse<JsonNode> startEliminationAction(EliminationRequestBody eliminationRequestBody); @Override RequestResponse<JsonNode> startPreservation(PreservationRequest preservationRequest); @Override RequestResponse<JsonNode> startComputeInheritedRules(JsonNode dslQuery); @Override RequestResponse<JsonNode> deleteComputeInheritedRules(JsonNode dslQuery); @Override RequestResponse<JsonNode> startTransferReplyWorkflow(InputStream transferReply); }
AccessInternalClientRest extends DefaultClient implements AccessInternalClient { @Override public Response getObject(String objectGroupId, String usage, int version, String unitId) throws InvalidParseOperationException, AccessInternalClientServerException, AccessInternalClientNotFoundException, AccessUnauthorizedException { ParametersChecker.checkParameter(BLANK_OBJECT_GROUP_ID, objectGroupId); ParametersChecker.checkParameter(BLANK_UNIT_ID, unitId); try { VitamRequestBuilder request = get().withPath(OBJECTS + objectGroupId + "/" + unitId) .withHeader(X_QUALIFIER, usage) .withHeader(X_VERSION, version) .withJsonOctet() .withBefore(CHECK_REQUEST_ID); Response response = make(request); check(response); return response; } catch (PreconditionFailedClientException e) { throw new IllegalArgumentException(e); } catch (VitamClientInternalException | NoWritingPermissionException | ForbiddenClientException | ExpectationFailedClientException e) { throw new AccessInternalClientServerException(e); } catch (BadRequestException e) { throw new InvalidParseOperationException(e); } } AccessInternalClientRest(AccessInternalClientFactory factory); @Override RequestResponse<JsonNode> selectUnits(JsonNode selectQuery); @Override RequestResponse<JsonNode> selectUnitbyId(JsonNode selectQuery, String idUnit); @Override RequestResponse<JsonNode> updateUnitbyId(JsonNode updateQuery, String unitId); @Override RequestResponse<JsonNode> updateUnits(JsonNode updateQuery); @Override RequestResponse<JsonNode> updateUnitsRules(MassUpdateUnitRuleRequest massUpdateUnitRuleRequest); @Override RequestResponse<JsonNode> selectObjectbyId(JsonNode selectObjectQuery, String objectId); @Override Response getObject(String objectGroupId, String usage, int version, String unitId); @Override RequestResponse<JsonNode> selectOperation(JsonNode select); @Override RequestResponse<JsonNode> selectOperationSliced(JsonNode select); @Override RequestResponse<JsonNode> selectOperationById(String processId, JsonNode select); @Override RequestResponse<JsonNode> selectUnitLifeCycleById(String idUnit, JsonNode queryDsl); @Override RequestResponse<JsonNode> selectObjectGroupLifeCycleById(String idObject, JsonNode queryDsl); @Override RequestResponse<JsonNode> checkTraceabilityOperation(JsonNode query); @Override Response downloadTraceabilityFile(String operationId); @Override RequestResponse<JsonNode> exportDIP(JsonNode dslRequest); @Override RequestResponse<JsonNode> exportByUsageFilter(ExportRequest exportRequest); @Override Response findExportByID(String id); @Override Response findTransferSIPByID(String id); @Override RequestResponse<JsonNode> reclassification(JsonNode reclassificationRequest); @Override RequestResponse<JsonNode> selectObjects(JsonNode selectQuery); @Override RequestResponse<JsonNode> selectUnitsWithInheritedRules(JsonNode selectQuery); @Override Response downloadAccessLogFile(JsonNode params); @Override RequestResponse<JsonNode> startEliminationAnalysis(EliminationRequestBody eliminationRequestBody); @Override RequestResponse<JsonNode> startEliminationAction(EliminationRequestBody eliminationRequestBody); @Override RequestResponse<JsonNode> startPreservation(PreservationRequest preservationRequest); @Override RequestResponse<JsonNode> startComputeInheritedRules(JsonNode dslQuery); @Override RequestResponse<JsonNode> deleteComputeInheritedRules(JsonNode dslQuery); @Override RequestResponse<JsonNode> startTransferReplyWorkflow(InputStream transferReply);  }