@Test public void givenClassificationLevelAutorizedWhenExecuteThenReturnResponseOK() throws Exception { List<String> allowList = new ArrayList<>(); allowList.add("Secret Défense"); classificationLevel = new ClassificationLevel(); classificationLevel.setAllowList(allowList); classificationLevel.setAuthorizeNotDefined(true); VitamConfiguration.setClassificationLevel(classificationLevel); when(workspaceClient.getObject(any(), eq("Units/archiveUnit.json"))) .thenReturn(Response.status(Response.Status.OK).entity(archiveUnit).build()); final ItemStatus response = plugin.execute(params, action); assertEquals(response.getGlobalStatus(), StatusCode.OK); }
@Override public ItemStatus execute(WorkerParameters param, HandlerIO handler){ final ItemStatus itemStatus = new ItemStatus(CHECK_CLASSIFICATION_LEVEL_TASK_ID); try { JsonNode archiveUnit = getArchiveUnit(param, handler); if (!ClassificationLevelUtil.checkClassificationLevel(archiveUnit)) { itemStatus.increment(StatusCode.KO); return new ItemStatus(CHECK_CLASSIFICATION_LEVEL_TASK_ID).setItemsStatus(CHECK_CLASSIFICATION_LEVEL_TASK_ID, itemStatus); } } catch (ContentAddressableStorageNotFoundException | ContentAddressableStorageServerException e) { LOGGER.error("Workspace Server Error"); itemStatus.increment(StatusCode.FATAL); return new ItemStatus(CHECK_CLASSIFICATION_LEVEL_TASK_ID).setItemsStatus(CHECK_CLASSIFICATION_LEVEL_TASK_ID, itemStatus); } catch (InvalidParseOperationException | IOException e) { LOGGER.error("File couldnt be converted into json", e); itemStatus.increment(StatusCode.KO); return new ItemStatus(CHECK_CLASSIFICATION_LEVEL_TASK_ID).setItemsStatus(CHECK_CLASSIFICATION_LEVEL_TASK_ID, itemStatus); } itemStatus.increment(StatusCode.OK); return new ItemStatus(CHECK_CLASSIFICATION_LEVEL_TASK_ID).setItemsStatus(CHECK_CLASSIFICATION_LEVEL_TASK_ID, itemStatus); }
CheckClassificationLevelActionPlugin extends ActionHandler { @Override public ItemStatus execute(WorkerParameters param, HandlerIO handler){ final ItemStatus itemStatus = new ItemStatus(CHECK_CLASSIFICATION_LEVEL_TASK_ID); try { JsonNode archiveUnit = getArchiveUnit(param, handler); if (!ClassificationLevelUtil.checkClassificationLevel(archiveUnit)) { itemStatus.increment(StatusCode.KO); return new ItemStatus(CHECK_CLASSIFICATION_LEVEL_TASK_ID).setItemsStatus(CHECK_CLASSIFICATION_LEVEL_TASK_ID, itemStatus); } } catch (ContentAddressableStorageNotFoundException | ContentAddressableStorageServerException e) { LOGGER.error("Workspace Server Error"); itemStatus.increment(StatusCode.FATAL); return new ItemStatus(CHECK_CLASSIFICATION_LEVEL_TASK_ID).setItemsStatus(CHECK_CLASSIFICATION_LEVEL_TASK_ID, itemStatus); } catch (InvalidParseOperationException | IOException e) { LOGGER.error("File couldnt be converted into json", e); itemStatus.increment(StatusCode.KO); return new ItemStatus(CHECK_CLASSIFICATION_LEVEL_TASK_ID).setItemsStatus(CHECK_CLASSIFICATION_LEVEL_TASK_ID, itemStatus); } itemStatus.increment(StatusCode.OK); return new ItemStatus(CHECK_CLASSIFICATION_LEVEL_TASK_ID).setItemsStatus(CHECK_CLASSIFICATION_LEVEL_TASK_ID, itemStatus); } }
CheckClassificationLevelActionPlugin extends ActionHandler { @Override public ItemStatus execute(WorkerParameters param, HandlerIO handler){ final ItemStatus itemStatus = new ItemStatus(CHECK_CLASSIFICATION_LEVEL_TASK_ID); try { JsonNode archiveUnit = getArchiveUnit(param, handler); if (!ClassificationLevelUtil.checkClassificationLevel(archiveUnit)) { itemStatus.increment(StatusCode.KO); return new ItemStatus(CHECK_CLASSIFICATION_LEVEL_TASK_ID).setItemsStatus(CHECK_CLASSIFICATION_LEVEL_TASK_ID, itemStatus); } } catch (ContentAddressableStorageNotFoundException | ContentAddressableStorageServerException e) { LOGGER.error("Workspace Server Error"); itemStatus.increment(StatusCode.FATAL); return new ItemStatus(CHECK_CLASSIFICATION_LEVEL_TASK_ID).setItemsStatus(CHECK_CLASSIFICATION_LEVEL_TASK_ID, itemStatus); } catch (InvalidParseOperationException | IOException e) { LOGGER.error("File couldnt be converted into json", e); itemStatus.increment(StatusCode.KO); return new ItemStatus(CHECK_CLASSIFICATION_LEVEL_TASK_ID).setItemsStatus(CHECK_CLASSIFICATION_LEVEL_TASK_ID, itemStatus); } itemStatus.increment(StatusCode.OK); return new ItemStatus(CHECK_CLASSIFICATION_LEVEL_TASK_ID).setItemsStatus(CHECK_CLASSIFICATION_LEVEL_TASK_ID, itemStatus); } CheckClassificationLevelActionPlugin(); }
CheckClassificationLevelActionPlugin extends ActionHandler { @Override public ItemStatus execute(WorkerParameters param, HandlerIO handler){ final ItemStatus itemStatus = new ItemStatus(CHECK_CLASSIFICATION_LEVEL_TASK_ID); try { JsonNode archiveUnit = getArchiveUnit(param, handler); if (!ClassificationLevelUtil.checkClassificationLevel(archiveUnit)) { itemStatus.increment(StatusCode.KO); return new ItemStatus(CHECK_CLASSIFICATION_LEVEL_TASK_ID).setItemsStatus(CHECK_CLASSIFICATION_LEVEL_TASK_ID, itemStatus); } } catch (ContentAddressableStorageNotFoundException | ContentAddressableStorageServerException e) { LOGGER.error("Workspace Server Error"); itemStatus.increment(StatusCode.FATAL); return new ItemStatus(CHECK_CLASSIFICATION_LEVEL_TASK_ID).setItemsStatus(CHECK_CLASSIFICATION_LEVEL_TASK_ID, itemStatus); } catch (InvalidParseOperationException | IOException e) { LOGGER.error("File couldnt be converted into json", e); itemStatus.increment(StatusCode.KO); return new ItemStatus(CHECK_CLASSIFICATION_LEVEL_TASK_ID).setItemsStatus(CHECK_CLASSIFICATION_LEVEL_TASK_ID, itemStatus); } itemStatus.increment(StatusCode.OK); return new ItemStatus(CHECK_CLASSIFICATION_LEVEL_TASK_ID).setItemsStatus(CHECK_CLASSIFICATION_LEVEL_TASK_ID, itemStatus); } CheckClassificationLevelActionPlugin(); @Override ItemStatus execute(WorkerParameters param, HandlerIO handler); @Override void checkMandatoryIOParameter(HandlerIO handler); }
CheckClassificationLevelActionPlugin extends ActionHandler { @Override public ItemStatus execute(WorkerParameters param, HandlerIO handler){ final ItemStatus itemStatus = new ItemStatus(CHECK_CLASSIFICATION_LEVEL_TASK_ID); try { JsonNode archiveUnit = getArchiveUnit(param, handler); if (!ClassificationLevelUtil.checkClassificationLevel(archiveUnit)) { itemStatus.increment(StatusCode.KO); return new ItemStatus(CHECK_CLASSIFICATION_LEVEL_TASK_ID).setItemsStatus(CHECK_CLASSIFICATION_LEVEL_TASK_ID, itemStatus); } } catch (ContentAddressableStorageNotFoundException | ContentAddressableStorageServerException e) { LOGGER.error("Workspace Server Error"); itemStatus.increment(StatusCode.FATAL); return new ItemStatus(CHECK_CLASSIFICATION_LEVEL_TASK_ID).setItemsStatus(CHECK_CLASSIFICATION_LEVEL_TASK_ID, itemStatus); } catch (InvalidParseOperationException | IOException e) { LOGGER.error("File couldnt be converted into json", e); itemStatus.increment(StatusCode.KO); return new ItemStatus(CHECK_CLASSIFICATION_LEVEL_TASK_ID).setItemsStatus(CHECK_CLASSIFICATION_LEVEL_TASK_ID, itemStatus); } itemStatus.increment(StatusCode.OK); return new ItemStatus(CHECK_CLASSIFICATION_LEVEL_TASK_ID).setItemsStatus(CHECK_CLASSIFICATION_LEVEL_TASK_ID, itemStatus); } CheckClassificationLevelActionPlugin(); @Override ItemStatus execute(WorkerParameters param, HandlerIO handler); @Override void checkMandatoryIOParameter(HandlerIO handler);  }