use of nl.nn.adapterframework.configuration.Configuration in project iaf by ibissource.
the class ShowConfiguration method reloadConfiguration.
@PUT
@RolesAllowed({ "IbisDataAdmin", "IbisAdmin", "IbisTester" })
@Path("/configurations/{configuration}")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response reloadConfiguration(@PathParam("configuration") String configurationName, LinkedHashMap<String, Object> json) throws ApiException {
initBase(servletConfig);
Configuration configuration = ibisManager.getConfiguration(configurationName);
if (configuration == null) {
throw new ApiException("Configuration not found!");
}
// PUT defaults to no content
Response.ResponseBuilder response = Response.status(Response.Status.NO_CONTENT);
for (Entry<String, Object> entry : json.entrySet()) {
String key = entry.getKey();
Object value = entry.getValue();
if (key.equalsIgnoreCase("action")) {
if (value.equals("reload")) {
ibisManager.handleAdapter("RELOAD", configurationName, "", "", null, false);
}
response.entity("{\"status\":\"ok\"}");
}
}
return response.build();
}
use of nl.nn.adapterframework.configuration.Configuration in project iaf by ibissource.
the class ConfigurationBase method toConfigurationsXml.
protected XmlBuilder toConfigurationsXml(List<Configuration> configurations) {
XmlBuilder configurationsXml = new XmlBuilder("configurations");
XmlBuilder configurationAllXml = new XmlBuilder("configuration");
configurationAllXml.setValue(CONFIG_ALL);
configurationAllXml.addAttribute("nameUC", "0" + Misc.toSortName(CONFIG_ALL));
configurationsXml.addSubElement(configurationAllXml);
for (Configuration configuration : configurations) {
XmlBuilder configurationXml = new XmlBuilder("configuration");
configurationXml.setValue(configuration.getConfigurationName());
configurationXml.addAttribute("nameUC", "1" + Misc.toSortName(configuration.getConfigurationName()));
configurationsXml.addSubElement(configurationXml);
}
return configurationsXml;
}
use of nl.nn.adapterframework.configuration.Configuration in project iaf by ibissource.
the class ShowConfiguration method doGet.
@Override
protected String doGet(IPipeLineSession session) throws PipeRunException {
IbisManager ibisManager = retrieveIbisManager();
String configurationName = retrieveConfigurationName(session);
Configuration configuration = null;
boolean configAll;
if (configurationName == null || configurationName.equalsIgnoreCase(CONFIG_ALL)) {
configAll = true;
} else {
configuration = ibisManager.getConfiguration(configurationName);
if (configuration == null) {
configAll = true;
} else {
configAll = false;
}
}
List<Configuration> allConfigurations = ibisManager.getConfigurations();
XmlBuilder configurationsXml = toConfigurationsXml(allConfigurations);
StringBuilder sb = new StringBuilder();
boolean showConfigurationOriginal = AppConstants.getInstance().getBoolean("showConfiguration.original", false);
if (configAll) {
sb.append("<configurations>");
for (Configuration configuration_iter : allConfigurations) {
if (showConfigurationOriginal) {
sb.append(XmlUtils.skipXmlDeclaration(configuration_iter.getOriginalConfiguration()));
} else {
sb.append(XmlUtils.skipXmlDeclaration(configuration_iter.getLoadedConfiguration()));
}
}
sb.append("</configurations>");
} else {
if (showConfigurationOriginal) {
sb.append(configuration.getOriginalConfiguration());
} else {
sb.append(configuration.getLoadedConfiguration());
}
}
XmlBuilder configSource = new XmlBuilder("configSource");
configSource.setCdataValue(sb.toString());
configSource.addAttribute("original", showConfigurationOriginal);
storeConfiguration(session, configAll, configuration);
XmlBuilder root = new XmlBuilder("root");
root.addSubElement(configurationsXml);
root.addSubElement(configSource);
return root.toXML();
}
use of nl.nn.adapterframework.configuration.Configuration in project iaf by ibissource.
the class ShowSecurityItems method retrieveUsedJmsDestinations.
private List<JmsDestination> retrieveUsedJmsDestinations() throws DomBuilderException {
List<JmsDestination> usedJmsDestinations = new ArrayList<JmsDestination>();
StringBuilder config = new StringBuilder("<config>");
for (Configuration configuration : ibisManager.getConfigurations()) {
config.append(configuration.getLoadedConfiguration());
}
config.append("</config>");
Document document = XmlUtils.buildDomDocument(config.toString());
NodeList nodeList = document.getElementsByTagName("*");
for (int i = 0; i < nodeList.getLength(); i++) {
Node node = nodeList.item(i);
if (node.getNodeType() == Node.ELEMENT_NODE) {
Element element = (Element) node;
if (element.hasAttribute("destinationName") && !"false".equalsIgnoreCase(element.getAttribute("lookupDestination"))) {
JmsRealm jmsRealm = JmsRealmFactory.getInstance().getJmsRealm(element.getAttribute("jmsRealm"));
if (jmsRealm != null) {
String connectionFactory = jmsRealm.retrieveConnectionFactoryName();
usedJmsDestinations.add(new JmsDestination(connectionFactory, element.getAttribute("destinationName")));
}
}
}
}
return usedJmsDestinations;
}
use of nl.nn.adapterframework.configuration.Configuration in project iaf by ibissource.
the class ShowSecurityItems method addAuthEntries.
private void addAuthEntries(XmlBuilder securityItems) {
XmlBuilder aes = new XmlBuilder("authEntries");
securityItems.addSubElement(aes);
List entries = new ArrayList();
try {
URL url = ClassUtils.getResourceURL(this, AUTHALIAS_XSLT);
if (url != null) {
for (Configuration configuration : ibisManager.getConfigurations()) {
Transformer t = XmlUtils.createTransformer(url, true);
String configString = configuration.getLoadedConfiguration();
String authEntries = XmlUtils.transformXml(t, configString);
log.debug("authentication aliases for configuration [" + configuration.getName() + "] found [" + authEntries.trim() + "]");
Collection<String> c = XmlUtils.evaluateXPathNodeSet(authEntries, "authEntries/entry/@alias");
if (c != null && c.size() > 0) {
for (Iterator<String> cit = c.iterator(); cit.hasNext(); ) {
String entry = cit.next();
if (!entries.contains(entry)) {
entries.add(entry);
}
}
}
}
}
} catch (Exception e) {
XmlBuilder ae = new XmlBuilder("entry");
aes.addSubElement(ae);
ae.addAttribute("alias", "*** ERROR ***");
}
if (entries != null) {
Collections.sort(entries);
Iterator iter = entries.iterator();
while (iter.hasNext()) {
String alias = (String) iter.next();
CredentialFactory cf = new CredentialFactory(alias, null, null);
XmlBuilder ae = new XmlBuilder("entry");
aes.addSubElement(ae);
ae.addAttribute("alias", alias);
String userName;
String passWord;
try {
userName = cf.getUsername();
passWord = StringUtils.repeat("*", cf.getPassword().length());
} catch (Exception e) {
userName = "*** ERROR ***";
passWord = "*** ERROR ***";
}
ae.addAttribute("userName", userName);
ae.addAttribute("passWord", passWord);
}
}
}
Aggregations