Package org.xmldb.api.base

Examples of org.xmldb.api.base.XMLDBException


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


     * @param type must be <code>XMLResource</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 ) ) {
            throw new XMLDBException( ErrorCodes.UNKNOWN_RESOURCE_TYPE, "only XMLResources 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 '/'" );
        }
       
        return new XMLResourceImpl(name, this);
    }
View Full Code Here

            i++;
            resources.add(resource);
         }
         catch (Exception e) {
            throw new XMLDBException(ErrorCodes.UNKNOWN_ERROR, e);
         }
      }
   }
View Full Code Here

    */
   public Collection getChildCollection(String name) throws XMLDBException {

      if (name.indexOf('/') != -1) {

         throw new XMLDBException(ErrorCodes.INVALID_COLLECTION);
      }

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

            Hashtable params = new Hashtable();
            params.put(RPCDefaultMessage.COLLECTION, collPath);
            return (String) runRemoteCommand("CreateNewOID", params);
        } catch (Exception e) {
           
            throw new XMLDBException(ErrorCodes.UNKNOWN_ERROR, e);
        }
    }
View Full Code Here

    */
    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 {

          Hashtable params = new Hashtable();
          params.put(RPCDefaultMessage.COLLECTION, collPath);
          params.put(RPCDefaultMessage.NAME, res.getId());
          runRemoteCommand("RemoveDocument", params);
       } catch (Exception e) {
          throw new XMLDBException(ErrorCodes.NO_SUCH_RESOURCE, e);
       }
    }
View Full Code Here

            Vector list = (Vector) runRemoteCommand("ListCollections", params);
           
            return (String[]) list.toArray(new String[list.size()]);
        } catch (Exception e) {
           
            throw new XMLDBException(ErrorCodes.UNKNOWN_ERROR, e);
        }  
    }
View Full Code Here

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

            Vector list = (Vector) runRemoteCommand("ListDocuments", params);
           
            return (String[]) list.toArray(new String[list.size()]);
        } catch (Exception e) {
           
            throw new XMLDBException(ErrorCodes.UNKNOWN_ERROR, e);
        }  
    }
View Full Code Here

           runRemoteCommand("CreateCollection", params);
          
           return getChildCollection(name);
        }
        catch (Exception e) {        
           throw new XMLDBException(ErrorCodes.INVALID_COLLECTION,
                    "Cannot create 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.