From c1cd4109e9b0fb4715ce2a073a1da19b71c89e51 Mon Sep 17 00:00:00 2001
From: Jan David Mol <mol@astron.nl>
Date: Wed, 29 Feb 2012 16:23:44 +0000
Subject: [PATCH] Task #1418: Added assertions to check parset validity
 (storage location keys)

---
 LCS/ApplCommon/src/Observation.cc | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/LCS/ApplCommon/src/Observation.cc b/LCS/ApplCommon/src/Observation.cc
index d2635ca6e95..1b33e4b93e3 100644
--- a/LCS/ApplCommon/src/Observation.cc
+++ b/LCS/ApplCommon/src/Observation.cc
@@ -358,6 +358,8 @@ Observation::Observation(const ParameterSet*		aParSet,
 			vector<string> locations = aParSet->getStringVector(prefix+str(format("DataProducts.Output_%s.locations") % dataProductNames[d]), true);
 			vector<unsigned> &psets = dataProductPhases[d] == 2 ? phaseTwoPsets : phaseThreePsets;
 
+			ASSERTSTR(filenames.size() == locations.size(), "Parset provides " << filenames.size() << " filenames but only " << locations.size() << " locations.");
+
 			unsigned numFiles = filenames.size();
 			unsigned filesPerPset = (numFiles + psets.size() - 1) / psets.size();
 
@@ -371,6 +373,8 @@ Observation::Observation(const ParameterSet*		aParSet,
 				a.sourcePset = psets[i / filesPerPset];
 
 				vector<string> locparts = StringUtil::split(locations[i],':');
+			    ASSERTSTR(locparts.size() == 2, "A DataProduct location must be of the format host:directory (but I found " << locations[i] << ")");
+
 				a.destStorageNode = locparts[0];
 				a.destDirectory = locparts[1];
 
-- 
GitLab