Improving lib

This commit is contained in:
luca.frosini 2023-07-20 15:18:03 +02:00
parent 525dfddd52
commit 3b832173e9
1 changed files with 10 additions and 10 deletions

View File

@ -142,9 +142,8 @@ public class StorageHubManagement {
return destinationFolder; return destinationFolder;
} }
protected boolean isPersistedFile(FileContainer fileContainer, String filename) { protected boolean checkMetadata(FileContainer fileContainer) {
// Checking if the file is already a persisted file of the workspace // Checking if the file is already a persisted file of the workspace
if(fileContainer.get().getName().startsWith(filename)) {
if(metadataMatcher != null) { if(metadataMatcher != null) {
Metadata metadata = fileContainer.get().getMetadata(); Metadata metadata = fileContainer.get().getMetadata();
return metadataMatcher.check(metadata); return metadataMatcher.check(metadata);
@ -152,8 +151,6 @@ public class StorageHubManagement {
return true; return true;
} }
} }
return false;
}
protected void logItem(ItemContainer<? extends Item> itemContainer) { protected void logItem(ItemContainer<? extends Item> itemContainer) {
logItem(itemContainer, 0); logItem(itemContainer, 0);
@ -196,9 +193,12 @@ public class StorageHubManagement {
List<ItemContainer<? extends Item>> itemContainers = listResolver.withMetadata().getContainers(); List<ItemContainer<? extends Item>> itemContainers = listResolver.withMetadata().getContainers();
for(ItemContainer<? extends Item> itemContainer : itemContainers) { for(ItemContainer<? extends Item> itemContainer : itemContainers) {
if(itemContainer.getType()==ContainerType.FILE) { if(itemContainer.getType()==ContainerType.FILE) {
if(isPersistedFile((FileContainer) itemContainer, filename)) { if(checkMetadata((FileContainer) itemContainer)) {
this.persitedFile = (FileContainer) itemContainer; this.persitedFile = (FileContainer) itemContainer;
return this.persitedFile; return this.persitedFile;
}else {
logger.warn("The file with mimetype {} and name {} was found in the expected folder (i.e. id:{}, path:{}) but the check on metadata failed. The file is not the one expected.",
mimeType, filename, destinationFolder.getId(), destinationFolder.get().getPath());
} }
} }
} }