summaryrefslogtreecommitdiff
path: root/bkucommon/src/main/java/at/gv
diff options
context:
space:
mode:
authormcentner <mcentner@8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4>2009-08-12 14:16:58 +0000
committermcentner <mcentner@8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4>2009-08-12 14:16:58 +0000
commit2dc37cef3cb0f5aa4dcc7a3bb28259181e6f5b3e (patch)
tree9319919572a0ac1f4fee50501990d2b66d037672 /bkucommon/src/main/java/at/gv
parent275aae71fbac34cee00f009cd9c1a02d2786a662 (diff)
downloadmocca-2dc37cef3cb0f5aa4dcc7a3bb28259181e6f5b3e.tar.gz
mocca-2dc37cef3cb0f5aa4dcc7a3bb28259181e6f5b3e.tar.bz2
mocca-2dc37cef3cb0f5aa4dcc7a3bb28259181e6f5b3e.zip
Fixed Bug#463 https://egovlabs.gv.at/tracker/index.php?func=detail&aid=463&group_id=13&atid=134.
git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@417 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4
Diffstat (limited to 'bkucommon/src/main/java/at/gv')
-rw-r--r--bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/IdentityLinkInfoboxImpl.java57
1 files changed, 29 insertions, 28 deletions
diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/IdentityLinkInfoboxImpl.java b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/IdentityLinkInfoboxImpl.java
index c3a40713..7a82e43f 100644
--- a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/IdentityLinkInfoboxImpl.java
+++ b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/impl/IdentityLinkInfoboxImpl.java
@@ -172,9 +172,29 @@ public class IdentityLinkInfoboxImpl extends AbstractBinaryFileInfobox {
InfoboxReadResultFileImpl result = new InfoboxReadResultFileImpl();
ByteArrayOutputStream resultBytes = null;
- Result xmlResult = (isXMLEntity() || getDomainIdentifier() != null)
- ? result.getXmlResult(true)
- : new StreamResult((resultBytes = new ByteArrayOutputStream()));
+ Result xmlResult;
+ if (isXMLEntity()) {
+ // we will return the result as XML entity
+ xmlResult = result.getXmlResult(true);
+ } else {
+ // we will return the result as binary data
+ if (getDomainIdentifier() != null) {
+ // we need an XML result to be able to replace the domain identifier below
+ Document doc;
+ try {
+ doc = dbf.newDocumentBuilder().newDocument();
+ } catch (ParserConfigurationException e) {
+ // it should always be possible to create a new Document
+ log.error("Failed to create XML document.", e);
+ throw new SLRuntimeException(e);
+ }
+ xmlResult = new DOMResult(doc);
+ } else {
+ resultBytes = new ByteArrayOutputStream();
+ xmlResult = new StreamResult(resultBytes);
+ }
+ }
+
try {
log.trace("Trying to transform identitylink");
identityLinkTransformer.transformIdLink(issuerTemplate, new DOMSource(document), xmlResult);
@@ -235,23 +255,9 @@ public class IdentityLinkInfoboxImpl extends AbstractBinaryFileInfobox {
if (!isXMLEntity()) {
if (resultBytes == null) {
resultBytes = new ByteArrayOutputStream();
-
if (xmlResult instanceof DOMResult) {
Node node = ((DOMResult) xmlResult).getNode();
- Node nextSibling = ((DOMResult) xmlResult).getNextSibling();
-
- DOMSource xmlSource;
- if (nextSibling != null) {
- xmlSource = new DOMSource(nextSibling.getPreviousSibling());
- } else if (node != null) {
- xmlSource = new DOMSource(node.getFirstChild());
- } else {
- log
- .error("IssuerTemplate transformation returned no node.");
- throw new SLCommandException(4000,
- SLExceptionMessages.EC4000_UNCLASSIFIED_IDLINK_TRANSFORMATION_FAILED,
- new Object[] { issuerTemplate });
- }
+ DOMSource xmlSource = new DOMSource(node);
TransformerFactory transformerFactory = TransformerFactory.newInstance();
try {
Transformer transformer = transformerFactory.newTransformer();
@@ -267,16 +273,11 @@ public class IdentityLinkInfoboxImpl extends AbstractBinaryFileInfobox {
SLExceptionMessages.EC4000_UNCLASSIFIED_IDLINK_TRANSFORMATION_FAILED,
new Object[] { issuerTemplate });
}
- } else if (xmlResult instanceof StreamResult) {
- OutputStream outputStream = ((StreamResult) xmlResult).getOutputStream();
- if (outputStream instanceof ByteArrayOutputStream) {
- result.setResultBytes(((ByteArrayOutputStream) outputStream).toByteArray());
- } else {
- log.error("ContentIsXMLEntity is set to 'false'. However, an XMLResult has already been set.");
- throw new SLCommandException(4000,
- SLExceptionMessages.EC4000_UNCLASSIFIED_IDLINK_TRANSFORMATION_FAILED,
- new Object[] { issuerTemplate });
- }
+ } else {
+ log.error("ContentIsXMLEntity is set to 'false'. However, an XMLResult has already been set.");
+ throw new SLCommandException(4000,
+ SLExceptionMessages.EC4000_UNCLASSIFIED_IDLINK_TRANSFORMATION_FAILED,
+ new Object[] { issuerTemplate });
}
}
result.setResultBytes(resultBytes.toByteArray());