You are viewing a plain text version of this content. The canonical link for it is here.
Posted to xindice-dev@xml.apache.org by fe...@apache.org on 2002/09/09 18:14:46 UTC

cvs commit: xml-xindice/java/src/org/apache/xindice/client/xmldb XindiceCollection.java

fern        2002/09/09 09:14:45

  Modified:    java/src/org/apache/xindice/client/xmldb
                        XindiceCollection.java
  Log:
  createResource with empty name, should call createId(), per xmldb spec
  
  Revision  Changes    Path
  1.3       +10 -15    xml-xindice/java/src/org/apache/xindice/client/xmldb/XindiceCollection.java
  
  Index: XindiceCollection.java
  ===================================================================
  RCS file: /home/cvs/xml-xindice/java/src/org/apache/xindice/client/xmldb/XindiceCollection.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- XindiceCollection.java	12 Jul 2002 10:09:51 -0000	1.2
  +++ XindiceCollection.java	9 Sep 2002 16:14:45 -0000	1.3
  @@ -247,22 +247,17 @@
        * @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 (name == null) {
  -
  -            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.indexOf('/') != -1) {
  -            
  -            throw new XMLDBException(ErrorCodes.INVALID_RESOURCE, 
  -                    "Name cannot contain '/'");
  -        }
  -        
  -        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);