#9 dropped collection can be opened. No exceptions are thrown.

serious
closed-fixed
5
2014-12-01
2004-07-30
No

Just dropped collection can be normally opened. Only
calling of some methods causes throwing of strange
exceptions.

I attach simple test. It try to create collection if
this collection cannot be opened. Then it gets list of
documents in the collection and drops one. On the
second iteration we have exception :-(

After the code it is attachched 2 output listings -
test on the just created database, and second call of
the same test.

I have tested it on dbXML 2.0 RC1, Linux, JDK 1.4.2_04.

begin dbXML_deleteCollectionError.java:

import com.dbxml.db.client.*;
import com.dbxml.db.client.xmlrpc.dbXMLClientImpl;
import com.dbxml.db.common.security.AccessManagerClient;
import com.dbxml.db.core.security.Access;
import com.dbxml.db.server.dbXML;
import com.dbxml.util.dbXMLException;
import com.dbxml.xml.dom.DOMHelper;
import org.w3c.dom.*;

public class dbXML_deleteCollectionError
{
public static void main( String [] args ) throws Exception
{
dbXML_deleteCollectionError instance = new
dbXML_deleteCollectionError();
instance.test();
}

private dbXML\_deleteCollectionError\(\) throws

dbXMLException
{
client = new dbXMLClientImpl();

    client.setProperty\( dbXMLClient.USER, "scott" \);
    client.setProperty\( dbXMLClient.PASS, "tiger" \);

    client.connect\(\);
\}

public void test\(\) throws dbXMLException
\{
    final String col\_name = "test";

for( int i=0; i<2; ++i )
{
System.out.println( "Iteration "+i );
if( ! exists( col_name ) )
create_collection( col_name );
test_collection( col_name );
delete_collection( col_name );
}
}

private void create\_collection\( String col\_name \)

throws dbXMLException
{
CollectionClient root = client.getCollection( "/" );
CollectionClient created = createCollection( root,
col_name );
assert( null != created );
}

public void test\_collection\( String col\_name \) throws

dbXMLException
{
CollectionClient col = client.getCollection(
"/"+col_name );
col.listKeys();
}

public void delete\_collection\( String col\_name \)

throws dbXMLException
{
CollectionClient root = client.getCollection( "/" );
root.dropCollection( col_name );
}

public boolean exists\( String col\_name \) throws

dbXMLException
{
try
{
CollectionClient root = client.getCollection(
"/"+col_name );
if( root == null )
System.out.println( "We think, that collection
'/"+col_name+"' does not exist because of getting null
as result of operation getCollection(...)" );
else
System.out.println( "We think, that collection
'/"+col_name+"' exists because of successfull opening
by getCollection(...)" );
return root != null;
}
catch( dbXMLException collection_does_not_exist )
{
System.out.print( "We think, that collection
'/"+col_name+"' does not exist because of getting
exception '" );
System.out.print(
collection_does_not_exist.getMessage() );
System.out.println( "'" );
}
return false;
}

private static final String DEFAULT\_COLLECTION\_CLASS =

dbXML.DEFAULT_FILER;
private static final String DEFAULT_COLLECTION_TYPE =
"compressed";

private static CollectionClient createCollection\(

CollectionClient col, String name ) throws dbXMLException
{
Document doc = DOMHelper.newDocument();
Element root = doc.createElement("collection");
root.setAttribute( "type", DEFAULT_COLLECTION_TYPE );
doc.appendChild(root);

    Element filer = doc.createElement\("filer"\);
    filer.setAttribute\( "class", DEFAULT\_COLLECTION\_CLASS \);

    root.appendChild\( filer \);

    root.appendChild\( doc.createElement\( "indexes" \) \);
    root.appendChild\( doc.createElement\( "triggers" \) \);
    root.appendChild\( doc.createElement\( "extensions" \) \);

    root.setAttribute\( "name", name \);
    col = col.createCollection\( name, doc \);

    AccessManagerClient manager = new

AccessManagerClient( col.getClient() );
manager.grant( col.getCanonicalName(), "admin",
Access.READ | Access.WRITE | Access.EXECUTE |
Access.CREATE );

    return col;
\}

private final dbXMLClient client;

}

end dbXML_deleteCollectionError.java:

Output on the just created database:
------------------------------------------------------------------
Iteration 0
We think, that collection '/test' does not exist
because of getting exception 'HTTP 500 (Internal Server
Error)
Server returned HTTP response code: 500 for URL:
http://:7280/xmlrpc/test'
Iteration 1
We think, that collection '/test' exists because of
successfull opening by getCollection(...)
Exception in thread "main"
com.dbxml.util.dbXMLException: Insufficient access to
'/test' for User 'scott'
at
com.dbxml.db.client.xmlrpc.ConnectionManager.execute(ConnectionManager.java:223)
at
com.dbxml.db.client.xmlrpc.ConnectionManager.executeList(ConnectionManager.java:244)
at
com.dbxml.db.client.xmlrpc.CollectionClientImpl.listKeys(CollectionClientImpl.java:250)
at
dbXML_deleteCollectionError.test_collection(dbXML_deleteCollectionError.java:54)
at
dbXML_deleteCollectionError.test(dbXML_deleteCollectionError.java:37)
at
dbXML_deleteCollectionError.main(dbXML_deleteCollectionError.java:15)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native
Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at
com.intellij.rt.execution.application.AppMain.main(AppMain.java:78)
Caused by: org.apache.xmlrpc.XmlRpcException:
Insufficient access to '/test' for User 'scott'
at
org.apache.xmlrpc.XmlRpcClient$Worker.execute(XmlRpcClient.java:248)
at
org.apache.xmlrpc.XmlRpcClient.execute(XmlRpcClient.java:143)
at
com.dbxml.db.client.xmlrpc.ConnectionManager.execute(ConnectionManager.java:207)
... 10 more

------------------------------------------------------------------

Output of the second call of the test:
------------------------------------------------------------------
Iteration 0
We think, that collection '/test' exists because of
successfull opening by getCollection(...)
Exception in thread "main"
com.dbxml.util.dbXMLException: Insufficient access to
'/test' for User 'scott'
at
com.dbxml.db.client.xmlrpc.ConnectionManager.execute(ConnectionManager.java:223)
at
com.dbxml.db.client.xmlrpc.ConnectionManager.executeList(ConnectionManager.java:244)
at
com.dbxml.db.client.xmlrpc.CollectionClientImpl.listKeys(CollectionClientImpl.java:250)
at
dbXML_deleteCollectionError.test_collection(dbXML_deleteCollectionError.java:54)
at
dbXML_deleteCollectionError.test(dbXML_deleteCollectionError.java:37)
at
dbXML_deleteCollectionError.main(dbXML_deleteCollectionError.java:15)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native
Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at
com.intellij.rt.execution.application.AppMain.main(AppMain.java:78)
Caused by: org.apache.xmlrpc.XmlRpcException:
Insufficient access to '/test' for User 'scott'
at
org.apache.xmlrpc.XmlRpcClient$Worker.execute(XmlRpcClient.java:248)
at
org.apache.xmlrpc.XmlRpcClient.execute(XmlRpcClient.java:143)
at
com.dbxml.db.client.xmlrpc.ConnectionManager.execute(ConnectionManager.java:207)
... 10 more

------------------------------------------------------------------

p.s. If just restart dbXML server, the test behavior
will be the same as in the first listing.

p.p.s. All the additional *.jar files were taken from
dbXML distribution.

Discussion

  • Tom Bradford

    Tom Bradford - 2004-07-30
    • status: open --> closed-invalid
     
  • Tom Bradford

    Tom Bradford - 2004-07-30

    Logged In: YES
    user_id=35410

    Newly created collections require access rights to be
    granted to them for the user that is going to access them.
    Rights are not automatically propagated to a newly created
    child collection, and require explicit grants. See the
    dbXML Programmer's guide
    (http://www.dbxml.com/docs/programmer.html) for more
    information. The class
    com.dbxml.db.client.tools.command.Grant for an example of
    programmatically granted access.

     
  • Yaroslav Sokolov

    • status: closed-invalid --> open-invalid
     
  • Yaroslav Sokolov

    Logged In: YES
    user_id=972975

    a) the error happenes after collection is dropped,
    b) in the test source you can see, that for this collection
    all rights are granted to role "admin" (line 108)
    c) there are different behaviors on the first and second
    time of running the test;
    d) the behavior can be "reset" by restarting the dbXML server

     
  • Tom Bradford

    Tom Bradford - 2004-07-30

    Logged In: YES
    user_id=35410

    Collections weren't removing their Labrador context when
    dropping. This has been resolved in CVS.

     
  • Tom Bradford

    Tom Bradford - 2004-07-30
    • status: open-invalid --> closed-fixed
     

Log in to post a comment.