comparison artifact-database/src/main/java/de/intevation/artifactdatabase/ArtifactDatabaseImpl.java @ 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 dc687827439f
children 268c2972d4a7
comparison
equal deleted inserted replaced
161:e4a1562dfc21 162:4ac91485b4e0
202 /** 202 /**
203 * Error message issued if the creation of a collection failed. 203 * Error message issued if the creation of a collection failed.
204 */ 204 */
205 public static final String COLLECTION_CREATION_FAILED = 205 public static final String COLLECTION_CREATION_FAILED =
206 "Creation of collection failed"; 206 "Creation of collection failed";
207
208 /**
209 * XPath to figure out the name of a collection described in the incoming
210 * document.
211 */
212 public static final String XPATH_COLLECTION_NAME =
213 "/art:action/art:type/art:collection/@name";
207 214
208 215
209 /** 216 /**
210 * Inner class that implements the call context handed 217 * Inner class that implements the call context handed
211 * to the methods calls describe(), feed(), etc. of the artifact. 218 * to the methods calls describe(), feed(), etc. of the artifact.
1120 1127
1121 if (acf == null) { 1128 if (acf == null) {
1122 throw new ArtifactDatabaseException(NO_SUCH_FACTORY); 1129 throw new ArtifactDatabaseException(NO_SUCH_FACTORY);
1123 } 1130 }
1124 1131
1125 // FIXME: fetch name from incoming document 1132 String name = XMLUtils.xpathString(
1126 String name = "Collection-" + new java.util.Date(); 1133 data, XPATH_COLLECTION_NAME, ArtifactNamespaceContext.INSTANCE);
1134
1135 logger.debug("Create new collection with name: " + name);
1127 1136
1128 ArtifactCollection ac = backend.createCollection( 1137 ArtifactCollection ac = backend.createCollection(
1129 ownerId, name, acf, data, context); 1138 ownerId, name, acf, data, context);
1130 1139
1131 if (ac == null) { 1140 if (ac == null) {
1146 1155
1147 return result; 1156 return result;
1148 } 1157 }
1149 1158
1150 public Document deleteCollection(String collectionId, CallMeta callMeta) 1159 public Document deleteCollection(String collectionId, CallMeta callMeta)
1151 throws ArtifactDatabaseException { 1160 throws ArtifactDatabaseException
1152 throw new ArtifactDatabaseException("Not implemented, yet!"); 1161 {
1162 logger.debug("Delete collection: " + collectionId);
1163
1164 Document result = XMLUtils.newDocument();
1165
1166 XMLUtils.ElementCreator ec = new XMLUtils.ElementCreator(
1167 result,
1168 ArtifactNamespaceContext.NAMESPACE_URI,
1169 ArtifactNamespaceContext.NAMESPACE_PREFIX);
1170
1171 Element root = ec.create("result");
1172 result.appendChild(root);
1173
1174 boolean success = backend.deleteCollection(collectionId);
1175
1176 root.setTextContent(success ? OPERATION_SUCCESSFUL: OPERATION_FAILURE);
1177
1178 return result;
1153 } 1179 }
1154 1180
1155 public Document getCollectionAttribute(String collectionId, String artifactId, 1181 public Document getCollectionAttribute(String collectionId, String artifactId,
1156 CallMeta callMeta) throws ArtifactDatabaseException { 1182 CallMeta callMeta) throws ArtifactDatabaseException {
1157 throw new ArtifactDatabaseException("Not implemented, yet!"); 1183 throw new ArtifactDatabaseException("Not implemented, yet!");

http://dive4elements.wald.intevation.org