use of nl.nn.adapterframework.util.XmlBuilder in project iaf by ibissource.
the class LdapSender method subContextsToXml.
private XmlBuilder subContextsToXml(String entryName, String[] subs, DirContext dirContext) throws NamingException {
XmlBuilder contextElem = new XmlBuilder("Context");
XmlBuilder currentContextElem = new XmlBuilder("CurrentContext");
currentContextElem.setValue(entryName + "," + dirContext.getNameInNamespace());
contextElem.addSubElement(currentContextElem);
if (subs != null) {
log.error("Subs.length = " + subs.length);
for (int i = 0; i < subs.length; i++) {
XmlBuilder subContextElem = new XmlBuilder("SubContext");
subContextElem.setValue(subs[i]);
contextElem.addSubElement(subContextElem);
}
}
return contextElem;
}
use of nl.nn.adapterframework.util.XmlBuilder in project iaf by ibissource.
the class LdapSender method storeLdapException.
public void storeLdapException(Throwable t, ParameterResolutionContext prc) {
IPipeLineSession pls = null;
if (prc != null) {
pls = prc.getSession();
}
if (StringUtils.isNotEmpty(getErrorSessionKey()) && pls != null && t != null) {
XmlBuilder ldapError = new XmlBuilder("ldapError");
ldapError.addAttribute("class", ClassUtils.nameOf(t));
String message = t.getMessage();
int magicPos = message.indexOf(LDAP_ERROR_MAGIC_STRING);
if (magicPos >= 0) {
int dashPos = message.indexOf('-', magicPos);
if (dashPos > magicPos) {
String codeString = message.substring(magicPos + LDAP_ERROR_MAGIC_STRING.length(), dashPos).trim();
ldapError.addAttribute("code", codeString);
int bracketPos = message.indexOf(']', dashPos);
if (bracketPos > dashPos) {
String description = message.substring(dashPos + 1, bracketPos).trim();
ldapError.addAttribute("description", description);
String msgPart1 = message.substring(0, magicPos).trim();
String msgPart2 = message.substring(bracketPos + 1).trim();
if (msgPart1.endsWith(":")) {
msgPart1 = msgPart1.substring(0, msgPart1.length() - 1).trim();
}
if (msgPart2.startsWith(";")) {
msgPart2 = msgPart2.substring(1).trim();
}
message = (msgPart1 + " " + msgPart2).trim();
}
}
}
ldapError.setValue(message);
String reasonXml = ldapError.toXML();
if (log.isDebugEnabled()) {
log.debug("sessionKey [" + getErrorSessionKey() + "] loaded with error message [" + reasonXml + "]");
}
pls.put(getErrorSessionKey(), reasonXml);
}
log.debug("exit storeLdapException");
}
use of nl.nn.adapterframework.util.XmlBuilder in project iaf by ibissource.
the class SlotIdRecord method getResult.
@Override
protected String getResult(ResultSet resultset, Object blobSessionVar, Object clobSessionVar, HttpServletResponse response, String contentType, String contentDisposition) throws JdbcException, SQLException, IOException {
XmlBuilder result = new XmlBuilder("result");
String previousType = null;
XmlBuilder typeXml = null;
String previousSlot = null;
XmlBuilder slotXml = null;
int typeslotcount = 0;
int typedatecount = 0;
int typemsgcount = 0;
int slotdatecount = 0;
int slotmsgcount = 0;
while (resultset.next()) {
String type = resultset.getString("type");
String slotid = resultset.getString("slotid");
String date = resultset.getString("msgdate");
int count = resultset.getInt("msgcount");
if (type == null) {
type = "";
}
if (slotid == null) {
slotid = "";
}
if (!type.equals(previousType)) {
if (typeXml != null) {
typeXml.addAttribute("slotcount", typeslotcount);
typeXml.addAttribute("datecount", typedatecount);
typeXml.addAttribute("msgcount", typemsgcount);
typeslotcount = 0;
typedatecount = 0;
typemsgcount = 0;
previousSlot = null;
}
typeXml = new XmlBuilder("type");
typeXml.addAttribute("id", type);
if (type.equalsIgnoreCase("E")) {
typeXml.addAttribute("name", "errorlog");
} else {
typeXml.addAttribute("name", "messagelog");
}
result.addSubElement(typeXml);
previousType = type;
}
if (!slotid.equals(previousSlot)) {
if (slotXml != null) {
slotXml.addAttribute("datecount", slotdatecount);
slotXml.addAttribute("msgcount", slotmsgcount);
slotdatecount = 0;
slotmsgcount = 0;
}
slotXml = new XmlBuilder("slot");
slotXml.addAttribute("id", slotid);
if (StringUtils.isNotEmpty(slotid)) {
SlotIdRecord sir = (SlotIdRecord) slotmap.get(type + "/" + slotid);
if (sir != null) {
slotXml.addAttribute("adapter", sir.adapterName);
if (StringUtils.isNotEmpty(sir.receiverName)) {
slotXml.addAttribute("receiver", sir.receiverName);
}
if (StringUtils.isNotEmpty(sir.pipeName)) {
slotXml.addAttribute("pipe", sir.pipeName);
}
}
}
typeXml.addSubElement(slotXml);
previousSlot = slotid;
typeslotcount++;
}
typemsgcount += count;
typedatecount++;
slotmsgcount += count;
slotdatecount++;
XmlBuilder dateXml = new XmlBuilder("date");
dateXml.addAttribute("id", date);
dateXml.addAttribute("count", count);
slotXml.addSubElement(dateXml);
}
if (typeXml != null) {
typeXml.addAttribute("slotcount", typeslotcount);
typeXml.addAttribute("datecount", typedatecount);
typeXml.addAttribute("msgcount", typemsgcount);
}
if (slotXml != null) {
slotXml.addAttribute("datecount", slotdatecount);
slotXml.addAttribute("msgcount", slotmsgcount);
slotdatecount = 0;
slotmsgcount = 0;
}
return result.toXML();
}
use of nl.nn.adapterframework.util.XmlBuilder in project iaf by ibissource.
the class ConfigurationBase method doGet.
/**
* When extending this class, copy and extend the doGet method in the new
* child class.
*/
protected String doGet(IPipeLineSession session) throws PipeRunException {
IbisManager ibisManager = RestListenerUtils.retrieveIbisManager(session);
String configurationName = null;
if (configurationName == null) {
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);
storeConfiguration(session, configAll, configuration);
XmlBuilder root = new XmlBuilder("root");
root.addSubElement(configurationsXml);
return root.toXML();
}
use of nl.nn.adapterframework.util.XmlBuilder in project iaf by ibissource.
the class ShowConfigurationStatus method toConfigurationExceptionsXml.
private XmlBuilder toConfigurationExceptionsXml(List<Configuration> configurations, Configuration configurationSelected) {
List<String[]> configurationExceptions = new ArrayList<String[]>();
if (configurationSelected != null) {
if (configurationSelected.getConfigurationException() != null) {
String[] item = new String[2];
item[0] = configurationSelected.getName();
item[1] = configurationSelected.getConfigurationException().getMessage();
configurationExceptions.add(item);
}
} else {
for (Configuration configuration : configurations) {
if (configuration.getConfigurationException() != null) {
String[] item = new String[2];
item[0] = configuration.getName();
item[1] = configuration.getConfigurationException().getMessage();
configurationExceptions.add(item);
}
}
}
if (!configurationExceptions.isEmpty()) {
XmlBuilder exceptionsXML = new XmlBuilder("exceptions");
for (int j = 0; j < configurationExceptions.size(); j++) {
XmlBuilder exceptionXML = new XmlBuilder("exception");
exceptionXML.addAttribute("config", configurationExceptions.get(j)[0]);
exceptionXML.setValue(configurationExceptions.get(j)[1]);
exceptionsXML.addSubElement(exceptionXML);
}
return exceptionsXML;
}
return null;
}
Aggregations