Package org.xmldb.api.base

Examples of org.xmldb.api.base.XMLDBException


      }
      catch (Exception e) {
         if (log.isInfoEnabled()) {
            log.info("Exception during creation of the Database", e);
         }
         throw new XMLDBException(ErrorCodes.INVALID_URI, uri, e);
      }
   }
View Full Code Here


      if (this.iterator != null) {
         if (this.iterator.hasNext()) {
            return (Resource) iterator.next();
         }
      }
      throw new XMLDBException(ErrorCodes.NO_SUCH_RESOURCE);
   }
View Full Code Here

               
        /* TODO: introduce authentication some day */
               
        if (!acceptsURI(uri)) {
           
            throw new XMLDBException(ErrorCodes.INVALID_URI);
        }

        /* Chop off driver prefix, and '://' */
        uri = uri.substring(getName().length() + 3);
       
        /* Extract host name & port, if present */
        int firstSlash = uri.indexOf('/');
        if (firstSlash == -1) {
           
            throw new XMLDBException(ErrorCodes.INVALID_URI);
        }
       
        String hostPort = uri.substring(0, firstSlash);
        String collPath = uri.substring(firstSlash);

View Full Code Here

        if (e instanceof DBException) {
            faultCode = ((DBException) e).faultCode;
        }

        return new XMLDBException(ErrorCodes.VENDOR_ERROR, faultCode, message, e);
    }
View Full Code Here

        try {
           
            XmlRpc.setDriver("xerces");
        } catch (Exception e) {
           
            throw new XMLDBException(ErrorCodes.VENDOR_ERROR, "Xerces needed", e);
        }
    
        try {
           
            client = new XmlRpcClient(xmlrpcURI);
           
            /* Just check the collection does actually exist */
            Hashtable params = new Hashtable();
            params.put(RPCDefaultMessage.COLLECTION, collPath);
            String exists =
                    (String) runRemoteCommand("GetCollectionConfiguration", params);
            if (!"yes".equals(exists)) {

                throw new XMLDBException(ErrorCodes.NO_SUCH_COLLECTION,
                                     "Collection not found: " + collPath);
            }
        } catch (MalformedURLException e) {
           
      client = null;
            throw new XMLDBException(ErrorCodes.INVALID_URI, e);
        } catch (Exception e) {

      client = null;
            throw new XMLDBException(ErrorCodes.NO_SUCH_COLLECTION,
                                     "Collection not found: " + collPath, e);
        }
    }
View Full Code Here

            params.put(RPCDefaultMessage.COLLECTION, collPath);
            return ((Integer) runRemoteCommand(
                    "GetDocumentCount", params)).intValue();
        } catch (Exception e) {
           
            throw new XMLDBException(ErrorCodes.UNKNOWN_ERROR, e);
        }
    }
View Full Code Here

    */
    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 {
           
            Hashtable params = new Hashtable();
            params.put(RPCDefaultMessage.COLLECTION, collPath);
            params.put(RPCDefaultMessage.NAME, res.getId());
            params.put(RPCDefaultMessage.DOCUMENT, res.getContent());

            String name = (String) runRemoteCommand("InsertDocument", params);
            ((XMLResourceImpl) res).setId(name);
           
        } catch (Exception e) {
           
            throw new XMLDBException(ErrorCodes.UNKNOWN_ERROR, e);
        }
    }
View Full Code Here

            throws XMLDBException {
               
        /* TODO: introduce authentication some day */
               
        if (!acceptsURI(uri)) {
            throw new XMLDBException(ErrorCodes.INVALID_URI);
        }

        /* Chop off driver prefix, and '://' */
        uri = uri.substring(getName().length() + 3);
       
        /* Extract host name & port, if present */
        int firstSlash = uri.indexOf('/');
        if (firstSlash == -1) {        
            throw new XMLDBException(ErrorCodes.INVALID_URI);
        }
       
        String collPath = uri.substring(firstSlash);
       
        // The path must start with a /
        if ( collPath.startsWith( "/" ) ) {
           // find the database name. We just skip the first slash
           int colIndex = collPath.indexOf( '/', 1 );

           // We assume there's no collection specified
           String dbName =  collPath.substring( 1 );
           String colName = "/";

           // if colIndex isn't -1 then we need to pick out the db and collection
           if ( colIndex != -1 ) {
              dbName = collPath.substring( 1, colIndex );

              // The rest of the name locates the collection
              colName = collPath.substring( colIndex );
           }

           if ( colName.equals("") ) {
              colName = "/";
           }
          
       try {
           return new CollectionImpl(db, colName);
       }
       catch(XMLDBException e) {
              if(e.errorCode == ErrorCodes.NO_SUCH_COLLECTION) {
                 // per getCollection contract, return null if not found
                 return null;
              }
        throw e;
       }
        }
        else {
           throw new XMLDBException(ErrorCodes.INVALID_URI,
                                    "Collection name must begin with a '/'" );
        }
    }
View Full Code Here

        this.db = db;
       
        try {
           this.col = db.getCollection(collPath);
        } catch (Exception e) {
            throw new XMLDBException(ErrorCodes.NO_SUCH_COLLECTION,
                                     "Collection not found: " + collPath, e);
        }
    if(this.col == null) {
            throw new XMLDBException(ErrorCodes.NO_SUCH_COLLECTION,
                                     "Collection not found: " + collPath);
    }
    }
View Full Code Here

       
        checkOpen();
        try {           
            return (int) col.getDocumentCount();
        } catch (Exception e) {           
            throw new XMLDBException(ErrorCodes.UNKNOWN_ERROR, 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.