Skip to content

Commit

Permalink
Support the use of properties in the basePollerConfig element attribute
Browse files Browse the repository at this point in the history
values.
  • Loading branch information
uhurusurfa committed Aug 1, 2023
1 parent 9cd3540 commit fed15e8
Showing 1 changed file with 19 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,13 @@ public void loadPartnership(Map<String, Object> partners, List<Partnership> part
// Now check if we need to add a directory polling module
Node pollerCfgNode = XMLUtil.findChildNode(node, Partnership.PCFG_POLLER);
if (pollerCfgNode != null) {
// Load a poller configuration
/* Load a poller configuration.
* This will require fetching the base configuration for the pollers loaded from
* the config.xml and merging with the configured setup in the partnership
* overriding the base attribute values with any found in the partnership
* pollerConfig element then enhancing the attribute values to cater for embedded
* dynamic variables before activating the poller.
*/
String[] requiredPollerAttributes = {"enabled"};
Map<String, String> partnershipPollerCfgAttributes = XMLUtil.mapAttributes(pollerCfgNode, requiredPollerAttributes);
if ("true".equalsIgnoreCase(partnershipPollerCfgAttributes.get("enabled"))) {
Expand All @@ -236,10 +242,15 @@ public void loadPartnership(Map<String, Object> partners, List<Partnership> part
}
Element pollerConfigElem = pollerDoc.getDocumentElement();
// Merge the attributes from the base config with the partnership specific ones
partnershipPollerCfgAttributes.forEach((key, value) -> {
Map<String, String> attributes = XMLUtil.mapAttributes(pollerConfigElem);
attributes.putAll(partnershipPollerCfgAttributes);
// Enhance the attribute values in case they are using dynamic variables
AS2Util.attributeEnhancer(attributes);
// Now update the XML with the attribute values
attributes.forEach((key, value) -> {
pollerConfigElem.setAttribute(key, value);
});
// replace the $parnertship.* placeholders
});
// replace the $partnertship.* placeholders
replacePartnershipPlaceHolders(pollerDoc, partnership);
// Now launch a directory poller module for this config
getSession().loadPartnershipPoller(pollerConfigElem, name, Session.PARTNERSHIP_POLLER);
Expand Down Expand Up @@ -354,6 +365,7 @@ public void replacePartnershipPlaceHolders(Document doc, Partnership partnership
for (int i = 0; i < nodes.getLength(); i++) {
Node node = nodes.item(i);
String val = node.getNodeValue();
//logger.debug("Partnership place holder NODE processing: " + val);
StringBuffer strBuf = new StringBuffer();
Matcher matcher = PATTERN.matcher(val);
boolean hasChanged = false;
Expand Down Expand Up @@ -392,6 +404,9 @@ public void replacePartnershipPlaceHolders(Document doc, Partnership partnership
} else {
hasChanged = true;
matcher.appendReplacement(strBuf, Matcher.quoteReplacement(value));
if (logger.isTraceEnabled()) {
logger.trace("Partnership place holder replaced: " + keys + " :: Replaced with: " + value);
}
}
}
if (hasChanged) {
Expand Down

0 comments on commit fed15e8

Please sign in to comment.