summaryrefslogtreecommitdiff
path: root/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/InfoboxReadResultFileImpl.java
diff options
context:
space:
mode:
Diffstat (limited to 'bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/InfoboxReadResultFileImpl.java')
-rw-r--r--bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/InfoboxReadResultFileImpl.java33
1 files changed, 27 insertions, 6 deletions
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/InfoboxReadResultFileImpl.java b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/InfoboxReadResultFileImpl.java
index 6f41b562..d8295227 100644
--- a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/InfoboxReadResultFileImpl.java
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/InfoboxReadResultFileImpl.java
@@ -29,6 +29,7 @@ import javax.xml.transform.dom.DOMResult;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.w3c.dom.Document;
+import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import at.buergerkarte.namespaces.securitylayer._1.Base64XMLContentType;
@@ -56,7 +57,7 @@ public class InfoboxReadResultFileImpl extends SLResultImpl implements
/**
* The XML document containing the infobox content.
*/
- Document xmlDocument;
+ protected Document xmlDocument;
/**
* Creates the response document from the given <code>binaryContent</code>.
@@ -95,7 +96,7 @@ public class InfoboxReadResultFileImpl extends SLResultImpl implements
JAXBElement<InfoboxReadResponseType> infoboxReadResponse = factory.createInfoboxReadResponse(infoboxReadResponseType);
- JAXBContext context = SLCommandFactory.getJaxbContext();
+ JAXBContext context = SLCommandFactory.getInstance().getJaxbContext();
try {
Marshaller marshaller = context.createMarshaller();
marshaller.marshal(infoboxReadResponse, doc);
@@ -112,22 +113,42 @@ public class InfoboxReadResultFileImpl extends SLResultImpl implements
/**
* @return an XMLResult for marshalling the infobox to
*/
- Result getXmlResult(boolean preserveSpace) {
+ public Result getXmlResult(boolean preserveSpace) {
xmlDocument = createResponseDocument(null, preserveSpace);
NodeList nodeList = xmlDocument.getElementsByTagNameNS(SLCommand.NAMESPACE_URI, "XMLContent");
return new DOMResult(nodeList.item(0));
- }
-
+ }
+
+ /**
+ * Creates a new <code>InfoboxReadResponse</code> document and appends
+ * the given <code>node</code> as child node of the <code>XMLContent</code> element.
+ *
+ * @param node the node to be appended as child node of the <code>XMLContnet</code> element
+ * @param preserveSpace if <code>true</code> the value of the <code>XMLContent</code>'s <code>space</code>
+ * attribute is set to <code>preserve</code>.
+ */
+ public void setResultXMLContent(Node node, boolean preserveSpace) {
+
+ xmlDocument = createResponseDocument(null, preserveSpace);
+
+ NodeList nodeList = xmlDocument.getElementsByTagNameNS(SLCommand.NAMESPACE_URI, "XMLContent");
+ if (node.getOwnerDocument() != xmlDocument) {
+ node = xmlDocument.importNode(node, true);
+ }
+ nodeList.item(0).appendChild(node);
+
+ }
+
/**
* Creates a new result document for this <code>InfoboxReadResult</code>
* and sets the given <code>resultBytes</code> as content.
*
* @param resultBytes
*/
- void setResultBytes(byte[] resultBytes) {
+ public void setResultBytes(byte[] resultBytes) {
xmlDocument = createResponseDocument(resultBytes, false);