You are viewing a plain text version of this content. The canonical link for it is here.
Posted to xindice-dev@xml.apache.org by vg...@apache.org on 2004/02/19 04:06:44 UTC
cvs commit: xml-xindice/java/src/org/apache/xindice/server/rpc/messages RemoveCollection.java
vgritsenko 2004/02/18 19:06:44
Modified: java/src/org/apache/xindice/server/rpc/messages
RemoveCollection.java
Log:
Exception handling: throw XMLDB exception when necessary.
Revision Changes Path
1.10 +25 -21 xml-xindice/java/src/org/apache/xindice/server/rpc/messages/RemoveCollection.java
Index: RemoveCollection.java
===================================================================
RCS file: /home/cvs/xml-xindice/java/src/org/apache/xindice/server/rpc/messages/RemoveCollection.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- RemoveCollection.java 8 Feb 2004 02:54:17 -0000 1.9
+++ RemoveCollection.java 19 Feb 2004 03:06:44 -0000 1.10
@@ -19,8 +19,12 @@
package org.apache.xindice.server.rpc.messages;
import org.apache.xindice.core.Collection;
+import org.apache.xindice.core.FaultCodes;
import org.apache.xindice.server.rpc.RPCDefaultMessage;
+import org.xmldb.api.base.XMLDBException;
+import org.xmldb.api.base.ErrorCodes;
+
import java.util.Hashtable;
/**
@@ -31,31 +35,31 @@
public Hashtable execute(Hashtable message) throws Exception {
- if (!message.containsKey(COLLECTION)) {
- throw new Exception(MISSING_COLLECTION_PARAM);
+ final String parentName = (String) message.get(COLLECTION);
+ if (parentName == null) {
+ throw new XMLDBException(ErrorCodes.NO_SUCH_COLLECTION,
+ FaultCodes.COL_COLLECTION_NOT_FOUND,
+ MISSING_COLLECTION_PARAM);
}
- final String childName= (String) message.get(NAME);
- if (null == childName || childName.length() == 0) {
- throw new Exception(MISSING_NAME_PARAM);
+ final String childName = (String) message.get(NAME);
+ if (childName == null || childName.length() == 0) {
+ throw new XMLDBException(ErrorCodes.NO_SUCH_COLLECTION,
+ FaultCodes.COL_COLLECTION_NOT_FOUND,
+ MISSING_NAME_PARAM);
}
- Hashtable result = new Hashtable();
- try {
-
- Collection col = getCollection((String) message.get(COLLECTION) + "/" + childName);
- if (col == null) {
- // No such collection
- result.put(RESULT, "no");
- } else {
- col.dropCollection(col);
- result.put(RESULT, "yes");
- }
- } catch (Exception e) {
- // FIXME Exception handling
- result.put(RESULT, "no");
+ final Collection col = getCollection((String) message.get(COLLECTION));
+ if (col == null) {
+ // No such collection
+ throw new XMLDBException(ErrorCodes.NO_SUCH_COLLECTION,
+ FaultCodes.COL_COLLECTION_NOT_FOUND,
+ "Cannot remove child collection '" + childName + "': Parent collection '" + parentName + "' not found.");
}
+ final Hashtable result = new Hashtable();
+ col.dropCollection(col.getCollection(childName));
+ result.put(RESULT, "yes");
return result;
}
}