Author: glandais Date: 2008-02-12 18:15:41 +0000 (Tue, 12 Feb 2008) New Revision: 869 Modified: trunk/simexplorer-is/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/factories/BaseEntityFactory.java Log: reformat Modified: trunk/simexplorer-is/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/factories/BaseEntityFactory.java =================================================================== --- trunk/simexplorer-is/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/factories/BaseEntityFactory.java 2008-02-12 17:34:11 UTC (rev 868) +++ trunk/simexplorer-is/simexplorer-is-entities/src/java/fr/cemagref/simexplorer/is/factories/BaseEntityFactory.java 2008-02-12 18:15:41 UTC (rev 869) @@ -20,11 +20,27 @@ import java.io.InputStream; import java.io.PipedInputStream; import java.io.PipedOutputStream; +import java.security.InvalidAlgorithmParameterException; +import java.security.NoSuchAlgorithmException; +import java.util.ArrayList; +import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.Set; +import javax.xml.crypto.dom.DOMStructure; +import javax.xml.crypto.dsig.CanonicalizationMethod; +import javax.xml.crypto.dsig.DigestMethod; +import javax.xml.crypto.dsig.Reference; +import javax.xml.crypto.dsig.SignatureMethod; +import javax.xml.crypto.dsig.SignedInfo; +import javax.xml.crypto.dsig.XMLSignature; +import javax.xml.crypto.dsig.XMLSignatureFactory; +import javax.xml.crypto.dsig.dom.DOMSignContext; +import javax.xml.crypto.dsig.keyinfo.KeyInfo; +import javax.xml.crypto.dsig.keyinfo.KeyInfoFactory; +import javax.xml.crypto.dsig.spec.C14NMethodParameterSpec; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.transform.dom.DOMSource; @@ -40,6 +56,7 @@ /** * A factory for creating BaseEntity objects. + * * @param <E> Entity type */ public abstract class BaseEntityFactory<E extends BaseEntity> implements @@ -57,15 +74,14 @@ /** * Retrieve instance of the factory. + * * @param <E> Entity type * - * @param entityClass - * Class wanted + * @param entityClass Class wanted * * @return Factory * - * @throws Exception - * the exception + * @throws Exception the exception */ @SuppressWarnings("unchecked") public static <E extends DataEntity> BaseEntityFactory<E> getFactory( @@ -90,13 +106,11 @@ /** * Retrieve a factory with class name. * - * @param entityClassName - * the entity class name + * @param entityClassName the entity class name * * @return the factory * - * @throws Exception - * the exception + * @throws Exception the exception */ public static BaseEntityFactory<? extends DataEntity> getFactory( String entityClassName) throws Exception { @@ -110,8 +124,7 @@ * * @return XML document builder * - * @throws Exception - * the exception + * @throws Exception the exception */ public static synchronized DocumentBuilder getXMLBuilder() throws Exception { if (documentBuilder == null) { @@ -137,13 +150,11 @@ /** * Load an element from an XML node. * - * @param xmlElement - * the xml element + * @param xmlElement the xml element * * @return the E * - * @throws Exception - * the exception + * @throws Exception the exception */ public E loadElement(Element xmlElement) throws Exception { E element = createInstance(); @@ -153,13 +164,11 @@ /** * Load an element from a XML stream. * - * @param stream - * the stream + * @param stream the stream * * @return the E * - * @throws Exception - * the exception + * @throws Exception the exception */ public E loadElement(InputStream stream) throws Exception { Document document = getXMLBuilder().parse(stream); @@ -171,15 +180,11 @@ /** * Save an element to a XML node. * - * @param document - * XML document - * @param xmlElement - * XML node storing the element (not null) - * @param element - * Element to save + * @param document XML document + * @param xmlElement XML node storing the element (not null) + * @param element Element to save * - * @throws Exception - * the exception + * @throws Exception the exception */ public abstract void saveElement(Document document, Element xmlElement, E element) throws Exception; @@ -187,15 +192,12 @@ /** * Save an element to a XML stream. * - * @param rootNodeName - * the root node name - * @param element - * the element + * @param rootNodeName the root node name + * @param element the element * * @return the input stream * - * @throws Exception - * the exception + * @throws Exception the exception */ public InputStream saveElement(String rootNodeName, E element) throws Exception { @@ -220,29 +222,32 @@ return is; } + public String signXmlElement(Element xmlElement) throws Exception { + String result = ""; + + + + return result; + } + /* * Collection methods : Help load/save of inner collections */ /** * Load a collection inside a node. + * * @param <T> Entity type * - * @param tagSetName - * Tag of the node of the collection - * @param tagName - * Tag of the node containing an item - * @param clazz - * Class type - * @param xmlElement - * Node containing the collection - * @param parentData - * Element holding the collection + * @param tagSetName Tag of the node of the collection + * @param tagName Tag of the node containing an item + * @param clazz Class type + * @param xmlElement Node containing the collection + * @param parentData Element holding the collection * * @return the set< t> * - * @throws Exception - * the exception + * @throws Exception the exception */ public <T extends DataEntity> Set<T> loadCollection(String tagSetName, String tagName, Class<T> clazz, Element xmlElement, @@ -270,23 +275,17 @@ /** * Save a collection of elements to XML node. + * * @param <T> Entity type * - * @param entities - * the entities - * @param tagSetName - * the tag set name - * @param tagName - * the tag name - * @param clazz - * the clazz - * @param document - * the document - * @param xmlElement - * the xml element + * @param entities the entities + * @param tagSetName the tag set name + * @param tagName the tag name + * @param clazz the clazz + * @param document the document + * @param xmlElement the xml element * - * @throws Exception - * the exception + * @throws Exception the exception */ public <T extends DataEntity> void saveCollection(Set<T> entities, String tagSetName, String tagName, Class<T> clazz, @@ -306,13 +305,11 @@ /** * Save an element as a XML stream. * - * @param node - * the node + * @param node the node * * @return the input stream * - * @throws Exception - * the exception + * @throws Exception the exception */ public static InputStream serializeElement(Element node) throws Exception { org.w3c.dom.Document xmlDocument = getXMLBuilder().newDocument(); @@ -339,14 +336,10 @@ /** * Set a property in XML. * - * @param document - * XML document - * @param xmlElement - * Node to modify - * @param tagName - * Tag of created node - * @param value - * Value of node + * @param document XML document + * @param xmlElement Node to modify + * @param tagName Tag of created node + * @param value Value of node */ protected void setXMLProperty(Document document, Element xmlElement, String tagName, Object value) { @@ -361,10 +354,8 @@ /** * Get a property in XML. * - * @param xmlElement - * Source node - * @param tagName - * Tag name of property + * @param xmlElement Source node + * @param tagName Tag name of property * * @return Property value */ @@ -383,10 +374,8 @@ /** * Retrieve XML element just under with specified tag name. * - * @param xmlElement - * the xml element - * @param tagName - * the tag name + * @param xmlElement the xml element + * @param tagName the tag name * * @return First child element with tagName */ @@ -401,10 +390,8 @@ /** * Retrieve all XML elements just under with specified tag name. * - * @param xmlElement - * the xml element - * @param tagName - * the tag name + * @param xmlElement the xml element + * @param tagName the tag name * * @return Children with tagName */