# HG changeset patch # User Ingo Weinzierl # Date 1269248610 0 # Node ID efe752c4f8b244e3ce148a7582172858b20b86f0 # Parent e9c80fdfee13b90147d4297be78de2aded8846d8 Call cleanup method to remove special data stored by an 'out'-target before exporting an artifact. artifacts/trunk@810 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r e9c80fdfee13 -r efe752c4f8b2 ChangeLog --- a/ChangeLog Fri Mar 19 14:57:23 2010 +0000 +++ b/ChangeLog Mon Mar 22 09:03:30 2010 +0000 @@ -1,3 +1,24 @@ +2010-03-22 Ingo Weinzierl + + Issue208 (Remove special data of an 'out'-target before exporting + artifacts) + + * artifacts/src/main/java/de/intevation/artifacts/Artifact.java: Added a + 'cleanup(Object context)' method to the interface definition of artifacts. + This method should be called before exporting an artifact and should + remove data stored on an artifact (or its current state) which have been + written by an 'out'. + + * artifact-database/src/main/java/de/intevation/artifactdatabase/DefaultArtifact.java: + Default implementation of cleanup method - nothing is done here yet. + Override this method if an artifact needs to be cleaned before an export. + + * artifact-database/src/main/java/de/intevation/artifactdatabase/ProxyArtifact.java: + Call cleanup method on the proxied artifact if proxied is existing. + + * artifact-database/src/main/java/de/intevation/artifactdatabase/ArtifactDatabaseImpl.java: + Call cleanup method before exporting an artifact as xml. + 2010-03-19 Ingo Weinzierl Issue208 (Artifact gets a new identifier after being imported) diff -r e9c80fdfee13 -r efe752c4f8b2 artifact-database/src/main/java/de/intevation/artifactdatabase/ArtifactDatabaseImpl.java --- a/artifact-database/src/main/java/de/intevation/artifactdatabase/ArtifactDatabaseImpl.java Fri Mar 19 14:57:23 2010 +0000 +++ b/artifact-database/src/main/java/de/intevation/artifactdatabase/ArtifactDatabaseImpl.java Mon Mar 22 09:03:30 2010 +0000 @@ -476,7 +476,13 @@ int id ) { factoryName[0] = factory.getName(); - return bytes; + + ArtifactSerializer serializer = factory.getSerializer(); + + Artifact artifact = serializer.fromBytes(bytes); + artifact.cleanup(context); + + return serializer.toBytes(artifact); } }); diff -r e9c80fdfee13 -r efe752c4f8b2 artifact-database/src/main/java/de/intevation/artifactdatabase/DefaultArtifact.java --- a/artifact-database/src/main/java/de/intevation/artifactdatabase/DefaultArtifact.java Fri Mar 19 14:57:23 2010 +0000 +++ b/artifact-database/src/main/java/de/intevation/artifactdatabase/DefaultArtifact.java Mon Mar 22 09:03:30 2010 +0000 @@ -94,5 +94,8 @@ logger.debug("DefaultArtifact.endOfLife: " + identifier); } } + + public void cleanup(Object context) { + } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8: diff -r e9c80fdfee13 -r efe752c4f8b2 artifact-database/src/main/java/de/intevation/artifactdatabase/ProxyArtifact.java --- a/artifact-database/src/main/java/de/intevation/artifactdatabase/ProxyArtifact.java Fri Mar 19 14:57:23 2010 +0000 +++ b/artifact-database/src/main/java/de/intevation/artifactdatabase/ProxyArtifact.java Mon Mar 22 09:03:30 2010 +0000 @@ -118,5 +118,12 @@ super.endOfLife(context); } } + + public void cleanup(Object context) { + if (proxied != null) + proxied.cleanup(context); + else + super.cleanup(context); + } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8: diff -r e9c80fdfee13 -r efe752c4f8b2 artifacts/src/main/java/de/intevation/artifacts/Artifact.java --- a/artifacts/src/main/java/de/intevation/artifacts/Artifact.java Fri Mar 19 14:57:23 2010 +0000 +++ b/artifacts/src/main/java/de/intevation/artifacts/Artifact.java Mon Mar 22 09:03:30 2010 +0000 @@ -116,5 +116,12 @@ * @param context The global context of the runtime system. */ public void endOfLife(Object context); + + + /** + * Called from artifact database before an artifact is + * going to be exported as xml document. + */ + public void cleanup(Object context); } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8: