@Test public void givenHeadOperationOKThenOK() { Response.ResponseBuilder builder = Response.status(Status.ACCEPTED) .header(GlobalDataRest.X_GLOBAL_EXECUTION_STATE, ProcessState.COMPLETED) .header(GlobalDataRest.X_GLOBAL_EXECUTION_STATUS, StatusCode.OK) .header(GlobalDataRest.X_CONTEXT_ID, LogbookTypeProcess.INGEST.toString()); when(mock.head()) .thenReturn(builder.build()); assertThatCode(() -> client.getOperationProcessStatus(ID)).doesNotThrowAnyException(); }
@Override public ItemStatus getOperationProcessStatus(String id) throws VitamClientException { ParametersChecker.checkParameter(BLANK_OPERATION_ID, id); try (Response response = make(head() .withPath(OPERATION_URI + "/" + id) .withJsonAccept() )) { check(response); return new ItemStatus() .setGlobalState(ProcessState.valueOf(response.getHeaderString(GlobalDataRest.X_GLOBAL_EXECUTION_STATE))) .setLogbookTypeProcess(response.getHeaderString(GlobalDataRest.X_CONTEXT_ID)) .increment(StatusCode.valueOf(response.getHeaderString(GlobalDataRest.X_GLOBAL_EXECUTION_STATUS))); } catch (InvalidParseOperationException | NotAcceptableClientException | WorkspaceClientServerException e) { throw new VitamClientException(e); } catch (VitamClientInternalException | IngestInternalClientNotFoundException | WorkflowNotFoundException | IngestInternalClientServerException e) { throw new VitamClientInternalException(e); } }
IngestInternalClientRest extends DefaultClient implements IngestInternalClient { @Override public ItemStatus getOperationProcessStatus(String id) throws VitamClientException { ParametersChecker.checkParameter(BLANK_OPERATION_ID, id); try (Response response = make(head() .withPath(OPERATION_URI + "/" + id) .withJsonAccept() )) { check(response); return new ItemStatus() .setGlobalState(ProcessState.valueOf(response.getHeaderString(GlobalDataRest.X_GLOBAL_EXECUTION_STATE))) .setLogbookTypeProcess(response.getHeaderString(GlobalDataRest.X_CONTEXT_ID)) .increment(StatusCode.valueOf(response.getHeaderString(GlobalDataRest.X_GLOBAL_EXECUTION_STATUS))); } catch (InvalidParseOperationException | NotAcceptableClientException | WorkspaceClientServerException e) { throw new VitamClientException(e); } catch (VitamClientInternalException | IngestInternalClientNotFoundException | WorkflowNotFoundException | IngestInternalClientServerException e) { throw new VitamClientInternalException(e); } } }
IngestInternalClientRest extends DefaultClient implements IngestInternalClient { @Override public ItemStatus getOperationProcessStatus(String id) throws VitamClientException { ParametersChecker.checkParameter(BLANK_OPERATION_ID, id); try (Response response = make(head() .withPath(OPERATION_URI + "/" + id) .withJsonAccept() )) { check(response); return new ItemStatus() .setGlobalState(ProcessState.valueOf(response.getHeaderString(GlobalDataRest.X_GLOBAL_EXECUTION_STATE))) .setLogbookTypeProcess(response.getHeaderString(GlobalDataRest.X_CONTEXT_ID)) .increment(StatusCode.valueOf(response.getHeaderString(GlobalDataRest.X_GLOBAL_EXECUTION_STATUS))); } catch (InvalidParseOperationException | NotAcceptableClientException | WorkspaceClientServerException e) { throw new VitamClientException(e); } catch (VitamClientInternalException | IngestInternalClientNotFoundException | WorkflowNotFoundException | IngestInternalClientServerException e) { throw new VitamClientInternalException(e); } } IngestInternalClientRest(IngestInternalClientFactory factory); }
IngestInternalClientRest extends DefaultClient implements IngestInternalClient { @Override public ItemStatus getOperationProcessStatus(String id) throws VitamClientException { ParametersChecker.checkParameter(BLANK_OPERATION_ID, id); try (Response response = make(head() .withPath(OPERATION_URI + "/" + id) .withJsonAccept() )) { check(response); return new ItemStatus() .setGlobalState(ProcessState.valueOf(response.getHeaderString(GlobalDataRest.X_GLOBAL_EXECUTION_STATE))) .setLogbookTypeProcess(response.getHeaderString(GlobalDataRest.X_CONTEXT_ID)) .increment(StatusCode.valueOf(response.getHeaderString(GlobalDataRest.X_GLOBAL_EXECUTION_STATUS))); } catch (InvalidParseOperationException | NotAcceptableClientException | WorkspaceClientServerException e) { throw new VitamClientException(e); } catch (VitamClientInternalException | IngestInternalClientNotFoundException | WorkflowNotFoundException | IngestInternalClientServerException e) { throw new VitamClientInternalException(e); } } IngestInternalClientRest(IngestInternalClientFactory factory); @Override void uploadInitialLogbook(Iterable<LogbookOperationParameters> logbookParametersList); @Override void upload(InputStream inputStream, MediaType archiveMimeType, WorkFlow workflow, String actionAfterInit); @Override void initWorkflow(WorkFlow workFlow); @Override void uploadFinalLogbook(Iterable<LogbookOperationParameters> logbookParametersList); @Override Response downloadObjectAsync(String objectId, IngestCollection type); @Override void storeATR(GUID guid, InputStream input); @Override RequestResponse<ItemStatus> updateOperationActionProcess(String actionId, String operationId); @Override ItemStatus getOperationProcessStatus(String id); @Override RequestResponse<ItemStatus> getOperationProcessExecutionDetails(String id); @Override RequestResponse<ItemStatus> cancelOperationProcessExecution(String id); @Override RequestResponse<ProcessDetail> listOperationsDetails(ProcessQuery query); @Override RequestResponse<WorkFlow> getWorkflowDefinitions(); @Override Optional<WorkFlow> getWorkflowDetails(String workflowIdentifier); }
IngestInternalClientRest extends DefaultClient implements IngestInternalClient { @Override public ItemStatus getOperationProcessStatus(String id) throws VitamClientException { ParametersChecker.checkParameter(BLANK_OPERATION_ID, id); try (Response response = make(head() .withPath(OPERATION_URI + "/" + id) .withJsonAccept() )) { check(response); return new ItemStatus() .setGlobalState(ProcessState.valueOf(response.getHeaderString(GlobalDataRest.X_GLOBAL_EXECUTION_STATE))) .setLogbookTypeProcess(response.getHeaderString(GlobalDataRest.X_CONTEXT_ID)) .increment(StatusCode.valueOf(response.getHeaderString(GlobalDataRest.X_GLOBAL_EXECUTION_STATUS))); } catch (InvalidParseOperationException | NotAcceptableClientException | WorkspaceClientServerException e) { throw new VitamClientException(e); } catch (VitamClientInternalException | IngestInternalClientNotFoundException | WorkflowNotFoundException | IngestInternalClientServerException e) { throw new VitamClientInternalException(e); } } IngestInternalClientRest(IngestInternalClientFactory factory); @Override void uploadInitialLogbook(Iterable<LogbookOperationParameters> logbookParametersList); @Override void upload(InputStream inputStream, MediaType archiveMimeType, WorkFlow workflow, String actionAfterInit); @Override void initWorkflow(WorkFlow workFlow); @Override void uploadFinalLogbook(Iterable<LogbookOperationParameters> logbookParametersList); @Override Response downloadObjectAsync(String objectId, IngestCollection type); @Override void storeATR(GUID guid, InputStream input); @Override RequestResponse<ItemStatus> updateOperationActionProcess(String actionId, String operationId); @Override ItemStatus getOperationProcessStatus(String id); @Override RequestResponse<ItemStatus> getOperationProcessExecutionDetails(String id); @Override RequestResponse<ItemStatus> cancelOperationProcessExecution(String id); @Override RequestResponse<ProcessDetail> listOperationsDetails(ProcessQuery query); @Override RequestResponse<WorkFlow> getWorkflowDefinitions(); @Override Optional<WorkFlow> getWorkflowDetails(String workflowIdentifier);  }