Commit d5e87016 authored by Matija Obreza's avatar Matija Obreza

Fix: NPE in AdminController#updateAccessionFolders

parent b5c514e0
......@@ -607,22 +607,26 @@ public class AdminController {
repositoryService.getFolder(Paths.get("/wiews")).getChildren().forEach(wiewsFolder -> {
try {
String instCode = wiewsFolder.getName();
LOG.warn("Processing acn folders for {}", instCode);
RepositoryFolder instAccnFolders = repositoryService.getFolder(wiewsFolder.getFolderPath().resolve("acn"));
instAccnFolders.getChildren().forEach(acceFolder -> {
try {
Accession accession = genesysService.getAccession(instCode, acceFolder.getName());
if (accession != null) {
LOG.warn("Folder for accession {}:{} is {}", instCode, accession.getAccessionNumber(), acceFolder.getPath());
accession.getAccessionId().setRepositoryFolder(acceFolder);
accessionIdRepository.save(accession.getAccessionId());
} else {
LOG.warn("No accession {}:{} for folder {}", instCode, acceFolder.getName(), acceFolder.getPath());
if (instAccnFolders != null) {
LOG.warn("Processing acn folders for {}", instCode);
instAccnFolders.getChildren().forEach(acceFolder -> {
try {
Accession accession = genesysService.getAccession(instCode, acceFolder.getName());
if (accession != null) {
LOG.warn("Folder for accession {}:{} is {}", instCode, accession.getAccessionNumber(), acceFolder.getPath());
accession.getAccessionId().setRepositoryFolder(acceFolder);
accessionIdRepository.save(accession.getAccessionId());
} else {
LOG.warn("No accession {}:{} for folder {}", instCode, acceFolder.getName(), acceFolder.getPath());
}
} catch (NonUniqueAccessionException e) {
LOG.warn("Accession not unique {}:{}", instCode, acceFolder.getName());
}
} catch (NonUniqueAccessionException e) {
LOG.warn("Accession not unique {}:{}", instCode, acceFolder.getName());
}
});
});
} else {
LOG.warn("No /wiews/{}/acn folder", instCode);
}
} catch (InvalidRepositoryPathException e) {
LOG.warn("Invalid path {}", e.getMessage());
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment