kevinross 2003/07/14 14:04:08
Modified: java/src/org/apache/xindice/client/xmldb/xmlrpc
CollectionImpl.java
Log:
propagate XMLDBExceptions that are encountered instead of endlessly wrapping
them with 'unknown' errors.
Revision Changes Path
1.23 +51 -2
xml-xindice/java/src/org/apache/xindice/client/xmldb/xmlrpc/CollectionImpl.java
Index: CollectionImpl.java
===================================================================
RCS file:
/home/cvs/xml-xindice/java/src/org/apache/xindice/client/xmldb/xmlrpc/CollectionImpl.java,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -r1.22 -r1.23
--- CollectionImpl.java 10 Jul 2003 21:45:17 -0000 1.22
+++ CollectionImpl.java 14 Jul 2003 21:04:07 -0000 1.23
@@ -91,6 +91,9 @@
import org.xmldb.api.base.XMLDBException;
import org.xmldb.api.modules.XMLResource;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
/**
* Implementation of XML:DB's <code>Collection</code> interface using
* XML-RPC to interact with database server
@@ -99,6 +102,9 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Kimbro Staken</a>
*/
public class CollectionImpl extends XindiceCollection {
+
+ private static Log log =
LogFactory.getLog("org.apache.xindice.client.xmldb.xmlrpc");
+
/* path to XML-RPC service on database */
private static String XINDICE_SERVICE_LOCATION = "/Xindice/";
@@ -182,7 +188,8 @@
if (!serviceLocation.endsWith("/")) {
serviceLocation = serviceLocation + "/";
}
- System.out.println("serviceLocation=<" + serviceLocation + ">");
+
+ log.debug("serviceLocation=<" + serviceLocation + ">");
String xmlrpcURI = "http://" + hostPort + serviceLocation;
try {
@@ -203,6 +210,10 @@
client = null;
throw new XMLDBException(ErrorCodes.INVALID_URI, e);
}
+ catch(XMLDBException x){
+
+ throw x; // propagate any xmldb exception.
+ }
catch (Exception e) {
client = null;
@@ -291,6 +302,10 @@
params.put(RPCDefaultMessage.COLLECTION, collPath);
return ((Integer) runRemoteCommand("GetDocumentCount",
params)).intValue();
}
+ catch(XMLDBException x){
+
+ throw x; // propagate any xmldb exception.
+ }
catch (Exception e) {
throw new XMLDBException(ErrorCodes.UNKNOWN_ERROR, e);
@@ -334,6 +349,10 @@
((XMLResourceImpl) res).setId(name);
}
+ catch(XMLDBException x){
+
+ throw x; // propagate any xmldb exception.
+ }
catch (Exception e) {
throw new XMLDBException(ErrorCodes.UNKNOWN_ERROR, e);
@@ -375,10 +394,12 @@
return new CollectionImpl(hostPort, serviceLocation,
xmlrpcDriver, collPath + "/" + name);
}
catch (XMLDBException e) {
+
if (e.errorCode == ErrorCodes.NO_SUCH_COLLECTION) {
// per getChildCollection contract, return null
if not found
return null;
}
+
throw e;
}
}
@@ -402,6 +423,10 @@
params.put(RPCDefaultMessage.COLLECTION, collPath);
return (String) runRemoteCommand("CreateNewOID",
params);
}
+ catch(XMLDBException x){
+
+ throw x; // propagate any xmldb exception.
+ }
catch (Exception e) {
throw new XMLDBException(ErrorCodes.UNKNOWN_ERROR, e);
@@ -487,6 +512,10 @@
params.put(RPCDefaultMessage.NAME, res.getId());
runRemoteCommand("RemoveDocument", params);
}
+ catch(XMLDBException x){
+
+ throw x; // propagate any xmldb exception.
+ }
catch (Exception e) {
throw new XMLDBException(ErrorCodes.NO_SUCH_RESOURCE,
e);
}
@@ -516,6 +545,10 @@
return (String[]) list.toArray(new String[list.size()]);
}
+ catch(XMLDBException x){
+
+ throw x; // propagate any xmldb exception.
+ }
catch (Exception e) {
throw new XMLDBException(ErrorCodes.UNKNOWN_ERROR, e);
@@ -544,6 +577,10 @@
return result.intValue();
}
+ catch(XMLDBException x){
+
+ throw x; // propagate any xmldb exception.
+ }
catch (Exception e) {
throw new XMLDBException(ErrorCodes.UNKNOWN_ERROR, e);
}
@@ -571,6 +608,10 @@
return (String[]) list.toArray(new String[list.size()]);
}
+ catch(XMLDBException x){
+
+ throw x; // propagate any xmldb exception.
+ }
catch (Exception e) {
throw new XMLDBException(ErrorCodes.UNKNOWN_ERROR, e);
@@ -639,6 +680,10 @@
return getChildCollection(name);
}
+ catch(XMLDBException x){
+
+ throw x; // propagate any xmldb exception.
+ }
catch (Exception e) {
throw new XMLDBException(ErrorCodes.INVALID_COLLECTION,
"Cannot create child collection", e);
}
@@ -659,6 +704,10 @@
throw new
XMLDBException(ErrorCodes.INVALID_COLLECTION, "Cannot remove child collection");
}
+ }
+ catch(XMLDBException x){
+
+ throw x; // propagate any xmldb exception.
}
catch (Exception e) {