Mercurial > dive4elements > framework
changeset 162:4ac91485b4e0
Implemented the deleteCollection() interface method in the artifact database.
artifacts/trunk@1387 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Thu, 03 Mar 2011 13:56:27 +0000 |
parents | e4a1562dfc21 |
children | 28dea2714e90 |
files | ChangeLog artifact-database/src/main/java/de/intevation/artifactdatabase/ArtifactDatabaseImpl.java |
diffstat | 2 files changed, 37 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- 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 <ingo@intevation.de> + + * 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 <ingo@intevation.de> * artifact-database/src/main/java/de/intevation/artifactdatabase/Backend.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,