diff options
Diffstat (limited to 'spss.server/src/at/gv/egovernment/moa/spss/server/invoke/TransformationFactory.java')
-rw-r--r-- | spss.server/src/at/gv/egovernment/moa/spss/server/invoke/TransformationFactory.java | 258 |
1 files changed, 0 insertions, 258 deletions
diff --git a/spss.server/src/at/gv/egovernment/moa/spss/server/invoke/TransformationFactory.java b/spss.server/src/at/gv/egovernment/moa/spss/server/invoke/TransformationFactory.java deleted file mode 100644 index 9984a95a5..000000000 --- a/spss.server/src/at/gv/egovernment/moa/spss/server/invoke/TransformationFactory.java +++ /dev/null @@ -1,258 +0,0 @@ -package at.gv.egovernment.moa.spss.server.invoke; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - -import iaik.server.modules.xml.Base64Transformation; -import iaik.server.modules.xml.Canonicalization; -import iaik.server.modules.xml.EnvelopedSignatureTransformation; -import iaik.server.modules.xml.Transformation; -import iaik.server.modules.xml.XPath2Transformation; -import iaik.server.modules.xml.XPathTransformation; -import iaik.server.modules.xml.XSLTTransformation; - -import at.gv.egovernment.moa.spss.MOAApplicationException; -import at.gv.egovernment.moa.spss.api.common.ExclusiveCanonicalizationTransform; -import at.gv.egovernment.moa.spss.api.common.Transform; -import at.gv.egovernment.moa.spss.api.common.XPathFilter; -import at.gv.egovernment.moa.spss.api.common.XPathFilter2Transform; -import at.gv.egovernment.moa.spss.api.common.XPathTransform; -import at.gv.egovernment.moa.spss.api.common.XSLTTransform; -import at.gv.egovernment.moa.spss.server.iaik.xml.Base64TransformationImpl; -import at.gv.egovernment.moa.spss.server.iaik.xml.CanonicalizationImpl; -import at.gv.egovernment.moa.spss.server.iaik.xml.EnvelopedSignatureTransformationImpl; -import at.gv.egovernment.moa.spss.server.iaik.xml.ExclusiveCanonicalizationImpl; -import at.gv.egovernment.moa.spss.server.iaik.xml.XPath2FilterImpl; -import at.gv.egovernment.moa.spss.server.iaik.xml.XPath2TransformationImpl; -import at.gv.egovernment.moa.spss.server.iaik.xml.XPathTransformationImpl; -import at.gv.egovernment.moa.spss.server.iaik.xml.XSLTTransformationImpl; - -/** - * A factory to create <code>Transformation</code> objects from - * <code>Transform</code> objects. - * - * @author Patrick Peck - * @version $Id$ - */ -public class TransformationFactory { - - - /** The single instance of this class. */ - private static TransformationFactory instance = null; - - /** Maps <code>XPathFilter</code> filter types to - * <code>XPath2Transformation</code> filter types. */ - private static Map FILTER_TYPE_MAPPING; - - static { - FILTER_TYPE_MAPPING = new HashMap(); - - FILTER_TYPE_MAPPING.put( - XPathFilter.INTERSECT_TYPE, - XPath2Transformation.XPath2Filter.INTERSECTION); - FILTER_TYPE_MAPPING.put( - XPathFilter.SUBTRACT_TYPE, - XPath2Transformation.XPath2Filter.SUBTRACTION); - FILTER_TYPE_MAPPING.put( - XPathFilter.UNION_TYPE, - XPath2Transformation.XPath2Filter.UNION); - } - - /** - * Get the single instance of the factory. - * - * @return TransformationFactory The single instance. - */ - public static synchronized TransformationFactory getInstance() { - if (instance == null) { - instance = new TransformationFactory(); - } - return instance; - } - - /** - * Create a new <code>TransformationFactory</code>. - * - * Protected to disallow multiple instances. - */ - protected TransformationFactory() { - } - - /** - * Create a <code>Transformation</code> based on a - * <code>Transform</code> object. - * - * @param transform The <code>Transform</code> object to extract - * transformation data from. - * @return The transformation contained in the <code>transform</code> - * object. - * @throws MOAApplicationException An error occured creating the - * <code>Transformation</code>. See exception message for details. - */ - public Transformation createTransformation(Transform transform) - throws MOAApplicationException { - String algorithmUri = transform.getAlgorithmURI(); - - if (Canonicalization.CANONICAL_XML.equals(algorithmUri) - || Canonicalization.CANONICAL_XML_WITH_COMMENTS.equals(algorithmUri)) { - return createC14nTransformation(algorithmUri); - } else if ( - Canonicalization.EXCLUSIVE_CANONICAL_XML.equals(algorithmUri) - || Canonicalization.EXCLUSIVE_CANONICAL_XML_WITH_COMMENTS.equals( - algorithmUri)) { - - return createExclusiveC14nTransformation( - (ExclusiveCanonicalizationTransform) transform); - - } else if (Base64Transformation.ALL.contains(algorithmUri)) { - return createBase64Transformation(); - } else if (EnvelopedSignatureTransformation.ALL.contains(algorithmUri)) { - return createEnvelopedSignatureTransformation(); - } else if (XPathTransformation.ALL.contains(algorithmUri)) { - return createXPathTransformation((XPathTransform) transform); - } else if (XPath2Transformation.ALL.contains(algorithmUri)) { - return createXPath2Transformation((XPathFilter2Transform) transform); - } else if (XSLTTransformation.ALL.contains(algorithmUri)) { - return createXSLTTransformation((XSLTTransform) transform); - } else { - throw new MOAApplicationException("1108", new Object[] { algorithmUri }); - } - } - - /** - * Create a <code>List</code> of <code>Transformation</code>s from a - * <code>List</code> of <code>Transform</code>s. - * - * @param transforms The <code>List</code> containing the - * <code>Transform</code>s. - * @return The <code>List</code> of <code>Transformation</code>s corresponding - * to the <code>transforms</code>. - * @throws MOAApplicationException An error occurred building one of the - * transformations. See exception message for details. - */ - public List createTransformationList(List transforms) - throws MOAApplicationException { - List transformationList = new ArrayList(); - Iterator trIter; - - for (trIter = transforms.iterator(); trIter.hasNext();) { - Transform transform = (Transform) trIter.next(); - transformationList.add(createTransformation(transform)); - } - - return transformationList; - } - - /** - * Create a <code>Canonicalization</code>. - * - * @param algorithmUri The algorithm URI of the canonicalization. - * @return The <code>Canonicalization</code>. - */ - private Transformation createC14nTransformation(String algorithmUri) { - return new CanonicalizationImpl(algorithmUri); - } - - /** - * Create a <code>ExclusiveCanonicalization</code>. - * - * @param transform The <code>ExclusiveCanonicalizationTransform</code> - * containing the transformation data. - * @return The <code>ExclusiveCanonicalization</code>. - */ - private Transformation createExclusiveC14nTransformation(ExclusiveCanonicalizationTransform transform) { - return new ExclusiveCanonicalizationImpl( - transform.getAlgorithmURI(), - transform.getInclusiveNamespacePrefixes()); - } - - /** - * Create a <code>Base64Transformation</code>. - * - * @return The <code></code> - */ - private Transformation createBase64Transformation() { - return new Base64TransformationImpl(); - } - - /** - * Create an <code>EnvelopedSignatureTransformation</code>. - * - * @return An <code>EnvelopedSignatureTransformation</code>. - */ - private Transformation createEnvelopedSignatureTransformation() { - return new EnvelopedSignatureTransformationImpl(); - } - - /** - * Create an <code>XPathTransformation</code>. - * - * @param transform The <code>Transform</code> object containing the - * XPath transformation. - * @return An <code>XPathTransformation</code> corresponding the - * transformation given in <code>transform</code>. - * @throws MOAApplicationException An error occurred creating the - * <code>Transformation</code>. - */ - private Transformation createXPathTransformation(XPathTransform transform) - throws MOAApplicationException { - - return new XPathTransformationImpl( - transform.getXPathExpression(), - transform.getNamespaceDeclarations()); - } - - /** - * Create an <code>XPath2Transformation</code>. - * - * @param transform The <code>Transform</code> object containing the - * XPath filter transformation. - * @return An <code>XPath2Transformation</code> corresponding the - * transformation given in <code>transform</code>. - * @throws MOAApplicationException An error occurred creating the - * <code>Transformation</code>. - */ - private Transformation createXPath2Transformation(XPathFilter2Transform transform) - throws MOAApplicationException { - - XPath2TransformationImpl xpath2 = new XPath2TransformationImpl(); - Iterator iter; - - for (iter = transform.getFilters().iterator(); iter.hasNext();) { - XPathFilter filter = (XPathFilter) iter.next(); - String mappedFilterType = - (String) FILTER_TYPE_MAPPING.get(filter.getFilterType()); - XPath2FilterImpl mappedFilter = - new XPath2FilterImpl( - mappedFilterType, - filter.getXPathExpression(), - filter.getNamespaceDeclarations()); - xpath2.addXPathFilter(mappedFilter); - } - - if (xpath2.getXPathFilters().size() == 0) { - throw new MOAApplicationException("2216", null); - } - - return xpath2; - } - - /** - * Create an <code>XSLTTransformation</code>. - * - * @param transform The <code>Transform</code> containing the XSLT stylesheet. - * @return An <code>XSLTTransformation</code> corresponding the transformation - * given in <code>transform</code>. - * @throws MOAApplicationException An error occurred creating the - * <code>Transformation</code>. - */ - private Transformation createXSLTTransformation(XSLTTransform transform) - throws MOAApplicationException { - - return new XSLTTransformationImpl(transform.getStylesheet()); - } - -} |