# HG changeset patch # User Tim Englich # Date 1265032445 0 # Node ID d4c4c23847f53dd63337421386589a25a48a878d # Parent 66f43d1e69eb56b3cdfcde55625dc7be0ea21b31 Extended the Artifact-Interface-Method setup to be able to put the XML-Document which can contain further Data to the Artifact-Implementation. artifacts/trunk@649 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r 66f43d1e69eb -r d4c4c23847f5 ChangeLog --- a/ChangeLog Wed Jan 27 14:58:20 2010 +0000 +++ b/ChangeLog Mon Feb 01 13:54:05 2010 +0000 @@ -1,3 +1,24 @@ +2010-02-01 Tim Englich + + * artifact-database/src/main/java/de/intevation/artifactdatabase/rest/CreateResource.java (innerPost): + Put the XML-Document which was send by the client to the + ArtifactDatabase.createArtifactWithFactory-Method. + + * artifact-database/src/main/java/de/intevation/artifactdatabase/DefaultArtifactFactory.java (createArtifact), + artifact-database/src/main/java/de/intevation/artifactdatabase/ArtifactDatabaseImpl.java (createArtifactWithFactory), + artifact-database/src/main/java/de/intevation/artifactdatabase/DefaultArtifact.java (setup), + artifacts/src/main/java/de/intevation/artifacts/ArtifactFactory.java (setup), + artifacts/src/main/java/de/intevation/artifacts/ArtifactDatabase.java (createArtifactWithFactory), + artifacts/src/main/java/de/intevation/artifacts/Artifact.java (setup): + Changed Method signatures so that it is possible to put the Document + which will be send during the create Step of an Artifact to the Setup-Routine + of an Artifact. + Now it is possible to send further Informations to the Artifact using the + XML-Document. + This is nessesary for manipoulating the Artifact e.g. setting Parameters + which should only be displaied or e.g. put an Geometry-Object into the + Artifact which should limit the displayed results. + 2010-01-27 Hans Plum RELEASE 0.4 diff -r 66f43d1e69eb -r d4c4c23847f5 artifact-database/src/main/java/de/intevation/artifactdatabase/ArtifactDatabaseImpl.java --- a/artifact-database/src/main/java/de/intevation/artifactdatabase/ArtifactDatabaseImpl.java Wed Jan 27 14:58:20 2010 +0000 +++ b/artifact-database/src/main/java/de/intevation/artifactdatabase/ArtifactDatabaseImpl.java Mon Feb 01 13:54:05 2010 +0000 @@ -1,7 +1,16 @@ package de.intevation.artifactdatabase; +import java.io.IOException; +import java.io.OutputStream; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; + +import org.apache.log4j.Logger; +import org.w3c.dom.Document; + import de.intevation.artifactdatabase.Backend.PersistentArtifact; - import de.intevation.artifacts.Artifact; import de.intevation.artifacts.ArtifactDatabase; import de.intevation.artifacts.ArtifactDatabaseException; @@ -11,18 +20,6 @@ import de.intevation.artifacts.Service; import de.intevation.artifacts.ServiceFactory; -import java.io.IOException; -import java.io.OutputStream; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; - -import org.apache.log4j.Logger; - -import org.w3c.dom.Document; - /** * @author Sascha L. Teichmann */ @@ -305,7 +302,8 @@ public Document createArtifactWithFactory( String factoryName, - CallMeta callMeta + CallMeta callMeta, + Document data ) throws ArtifactDatabaseException { @@ -317,7 +315,8 @@ Artifact artifact = factory.createArtifact( backend.newIdentifier(), - context); + context, + data); if (artifact == null) { throw new ArtifactDatabaseException(CREATION_FAILED); diff -r 66f43d1e69eb -r d4c4c23847f5 artifact-database/src/main/java/de/intevation/artifactdatabase/DefaultArtifact.java --- a/artifact-database/src/main/java/de/intevation/artifactdatabase/DefaultArtifact.java Wed Jan 27 14:58:20 2010 +0000 +++ b/artifact-database/src/main/java/de/intevation/artifactdatabase/DefaultArtifact.java Mon Feb 01 13:54:05 2010 +0000 @@ -1,15 +1,14 @@ package de.intevation.artifactdatabase; +import java.io.IOException; +import java.io.OutputStream; + +import org.apache.log4j.Logger; import org.w3c.dom.Document; import de.intevation.artifacts.Artifact; -import de.intevation.artifacts.CallContext; import de.intevation.artifacts.ArtifactFactory; - -import org.apache.log4j.Logger; - -import java.io.IOException; -import java.io.OutputStream; +import de.intevation.artifacts.CallContext; /** * @author Sascha L. Teichmann (sascha.teichmann@intevation.de) @@ -73,7 +72,8 @@ } } - public void setup(String identifier, ArtifactFactory factory, Object context) { + public void setup(String identifier, ArtifactFactory factory, + Object context, Document data) { if (logger.isDebugEnabled()) { logger.debug("DefaultArtifact.setup: " + identifier); } diff -r 66f43d1e69eb -r d4c4c23847f5 artifact-database/src/main/java/de/intevation/artifactdatabase/DefaultArtifactFactory.java --- a/artifact-database/src/main/java/de/intevation/artifactdatabase/DefaultArtifactFactory.java Wed Jan 27 14:58:20 2010 +0000 +++ b/artifact-database/src/main/java/de/intevation/artifactdatabase/DefaultArtifactFactory.java Mon Feb 01 13:54:05 2010 +0000 @@ -1,14 +1,13 @@ package de.intevation.artifactdatabase; +import org.apache.log4j.Logger; import org.w3c.dom.Document; import org.w3c.dom.Node; -import de.intevation.artifacts.ArtifactFactory; import de.intevation.artifacts.Artifact; +import de.intevation.artifacts.ArtifactFactory; import de.intevation.artifacts.ArtifactSerializer; -import org.apache.log4j.Logger; - /** * @author Sascha L. Teichmann (sascha.teichmann@intevation.de) */ @@ -48,13 +47,15 @@ return description; } - public Artifact createArtifact(String identifier, Object context) { + public Artifact createArtifact(String identifier, + Object context, + Document data) { try { Artifact artifact = (Artifact)artifactClass.newInstance(); - artifact.setup(identifier, this, context); + artifact.setup(identifier, this, context, data); return artifact; } diff -r 66f43d1e69eb -r d4c4c23847f5 artifact-database/src/main/java/de/intevation/artifactdatabase/rest/CreateResource.java --- a/artifact-database/src/main/java/de/intevation/artifactdatabase/rest/CreateResource.java Wed Jan 27 14:58:20 2010 +0000 +++ b/artifact-database/src/main/java/de/intevation/artifactdatabase/rest/CreateResource.java Mon Feb 01 13:54:05 2010 +0000 @@ -1,28 +1,21 @@ package de.intevation.artifactdatabase.rest; -import org.w3c.dom.Document; - -import org.restlet.ext.xml.DomRepresentation; - -import org.restlet.resource.ResourceException; - -import org.restlet.data.Response; -import org.restlet.data.Status; - -import org.restlet.data.MediaType; - -import org.apache.log4j.Logger; - -import de.intevation.artifactdatabase.XMLUtils; - -import org.restlet.representation.Representation; -import org.restlet.representation.EmptyRepresentation; - import java.io.IOException; +import org.apache.log4j.Logger; +import org.restlet.data.MediaType; +import org.restlet.data.Response; +import org.restlet.data.Status; +import org.restlet.ext.xml.DomRepresentation; +import org.restlet.representation.EmptyRepresentation; +import org.restlet.representation.Representation; +import org.restlet.resource.ResourceException; +import org.w3c.dom.Document; + +import de.intevation.artifactdatabase.XMLUtils; +import de.intevation.artifacts.ArtifactDatabase; +import de.intevation.artifacts.ArtifactDatabaseException; import de.intevation.artifacts.ArtifactNamespaceContext; -import de.intevation.artifacts.ArtifactDatabaseException; -import de.intevation.artifacts.ArtifactDatabase; /** * @author Sascha L. Teichmann (sascha.teichmann@intevation) @@ -78,7 +71,9 @@ try { return new DomRepresentation( MediaType.APPLICATION_XML, - db.createArtifactWithFactory(factory, getCallMeta())); + db.createArtifactWithFactory(factory, + getCallMeta(), + inputDocument)); } catch (ArtifactDatabaseException adbe) { Response response = getResponse(); diff -r 66f43d1e69eb -r d4c4c23847f5 artifacts/src/main/java/de/intevation/artifacts/Artifact.java --- a/artifacts/src/main/java/de/intevation/artifacts/Artifact.java Wed Jan 27 14:58:20 2010 +0000 +++ b/artifacts/src/main/java/de/intevation/artifacts/Artifact.java Mon Feb 01 13:54:05 2010 +0000 @@ -1,11 +1,11 @@ package de.intevation.artifacts; +import java.io.IOException; +import java.io.OutputStream; +import java.io.Serializable; + import org.w3c.dom.Document; -import java.io.Serializable; -import java.io.OutputStream; -import java.io.IOException; - /** * Interface of the core component of the artifact system: The artifact. *
@@ -91,11 +91,14 @@ * @param identifier The identifier from artifact database * @param factory The factory which created this artifact. * @param context The global context of the runtime system. + * @param data The data which can be use to setup an Artifact with + * more details. */ public void setup( String identifier, ArtifactFactory factory, - Object context); + Object context, + Document data); /** * Called from artifact database when an artifact is diff -r 66f43d1e69eb -r d4c4c23847f5 artifacts/src/main/java/de/intevation/artifacts/ArtifactDatabase.java --- a/artifacts/src/main/java/de/intevation/artifacts/ArtifactDatabase.java Wed Jan 27 14:58:20 2010 +0000 +++ b/artifacts/src/main/java/de/intevation/artifacts/ArtifactDatabase.java Mon Feb 01 13:54:05 2010 +0000 @@ -1,10 +1,10 @@ package de.intevation.artifacts; +import java.io.IOException; +import java.io.OutputStream; + import org.w3c.dom.Document; -import java.io.OutputStream; -import java.io.IOException; - /** * Interface of an artifact managing database. * @@ -26,7 +26,9 @@ ArtifactFactory getInternalArtifactFactory(String factoryName); - Document createArtifactWithFactory(String factory, CallMeta callMeta) + Document createArtifactWithFactory(String factory, + CallMeta callMeta, + Document data) throws ArtifactDatabaseException; Document describe(String artifact, Document data, CallMeta callMeta) diff -r 66f43d1e69eb -r d4c4c23847f5 artifacts/src/main/java/de/intevation/artifacts/ArtifactFactory.java --- a/artifacts/src/main/java/de/intevation/artifacts/ArtifactFactory.java Wed Jan 27 14:58:20 2010 +0000 +++ b/artifacts/src/main/java/de/intevation/artifacts/ArtifactFactory.java Mon Feb 01 13:54:05 2010 +0000 @@ -29,9 +29,10 @@ * an identifier. * @param context a context from the ArtifactDatabase. * @param identifier unique identifer for the new artifact + * @param data the data containing more details for the setup of an Artifact. * @return a new {@linkplain de.intevation.artifacts.Artifact Artifact} */ - Artifact createArtifact(String identifier, Object context); + Artifact createArtifact(String identifier, Object context, Document data); /** * Setup the factory with a given configuration