Package org.apache.xindice.client.corba.db

Examples of org.apache.xindice.client.corba.db.Collection


      }
   }
  
   public void testGetParentCollection() {
  
      Collection parentcol = null;
     
      try {
         parentcol = col.getParentCollection();
           
         // Verify that a collection was returned
         assertNotNull(parentcol);
         assertTrue( parentcol.getName().equals(INSTANCE_NAME) );
        
      } catch ( Exception e) {
         fail( e.getMessage() );
      } finally {
         parentcol.remove();
      }
   }
View Full Code Here


         fail( e.getMessage() );
      }
   }

   public void testGetCollection() {
      Collection childcol = null;
     
      try {
         // Try getting a Collection instance for TEST_COLLECTION_CHILD1_NAME
         childcol = col.getCollection(TEST_COLLECTION_CHILD1_NAME);
         assertNotNull(childcol);
         // Verify that we retrived the correct collection
         assertTrue( childcol.getName().equals(TEST_COLLECTION_CHILD1_NAME) );

         // Try getting a Collection instance for TEST_COLLECTION_CHILD1_NAME
         childcol = col.getCollection(TEST_COLLECTION_CHILD2_NAME);
         assertNotNull(childcol);
         // Verify that we retrived the correct collection
         assertTrue( childcol.getName().equals(TEST_COLLECTION_CHILD2_NAME) );
     
         // Try retrieving a bogus collection, should get an COL_COLLECTION_NOT_FOUND faultCode
         try {
            exceptioncaught = false;
            childcol = col.getCollection("lkasdfljkasdf");
         } catch( APIException e ) {
            exceptioncaught = true;
            assertTrue( e.faultCode == FaultCodes.COL_COLLECTION_NOT_FOUND );
         } finally {
            assertTrue( exceptioncaught );
         }
        
         // Try retrieving an empty string
         try {
            exceptioncaught = false;
            childcol = col.getCollection("");
         } catch( APIException e ) {
            exceptioncaught = true;
            assertTrue( e.faultCode == FaultCodes.COL_COLLECTION_NOT_FOUND );
         } finally {
            assertTrue( exceptioncaught );
         }
        
      } catch ( APIException e) {
         fail( e.getMessage() );
      } finally {
         childcol.remove();
      }
   }
View Full Code Here

      int i = 0;
      while (i < topcols.length) {
         System.out.println(topcols[i] + ":");

         // Get all the collections for this database.
         Collection col = app.getCollection(topcols[i]);
         String [] collections = col.listCollections();
         int j = 0;
         while (j < collections.length) {
            System.out.println("\t" + collections[j]);
            j++;
         }
         col.remove();
         i++;
      }
   }
View Full Code Here

   public static String insertDocument(Database app) throws Exception {
      // Document must be a valid XML document.
      String document = "<?xml version=\"1.0\"?>\n <test>Hello</test>";

      // The default install includes a test database with an ocs collection
      Collection col = app.getCollection("root/ocs");

      // CORBA requires the document to be an EncodedBuffer
      EncodedBuffer buf = new EncodedBuffer(-1, EmptyBytes, document.getBytes());
      String key = col.insertDocument("testdoc", buf);
      System.out.println("Document Key: " + key);


      col.remove();
      return key;
   }
View Full Code Here

     * Updates an existing document using XUpdate
     */
   public static void updateDocument(Database app) throws Exception {
      String commands = "<xupdate:modifications version=\"1.0\" xmlns:xupdate=\"http://www.xmldb.org/xupdate\"><xupdate:remove select=\"/address/first-name\"/></xupdate:modifications>";

      Collection col = app.getCollection("root");

      col.queryDocument("XUpdate", commands, null, "address4", -1);
      System.out.println("Document Updated");

      col.remove();

   }
View Full Code Here

      * Retrieve and print a stored document
      */
   public static void retrieveDocument(Database app, String oid)
         throws Exception {
      // The default install includes a test database with an ocs collection
      Collection col = app.getCollection("root/ocs");
      System.out.println(oid);
      EncodedBuffer buffer = col.getDocument(oid, -1);

      // The XML data is stored in buffer.buf
      System.out.println(new String(buffer.buf));

      col.remove();
   }
View Full Code Here

       return nv;
    }

   public XMLResource updateResult(String commands) throws XMLDBException {
      // Get the Xindice collection object from the XML:DB collection wrapper.
      Collection col = ((CollectionImpl) collection).getServerObject();

      try {
         EncodedBuffer buffer = col.queryCollection("XUpdate", commands, getNamespaces(), -1);
         return new XMLResourceImpl("", collection, new String(buffer.buf));
      }
      catch (Exception e) {
      e.printStackTrace();
         throw FaultCodes.createXMLDBException(e);
View Full Code Here

      return getResultCount(result);
   }

   public XMLResource updateResourceResult(String id, String commands) throws XMLDBException {
      // Get the Xindice collection object from the XML:DB collection wrapper.
      Collection col = ((CollectionImpl) collection).getServerObject();

      try {
         EncodedBuffer buffer = col.queryDocument("XUpdate", commands, getNamespaces(), id, -1);
         return new XMLResourceImpl("", collection, new String(buffer.buf));
      }
      catch (Exception e) {     
         throw FaultCodes.createXMLDBException(e);
      }
View Full Code Here

    * @exception XMLDBException
    */
   public org.xmldb.api.base.ResourceSet query (String query)
         throws XMLDBException {
      // Get the Xindice collection object from the XML:DB collection wrapper.
      Collection col = ((CollectionImpl) collection).getServerObject();

      ResourceSet result = null;
      try {
         EncodedBuffer buffer = col.queryCollection("XPath", query,
            getNamespaces(), syms.getLastModified());

         if ( buffer.stamp != -1 ) {
            SymbolTable s = syms.getSymbols(buffer);
            result = new ResourceSetImpl(collection, s, buffer.buf);
View Full Code Here

   }
  
   public org.xmldb.api.base.ResourceSet queryResource (String id, String query)
         throws XMLDBException {
      // Get the Xindice collection object from the XML:DB collection wrapper.
      Collection col = ((CollectionImpl) collection).getServerObject();

      ResourceSet result = null;
      try {
         EncodedBuffer buffer = col.queryDocument("XPath", query,
            getNamespaces(), id, syms.getLastModified());

         if ( buffer.stamp != -1 ) {
            SymbolTable s = syms.getSymbols(buffer);
            result = new ResourceSetImpl(collection, s, buffer.buf);
View Full Code Here

TOP

Related Classes of org.apache.xindice.client.corba.db.Collection

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.