/*
  * @{InheritDoc}
  */
 public List<String[]> getAllIndexes() {
   List<String[]> indexes = new ArrayList<String[]>();
   XmlIndexSpecification indexSpec = null;
   XmlContainer cont = null;
   XmlTransaction trans = null;
   try {
     cont = xmlManager.openContainer(containerName);
     trans = xmlManager.createTransaction();
     indexSpec = cont.getIndexSpecification();
     XmlIndexDeclaration indexDeclaration = null;
     while ((indexDeclaration = (indexSpec.next())) != null) {
       indexes.add(new String[] {indexDeclaration.name, indexDeclaration.index});
     }
     return indexes;
   } catch (XmlException e) {
     logger.logWarning(this.getClass().toString(), "Listing indexes failed! - Xml exeption");
     return null;
   } finally {
     indexSpec.delete();
     commitAndClose(trans, cont);
   }
 }
Beispiel #2
0
  // Method used to replace an index with a new index type
  private static void replaceAnIndex(
      XmlManager mgr,
      XmlContainer container,
      String URI,
      String nodeName,
      String indexType,
      XmlTransaction txn)
      throws Throwable {
    System.out.println("Replacing index specification " + indexType + " for node " + nodeName);

    // Retrieve the index specification from the container
    XmlIndexSpecification idxSpec = container.getIndexSpecification(txn);

    // See what indexes exist on the container
    int count = 0;
    System.out.println("Before index replacement.");
    XmlIndexDeclaration idxDecl = null;
    while ((idxDecl = (idxSpec.next())) != null) {
      System.out.println(
          "\tFor node '" + idxDecl.name + "', found index: '" + idxDecl.index + "'.");
      count++;
    }

    System.out.println(count + " indexes found.");

    // Replace the container's index specification with a new specification
    idxSpec.replaceIndex(URI, nodeName, indexType);

    // Set the specification back to the container
    container.setIndexSpecification(txn, idxSpec, mgr.createUpdateContext());

    // Look at the indexes again to make sure our replacement took.
    count = 0;
    idxSpec.reset();
    System.out.println("After index replacement.");
    while ((idxDecl = (idxSpec.next())) != null) {
      System.out.println(
          "\tFor node '" + idxDecl.name + "', found index: '" + idxDecl.index + "'.");
      count++;
    }

    System.out.println(count + " indexes found.");
    idxSpec.delete();
  }