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 b388cf495593f3bbaa50bfa166f1529a7320072b..2fa82b65aa5832033ba12853ef571d5a640606c5 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 =