use of nl.nn.adapterframework.util.XmlBuilder in project iaf by ibissource.
the class LdapSender method getTree.
/**
* Return xml element containing all of the subcontexts of the parent context with their attributes.
* @return tree xml.
*/
private XmlBuilder getTree(DirContext parentContext, String context, ParameterResolutionContext prc, Map paramValueMap) {
XmlBuilder contextElem = new XmlBuilder("context");
contextElem.addAttribute("name", context);
String[] subCtxList = getSubContextList(parentContext, context, prc);
try {
if (subCtxList.length == 0) {
XmlBuilder attrs = attributesToXml(parentContext.getAttributes(context, getAttributesReturnedParameter()));
contextElem.addSubElement(attrs);
} else {
for (int i = 0; i < subCtxList.length; i++) {
contextElem.addSubElement(getTree((DirContext) parentContext.lookup(context), subCtxList[i], prc, paramValueMap));
}
contextElem.addSubElement(attributesToXml(parentContext.getAttributes(context, getAttributesReturnedParameter())));
}
} catch (NamingException e) {
storeLdapException(e, prc);
log.error("Exception in operation [" + getOperation() + "]: ", e);
}
return contextElem;
}
use of nl.nn.adapterframework.util.XmlBuilder in project iaf by ibissource.
the class LdapSender method attributesToXml.
/* protected String searchResultsToXml(NamingEnumeration searchresults) {
// log.debug("SearchResultsToXml for class ["+searchresults.getClass().getName()+"]:"+ToStringBuilder.reflectionToString(searchresults));
log.debug("LDAP STEP: SearchResultsToXml(NamingEnumeration searchresults)");
XmlBuilder searchresultsElem = new XmlBuilder("searchresults");
if (searchresults!=null) {
try {
while (searchresults.hasMore()) {
SearchResult sr = (SearchResult)searchresults.next();
// log.debug("result:"+ sr.toString());
XmlBuilder itemElem = new XmlBuilder("item");
itemElem.addAttribute("name",sr.getName());
try {
itemElem.addSubElement(attributesToXml(sr.getAttributes()));
} catch (NamingException e) {
itemElem.addAttribute("exceptionType",e.getClass().getName());
itemElem.addAttribute("exceptionExplanation",e.getExplanation());
} catch (Throwable t) {
itemElem.addAttribute("exceptionType",t.getClass().getName());
itemElem.addAttribute("exceptionExplanation",t.getMessage());
itemElem.addAttribute("itemclass",sr.getClass().getName());
}
searchresultsElem.addSubElement(itemElem);
}
} catch (NamingException e) {
searchresultsElem.addAttribute("exceptionType",e.getClass().getName());
searchresultsElem.addAttribute("exceptionExplanation",e.getExplanation());
}
}
return searchresultsElem.toXML();
}*/
protected XmlBuilder attributesToXml(Attributes atts) throws NamingException {
XmlBuilder attributesElem = new XmlBuilder("attributes");
NamingEnumeration all = atts.getAll();
while (all.hasMore()) {
Attribute attribute = (Attribute) all.next();
XmlBuilder attributeElem = new XmlBuilder("attribute");
attributeElem.addAttribute("name", attribute.getID());
if (attribute.size() == 1 && attribute.get() != null) {
attributeElem.addAttribute("value", attribute.get().toString());
} else {
NamingEnumeration values = attribute.getAll();
while (values.hasMore()) {
Object value = values.next();
XmlBuilder itemElem = new XmlBuilder("item");
itemElem.addAttribute("value", value.toString());
attributeElem.addSubElement(itemElem);
}
}
attributesElem.addSubElement(attributeElem);
}
return attributesElem;
}
use of nl.nn.adapterframework.util.XmlBuilder in project iaf by ibissource.
the class CreateRestViewPipe method createImagelinkElement.
private XmlBuilder createImagelinkElement(String srcPrefix, String href, String type, String alt) {
XmlBuilder imagelink = new XmlBuilder("imagelink");
if (StringUtils.startsWithIgnoreCase(href, "javascript:") || StringUtils.startsWithIgnoreCase(href, "?")) {
imagelink.addAttribute("href", href);
} else {
imagelink.addAttribute("href", srcPrefix + href);
}
imagelink.addAttribute("type", type);
imagelink.addAttribute("alt", alt);
return imagelink;
}
use of nl.nn.adapterframework.util.XmlBuilder in project iaf by ibissource.
the class CrlPipe method doPipe.
public PipeRunResult doPipe(Object input, IPipeLineSession session) throws PipeRunException {
X509CRL crl;
InputStream inputStream = (InputStream) input;
try {
CertificateFactory cf = CertificateFactory.getInstance("X.509");
crl = (X509CRL) cf.generateCRL(inputStream);
} catch (CertificateException e) {
throw new PipeRunException(this, "Could not read CRL", e);
} catch (CRLException e) {
throw new PipeRunException(this, "Could not read CRL", e);
} finally {
if (inputStream != null) {
try {
inputStream.close();
} catch (IOException e) {
log.warn("Could not close CRL input stream", e);
}
}
}
String result = null;
if (isCRLOK(crl, (InputStream) session.get(getIssuerSessionKey()))) {
XmlBuilder root = new XmlBuilder("SerialNumbers");
Iterator<? extends X509CRLEntry> it = crl.getRevokedCertificates().iterator();
while (it.hasNext()) {
X509CRLEntry e = (X509CRLEntry) it.next();
XmlBuilder serialNumber = new XmlBuilder("SerialNumber");
serialNumber.setValue(e.getSerialNumber().toString(16));
root.addSubElement(serialNumber);
}
result = root.toXML();
}
return new PipeRunResult(getForward(), result);
}
use of nl.nn.adapterframework.util.XmlBuilder in project iaf by ibissource.
the class CmisSender method getPropertyXml.
private XmlBuilder getPropertyXml(PropertyData property) {
XmlBuilder propertyXml = new XmlBuilder("property");
String name = property.getId();
propertyXml.addAttribute("name", name);
Object value = property.getFirstValue();
if (value == null) {
propertyXml.addAttribute("isNull", "true");
}
if (value instanceof BigInteger) {
BigInteger bi = (BigInteger) property.getFirstValue();
propertyXml.setValue(String.valueOf(bi));
propertyXml.addAttribute("type", "integer");
} else if (value instanceof Boolean) {
Boolean b = (Boolean) property.getFirstValue();
propertyXml.setValue(String.valueOf(b));
propertyXml.addAttribute("type", "boolean");
} else if (value instanceof GregorianCalendar) {
GregorianCalendar gc = (GregorianCalendar) property.getFirstValue();
// TODO shouldn't this be "yyyy-MM-dd'T'HH:mm:ss.SSSZ"
SimpleDateFormat sdf = new SimpleDateFormat(FORMATSTRING_BY_DEFAULT);
propertyXml.setValue(sdf.format(gc.getTime()));
propertyXml.addAttribute("type", "datetime");
} else {
propertyXml.setValue((String) property.getFirstValue());
}
return propertyXml;
}
Aggregations