The line
service.createIndexer(name);
does not belong in the example. I was starting to play around with the possibility that  I needed to also create an Indexer, but stopped to write the post before trying it out. Obviously the argument "name" is not appropriate here, it was left over from the cut and paste on the previous line.

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
 
 

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

Reply via email to