use of com.tremolosecurity.config.xml.ProvisioningType in project OpenUnison by TremoloSecurity.
the class ForRemoval method loadUnisonConfiguration.
@Override
public JAXBElement<TremoloType> loadUnisonConfiguration(Unmarshaller unmarshaller) throws Exception {
InputStream in;
if (configXML.startsWith("WEB-INF")) {
in = new ByteArrayInputStream(OpenUnisonConfigLoader.generateOpenUnisonConfig(ctx.getRealPath("/" + configXML)).getBytes("UTF-8"));
} else {
in = new ByteArrayInputStream(OpenUnisonConfigLoader.generateOpenUnisonConfig(configXML).getBytes("UTF-8"));
}
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder loader = factory.newDocumentBuilder();
Document document = loader.parse(in);
DocumentTraversal traversal = (DocumentTraversal) document;
TreeWalker walker = traversal.createTreeWalker(document.getDocumentElement(), NodeFilter.SHOW_ELEMENT, null, true);
traverseLevel(walker, "");
StringWriter writer = new StringWriter();
TransformerFactory tf = TransformerFactory.newInstance();
Transformer transformer;
transformer = tf.newTransformer();
transformer.transform(new DOMSource(document), new StreamResult(writer));
String xmlString = writer.getBuffer().toString();
ByteArrayInputStream bais = new ByteArrayInputStream(xmlString.getBytes("UTF-8"));
Object obj = unmarshaller.unmarshal(bais);
JAXBElement<TremoloType> cfg = (JAXBElement<TremoloType>) obj;
this.unisonConfig = cfg.getValue();
QueueConfigType qct = (QueueConfigType) GlobalEntries.getGlobalEntries().get("openunison.queueconfig");
if (qct != null) {
logger.info("Overriding Queue Configuration");
if (cfg.getValue().getProvisioning() == null) {
cfg.getValue().setProvisioning(new ProvisioningType());
}
cfg.getValue().getProvisioning().setQueueConfig(qct);
}
return cfg;
}
Aggregations