# HG changeset patch # User Ingo Weinzierl # Date 1299160587 0 # Node ID 4ac91485b4e06439c2ad87eb45b5690130ec2858 # Parent e4a1562dfc21c97e9900d0a36e4c9af8fc6c71b3 Implemented the deleteCollection() interface method in the artifact database. artifacts/trunk@1387 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r e4a1562dfc21 -r 4ac91485b4e0 ChangeLog --- a/ChangeLog Thu Mar 03 13:53:55 2011 +0000 +++ b/ChangeLog Thu Mar 03 13:56:27 2011 +0000 @@ -1,3 +1,10 @@ +2011-03-03 Ingo Weinzierl + + * artifact-database/src/main/java/de/intevation/artifactdatabase/ArtifactDatabaseImpl.java: + Two things: the collection get names specified in the incoming document + of the POST request, and the deleteCollection() interface method is now + implemented. + 2011-03-03 Ingo Weinzierl * artifact-database/src/main/java/de/intevation/artifactdatabase/Backend.java: diff -r e4a1562dfc21 -r 4ac91485b4e0 artifact-database/src/main/java/de/intevation/artifactdatabase/ArtifactDatabaseImpl.java --- a/artifact-database/src/main/java/de/intevation/artifactdatabase/ArtifactDatabaseImpl.java Thu Mar 03 13:53:55 2011 +0000 +++ b/artifact-database/src/main/java/de/intevation/artifactdatabase/ArtifactDatabaseImpl.java Thu Mar 03 13:56:27 2011 +0000 @@ -205,6 +205,13 @@ public static final String COLLECTION_CREATION_FAILED = "Creation of collection failed"; + /** + * XPath to figure out the name of a collection described in the incoming + * document. + */ + public static final String XPATH_COLLECTION_NAME = + "/art:action/art:type/art:collection/@name"; + /** * Inner class that implements the call context handed @@ -1122,8 +1129,10 @@ throw new ArtifactDatabaseException(NO_SUCH_FACTORY); } - // FIXME: fetch name from incoming document - String name = "Collection-" + new java.util.Date(); + String name = XMLUtils.xpathString( + data, XPATH_COLLECTION_NAME, ArtifactNamespaceContext.INSTANCE); + + logger.debug("Create new collection with name: " + name); ArtifactCollection ac = backend.createCollection( ownerId, name, acf, data, context); @@ -1148,8 +1157,25 @@ } public Document deleteCollection(String collectionId, CallMeta callMeta) - throws ArtifactDatabaseException { - throw new ArtifactDatabaseException("Not implemented, yet!"); + throws ArtifactDatabaseException + { + logger.debug("Delete collection: " + collectionId); + + 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); + + boolean success = backend.deleteCollection(collectionId); + + root.setTextContent(success ? OPERATION_SUCCESSFUL: OPERATION_FAILURE); + + return result; } public Document getCollectionAttribute(String collectionId, String artifactId,