Package org.xmldb.api.base

Examples of org.xmldb.api.base.XMLDBException


     *  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,
                                     "Invalid collection: " + name);
        }

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


     */
    public void removeResource(Resource res) throws XMLDBException {

        if (res == null || res.getId() == null || res.getId().length() == 0) {
            // Query result resource will have null ID
            throw new XMLDBException(ErrorCodes.INVALID_RESOURCE,
                                     "Resource passed is null or its ID is empty.");
        }

        checkOpen();
        try {
View Full Code Here

     */
    public Collection getCollection( String uri )
        throws XMLDBException {
        // we don't know how to handle this uri
        if ( !acceptsURI( uri ) )
            throw new XMLDBException( ErrorCodes.INVALID_URI, "INVALID_URI" );

        Collection collection = null;
        try {
            ExternalDatabase db = null;
            StringBuffer ozoneDB = new StringBuffer();
            if ( getProperty( DB_HOST ) == null )
                ozoneDB.append( "ozonedb:local:").append( getProperty( DB_NAME ) );
            else
                ozoneDB.append( "ozonedb:remote://" ).append( getProperty( DB_HOST ) ).append(
                  ":").append( getProperty( DB_PORT ) );

            System.out.println("DatabaseImpl.getCollection() - Remote DB: " + getProperty(DB_HOST) + " " + getProperty(DB_PORT));
            System.out.println("DatabaseImpl.getCollection() - Local DB: " + getProperty(DB_NAME));
            System.out.println("DatabaseImpl.getCollection() - Load Collection: " + getProperty(COL_NAME));

            db = ExternalDatabase.openDatabase( ozoneDB.toString() );
            if (db == null)
                throw new XMLDBException( ErrorCodes.INVALID_DATABASE, "INVALID_DATABASE" );

            db.reloadClasses();

            collection = CollectionImpl.forName( db, getProperty( COL_NAME ) );

            if (collection == null)
                throw new XMLDBException( ErrorCodes.INVALID_COLLECTION, "INVALID_COLLECTION" );

        } catch ( XMLDBException e ) {
            // re-throw this exception
            throw e;
        } catch ( Exception e ) {
            // encapsulate all other exceptions
            throw new XMLDBException( ErrorCodes.VENDOR_ERROR, e.toString() );
        }
        return collection;
    }
View Full Code Here

    }

    /**
    */
    public boolean hasMoreResources() throws XMLDBException {
        throw new XMLDBException( ErrorCodes.VENDOR_ERROR, "hasMoreResources(): Not yet implemented");
    }
View Full Code Here

    }

    /**
    */
    public Resource nextResource() throws XMLDBException {
        throw new XMLDBException( ErrorCodes.VENDOR_ERROR, "nextResource(): Not yet implemented");
    }
View Full Code Here

    public Collection createCollection(String name) throws XMLDBException {
        try {
            // get the XMLCollection from the database
            // create a new XMLCollection
            // set the parent-child relationships
           throw new XMLDBException(ErrorCodes.VENDOR_ERROR,"Not yet implemented");
        }
        catch (Exception e) {
            throw new XMLDBException(ErrorCodes.VENDOR_ERROR, e.getMessage());
        }
    }
View Full Code Here

    }
   
    /** Remove the named collection  */
    public void removeCollection(String name) throws XMLDBException {
        try {
            throw new XMLDBException(ErrorCodes.VENDOR_ERROR,"Not implemented yet");
            //db.deleteObject((XMLCollection)db.objectForName(name));
            //System.out.println("CollectionStorageHelper.deleteCollection() - deleted " + name);       
        }
        catch (Exception e) {
            throw new XMLDBException(ErrorCodes.VENDOR_ERROR, e.getMessage());
        }
    }
View Full Code Here

            if ( type.equals(XMLResource.RESOURCE_TYPE) ) {
                //System.out.println("CollectionImpl.createResource() - Creating container");
                XMLContainer container = XMLContainer.forName(database, id);
                if (container != null ) {
                    System.out.println("container exists already");
                    throw new XMLDBException(ErrorCodes.INVALID_RESOURCE, "resource " + id + " already exists");
                }
                container = XMLContainer.newContainer(database, id);
                //System.out.println("CollectionImpl.createResource() - created XMLContainer, adding id to the XMLCollection");
                collection.addResource(id);
                return new XMLResourceImpl(id, database, this, container);
            } else if ( type.equals(BinaryResource.RESOURCE_TYPE) ) {
                //return new BinaryResourceImpl(this, id);
                throw new XMLDBException( ErrorCodes.VENDOR_ERROR, "BinaryResource: Not yet implemented");
            } else {
                throw new XMLDBException(ErrorCodes.UNKNOWN_RESOURCE_TYPE);
            }
        } catch (Exception e) {
            throw new XMLDBException(ErrorCodes.VENDOR_ERROR, e.getMessage());
        }
    }
View Full Code Here

            String id = res.getId();
            if ( collection.hasResource(id) ) {
                container = XMLContainer.forName(database, id);
                container.delete();
            } else {
                throw new XMLDBException(ErrorCodes.NO_SUCH_RESOURCE, "the resource is not a part of this collection");
            }
        } catch (Exception e) {
            throw new XMLDBException(ErrorCodes.VENDOR_ERROR, e.toString());
        }
    }
View Full Code Here

                id = createId();
            }
            System.out.println("CollectionImpl.storeResource() - Dont know what to do here");

        } catch (Exception e) {
            throw new XMLDBException(ErrorCodes.VENDOR_ERROR, e.toString());
        }
    }
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.