@Test @RunWithCustomExecutor public void should_remove_sip_when_atr_is_ok() throws Exception { HandlerIO handlerIO = mock(HandlerIO.class); when(handlerIO.getWorkspaceClientFactory()).thenReturn(workspaceClientFactory); when(workspaceClientFactory.getClient()).thenReturn(workspaceClient); File transferReplyContext = PropertiesUtils.getResourceFile("transfer/transfer_reply_context.json"); when(handlerIO.getInput(0)).thenReturn(transferReplyContext); ItemStatus itemStatus = transferReplyDeleteSIPPlugin.execute(null, handlerIO); assertThat(itemStatus.getItemId()).isEqualTo("TRANSFER_REPLY_DELETE_SIP"); assertThat(itemStatus.getGlobalStatus()).isEqualTo(StatusCode.OK); ArgumentCaptor<String> containerNameCaptor = ArgumentCaptor.forClass(String.class); ArgumentCaptor<String> objectNameCaptor = ArgumentCaptor.forClass(String.class); verify(workspaceClient, times(1)).deleteObject(containerNameCaptor.capture(), objectNameCaptor.capture()); assertThat(containerNameCaptor.getValue()).isEqualTo(TRANSFER_CONTAINER); String expectedFilename = tenant + "/ATR_MESSAGE_REQUEST_IDENTIFIER"; assertThat(objectNameCaptor.getValue()).isEqualTo(expectedFilename); }
@Override public ItemStatus execute(WorkerParameters param, HandlerIO handler) { try (WorkspaceClient workspaceClient = handler.getWorkspaceClientFactory().getClient()) { TransferReplyContext transferReplyContext = JsonHandler.getFromFile((File) handler.getInput(TRANSFER_REPLY_CONTEXT_IN_RANK), TransferReplyContext.class); String optId = transferReplyContext.getTransferMessageRequestIdentifier(); String tenantFolder = Integer.toString(VitamThreadUtils.getVitamSession().getTenantId()); workspaceClient.deleteObject(TRANSFER_CONTAINER, tenantFolder + "/" + optId); } catch (InvalidParseOperationException | ContentAddressableStorageServerException e) { LOGGER.error(e); return buildItemStatus(PLUGIN_NAME, FATAL, EventDetails.of(e.getMessage())); } catch (ContentAddressableStorageNotFoundException e) { return buildItemStatusWithMessage(PLUGIN_NAME, StatusCode.WARNING, "File not found"); } return buildItemStatusWithMessage(PLUGIN_NAME, StatusCode.OK, "Delete SIP ok."); }
TransferReplyDeleteSIP extends ActionHandler { @Override public ItemStatus execute(WorkerParameters param, HandlerIO handler) { try (WorkspaceClient workspaceClient = handler.getWorkspaceClientFactory().getClient()) { TransferReplyContext transferReplyContext = JsonHandler.getFromFile((File) handler.getInput(TRANSFER_REPLY_CONTEXT_IN_RANK), TransferReplyContext.class); String optId = transferReplyContext.getTransferMessageRequestIdentifier(); String tenantFolder = Integer.toString(VitamThreadUtils.getVitamSession().getTenantId()); workspaceClient.deleteObject(TRANSFER_CONTAINER, tenantFolder + "/" + optId); } catch (InvalidParseOperationException | ContentAddressableStorageServerException e) { LOGGER.error(e); return buildItemStatus(PLUGIN_NAME, FATAL, EventDetails.of(e.getMessage())); } catch (ContentAddressableStorageNotFoundException e) { return buildItemStatusWithMessage(PLUGIN_NAME, StatusCode.WARNING, "File not found"); } return buildItemStatusWithMessage(PLUGIN_NAME, StatusCode.OK, "Delete SIP ok."); } }
TransferReplyDeleteSIP extends ActionHandler { @Override public ItemStatus execute(WorkerParameters param, HandlerIO handler) { try (WorkspaceClient workspaceClient = handler.getWorkspaceClientFactory().getClient()) { TransferReplyContext transferReplyContext = JsonHandler.getFromFile((File) handler.getInput(TRANSFER_REPLY_CONTEXT_IN_RANK), TransferReplyContext.class); String optId = transferReplyContext.getTransferMessageRequestIdentifier(); String tenantFolder = Integer.toString(VitamThreadUtils.getVitamSession().getTenantId()); workspaceClient.deleteObject(TRANSFER_CONTAINER, tenantFolder + "/" + optId); } catch (InvalidParseOperationException | ContentAddressableStorageServerException e) { LOGGER.error(e); return buildItemStatus(PLUGIN_NAME, FATAL, EventDetails.of(e.getMessage())); } catch (ContentAddressableStorageNotFoundException e) { return buildItemStatusWithMessage(PLUGIN_NAME, StatusCode.WARNING, "File not found"); } return buildItemStatusWithMessage(PLUGIN_NAME, StatusCode.OK, "Delete SIP ok."); } TransferReplyDeleteSIP(); }
TransferReplyDeleteSIP extends ActionHandler { @Override public ItemStatus execute(WorkerParameters param, HandlerIO handler) { try (WorkspaceClient workspaceClient = handler.getWorkspaceClientFactory().getClient()) { TransferReplyContext transferReplyContext = JsonHandler.getFromFile((File) handler.getInput(TRANSFER_REPLY_CONTEXT_IN_RANK), TransferReplyContext.class); String optId = transferReplyContext.getTransferMessageRequestIdentifier(); String tenantFolder = Integer.toString(VitamThreadUtils.getVitamSession().getTenantId()); workspaceClient.deleteObject(TRANSFER_CONTAINER, tenantFolder + "/" + optId); } catch (InvalidParseOperationException | ContentAddressableStorageServerException e) { LOGGER.error(e); return buildItemStatus(PLUGIN_NAME, FATAL, EventDetails.of(e.getMessage())); } catch (ContentAddressableStorageNotFoundException e) { return buildItemStatusWithMessage(PLUGIN_NAME, StatusCode.WARNING, "File not found"); } return buildItemStatusWithMessage(PLUGIN_NAME, StatusCode.OK, "Delete SIP ok."); } TransferReplyDeleteSIP(); @Override ItemStatus execute(WorkerParameters param, HandlerIO handler); }
TransferReplyDeleteSIP extends ActionHandler { @Override public ItemStatus execute(WorkerParameters param, HandlerIO handler) { try (WorkspaceClient workspaceClient = handler.getWorkspaceClientFactory().getClient()) { TransferReplyContext transferReplyContext = JsonHandler.getFromFile((File) handler.getInput(TRANSFER_REPLY_CONTEXT_IN_RANK), TransferReplyContext.class); String optId = transferReplyContext.getTransferMessageRequestIdentifier(); String tenantFolder = Integer.toString(VitamThreadUtils.getVitamSession().getTenantId()); workspaceClient.deleteObject(TRANSFER_CONTAINER, tenantFolder + "/" + optId); } catch (InvalidParseOperationException | ContentAddressableStorageServerException e) { LOGGER.error(e); return buildItemStatus(PLUGIN_NAME, FATAL, EventDetails.of(e.getMessage())); } catch (ContentAddressableStorageNotFoundException e) { return buildItemStatusWithMessage(PLUGIN_NAME, StatusCode.WARNING, "File not found"); } return buildItemStatusWithMessage(PLUGIN_NAME, StatusCode.OK, "Delete SIP ok."); } TransferReplyDeleteSIP(); @Override ItemStatus execute(WorkerParameters param, HandlerIO handler);  }