@Test public void should_creaste_list_files() throws Exception { when(defaultWorkerParameters.getObjectName()).thenReturn("test"); when(handlerIO.getContainerName()).thenReturn("test"); File file2 = tempFolder.newFile(); List<URI> uriListObjectsWorkspace = new ArrayList<>(); uriListObjectsWorkspace.add(new URI("aeaqaaaaaaebta56aaoc4alcdk4hlcqaaaaq")); when(handlerIO.getUriList(handlerIO.getContainerName(), "data")).thenReturn(uriListObjectsWorkspace); when(handlerIO.getFileFromWorkspace("data/aeaqaaaaaaebta56aaoc4alcdk4hlcqaaaaq")) .thenReturn(PropertiesUtils.getResourceFile("evidenceAudit/test.json")); when(handlerIO.getNewLocalFile("0_LogbookLifecycles_20180312_181919.zip")).thenReturn(file2); File resourceFile = PropertiesUtils.getResourceFile("evidenceAudit/data.txt"); when(handlerIO.getFileFromWorkspace("zip/test")).thenReturn(resourceFile); File report = tempFolder.newFile(); when(handlerIO.getNewLocalFile("aeaqaaaaaaebta56aaoc4alcdk4hlcqaaaaq")).thenReturn(report); ItemStatus execute = evidenceAuditListSecuredFiles.execute(defaultWorkerParameters, handlerIO); Assertions.assertThat(execute.getGlobalStatus()).isEqualTo(StatusCode.OK); }
@Override public ItemStatus execute(WorkerParameters param, HandlerIO handlerIO) throws ProcessingException { ItemStatus itemStatus = new ItemStatus(EVIDENCE_AUDIT_LIST_SECURED_FILES_TO_DOWNLOAD); List<URI> uriListObjectsWorkspace = handlerIO.getUriList(handlerIO.getContainerName(), DATA); Map<String, List<String>> securedFilenameList = new HashMap<>(); try { for (URI element : uriListObjectsWorkspace) { File file = handlerIO.getFileFromWorkspace(DATA + File.separator + element.getPath()); JsonNode jsonName = getFromFile(file); JsonNode fileNameNode = jsonName.get(FILE_NAME); if (fileNameNode == null) { continue; } String identifier = fileNameNode.textValue(); if (securedFilenameList.get(identifier) == null) { ArrayList<String> listIds = new ArrayList<>(); listIds.add(element.toString()); securedFilenameList.put(identifier, listIds); continue; } securedFilenameList.get(identifier).add(element.toString()); } Set<Entry<String, List<String>>> entrySet = securedFilenameList.entrySet(); for (Entry<String, List<String>> me : entrySet) { File file = handlerIO.getNewLocalFile(me.getKey()); JsonHandler.writeAsFile(me.getValue(), file); handlerIO.transferFileToWorkspace("fileNames" + "/" + me.getKey(), file, true, false); } } catch (ContentAddressableStorageNotFoundException | InvalidParseOperationException | ContentAddressableStorageServerException | IOException e) { LOGGER.error(e); return itemStatus.increment(StatusCode.FATAL); } itemStatus.increment(StatusCode.OK); return new ItemStatus(EVIDENCE_AUDIT_LIST_SECURED_FILES_TO_DOWNLOAD) .setItemsStatus(EVIDENCE_AUDIT_LIST_SECURED_FILES_TO_DOWNLOAD, itemStatus); }
EvidenceAuditListSecuredFiles extends ActionHandler { @Override public ItemStatus execute(WorkerParameters param, HandlerIO handlerIO) throws ProcessingException { ItemStatus itemStatus = new ItemStatus(EVIDENCE_AUDIT_LIST_SECURED_FILES_TO_DOWNLOAD); List<URI> uriListObjectsWorkspace = handlerIO.getUriList(handlerIO.getContainerName(), DATA); Map<String, List<String>> securedFilenameList = new HashMap<>(); try { for (URI element : uriListObjectsWorkspace) { File file = handlerIO.getFileFromWorkspace(DATA + File.separator + element.getPath()); JsonNode jsonName = getFromFile(file); JsonNode fileNameNode = jsonName.get(FILE_NAME); if (fileNameNode == null) { continue; } String identifier = fileNameNode.textValue(); if (securedFilenameList.get(identifier) == null) { ArrayList<String> listIds = new ArrayList<>(); listIds.add(element.toString()); securedFilenameList.put(identifier, listIds); continue; } securedFilenameList.get(identifier).add(element.toString()); } Set<Entry<String, List<String>>> entrySet = securedFilenameList.entrySet(); for (Entry<String, List<String>> me : entrySet) { File file = handlerIO.getNewLocalFile(me.getKey()); JsonHandler.writeAsFile(me.getValue(), file); handlerIO.transferFileToWorkspace("fileNames" + "/" + me.getKey(), file, true, false); } } catch (ContentAddressableStorageNotFoundException | InvalidParseOperationException | ContentAddressableStorageServerException | IOException e) { LOGGER.error(e); return itemStatus.increment(StatusCode.FATAL); } itemStatus.increment(StatusCode.OK); return new ItemStatus(EVIDENCE_AUDIT_LIST_SECURED_FILES_TO_DOWNLOAD) .setItemsStatus(EVIDENCE_AUDIT_LIST_SECURED_FILES_TO_DOWNLOAD, itemStatus); } }
EvidenceAuditListSecuredFiles extends ActionHandler { @Override public ItemStatus execute(WorkerParameters param, HandlerIO handlerIO) throws ProcessingException { ItemStatus itemStatus = new ItemStatus(EVIDENCE_AUDIT_LIST_SECURED_FILES_TO_DOWNLOAD); List<URI> uriListObjectsWorkspace = handlerIO.getUriList(handlerIO.getContainerName(), DATA); Map<String, List<String>> securedFilenameList = new HashMap<>(); try { for (URI element : uriListObjectsWorkspace) { File file = handlerIO.getFileFromWorkspace(DATA + File.separator + element.getPath()); JsonNode jsonName = getFromFile(file); JsonNode fileNameNode = jsonName.get(FILE_NAME); if (fileNameNode == null) { continue; } String identifier = fileNameNode.textValue(); if (securedFilenameList.get(identifier) == null) { ArrayList<String> listIds = new ArrayList<>(); listIds.add(element.toString()); securedFilenameList.put(identifier, listIds); continue; } securedFilenameList.get(identifier).add(element.toString()); } Set<Entry<String, List<String>>> entrySet = securedFilenameList.entrySet(); for (Entry<String, List<String>> me : entrySet) { File file = handlerIO.getNewLocalFile(me.getKey()); JsonHandler.writeAsFile(me.getValue(), file); handlerIO.transferFileToWorkspace("fileNames" + "/" + me.getKey(), file, true, false); } } catch (ContentAddressableStorageNotFoundException | InvalidParseOperationException | ContentAddressableStorageServerException | IOException e) { LOGGER.error(e); return itemStatus.increment(StatusCode.FATAL); } itemStatus.increment(StatusCode.OK); return new ItemStatus(EVIDENCE_AUDIT_LIST_SECURED_FILES_TO_DOWNLOAD) .setItemsStatus(EVIDENCE_AUDIT_LIST_SECURED_FILES_TO_DOWNLOAD, itemStatus); }  }
EvidenceAuditListSecuredFiles extends ActionHandler { @Override public ItemStatus execute(WorkerParameters param, HandlerIO handlerIO) throws ProcessingException { ItemStatus itemStatus = new ItemStatus(EVIDENCE_AUDIT_LIST_SECURED_FILES_TO_DOWNLOAD); List<URI> uriListObjectsWorkspace = handlerIO.getUriList(handlerIO.getContainerName(), DATA); Map<String, List<String>> securedFilenameList = new HashMap<>(); try { for (URI element : uriListObjectsWorkspace) { File file = handlerIO.getFileFromWorkspace(DATA + File.separator + element.getPath()); JsonNode jsonName = getFromFile(file); JsonNode fileNameNode = jsonName.get(FILE_NAME); if (fileNameNode == null) { continue; } String identifier = fileNameNode.textValue(); if (securedFilenameList.get(identifier) == null) { ArrayList<String> listIds = new ArrayList<>(); listIds.add(element.toString()); securedFilenameList.put(identifier, listIds); continue; } securedFilenameList.get(identifier).add(element.toString()); } Set<Entry<String, List<String>>> entrySet = securedFilenameList.entrySet(); for (Entry<String, List<String>> me : entrySet) { File file = handlerIO.getNewLocalFile(me.getKey()); JsonHandler.writeAsFile(me.getValue(), file); handlerIO.transferFileToWorkspace("fileNames" + "/" + me.getKey(), file, true, false); } } catch (ContentAddressableStorageNotFoundException | InvalidParseOperationException | ContentAddressableStorageServerException | IOException e) { LOGGER.error(e); return itemStatus.increment(StatusCode.FATAL); } itemStatus.increment(StatusCode.OK); return new ItemStatus(EVIDENCE_AUDIT_LIST_SECURED_FILES_TO_DOWNLOAD) .setItemsStatus(EVIDENCE_AUDIT_LIST_SECURED_FILES_TO_DOWNLOAD, itemStatus); }  @Override ItemStatus execute(WorkerParameters param, HandlerIO handlerIO); }
EvidenceAuditListSecuredFiles extends ActionHandler { @Override public ItemStatus execute(WorkerParameters param, HandlerIO handlerIO) throws ProcessingException { ItemStatus itemStatus = new ItemStatus(EVIDENCE_AUDIT_LIST_SECURED_FILES_TO_DOWNLOAD); List<URI> uriListObjectsWorkspace = handlerIO.getUriList(handlerIO.getContainerName(), DATA); Map<String, List<String>> securedFilenameList = new HashMap<>(); try { for (URI element : uriListObjectsWorkspace) { File file = handlerIO.getFileFromWorkspace(DATA + File.separator + element.getPath()); JsonNode jsonName = getFromFile(file); JsonNode fileNameNode = jsonName.get(FILE_NAME); if (fileNameNode == null) { continue; } String identifier = fileNameNode.textValue(); if (securedFilenameList.get(identifier) == null) { ArrayList<String> listIds = new ArrayList<>(); listIds.add(element.toString()); securedFilenameList.put(identifier, listIds); continue; } securedFilenameList.get(identifier).add(element.toString()); } Set<Entry<String, List<String>>> entrySet = securedFilenameList.entrySet(); for (Entry<String, List<String>> me : entrySet) { File file = handlerIO.getNewLocalFile(me.getKey()); JsonHandler.writeAsFile(me.getValue(), file); handlerIO.transferFileToWorkspace("fileNames" + "/" + me.getKey(), file, true, false); } } catch (ContentAddressableStorageNotFoundException | InvalidParseOperationException | ContentAddressableStorageServerException | IOException e) { LOGGER.error(e); return itemStatus.increment(StatusCode.FATAL); } itemStatus.increment(StatusCode.OK); return new ItemStatus(EVIDENCE_AUDIT_LIST_SECURED_FILES_TO_DOWNLOAD) .setItemsStatus(EVIDENCE_AUDIT_LIST_SECURED_FILES_TO_DOWNLOAD, itemStatus); }  @Override ItemStatus execute(WorkerParameters param, HandlerIO handlerIO);  }