changeset 222:98695dc6d94d

The operation that adds an artifact to an artifact collection will now return the DESCRIBE document of the artifact collection. artifacts/trunk@1566 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Fri, 25 Mar 2011 08:27:07 +0000
parents f75f83af19e0
children 91333a41b234
files ChangeLog artifact-database/src/main/java/de/intevation/artifactdatabase/ArtifactDatabaseImpl.java
diffstat 2 files changed, 27 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Thu Mar 24 18:42:43 2011 +0000
+++ b/ChangeLog	Fri Mar 25 08:27:07 2011 +0000
@@ -1,3 +1,9 @@
+2011-03-25  Ingo Weinzierl <ingo@intevation.de>
+
+	* artifact-database/src/main/java/de/intevation/artifactdatabase/ArtifactDatabaseImpl.java:
+	  The operation that adds an artifact to an artifact collection will
+	  return the DESCRIBE document of the artifact collection now.
+
 2011-03-24  Ingo Weinzierl <ingo@intevation.de>
 
 	* artifact-database/src/main/java/de/intevation/artifactdatabase/DefaultArtifactCollection.java,
--- a/artifact-database/src/main/java/de/intevation/artifactdatabase/ArtifactDatabaseImpl.java	Thu Mar 24 18:42:43 2011 +0000
+++ b/artifact-database/src/main/java/de/intevation/artifactdatabase/ArtifactDatabaseImpl.java	Fri Mar 25 08:27:07 2011 +0000
@@ -88,6 +88,13 @@
         "No such artifact";
 
     /**
+     * Error message issued if a requested artifact is not found
+     * in this database.
+     */
+    public static final String NO_SUCH_COLLECTION =
+        "No such collection";
+
+    /**
      * Error message issued if the creation of an artifact failed.
      */
     public static final String CREATION_FAILED =
@@ -1174,6 +1181,7 @@
 
         if (c == null) {
             logger.warn("No collection found with identifier: " + collectionId);
+            throw new ArtifactDatabaseException(NO_SUCH_COLLECTION);
         }
 
         CallContext cc = new CollectionCallContext(
@@ -1257,19 +1265,23 @@
             artifactId,
             attr);
 
-        Document result = XMLUtils.newDocument();
+        if (!success) {
+            Document result = XMLUtils.newDocument();
 
-        XMLUtils.ElementCreator ec = new XMLUtils.ElementCreator(
-            result,
-            ArtifactNamespaceContext.NAMESPACE_URI,
-            ArtifactNamespaceContext.NAMESPACE_PREFIX);
+            XMLUtils.ElementCreator ec = new XMLUtils.ElementCreator(
+                result,
+                ArtifactNamespaceContext.NAMESPACE_URI,
+                ArtifactNamespaceContext.NAMESPACE_PREFIX);
 
-        Element root = ec.create("result");
-        result.appendChild(root);
+            Element root = ec.create("result");
+            result.appendChild(root);
 
-        root.setTextContent(success ? OPERATION_SUCCESSFUL: OPERATION_FAILURE);
+            root.setTextContent(OPERATION_FAILURE);
 
-        return result;
+            return result;
+        }
+
+        return describeCollection(collectionId, callMeta);
     }
 
     public Document removeCollectionArtifact(String collectionId, String artifactId,

http://dive4elements.wald.intevation.org