Package org.xmldb.api.base

Examples of org.xmldb.api.base.XMLDBException


    *  method has been called on the <code>Collection</code><br />
    */
    public void storeResource(Resource res) throws XMLDBException {

       if (!(res instanceof XMLResource)) {
          throw new XMLDBException(ErrorCodes.INVALID_RESOURCE,
                                   "Only XML resources supported");
       }

       if (res.getContent() == null) {
          throw new XMLDBException(ErrorCodes.INVALID_RESOURCE,
                                   "no resource data");
       }
      
       checkOpen();

       try {
          String name = "";
          Node content = ((XMLResourceImpl) res).getContentAsDOM();
          if (content != null && content instanceof Document) {          
             if (res.getId() != null) {
                col.insertDocument(res.getId(),
                                   (Document) content);
             }
             else {
                name = col.insertDocument((Document) content).toString();
                ((XMLResourceImpl) res).setId(name);
             }
          }
          else {
             throw new XMLDBException(ErrorCodes.INVALID_RESOURCE,
                                      "A resource must be a document in order to be stored.");
          }
       } catch (Exception e) {
          throw new XMLDBException(ErrorCodes.UNKNOWN_ERROR, e);
       }
    }
View Full Code Here


    *  method has been called on the <code>Collection</code><br />
    */
   public org.xmldb.api.base.Collection getChildCollection(String name) throws XMLDBException {

      if (name.indexOf('/') != -1) {
         throw new XMLDBException(ErrorCodes.INVALID_COLLECTION);
      }

      try {
         return new CollectionImpl(db, collPath + "/" + name);
      }
View Full Code Here

        checkOpen();
        try {           
            return col.createNewOID().toString();
        } catch (Exception e) {           
            throw new XMLDBException(ErrorCodes.UNKNOWN_ERROR, e);
        }
    }
View Full Code Here

    *  method has been called on the <code>Collection</code><br />
    */
    public void removeResource(Resource res) throws XMLDBException {

       if (!(res instanceof XMLResource)) {
          throw new XMLDBException(ErrorCodes.INVALID_RESOURCE,
                                   "Only XML resources supported");
       }

       if (res.getId() == null) {
          throw new XMLDBException(ErrorCodes.VENDOR_ERROR,
                                   "This resource is a query result and can " +
                                   "not be removed from the database.");
       }
      
       checkOpen();
       try {
          col.remove(res.getId());
       } catch (Exception e) {
          throw new XMLDBException(ErrorCodes.NO_SUCH_RESOURCE, e);
       }
    }
View Full Code Here

       
        checkOpen();
        try {           
            return col.listCollections();
        } catch (Exception e) {           
            throw new XMLDBException(ErrorCodes.UNKNOWN_ERROR, e);
        }  
    }
View Full Code Here

        checkOpen();
        try {           
            return (int) col.countCollections();           
        } catch (Exception e) {
            throw new XMLDBException(ErrorCodes.UNKNOWN_ERROR, e);
        }  
    }
View Full Code Here

       
        checkOpen();
        try {
            return col.listDocuments();
        } catch (Exception e) {           
            throw new XMLDBException(ErrorCodes.UNKNOWN_ERROR, e);
        }  
    } 
View Full Code Here

           filEle.setAttribute("class", "org.apache.xindice.core.filer.BTreeFiler");
           colEle.appendChild(filEle);          

           return createCollection(name, doc);
        } catch (Exception e) {           
            throw new XMLDBException(ErrorCodes.INVALID_COLLECTION,
                    "Cannot create child collection", e);
        }
    }
View Full Code Here

           col.createCollection( name, config );

           return getChildCollection(name);
        }
        catch (Exception e) {        
           throw new XMLDBException(ErrorCodes.INVALID_COLLECTION,
                    "Cannot create child collection", e);
        }
     }
View Full Code Here

       
        checkOpen();
        try {
            col.dropCollection( col.getCollection( childName ) );
        } catch (Exception e) {
            throw new XMLDBException(ErrorCodes.INVALID_COLLECTION,
                    "Cannot remove child collection", e);
        }
    }
View Full Code Here

TOP

Related Classes of org.xmldb.api.base.XMLDBException

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.