if (srcPathPrefix == null || srcPathPrefix.length() == 0) {
throw new HighTideConfigurationException("Bad configuration file: " +
"srcPath node does not have a path.");
}
PolicyInfo policyInfo = new PolicyInfo(srcPathPrefix, conf);
policyName = srcPathPrefix;
Properties policyProperties;
// loop through all elements of this policy
NodeList policies = element.getChildNodes();
for (int j = 0; j < policies.getLength(); j++) {
Node node1 = policies.item(j);
if (!(node1 instanceof Element)) {
continue;
}
Element policy = (Element)node1;
if ((!"property".equalsIgnoreCase(policy.getTagName())) &&
(!"destPath".equalsIgnoreCase(policy.getTagName()))) {
throw new HighTideConfigurationException("Bad configuration file: " +
"Expecting <property> or <destPath> for srcPath " + srcPathPrefix +
" but found " + policy.getTagName());
}
// parse the <destPath> items
if ("destPath".equalsIgnoreCase(policy.getTagName())) {
String destPath = policy.getAttribute("name");
if (destPath == null) {
throw new HighTideConfigurationException("Bad configuration file: " +
"<destPath> tag should have an attribute named 'name'.");
}
NodeList properties = policy.getChildNodes();
Properties destProperties = new Properties();
for (int k = 0; k < properties.getLength(); k++) {
Node node2 = properties.item(k);
if (!(node2 instanceof Element)) {
continue;
}
Element property = (Element)node2;
String propertyName = property.getTagName();
if (!("property".equalsIgnoreCase(propertyName))) {
throw new HighTideConfigurationException("Bad configuration file: " +
"<destPath> can have only <property> children." +
" but found " + propertyName);
}
NodeList nl = property.getChildNodes();
String pname=null,pvalue=null;
for (int l = 0; l < nl.getLength(); l++){
Node node3 = nl.item(l);
if (!(node3 instanceof Element)) {
continue;
}
Element item = (Element) node3;
String itemName = item.getTagName();
if ("name".equalsIgnoreCase(itemName)){
pname = ((Text)item.getFirstChild()).getData().trim();
} else if ("value".equalsIgnoreCase(itemName)){
pvalue = ((Text)item.getFirstChild()).getData().trim();
}
}
if (pname == null || pvalue == null) {
throw new HighTideConfigurationException("Bad configuration file: " +
"All property for destPath " + destPath +
" must have name and value ");
}
LOG.info(policyName + "." + pname + " = " + pvalue);
destProperties.setProperty(pname, pvalue);
}
policyInfo.addDestPath(destPath, destProperties);
} else if ("property".equalsIgnoreCase(policy.getTagName())) {
Element property = (Element)node1;
NodeList nl = property.getChildNodes();
String pname=null,pvalue=null;
for (int l = 0; l < nl.getLength(); l++){
Node node3 = nl.item(l);
if (!(node3 instanceof Element)) {
continue;
}
Element item = (Element) node3;
String itemName = item.getTagName();
if ("name".equalsIgnoreCase(itemName)){
pname = ((Text)item.getFirstChild()).getData().trim();
} else if ("value".equalsIgnoreCase(itemName)){
pvalue = ((Text)item.getFirstChild()).getData().trim();
}
}
if (pname == null || pvalue == null) {
throw new HighTideConfigurationException("Bad configuration file: " +
"All property for srcPath " + srcPathPrefix +
" must have name and value ");
}
LOG.info(policyName + "." + pname + " = " + pvalue);
policyInfo.setProperty(pname,pvalue);
}
}
existingPolicies.add(policyInfo);
} else {
throw new HighTideConfigurationException("Bad configuration file: " +