changeset 166:89db80380f7f

Implemented the method addCollectionArtifact() in the artifact database. artifacts/trunk@1391 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Thu, 03 Mar 2011 14:49:09 +0000
parents 81ad657569e1
children c9c27aca2f70
files ChangeLog artifact-database/src/main/java/de/intevation/artifactdatabase/ArtifactDatabaseImpl.java
diffstat 2 files changed, 26 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Thu Mar 03 14:30:21 2011 +0000
+++ b/ChangeLog	Thu Mar 03 14:49:09 2011 +0000
@@ -1,3 +1,8 @@
+2011-03-03  Ingo Weinzierl <ingo@intevation.de>
+
+	* artifact-database/src/main/java/de/intevation/artifactdatabase/ArtifactDatabaseImpl.java:
+	  Implemented the interface method addCollectionArtifact().
+
 2011-03-03	Sascha L. Teichmann	<sascha.teichmann@intevation.de>
 
 	* artifact-database/src/main/java/de/intevation/artifactdatabase/LazyBackendUser.java:
--- a/artifact-database/src/main/java/de/intevation/artifactdatabase/ArtifactDatabaseImpl.java	Thu Mar 03 14:30:21 2011 +0000
+++ b/artifact-database/src/main/java/de/intevation/artifactdatabase/ArtifactDatabaseImpl.java	Thu Mar 03 14:49:09 2011 +0000
@@ -1230,8 +1230,27 @@
     }
 
     public Document addCollectionArtifact(String collectionId, String artifactId,
-        CallMeta callMeta) throws ArtifactDatabaseException {
-        throw new ArtifactDatabaseException("Not implemented, yet!");
+        CallMeta callMeta) throws ArtifactDatabaseException
+    {
+        logger.debug(
+            "Add artifact '" + artifactId + "' collection '" +collectionId+"'");
+
+        boolean success = backend.addCollectionArtifact(
+            collectionId, artifactId);
+
+        Document result = XMLUtils.newDocument();
+
+        XMLUtils.ElementCreator ec = new XMLUtils.ElementCreator(
+            result,
+            ArtifactNamespaceContext.NAMESPACE_URI,
+            ArtifactNamespaceContext.NAMESPACE_PREFIX);
+
+        Element root = ec.create("result");
+        result.appendChild(root);
+
+        root.setTextContent(success ? OPERATION_SUCCESSFUL: OPERATION_FAILURE);
+
+        return result;
     }
 
     public Document removeCollectionArtifact(String collectionId, String artifactId,

http://dive4elements.wald.intevation.org