Mercurial > dive4elements > framework
changeset 82:efe752c4f8b2
Call cleanup method to remove special data stored by an 'out'-target before exporting an artifact.
artifacts/trunk@810 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Mon, 22 Mar 2010 09:03:30 +0000 |
parents | e9c80fdfee13 |
children | 8c4638abd518 |
files | ChangeLog artifact-database/src/main/java/de/intevation/artifactdatabase/ArtifactDatabaseImpl.java artifact-database/src/main/java/de/intevation/artifactdatabase/DefaultArtifact.java artifact-database/src/main/java/de/intevation/artifactdatabase/ProxyArtifact.java artifacts/src/main/java/de/intevation/artifacts/Artifact.java |
diffstat | 5 files changed, 45 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- 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 <ingo.weinzierl@intevation.de> + + 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 <ingo.weinzierl@intevation.de> Issue208 (Artifact gets a new identifier after being imported)
--- 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); } });
--- 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:
--- 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:
--- 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: