From 417753f9352d94c71d9606cd026768811b34d824 Mon Sep 17 00:00:00 2001 From: pkupczyk <pkupczyk> Date: Tue, 31 Jul 2012 08:51:34 +0000 Subject: [PATCH] SP-204 / BIS-38: Processing task to verify data set versus checksums in PathInfoDB - finish up: - make it send an email with differences even if a data set doesn't exist on the file system or it doesn't exist in the path info database - treat a case when a data set doesn't exist on the files system nor in the path info database as an error (send an error email then) SVN: 26289 --- ...nfoDBConsistencyCheckProcessingPlugin.java | 67 +++++++++++++++---- 1 file changed, 54 insertions(+), 13 deletions(-) diff --git a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/plugins/standard/DataSetAndPathInfoDBConsistencyCheckProcessingPlugin.java b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/plugins/standard/DataSetAndPathInfoDBConsistencyCheckProcessingPlugin.java index b388cf49559..2fa82b65aa5 100644 --- a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/plugins/standard/DataSetAndPathInfoDBConsistencyCheckProcessingPlugin.java +++ b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/plugins/standard/DataSetAndPathInfoDBConsistencyCheckProcessingPlugin.java @@ -96,21 +96,15 @@ public class DataSetAndPathInfoDBConsistencyCheckProcessingPlugin implements IPr { IHierarchicalContent fileContent = null; IHierarchicalContent pathInfoContent = null; + try { - fileContent = getFileProvider().asContent(dataset.getDataSetCode()); - pathInfoContent = getPathInfoProvider().asContent(dataset.getDataSetCode()); + fileContent = tryGetContent(getFileProvider(), dataset.getDataSetCode()); + pathInfoContent = tryGetContent(getPathInfoProvider(), dataset.getDataSetCode()); List<Difference> datasetDifferences = new ArrayList<Difference>(); - - if (fileContent != null && pathInfoContent != null) - { - compare(fileContent.getRootNode(), pathInfoContent.getRootNode(), - datasetDifferences); - } else if (fileContent == null ^ pathInfoContent == null) - { - datasetDifferences.add(new RootExistenceDifference(fileContent != null)); - } + + compare(fileContent, pathInfoContent, datasetDifferences); if (datasetDifferences.isEmpty() == false) { @@ -152,6 +146,25 @@ public class DataSetAndPathInfoDBConsistencyCheckProcessingPlugin implements IPr return status; } + private void compare(IHierarchicalContent fileContent, IHierarchicalContent pathInfoContent, + List<Difference> differences) + { + IHierarchicalContentNode fileRoot = tryGetRoot(fileContent); + IHierarchicalContentNode pathInfoRoot = tryGetRoot(pathInfoContent); + + if (fileRoot != null && pathInfoRoot != null) + { + compare(fileRoot, pathInfoRoot, differences); + } else if (fileRoot == null ^ pathInfoRoot == null) + { + differences.add(new RootExistenceDifference(fileRoot != null)); + } else + { + throw new IllegalArgumentException( + "Data set does not exist on the file system nor in the path info database"); + } + } + @SuppressWarnings("null") private void compare(IHierarchicalContentNode fileNode, IHierarchicalContentNode pathInfoNode, List<Difference> differences) @@ -554,6 +567,35 @@ public class DataSetAndPathInfoDBConsistencyCheckProcessingPlugin implements IPr } + private IHierarchicalContent tryGetContent(IHierarchicalContentProvider contentProvider, + String datasetCode) + { + try + { + return contentProvider.asContent(datasetCode); + } catch (IllegalArgumentException e) + { + return null; + } + } + + private IHierarchicalContentNode tryGetRoot(IHierarchicalContent content) + { + try + { + if (content == null) + { + return null; + } else + { + return content.getRootNode(); + } + } catch (IllegalArgumentException e) + { + return null; + } + } + private IHierarchicalContentProvider getFileProvider() { if (fileProvider == null) @@ -576,8 +618,7 @@ public class DataSetAndPathInfoDBConsistencyCheckProcessingPlugin implements IPr if (pathInfoDBFactory == null) { - throw new IllegalArgumentException( - "Cannot check consistency of the file system and the path info database because the database is not configured."); + throw new IllegalArgumentException("Path info database is not configured."); } else { pathInfoProvider = -- GitLab