Skip to content
Snippets Groups Projects
Commit 417753f9 authored by pkupczyk's avatar pkupczyk
Browse files

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
parent be177308
No related branches found
No related tags found
No related merge requests found
...@@ -96,21 +96,15 @@ public class DataSetAndPathInfoDBConsistencyCheckProcessingPlugin implements IPr ...@@ -96,21 +96,15 @@ public class DataSetAndPathInfoDBConsistencyCheckProcessingPlugin implements IPr
{ {
IHierarchicalContent fileContent = null; IHierarchicalContent fileContent = null;
IHierarchicalContent pathInfoContent = null; IHierarchicalContent pathInfoContent = null;
try try
{ {
fileContent = getFileProvider().asContent(dataset.getDataSetCode()); fileContent = tryGetContent(getFileProvider(), dataset.getDataSetCode());
pathInfoContent = getPathInfoProvider().asContent(dataset.getDataSetCode()); pathInfoContent = tryGetContent(getPathInfoProvider(), dataset.getDataSetCode());
List<Difference> datasetDifferences = new ArrayList<Difference>(); List<Difference> datasetDifferences = new ArrayList<Difference>();
if (fileContent != null && pathInfoContent != null) compare(fileContent, pathInfoContent, datasetDifferences);
{
compare(fileContent.getRootNode(), pathInfoContent.getRootNode(),
datasetDifferences);
} else if (fileContent == null ^ pathInfoContent == null)
{
datasetDifferences.add(new RootExistenceDifference(fileContent != null));
}
if (datasetDifferences.isEmpty() == false) if (datasetDifferences.isEmpty() == false)
{ {
...@@ -152,6 +146,25 @@ public class DataSetAndPathInfoDBConsistencyCheckProcessingPlugin implements IPr ...@@ -152,6 +146,25 @@ public class DataSetAndPathInfoDBConsistencyCheckProcessingPlugin implements IPr
return status; 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") @SuppressWarnings("null")
private void compare(IHierarchicalContentNode fileNode, IHierarchicalContentNode pathInfoNode, private void compare(IHierarchicalContentNode fileNode, IHierarchicalContentNode pathInfoNode,
List<Difference> differences) List<Difference> differences)
...@@ -554,6 +567,35 @@ public class DataSetAndPathInfoDBConsistencyCheckProcessingPlugin implements IPr ...@@ -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() private IHierarchicalContentProvider getFileProvider()
{ {
if (fileProvider == null) if (fileProvider == null)
...@@ -576,8 +618,7 @@ public class DataSetAndPathInfoDBConsistencyCheckProcessingPlugin implements IPr ...@@ -576,8 +618,7 @@ public class DataSetAndPathInfoDBConsistencyCheckProcessingPlugin implements IPr
if (pathInfoDBFactory == null) if (pathInfoDBFactory == null)
{ {
throw new IllegalArgumentException( throw new IllegalArgumentException("Path info database is not configured.");
"Cannot check consistency of the file system and the path info database because the database is not configured.");
} else } else
{ {
pathInfoProvider = pathInfoProvider =
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment