Improved logging
This commit is contained in:
parent
3b832173e9
commit
9f366ad4ad
|
@ -142,14 +142,17 @@ public class StorageHubManagement {
|
||||||
return destinationFolder;
|
return destinationFolder;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean checkMetadata(FileContainer fileContainer) {
|
protected boolean isPersistedFile(FileContainer fileContainer, String filename) {
|
||||||
// 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(metadataMatcher != null) {
|
if(fileContainer.get().getName().startsWith(filename)) {
|
||||||
Metadata metadata = fileContainer.get().getMetadata();
|
if(metadataMatcher != null) {
|
||||||
return metadataMatcher.check(metadata);
|
Metadata metadata = fileContainer.get().getMetadata();
|
||||||
} else {
|
return metadataMatcher.check(metadata);
|
||||||
return true;
|
} else {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void logItem(ItemContainer<? extends Item> itemContainer) {
|
protected void logItem(ItemContainer<? extends Item> itemContainer) {
|
||||||
|
@ -193,7 +196,9 @@ 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(checkMetadata((FileContainer) itemContainer)) {
|
if(isPersistedFile((FileContainer) itemContainer, filename)) {
|
||||||
|
logger.debug("The file with mimetype {} and name {} was found in the expected folder (i.e. id:{}, path:{}) and the check on metadata succeded. The file is the one expected.",
|
||||||
|
mimeType, filename, destinationFolder.getId(), destinationFolder.get().getPath());
|
||||||
this.persitedFile = (FileContainer) itemContainer;
|
this.persitedFile = (FileContainer) itemContainer;
|
||||||
return this.persitedFile;
|
return this.persitedFile;
|
||||||
}else {
|
}else {
|
||||||
|
@ -210,6 +215,7 @@ public class StorageHubManagement {
|
||||||
public void removePersistedFile(String filename, String mimeType) throws Exception {
|
public void removePersistedFile(String filename, String mimeType) throws Exception {
|
||||||
persitedFile = getPersistedFile(filename, mimeType);
|
persitedFile = getPersistedFile(filename, mimeType);
|
||||||
if(persitedFile !=null) {
|
if(persitedFile !=null) {
|
||||||
|
logger.info("Persited file with mimetype {} and name {} was found. Goign to remove it.", mimeType, filename);
|
||||||
persitedFile.delete();
|
persitedFile.delete();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue