use of com.helger.as2lib.partner.PartnershipMap in project as2-lib by phax.
the class XMLPartnershipFactory method load.
protected void load(@Nullable @WillClose final InputStream aIS) throws AS2Exception {
final PartnerMap aNewPartners = new PartnerMap();
final PartnershipMap aNewPartnerships = new PartnershipMap();
if (aIS != null) {
final IMicroDocument aDocument = MicroReader.readMicroXML(aIS);
if (aDocument == null)
throw new AS2Exception("Failed to read the XML partnership information");
final IMicroElement aRoot = aDocument.getDocumentElement();
for (final IMicroElement eRootNode : aRoot.getAllChildElements()) {
final String sNodeName = eRootNode.getTagName();
if (sNodeName.equals("partner")) {
final Partner aNewPartner = loadPartner(eRootNode);
aNewPartners.addPartner(aNewPartner);
} else if (sNodeName.equals("partnership")) {
final Partnership aNewPartnership = loadPartnership(eRootNode, aNewPartners);
if (aNewPartnerships.getPartnershipByName(aNewPartnership.getName()) != null)
throw new AS2Exception("Partnership with name '" + aNewPartnership.getName() + "' is defined more than once");
aNewPartnerships.addPartnership(aNewPartnership);
} else {
if (LOGGER.isWarnEnabled())
LOGGER.warn("Invalid element '" + sNodeName + "' in XML partnership file");
}
}
}
setPartners(aNewPartners);
setPartnerships(aNewPartnerships);
}
Aggregations