String collectionConfig =Note that the filer class needs to be on the new package structure. I guess that in the bowls the InstantiationException is caught and passed back up as a generic NO MANAGER. Kimbro, ever consider adding log4j into Xindice? It would take a bit of grunt work to get into place in a meaningful way, but I think in the end it will save a lot of hours of frustration in looking for odd behaviour. Just a thought.
"<collection compressed=\"true\" name=\""
+ name
+ "\">"
+ " <filer class=\"org.apache.xindice.core.filer.BTreeFiler\" gzip=\"true\"/>"
+ "</collection>";
Cheerio,
Joel
Joel Rosi-Schwartz wrote:
Kimbro Staken wrote:> On Tuesday, January 29, 2002, at 07:51 AM, Joel Rosi-Schwartz wrote:
>
> > Well, I finally realized that the creation code I was using is copied
> > directly from the dbXML Developers Guide 0.5 and that the API for
> > theCollectionManager has a simpler createCollection() method that takes
> > only a name as the parameter and then creates a default collection. Using
> > this method clears all of my problems.
> >
> > I am still wondering about the original problem, however. Is the Guide
> > wrong, is the release broken or am I applying this wrongly? Is there more
> > information on the usage of the collection configuration facility? Is
> > this useful to pursue or is it best in general to stay with the default
> > collection creation mechanism?
> >
>
> There are two services you can use to create collections,
> CollectionManager which is Xindice specific and
> CollectionManagementService that is part of the XML:DB API. They're both
> actually implemented by the same class and the simpler method that you're
> calling is part of CollectionManagementService.
>
> CollectionManagementService just allows creation and deletion of
> collections, but not indexes or XMLObjects. In theory it should work for
> more then one database though. If you can get away with the limitations
> you should use this service.
>
> CollectionManager is specific to Xindice and exposes all the other
> management functionality, plus different methods for creating and deleting
> collections. If you need more advanced functionality this is the only way
> to get it.Thanks Kimbro, that clears up a lot. I have taken a new look at the API and the
separation of concerns between xmldb and Xindice are a bit clearer now.In fact, however, the limitations are not acceptable in my project, I will
certainly need to take advantage of indexes and possibly XMLObjects. So this
leaves me with wondering why the code that I copied does not work in my case. Is
the Developer's Guide behind the times or am I applying it wrongly? btw, the
creation goes without any indication of a problem, it is not until I try to access
the collection that I get the exception.> > Thanks,
> > Joel
> >
> >
> > Joel Rosi-Schwartz wrote:
> >
> > Hi,
> >
> > I am moving from xmldb beta 4 to the current cvs Xindice 1.0rc1 and am
> > having some problems with the creation of collections that I did not see
> > previously. I am wondering whether something I am not aware of has
> > changed or if there is now a bug in the system.
> >
> > I am creating the new collections thus:
> >
> > private boolean createCollection(String name, String path) {
> > System.err.println("createCollection " + name + " " + path);
> > Collection col = myServer.getCollection(path);
> >
> > if (col == null) return false;
> >
> > try {
> > CollectionManager service = (CollectionManager)
> > col.getService("CollectionManager", "1.0");
> >
> > // Build up the Collection XML configuration.
> > String collectionConfig =
> > "<collection compressed=\"true\" name=\""
> > + name
> > + "\">"
> > + " <filer class=\"org.dbxml.core.filer.BTreeFiler\" gzip=\"true\
> > "/>"
> > + "</collection>";
> >
> > service.createCollection(name, DOMParser.toDocument(collectionConfig)
> > );
> > service.createIndexer(name);
> >
> > System.err.println("Collection " + name + " created.");
> > }
> > catch (XMLDBException e) {
> > System.err.println("XML:DB Exception occured " + e.errorCode);
> > return false;
> > }
> > catch (XindiceException e) {
> > System.err.println("XML:DB Exception occured " + e.getMessage());
> > return false;
> > }
> > }
> > finally {
> > myServer.closeCollection(col);
> > }
> >
> > return true;
> > }
> >
> > When I try to add a new an exception if thrown:
> >
> > XML:DB Exception occured 1
> > org.xmldb.api.base.XMLDBException: Collection No IndexManager
> > at org.apache.xindice.core.FaultCodes.createXMLDBException(Unknown
> > Source)
> > at org.apache.xindice.client.xmldb.CollectionImpl.storeResource(Unknown
> > Source)
> > at
> > com.xindice.proto.internal.core.internuncio.Mediator.addDocument(Mediator.
> > java:134)
> > at
> > com.xindice.proto.internal.core.internuncio.Mediator.addDocument(Mediator.
> > java:98)
> > at
> > com.xindice.proto.internal.core.internuncio.Mediator.main(Mediator.java:301)
> >
> > I am using the following code to add the document:
> >
> > public boolean addDocument(DocumentDescriptor descriptor, boolean
> > overwrite) {
> >
> > Collection col = myServer.getCollection(descriptor.getCollectionPath())
> > ;
> >
> > if (col == null) {
> > String error =
> > "Collection \""
> > + descriptor.getCollectionPath()
> > + "\" not found, document \""
> > + descriptor.getName()
> > + "\" skipped";
> >
> > System.out.println(error);
> > descriptor.setError(error);
> > return false;
> > }
> >
> > try {
> > if (!overwrite) {
> > // This code also throws an exception, but I believe
> > // that it should simply return null
> > try {
> > Resource res = col.getResource(descriptor.getName());
> >
> > if (res == null) {
> > System.out.println("Document \"" + descriptor.getName() + "\"
> > skipped");
> > return true;
> > }
> > }
> > catch (XMLDBException ignore) {
> > }
> > }
> >
> > XMLResource document = (XMLResource)
> > col.createResource(descriptor.getName(), "XMLResource");
> > document.setContent(descriptor.getDocument());
> > // throws exception here
> > col.storeResource(document);
> > System.out.println("Document " + descriptor.getName() + " inserted");
> > }
> > catch (XMLDBException e) {
> > System.err.println("XML:DB Exception occured " + e.errorCode);
> > e.printStackTrace();
> > descriptor.setError("XML:DB Exception occured " + e.errorCode);
> > return false;
> > }
> > finally {
> > myServer.closeCollection(col);
> > }
> >
> > return true;
> > }
> >
> >
> > Any insights would be very appreciated.
> >
> > Tia,
> > Joel
> >
> >
> >
> >
> Kimbro Staken
> XML Database Software, Consulting and Writing
> http://www.xmldatabases.org/
begin:vcard n:Rosi-Schwartz;Joel tel;fax:+44 1435 831011 tel;home:+44 1435 831010 tel;work:+44 1435 831010 x-mozilla-html:TRUE org:Techne Research Limited version:2.1 email;internet:[EMAIL PROTECTED] title:Architect adr;quoted-printable:;;Downgate Farmhouse=0D=0AFurnace Lane;Warbleton near Heathfield;East Sussex;TN21 9AZ;United Kingdom fn:Joel Rosi-Schwartz end:vcard
