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 fe...@apache.org on 2002/10/03 22:47:59 UTC
cvs commit: xml-xindice/java/src/org/apache/xindice/client/xmldb/xmlrpc CollectionImpl.java DatabaseImpl.java
fern 2002/10/03 13:47:59
Modified: java/src/org/apache/xindice/client/xmldb/embed
CollectionImpl.java DatabaseImpl.java
java/src/org/apache/xindice/client/xmldb/xmlrpc
CollectionImpl.java DatabaseImpl.java
Log:
- all forms of getCollection should be returning null instead of
exceptions, for "no collection"
Submitted by: Terry Rosenbaum
Revision Changes Path
1.6 +27 -3 xml-xindice/java/src/org/apache/xindice/client/xmldb/embed/CollectionImpl.java
Index: CollectionImpl.java
===================================================================
RCS file: /home/cvs/xml-xindice/java/src/org/apache/xindice/client/xmldb/embed/CollectionImpl.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- CollectionImpl.java 23 Sep 2002 23:23:23 -0000 1.5
+++ CollectionImpl.java 3 Oct 2002 20:47:58 -0000 1.6
@@ -108,6 +108,10 @@
throw new XMLDBException(ErrorCodes.NO_SUCH_COLLECTION,
"Collection not found: " + collPath);
}
+ if(this.col == null) {
+ throw new XMLDBException(ErrorCodes.NO_SUCH_COLLECTION,
+ "Collection not found: " + collPath);
+ }
}
/**
@@ -224,8 +228,17 @@
throw new XMLDBException(ErrorCodes.INVALID_COLLECTION);
}
+ try {
return new CollectionImpl(db, collPath + "/" + collName);
}
+ catch(XMLDBException e) {
+ if(e.errorCode == ErrorCodes.NO_SUCH_COLLECTION) {
+ // per getChildCollection contract, return null if not found
+ return null;
+ }
+ throw e;
+ }
+ }
/**
* Creates a new identifier that can be used as name for a resource in this
@@ -270,9 +283,18 @@
return null;
}
+ try {
return new CollectionImpl(db, collPath.substring(0,
collPath.lastIndexOf('/')));
}
+ catch(XMLDBException e) {
+ if(e.errorCode == ErrorCodes.NO_SUCH_COLLECTION) {
+ // per getParentCollection contract, return null if no parent
+ return null;
+ }
+ throw e;
+ }
+ }
/**
* Removes a (XML) resource from this collection.
@@ -459,8 +481,7 @@
* Removes child collection from this collection
*
* @param childName name of child collection
- * @exception XMLDBException thrown if collection createion fails for some
- * reason
+ * @exception XMLDBException if an error occurs or the collection does not exist
*/
public void removeCollection(String childName) throws XMLDBException {
@@ -480,6 +501,7 @@
* @exception XMLDBException
*/
public String[] listIndexers() throws XMLDBException {
+ checkOpen();
try {
return col.listIndexers();
}
@@ -496,6 +518,7 @@
* @exception XMLDBException
*/
public void createIndexer(Document configuration) throws XMLDBException {
+ checkOpen();
try {
col.createIndexer(new Configuration(configuration, false));
}
@@ -511,6 +534,7 @@
* @exception XMLDBException
*/
public void dropIndexer(String name) throws XMLDBException {
+ checkOpen();
try {
col.dropIndexer(col.getIndexer(name));
}
1.3 +10 -1 xml-xindice/java/src/org/apache/xindice/client/xmldb/embed/DatabaseImpl.java
Index: DatabaseImpl.java
===================================================================
RCS file: /home/cvs/xml-xindice/java/src/org/apache/xindice/client/xmldb/embed/DatabaseImpl.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- DatabaseImpl.java 18 Sep 2002 02:38:04 -0000 1.2
+++ DatabaseImpl.java 3 Oct 2002 20:47:59 -0000 1.3
@@ -182,7 +182,16 @@
colName = "/";
}
+ try {
return new CollectionImpl(db, colName);
+ }
+ catch(XMLDBException e) {
+ if(e.errorCode == ErrorCodes.NO_SUCH_COLLECTION) {
+ // per getCollection contract, return null if not found
+ return null;
+ }
+ throw e;
+ }
}
else {
throw new XMLDBException(ErrorCodes.INVALID_URI,
1.12 +27 -4 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.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- CollectionImpl.java 23 Sep 2002 23:06:19 -0000 1.11
+++ CollectionImpl.java 3 Oct 2002 20:47:59 -0000 1.12
@@ -135,9 +135,11 @@
runRemoteCommand("GetCollectionConfiguration", params);
} catch (MalformedURLException e) {
+ client = null;
throw new XMLDBException(ErrorCodes.INVALID_URI);
} catch (Exception e) {
+ client = null;
throw new XMLDBException(ErrorCodes.NO_SUCH_COLLECTION,
"Collection not found: " + collPath);
}
@@ -283,9 +285,8 @@
* Returns child collection of this collection with specified name
*
* @param colName child's name
- * @return the child collection
- * @exception XMLDBException thrown if there is no such child, or some
- * other connection error occurred
+ * @return the child collection or null if not found
+ * @exception XMLDBException if an error occurs
*/
public Collection getChildCollection(String collName) throws XMLDBException {
@@ -294,8 +295,17 @@
throw new XMLDBException(ErrorCodes.INVALID_COLLECTION);
}
+ try {
return new CollectionImpl(hostPort, collPath + "/" + collName);
}
+ catch(XMLDBException e) {
+ if(e.errorCode == ErrorCodes.NO_SUCH_COLLECTION) {
+ // per getChildCollection contract, return null if not found
+ return null;
+ }
+ throw e;
+ }
+ }
/**
* Creates a new identifier that can be used as name for a resource in this
@@ -344,9 +354,18 @@
return null;
}
+ try {
return new CollectionImpl(hostPort, collPath.substring(0,
collPath.lastIndexOf('/')));
}
+ catch(XMLDBException e) {
+ if(e.errorCode == ErrorCodes.NO_SUCH_COLLECTION) {
+ // per getParentCollection contract, return null if no parent
+ return null;
+ }
+ throw e;
+ }
+ }
/**
* Removes a (XML) resource from this collection.
@@ -580,6 +599,7 @@
* @exception XMLDBException
*/
public String[] listIndexers() throws XMLDBException {
+ checkOpen();
try {
Hashtable params = new Hashtable();
params.put(RPCDefaultMessage.COLLECTION, collPath);
@@ -600,6 +620,7 @@
* @exception XMLDBException
*/
public void createIndexer(Document configuration) throws XMLDBException {
+ checkOpen();
try {
Hashtable params = new Hashtable();
params.put(RPCDefaultMessage.COLLECTION, collPath);
@@ -620,6 +641,7 @@
* @exception XMLDBException
*/
public void dropIndexer(String name) throws XMLDBException {
+ checkOpen();
try {
Hashtable params = new Hashtable();
params.put(RPCDefaultMessage.COLLECTION, collPath);
@@ -639,6 +661,7 @@
* @exception XMLDBException
*/
public void shutdown() throws XMLDBException {
+ checkOpen();
try {
Hashtable params = new Hashtable();
1.4 +10 -1 xml-xindice/java/src/org/apache/xindice/client/xmldb/xmlrpc/DatabaseImpl.java
Index: DatabaseImpl.java
===================================================================
RCS file: /home/cvs/xml-xindice/java/src/org/apache/xindice/client/xmldb/xmlrpc/DatabaseImpl.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- DatabaseImpl.java 21 Jul 2002 02:52:17 -0000 1.3
+++ DatabaseImpl.java 3 Oct 2002 20:47:59 -0000 1.4
@@ -140,7 +140,16 @@
hostPort = "127.0.0.1:8080";
}
+ try {
return new CollectionImpl(hostPort, collPath);
+ }
+ catch(XMLDBException e) {
+ if(e.errorCode == ErrorCodes.NO_SUCH_COLLECTION) {
+ // per getCollection contract, return null if not found
+ return null;
+ }
+ throw e;
+ }
}
/**
Error Codes
Posted by Dirk Bromberg <br...@tzi.de>.
Hi,
is there an overview of all error codes somewhere ???
i got an error with: CODE: 202 at xindice 1.0 ....
greets
Dirk Bromberg
Re: cvs commit:
xml-xindice/java/src/org/apache/xindice/client/xmldb/xmlrpc
CollectionImpl.java DatabaseImpl.java
Posted by Vladimir Bossicard <vl...@adnovum.com>.
> - all forms of getCollection should be returning null instead of
> exceptions, for "no collection"
Could we start the good practice to _first_ write a test that reveals a
bug before fixing it? I know it's extra work but it brings a lot to the
project:
- the bug is easily reproductible by everybody
- the tests are designed to be run in the embeded and/or xmlprc modes.
It's then easy to make sure that _all_ implementations follow the same
contracts.
If nobody's writing nor executing the tests, why do we have them?
-Vladimir
any notes on architecture?
Posted by babak farhang <ba...@topoweb.com>.
Hi folks,
I just signed up for the project's mailing list,
today. I was wondering if any one has written up
anything about the general architecture of xindice.
I'm less interested in the exposed API, than in how
XML structures are persisted by the engine.
Is this an ACID engine? Is that a goal?
-b.