changeset 81:e9c80fdfee13

Set new identifiers on artifacts after an artifact import. artifacts/trunk@809 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Fri, 19 Mar 2010 14:57:23 +0000
parents 8447467cef86
children efe752c4f8b2
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, 42 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Fri Mar 19 09:34:40 2010 +0000
+++ b/ChangeLog	Fri Mar 19 14:57:23 2010 +0000
@@ -1,3 +1,21 @@
+2010-03-19  Ingo Weinzierl <ingo.weinzierl@intevation.de>
+
+	  Issue208 (Artifact gets a new identifier after being imported)
+
+	* artifacts/src/main/java/de/intevation/artifacts/Artifact.java: Added a new
+	  method setIdentifier(String identifier).
+
+	* artifact-database/src/main/java/de/intevation/artifactdatabase/DefaultArtifact.java:
+	  Default implementation of setIdentifier(String identifier) to give an 
+	  artifact a new identifier.
+
+	* artifact-database/src/main/java/de/intevation/artifactdatabase/ArtifactDatabaseImpl.java:
+	  Set a new identifier on an artifact after deserializing it.
+
+	* artifact-database/src/main/java/de/intevation/artifactdatabase/ProxyArtifact.java:
+	  Set the identifier of the proxied artifact right after setting its own
+	  identifier.
+
 2010-03-19  Ingo Weinzierl <ingo.weinzierl@intevation.de>
 
 	  Issue208 (Artifact import)
--- a/artifact-database/src/main/java/de/intevation/artifactdatabase/ArtifactDatabaseImpl.java	Fri Mar 19 09:34:40 2010 +0000
+++ b/artifact-database/src/main/java/de/intevation/artifactdatabase/ArtifactDatabaseImpl.java	Fri Mar 19 14:57:23 2010 +0000
@@ -605,6 +605,7 @@
             throw new ArtifactDatabaseException(INVALID_ARTIFACT);
         }
 
+        artifact.setIdentifier(backend.newIdentifier());
         PersistentArtifact persistentArtifact;
 
         try {
--- a/artifact-database/src/main/java/de/intevation/artifactdatabase/DefaultArtifact.java	Fri Mar 19 09:34:40 2010 +0000
+++ b/artifact-database/src/main/java/de/intevation/artifactdatabase/DefaultArtifact.java	Fri Mar 19 14:57:23 2010 +0000
@@ -23,6 +23,15 @@
     public DefaultArtifact() {
     }
 
+
+    public void setIdentifier(String identifier) {
+        if (logger.isDebugEnabled()) {
+            logger.debug("Change identifier: "
+                + this.identifier + " -> " + identifier);
+        }
+        this.identifier = identifier;
+    }
+
     public String identifier() {
         if (logger.isDebugEnabled()) {
             logger.debug("DefaultArtifact.identifier: " + identifier);
--- a/artifact-database/src/main/java/de/intevation/artifactdatabase/ProxyArtifact.java	Fri Mar 19 09:34:40 2010 +0000
+++ b/artifact-database/src/main/java/de/intevation/artifactdatabase/ProxyArtifact.java	Fri Mar 19 14:57:23 2010 +0000
@@ -37,6 +37,13 @@
         this.proxied = proxied;
     }
 
+    public void setIdentifier(String identifier) {
+        this.identifier = identifier;
+
+        if (proxied != null)
+            proxied.setIdentifier(identifier);
+    }
+
     protected void checkReplacement(CallContext callContext) {
         Object replacement = callContext.getContextValue(REPLACE_PROXY);
         if (replacement instanceof Artifact) {
--- a/artifacts/src/main/java/de/intevation/artifacts/Artifact.java	Fri Mar 19 09:34:40 2010 +0000
+++ b/artifacts/src/main/java/de/intevation/artifacts/Artifact.java	Fri Mar 19 14:57:23 2010 +0000
@@ -38,6 +38,13 @@
 public interface Artifact
 extends          Serializable
 {
+
+    /**
+     * Set a new identifier for this artifact.
+     * @param identifier New identifier for this artifact.
+     */
+    public void setIdentifier(String identifier);
+
     /**
      * Identify this artifact.
      * @return Returns unique string to identify this artifact globally.

http://dive4elements.wald.intevation.org