aboutsummaryrefslogtreecommitdiff
path: root/spss.server/src/at/gv/egovernment/moa/spss/server/invoke/DataObjectFactory.java
diff options
context:
space:
mode:
Diffstat (limited to 'spss.server/src/at/gv/egovernment/moa/spss/server/invoke/DataObjectFactory.java')
-rw-r--r--spss.server/src/at/gv/egovernment/moa/spss/server/invoke/DataObjectFactory.java146
1 files changed, 113 insertions, 33 deletions
diff --git a/spss.server/src/at/gv/egovernment/moa/spss/server/invoke/DataObjectFactory.java b/spss.server/src/at/gv/egovernment/moa/spss/server/invoke/DataObjectFactory.java
index 32c81dc07..6f541ed42 100644
--- a/spss.server/src/at/gv/egovernment/moa/spss/server/invoke/DataObjectFactory.java
+++ b/spss.server/src/at/gv/egovernment/moa/spss/server/invoke/DataObjectFactory.java
@@ -37,6 +37,7 @@ import at.gv.egovernment.moa.spss.MOAApplicationException;
import at.gv.egovernment.moa.spss.MOASystemException;
import at.gv.egovernment.moa.spss.api.common.Content;
import at.gv.egovernment.moa.spss.api.common.ContentBinary;
+import at.gv.egovernment.moa.spss.api.common.ContentLocRef;
import at.gv.egovernment.moa.spss.api.common.ContentXML;
import at.gv.egovernment.moa.spss.api.common.MetaInfo;
import at.gv.egovernment.moa.spss.api.common.XMLDataObjectAssociation;
@@ -54,6 +55,7 @@ import at.gv.egovernment.moa.spss.util.MessageProvider;
* locations of the MOA XML request format.
*
* @author Patrick Peck
+ * @author Gregor Karlinger
* @version $Id$
*/
public class DataObjectFactory {
@@ -128,6 +130,21 @@ public class DataObjectFactory {
contentBytes = StreamUtils.readStream(is);
break;
}
+ case Content.LOCREF_CONTENT:
+ {
+ ExternalURIResolver uriResolver = new ExternalURIResolver();
+ String locRefURI = ((ContentLocRef) content).getLocationReferenceURI();
+ try
+ {
+ InputStream is = uriResolver.resolve(locRefURI);
+ contentBytes = StreamUtils.readStream(is);
+ }
+ catch (MOAApplicationException e)
+ {
+ throw new MOAApplicationException("3203", new Object[]{reference, locRefURI}, e);
+ }
+ break;
+ }
case Content.REFERENCE_CONTENT :
{
ExternalURIResolver uriResolver = new ExternalURIResolver();
@@ -245,7 +262,9 @@ public class DataObjectFactory {
* their reference URI to an <code>InputStream</code> of their respective
* content.
*/
- private static StreamEntityResolver buildSupplementEntityResolver(List supplements) {
+ private static StreamEntityResolver buildSupplementEntityResolver(List supplements)
+ throws MOAApplicationException
+ {
Map entities = new HashMap();
Iterator iter;
@@ -257,31 +276,52 @@ public class DataObjectFactory {
switch (content.getContentType()) {
case Content.BINARY_CONTENT :
- entities.put(reference, ((ContentBinary) content).getBinaryContent());
- break;
+ {
+ entities.put(reference, ((ContentBinary) content).getBinaryContent());
+ break;
+ }
+ case Content.LOCREF_CONTENT:
+ {
+ ExternalURIResolver uriResolver = new ExternalURIResolver();
+ String locRefURI = ((ContentLocRef) content).getLocationReferenceURI();
+ InputStream contentIS = null;
+ try
+ {
+ contentIS = uriResolver.resolve(locRefURI);
+ }
+ catch (MOAApplicationException e)
+ {
+ throw new MOAApplicationException("3202", new Object[]{reference, locRefURI}, e);
+ }
+ entities.put(reference, contentIS);
+ break;
+ }
case Content.XML_CONTENT :
- // serialize the first element node that is found in the supplement
- // and make it available as a stream
- NodeList nodes = ((ContentXML) content).getXMLContent();
- int i = 0;
-
- // find the first element node
- while (i < nodes.getLength()
- && nodes.item(i).getNodeType() != Node.ELEMENT_NODE)
- i++;
-
- // serialize the node
- if (i < nodes.getLength()) {
- try {
- byte[] serialized =
- DOMUtils.serializeNode(nodes.item(i), "UTF-8");
- entities.put(reference, new ByteArrayInputStream(serialized));
- } catch (Exception e) {
- // serializing the element failed - just don't put it in the map
+ {
+ // serialize the first element node that is found in the supplement
+ // and make it available as a stream
+ NodeList nodes = ((ContentXML) content).getXMLContent();
+ int i = 0;
+
+ // find the first element node
+ while (i < nodes.getLength()
+ && nodes.item(i).getNodeType() != Node.ELEMENT_NODE)
+ i++;
+
+ // serialize the node
+ if (i < nodes.getLength()) {
+ try
+ {
+ byte[] serialized = DOMUtils.serializeNode(nodes.item(i), "UTF-8");
+ entities.put(reference, new ByteArrayInputStream(serialized));
+ }
+ catch (Exception e)
+ {
+ throw new MOAApplicationException("2282", new Object[]{reference}, e);
+ }
}
+ break;
}
-
- break;
}
}
@@ -336,22 +376,42 @@ public class DataObjectFactory {
checkAllowContentAndReference(content, allowContentAndReference);
// ok, build the data object; use content first, if available
- switch (content.getContentType()) {
+ switch (content.getContentType())
+ {
case Content.XML_CONTENT :
+ {
ContentXML contentXml = (ContentXML) content;
dataObject = createFromXmlContent(contentXml, xmlAsNodeList);
break;
+ }
case Content.BINARY_CONTENT :
+ {
ContentBinary contentBinary = (ContentBinary) content;
dataObject = createFromBinaryContent(contentBinary, binaryAsXml, false);
break;
+ }
+ case Content.LOCREF_CONTENT :
+ {
+ String locRefURI = ((ContentLocRef) content).getLocationReferenceURI();
+ try
+ {
+ dataObject = createFromURIImpl(locRefURI, referenceAsXml);
+ }
+ catch (MOAApplicationException e)
+ {
+ throw new MOAApplicationException("3201", new Object[]{reference, locRefURI}, e);
+ }
+ break;
+ }
case Content.REFERENCE_CONTENT :
+ {
dataObject = createFromURIImpl(reference, referenceAsXml);
break;
+ }
}
// set URI and reference ID
- dataObject.setURI(content.getReference());
+ dataObject.setURI(reference);
dataObject.setReferenceID(referenceID);
return dataObject;
@@ -417,21 +477,41 @@ public class DataObjectFactory {
String mimeType = metaInfo != null ? metaInfo.getMimeType() : null;
DataObjectImpl dataObject = null;
- switch (content.getContentType()) {
+ switch (content.getContentType())
+ {
case Content.XML_CONTENT :
- if (xmlContentAllowed) {
+ {
+ if (xmlContentAllowed)
+ {
dataObject = createFromXmlContent((ContentXML) content, true);
- } else {
+ }
+ else
+ {
throw new MOAApplicationException("2280", null);
}
break;
+ }
case Content.BINARY_CONTENT :
- dataObject =
- createFromBinaryContent(
- (ContentBinary) content,
- false,
- binaryContentRepeatable);
+ {
+ dataObject = createFromBinaryContent(
+ (ContentBinary) content,
+ false,
+ binaryContentRepeatable);
+ break;
+ }
+ case Content.LOCREF_CONTENT :
+ {
+ String locRefURI = ((ContentLocRef) content).getLocationReferenceURI();
+ try
+ {
+ dataObject = createFromURIImpl(locRefURI, false);
+ }
+ catch (MOAApplicationException e)
+ {
+ throw new MOAApplicationException("3201", new Object[]{content.getReference(), locRefURI}, e);
+ }
break;
+ }
}
dataObject.setURI(content.getReference());