Package org.xmldb.api.base

Examples of org.xmldb.api.base.XMLDBException


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


                    if (log.isDebugEnabled()) {
                        log.debug("Using SAX Driver: '" + xmlrpcDriver + "'");
                    }
                    XmlRpc.setDriver(xmlrpcDriver);
                } catch (Exception e) {
                    throw new XMLDBException(ErrorCodes.VENDOR_ERROR,
                                             "SAX Driver " + xmlrpcDriver + " is not available", e);
                }
            }

            xmlRpcInitialized = true;
View Full Code Here

     */
    public Collection getCollection(String uri, String userName, String password) throws XMLDBException {
        /* TODO: introduce authentication some day */

        if (!acceptsURI(uri)) {
            throw new XMLDBException(ErrorCodes.INVALID_URI, "Invalid URL: " + 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, "Invalid URL (must have '/'): " + uri);
        }

        String collPath = uri.substring(firstSlash);
        String hostPort = uri.substring(0, firstSlash);

View Full Code Here

     */
    public Collection getCollection(String uri, String userName, String password) throws XMLDBException {
        /* TODO: introduce authentication some day */

        if (!acceptsURI(uri)) {
            throw new XMLDBException(ErrorCodes.INVALID_URI,
                                     "Invalid URL: " + 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,
                                     "Invalid URL (must have '/'): " + uri);
        }

        /* Extract collection name */
        String collPath = uri.substring(firstSlash);
        if (!collPath.startsWith("/")) {
            throw new XMLDBException(ErrorCodes.INVALID_URI,
                                     "Invalid URL (collection name must start with '/'): " + uri);
        }

        // 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 = "/";
            }
        }

        // TODO: Is this correct behavior?
        if (!database.getName().equals(dbName)) {
            throw new XMLDBException(ErrorCodes.NO_SUCH_DATABASE,
                                     "Unknown database (must be '" + database.getName() + "'): " + uri);
        }

        try {
            return new CollectionImpl(database, colName);
View Full Code Here

     * @param value The new Content value
     * @exception XMLDBException
     */
    public void setContent(Object value) throws XMLDBException {
        if (value == null) {
            throw new XMLDBException(ErrorCodes.INVALID_RESOURCE);
        } else if (value instanceof String) {
            this.content = (String) value;
            this.bytes = null;
        } else {
            throw new XMLDBException(ErrorCodes.WRONG_CONTENT_TYPE);
        }
    }
View Full Code Here

    public void setContentAsDOM(Node content) throws XMLDBException {
        if (content != null) {
            this.content = TextWriter.toString(content);
            this.bytes = null;
        } else {
            throw new XMLDBException(ErrorCodes.INVALID_RESOURCE);
        }
    }
View Full Code Here

     */
    public Collection getCollection(String uri, String username, String password) throws XMLDBException {
        /* TODO: introduce authentication some day */

        if (!acceptsURI(uri)) {
            throw new XMLDBException(ErrorCodes.INVALID_URI,
                                     "Invalid URL: " + 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,
                                     "Invalid URL (must have '/'): " + uri);
        }

        /* Extract collection name */
        String collPath = uri.substring(firstSlash);
        if (!collPath.startsWith("/")) {
            throw new XMLDBException(ErrorCodes.INVALID_URI,
                                     "Invalid URL (collection name must start with '/'): " + uri);
        }

        // 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 = "/";
            }
        }

        // TODO: Is this correct behavior?
        if (!database.getName().equals(dbName)) {
            throw new XMLDBException(ErrorCodes.NO_SUCH_DATABASE,
                                     "Unknown database (must be '" + database.getName() + "'): " + uri);
        }

        try {
            return new CollectionImpl(database, colName);
View Full Code Here

     *
     * @exception XMLDBException thrown if collection is closed
     */
    protected void checkOpen() throws XMLDBException {
        if (!isOpen()) {
            throw new XMLDBException(ErrorCodes.COLLECTION_CLOSED);
        }
    }
View Full Code Here

     * @param type Type must be either <code>XMLResource</code> or <code>BinaryResource</code>.
     * @exception XMLDBException thrown in case of an invalid resource type or name
     */
    public Resource createResource(String name, String type) throws XMLDBException {
        if (!"XMLResource".equals(type) && !"BinaryResource".equals(type)) {
            throw new XMLDBException(ErrorCodes.UNKNOWN_RESOURCE_TYPE,
                                     "Only XMLResource and BinaryResource supported");
        }

        if (name == null || name.length() == 0) {
            // fulfill contract stating
            // "If id is null or its value is empty then an id is generated by calling createId()."
            name = createId();
        } else if (name.indexOf('/') != -1) {
            throw new XMLDBException(ErrorCodes.INVALID_RESOURCE,
                                     "Name cannot contain '/'");
        }

        if ("XMLResource".equals(type)) {
            return new XMLResourceImpl(name, this);
View Full Code Here

        final XObject xobject = xp.execute(xpc, n, pfx);

        switch (xobject.getType())
        {
          default :
            throw new XMLDBException(
              ErrorCodes.NOT_IMPLEMENTED,
              "Unsupported result type: " + xobject.getTypeString());

          case XObject.CLASS_NODESET :
            ni = xobject.nodeset();
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.