directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: rev 10349 - in incubator/directory/rms/trunk/je/src/java/org/apache/rms/je: permissions role
Date Wed, 28 Apr 2004 05:29:58 GMT
Author: akarasulu
Date: Tue Apr 27 22:29:57 2004
New Revision: 10349

Added:
   incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/role/
   incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/role/JeRole.java   (contents,
props changed)
   incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/role/JeRoleBinding.java   (contents,
props changed)
   incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/role/JeRoleDAO.java   (contents,
props changed)
   incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/role/RoleDAO.java   (contents,
props changed)
   incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/role/RoleDAOMonitor.java  
(contents, props changed)
   incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/role/RoleDAOMonitorAdapter.java
  (contents, props changed)
Modified:
   incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/permissions/JeBitPermissionDAO.java
Log:
some skeletal files to start on the role stuff

Modified: incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/permissions/JeBitPermissionDAO.java
==============================================================================
--- incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/permissions/JeBitPermissionDAO.java
(original)
+++ incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/permissions/JeBitPermissionDAO.java
Tue Apr 27 22:29:57 2004
@@ -924,7 +924,7 @@
     {
         if ( cursor == null )
         {
-            monitor.cleanedUp( this, "close()", cursor ) ;
+            monitor.cleanedUp( this, "close", cursor ) ;
             return ;
         }
 
@@ -934,7 +934,7 @@
         }
         catch ( DatabaseException e )
         {
-            monitor.failedOnCleanupOperation( this, "close()", cursor, e ) ;
+            monitor.failedOnCleanupOperation( this, "close", cursor, e ) ;
         }
     }
 
@@ -948,7 +948,7 @@
     {
         if ( cursor == null )
         {
-            monitor.cleanedUp( this, "close()", cursor ) ;
+            monitor.cleanedUp( this, "close", cursor ) ;
             return ;
         }
 
@@ -958,7 +958,7 @@
         }
         catch ( DatabaseException e )
         {
-            monitor.failedOnCleanupOperation( this, "close()", cursor, e ) ;
+            monitor.failedOnCleanupOperation( this, "close", cursor, e ) ;
         }
     }
 

Added: incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/role/JeRole.java
==============================================================================
--- (empty file)
+++ incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/role/JeRole.java	Tue Apr 27
22:29:57 2004
@@ -0,0 +1,48 @@
+/*
+ *   Copyright 2004 The Apache Software Foundation
+ *
+ *   Licensed under the Apache License, Version 2.0 (the "License");
+ *   you may not use this file except in compliance with the License.
+ *   You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *   limitations under the License.
+ *
+ */
+package org.apache.rms.je.role ;
+
+import org.apache.rms.DefaultRole ;
+import org.apache.rms.Application ;
+
+
+/**
+ * A Role implementation for the Je provider implementation.
+ * 
+ * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class JeRole extends DefaultRole
+{
+    /**
+     * Creates a default Role instance.
+     *
+     * @param name   the name of the Role
+     * @param grants the granted binary permissions for the Role
+     * @param an_app the application the Role is defined for
+     */
+    public JeRole( String name, byte[] grants, Application an_app )
+    {
+        super( name, grants, an_app ) ;
+    }
+
+
+    public byte[] getGrantBits()
+    {
+        return super.getGrantBits() ;
+    }
+}

Added: incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/role/JeRoleBinding.java
==============================================================================
--- (empty file)
+++ incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/role/JeRoleBinding.java	Tue
Apr 27 22:29:57 2004
@@ -0,0 +1,184 @@
+/*
+ *   Copyright 2004 The Apache Software Foundation
+ *
+ *   Licensed under the Apache License, Version 2.0 (the "License");
+ *   you may not use this file except in compliance with the License.
+ *   You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *   limitations under the License.
+ *
+ */
+package org.apache.rms.je.role ;
+
+import com.sleepycat.je.DatabaseEntry ;
+import com.sleepycat.bind.tuple.TupleInput ;
+import com.sleepycat.bind.tuple.TupleOutput ;
+import com.sleepycat.bind.tuple.TupleBinding ;
+
+import java.io.IOException ;
+
+import org.apache.rms.Application ;
+
+
+/**
+ * A JE object binding.  The binding stores the application name bytes first,
+ * then the role name bytes then finally the granted permission bit vector as
+ * a byte array.
+ * 
+ * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class JeRoleBinding extends TupleBinding
+{
+    private static ThreadLocal applications = new ThreadLocal() ;
+
+
+    /**
+     * Sets the application associated with the current thread for access by
+     * the binding.
+     *
+     * @param application the application associated with the role
+     */
+    static void setApplication( Application application )
+    {
+        applications.set( application ) ;
+    }
+
+
+    /**
+     * Gets the current Thread's application associated with the role.
+     *
+     * @return the application associated with the role.
+     */
+    static Application getApplication()
+    {
+        return ( Application ) applications.get() ;
+    }
+
+
+    // -----------------------------------------------------------------------
+    // TupleBinding implementations and overrides
+    // -----------------------------------------------------------------------
+
+
+    /**
+     * Reconstructs a Role using a serialized entry.
+     *
+     * @param tupleInput the tuple data
+     * @return the newly constructed bit permission
+     * @throws java.io.IOException if there are any failures accessing the tuple data
+     */
+    public Object entryToObject( TupleInput tupleInput ) throws IOException
+    {
+        Application application = getApplication() ;
+        String appName = tupleInput.readString() ;
+        if ( application.getName() != appName )
+        {
+            throw new IllegalStateException(
+                    "Expected application by the name of " + appName
+                    + " but instead got " + application.getName() ) ;
+        }
+
+        String roleName = tupleInput.readString() ;
+        byte[] grants = new byte[tupleInput.available()] ;
+        tupleInput.read( grants ) ;
+
+        return new JeRole( roleName, grants, application ) ;
+    }
+
+
+    /**
+     * Marshals a Role into serialized Tuple data.
+     *
+     * @param o the bit permission to marshal
+     * @param tupleOutput
+     * @throws IOException
+     */
+    public void objectToEntry( Object o, TupleOutput tupleOutput ) throws IOException
+    {
+        JeRole role = ( JeRole ) o ;
+
+        if ( role == null )
+        {
+            return ;
+        }
+
+        tupleOutput.writeString( role.getName() ) ;
+        tupleOutput.writeString( role.getApplicationName() ) ;
+        tupleOutput.write( role.getGrantBits() ) ;
+    }
+
+
+    /**
+     * Marshals the components of a Role into a serialized Tuple.
+     *
+     * @param entry the entry to populate
+     * @param appName the name of the application
+     * @param name the name of the role
+     * @param grants the permission grants for the role
+     * @throws IOException if there are failures writing the data
+     */
+    public void objectToEntry( DatabaseEntry entry, String appName,
+                               String name, byte[] grants ) throws IOException
+    {
+        TupleOutput output = new TupleOutput() ;
+        output.writeString( name ) ;
+        output.writeString( appName ) ;
+        output.write( grants ) ;
+        entry.setData( output.getBufferBytes(), output.getBufferOffset(),
+                output.getBufferLength() ) ;
+    }
+
+
+    /**
+     * Gets the grants of a role stored within the database entry.
+     *
+     * @param entry the database entry for the role
+     * @return the role's grants field
+     * @throws IOException if there are failures reading from the entry
+     */
+    public byte[] getGrants( DatabaseEntry entry ) throws IOException
+    {
+        TupleInput in = new TupleInput( entry.getData() ) ;
+        in.readString() ;
+        in.readString() ;
+        byte[] grants = new byte[in.available()] ;
+        in.read(grants) ;
+        return grants ;
+    }
+
+
+    /**
+     * Gets the name of a role stored within the database entry.
+     *
+     * @param entry the database entry for the role
+     * @return the role's name field
+     * @throws IOException if there are failures reading from the entry
+     */
+    public String getRoleName( DatabaseEntry entry ) throws IOException
+    {
+        TupleInput in = new TupleInput( entry.getData() ) ;
+        in.readString() ;
+        return in.readString() ;
+    }
+
+
+    /**
+     * Gets the name of a role's application stored within the database entry.
+     *
+     * @param entry the database entry for the role
+     * @return the role's application name field
+     * @throws IOException if there are failures reading from the entry
+     */
+    public String getApplicationName( DatabaseEntry entry ) throws IOException
+    {
+        TupleInput in = new TupleInput( entry.getData() ) ;
+        return in.readString() ;
+    }
+}

Added: incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/role/JeRoleDAO.java
==============================================================================
--- (empty file)
+++ incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/role/JeRoleDAO.java	Tue Apr
27 22:29:57 2004
@@ -0,0 +1,390 @@
+/*
+ *   Copyright 2004 The Apache Software Foundation
+ *
+ *   Licensed under the Apache License, Version 2.0 (the "License");
+ *   you may not use this file except in compliance with the License.
+ *   You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *   limitations under the License.
+ *
+ */
+package org.apache.rms.je.role ;
+
+
+import org.apache.rms.Role ;
+import org.apache.rms.RmsException ;
+import org.apache.rms.Application;
+import org.apache.rms.je.sequence.Sequence ;
+
+import org.apache.commons.lang.Validate ;
+import org.apache.commons.lang.NotImplementedException ;
+
+import java.util.List ;
+import java.util.Iterator ;
+import java.io.UnsupportedEncodingException;
+
+import com.sleepycat.je.*;
+
+
+/**
+ * A RoleDAO implementation based on the Berkeley Database Je.
+ * 
+ * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class JeRoleDAO implements RoleDAO
+{
+    /** the name of the secondary database keyed by application name */
+    static final String APP_SECDB = "byAppName" ;
+    /** the name of the secondary database keyed by role name */
+    static final String ROLE_SECDB = "byRoleName" ;
+
+    /** A Role binding */
+    private static final JeRoleBinding BINDING =
+            new JeRoleBinding() ;
+
+    /** the JE database to use for this DAO */
+    private final Database db ;
+    /** the sequence we use to create new role database row ids with */
+    private final Sequence seq ;
+    /** the secondary database keyed by application name */
+    private SecondaryDatabase byAppName ;
+    /** the secondary database keyed by role name*/
+    private SecondaryDatabase byRoleName ;
+    /** the monitor notified on important DAO operations */
+    private RoleDAOMonitor monitor ;
+
+
+    // ----------------------------------------------------------------------
+    // C O N S T R U C T O R S
+    // ----------------------------------------------------------------------
+
+
+    /**
+     * Creates a JE based permission DAO using a JE database.
+     *
+     * @param db the JE Database for the permission DAO
+     */
+    public JeRoleDAO( Database db, Sequence seq ) throws RmsException
+    {
+        Validate.notNull( db ) ;
+        Validate.notNull( seq ) ;
+
+        this.db = db ;
+        this.seq = seq ;
+        this.monitor = new RoleDAOMonitorAdapter() ;
+
+        List secdbs = null ;
+        try
+        {
+            secdbs = this.db.getSecondaryDatabases() ;
+            for ( int ii = 0; ii < secdbs.size(); ii++ )
+            {
+                SecondaryDatabase secdb = ( SecondaryDatabase ) secdbs.get( ii ) ;
+                if ( secdb.getDatabaseName().equals( APP_SECDB ) )
+                {
+                    byAppName = secdb ;
+                }
+                else if ( secdb.getDatabaseName().equals( ROLE_SECDB ) )
+                {
+                    byRoleName = secdb ;
+                }
+            }
+        }
+        catch ( DatabaseException e )
+        {
+            throw new RmsException( e ) ;
+        }
+
+        Validate.notNull( byAppName ) ;
+        Validate.notNull( byRoleName ) ;
+    }
+
+
+    // ----------------------------------------------------------------------
+    // D A O   I M P L E M E N T A T I O N S
+    // ----------------------------------------------------------------------
+
+
+    /**
+     * Creates a role within the database for an application.
+     *
+     * @param application the application associated with the role
+     * @param roleName the name of the role
+     * @throws org.apache.rms.RmsException if there is a failure accessing
+     * the underlying database, or the role already exists, or the application
+     * does not exist
+     */
+    public void create( Application application, String roleName ) throws RmsException
+    {
+        throw new NotImplementedException( "STUB" ) ;
+    }
+
+
+    /**
+     * Deletes a role within the database for an application.
+     *
+     * @param appName the name of the application associated with the role
+     * @param roleName the name of the role
+     * @throws org.apache.rms.RmsException if there is a failure accessing
+     * the underlying database, or the role does not exist, or the application
+     * does not exist
+     */
+    public void delete( String appName, String roleName ) throws RmsException
+    {
+        throw new NotImplementedException( "STUB" ) ;
+    }
+
+
+    /**
+     * Renames a role within the database for an application.
+     *
+     * @param appName the name of the application
+     * @param oldName the old name of the role
+     * @param newName the new name for the role
+     * @throws org.apache.rms.RmsException if there is a failure accessing
+     * the underlying database, or the role does not exist, or the application
+     * does not exist or a role with the new name already exists.
+     */
+    public void rename( String appName, String oldName, String newName ) throws RmsException
+    {
+        throw new NotImplementedException( "STUB" ) ;
+    }
+
+
+    /**
+     * Gets a role within the database for an application.
+     *
+     * @param application the application associated with the role
+     * @param roleName the name of the role
+     * @return the role with the specified name for the specified application
+     * @throws org.apache.rms.RmsException if there is a failure accessing the
+     * underlying database, or the role does not exist, or the application
+     * does not exist
+     */
+    public Role get( Application application, String roleName ) throws RmsException
+    {
+        throw new NotImplementedException( "STUB" ) ;
+    }
+
+
+    /**
+     * Checks to see if a role exists within the database for an application.
+     *
+     * @param appName  the name of the application
+     * @param roleName the name of the role
+     * @return true if the role exists false if it does not
+     * @throws org.apache.rms.RmsException if there is a failure accessing the
+     * underlying database
+     */
+    public boolean has( String appName, String roleName ) throws RmsException
+    {
+        DatabaseEntry key = new DatabaseEntry() ;
+        DatabaseEntry value = new DatabaseEntry() ;
+        DatabaseEntry nameEntry = new DatabaseEntry() ;
+        DatabaseEntry appNameEntry = new DatabaseEntry() ;
+        OperationStatus status = null ;
+
+        try
+        {
+            nameEntry.setData( roleName.getBytes( "UTF-8" ) ) ;
+            appNameEntry.setData( appName.getBytes( "UTF-8" ) ) ;
+        }
+        catch ( UnsupportedEncodingException e )
+        {
+            throw new RmsException( e ) ;
+        }
+
+        JoinCursor cursor = null ;
+        SecondaryCursor appNameCursor = null ;
+        SecondaryCursor roleNameCursor = null ;
+
+        try
+        {
+            appNameCursor = byAppName.openSecondaryCursor( null, null ) ;
+            roleNameCursor = byRoleName.openSecondaryCursor( null, null ) ;
+
+            status = roleNameCursor.getSearchKey( nameEntry, value,
+                    LockMode.DEFAULT ) ;
+
+            if ( status != OperationStatus.SUCCESS )
+            {
+                return false ;
+            }
+
+            status = appNameCursor.getSearchKey( appNameEntry, value,
+                    LockMode.DEFAULT ) ;
+
+            if ( status != OperationStatus.SUCCESS )
+            {
+                return false ;
+            }
+
+            SecondaryCursor [] secCursors = { roleNameCursor, appNameCursor } ;
+            cursor = db.join( secCursors, null ) ;
+            status = cursor.getNext( key, value, LockMode.DEFAULT ) ;
+
+            if ( status != OperationStatus.SUCCESS )
+            {
+                return false ;
+            }
+        }
+        catch ( DatabaseException e )
+        {
+            throw new RmsException( e ) ;
+        }
+        finally
+        {
+            closeNoError( cursor ) ;
+            closeNoError( roleNameCursor ) ;
+            closeNoError( appNameCursor ) ;
+        }
+
+        return true ;
+    }
+
+
+    /**
+     * Gets the grants bit permission vector associated with a role.
+     *
+     * @param appName  the name of the application
+     * @param roleName the name of the role
+     * @return a byte array representing the permission grants bit vector
+     * @throws org.apache.rms.RmsException if there is a failure accessing the
+     * underlying database, or the role does not exist, or the application
+     * does not exist
+     */
+    public byte[] getGrants( String appName, String roleName ) throws RmsException
+    {
+        throw new NotImplementedException( "STUB" ) ;
+    }
+
+
+    /**
+     * Gets the grants bit permission vector associated with a role.
+     *
+     * @param appName  the name of the application
+     * @param roleName the name of the role
+     * @param grants   byte array representing the permission grants bit vector
+     * @throws org.apache.rms.RmsException if there is a failure accessing the
+     * underlying database, or the role does not exist, or the application
+     * does not exist
+     */
+    public void setGrants( String appName, String roleName, byte[] grants ) throws RmsException
+    {
+        throw new NotImplementedException( "STUB" ) ;
+    }
+
+
+    /**
+     * Lists all the roles within the entire database for all applications.
+     *
+     * @return an iterator listing all the Role objects within the database
+     * @throws org.apache.rms.RmsException if there is a failure accessing the
+     * underlying database
+     */
+    public Iterator list() throws RmsException
+    {
+        throw new NotImplementedException( "STUB" ) ;
+    }
+
+
+    /**
+     * Lists all the roles within the database defined for an application.
+     *
+     * @param appName the name of the application
+     * @return an iterator listing all the Role objects for the application
+     * @throws org.apache.rms.RmsException if there is a failure accessing the
+     * underlying database, or if the application does not exist
+     */
+    public Iterator list( String appName ) throws RmsException
+    {
+        throw new NotImplementedException( "STUB" ) ;
+    }
+
+
+    /**
+     * Lists the role names within the database for all applications.
+     *
+     * @return an iterator listing all names of roles within the database
+     * @throws org.apache.rms.RmsException if there is a failure accessing
+     * the underlying database
+     */
+    public Iterator listNames() throws RmsException
+    {
+        throw new NotImplementedException( "STUB" ) ;
+    }
+
+
+    /**
+     * Lists the role names within the database defined for an application.
+     *
+     * @param appName the name of the application
+     * @return an iterator listing the role names defined for an application
+     * @throws org.apache.rms.RmsException if there is a failure accessing the
+     * underlying database, or if the application does not exist
+     */
+    public Iterator listNames( String appName ) throws RmsException
+    {
+        throw new NotImplementedException( "STUB" ) ;
+    }
+
+
+    // -----------------------------------------------------------------------
+    // Utility Methods
+    // -----------------------------------------------------------------------
+
+
+    /**
+     * Closes a cursor without throwing an error.
+     *
+     * @param cursor the cursor to close.
+     */
+    private void closeNoError( Cursor cursor )
+    {
+        if ( cursor == null )
+        {
+            monitor.cleanedUp( this, "close", cursor ) ;
+            return ;
+        }
+
+        try
+        {
+            cursor.close() ;
+        }
+        catch ( DatabaseException e )
+        {
+            monitor.failedOnCleanupOperation( this, "close", cursor, e ) ;
+        }
+    }
+
+
+    /**
+     * Closes a cursor without throwing an error.
+     *
+     * @param cursor the cursor to close.
+     */
+    private void closeNoError( JoinCursor cursor )
+    {
+        if ( cursor == null )
+        {
+            monitor.cleanedUp( this, "close", cursor ) ;
+            return ;
+        }
+
+        try
+        {
+            cursor.close() ;
+        }
+        catch ( DatabaseException e )
+        {
+            monitor.failedOnCleanupOperation( this, "close", cursor, e ) ;
+        }
+    }
+}

Added: incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/role/RoleDAO.java
==============================================================================
--- (empty file)
+++ incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/role/RoleDAO.java	Tue Apr
27 22:29:57 2004
@@ -0,0 +1,149 @@
+/*
+ *   Copyright 2004 The Apache Software Foundation
+ *
+ *   Licensed under the Apache License, Version 2.0 (the "License");
+ *   you may not use this file except in compliance with the License.
+ *   You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *   limitations under the License.
+ *
+ */
+package org.apache.rms.je.role ;
+
+
+import org.apache.rms.Role ;
+import org.apache.rms.RmsException ;
+import org.apache.rms.Application;
+
+import java.util.Iterator ;
+
+
+/**
+ * A Role data access object interface.
+ * 
+ * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory Project</a>
+ * @version $Rev$
+ */
+public interface RoleDAO
+{
+    /**
+     * Creates a role within the database for an application.
+     *
+     * @param application the application associated with the role
+     * @param roleName the name of the role
+     * @throws RmsException if there is a failure accessing the underlying
+     * database, or the role already exists, or the application does not exist
+     */
+    void create( Application application, String roleName ) throws RmsException ;
+
+    /**
+     * Deletes a role within the database for an application.
+     *
+     * @param appName the name of the application associated with the role
+     * @param roleName the name of the role
+     * @throws RmsException if there is a failure accessing the underlying
+     * database, or the role does not exist, or the application does not exist
+     */
+    void delete( String appName, String roleName ) throws RmsException ;
+
+    /**
+     * Renames a role within the database for an application.
+     *
+     * @param appName the name of the application
+     * @param oldName the old name of the role
+     * @param newName the new name for the role
+     * @throws RmsException if there is a failure accessing the underlying
+     * database, or the role does not exist, or the application does not exist
+     * or a role with the new name already exists.
+     */
+    void rename( String appName, String oldName, String newName ) throws RmsException ;
+
+    /**
+     * Gets a role within the database for an application.
+     *
+     * @param application the application associated with the role
+     * @param roleName the name of the role
+     * @return the role with the specified name for the specified application
+     * @throws RmsException if there is a failure accessing the underlying
+     * database, or the role does not exist, or the application does not exist
+     */
+    Role get( Application application, String roleName ) throws RmsException ;
+
+    /**
+     * Gets the grants bit permission vector associated with a role.
+     *
+     * @param appName the name of the application
+     * @param roleName the name of the role
+     * @return a byte array representing the permission grants bit vector
+     * @throws RmsException if there is a failure accessing the underlying
+     * database, or the role does not exist, or the application does not exist
+     */
+    byte[] getGrants( String appName, String roleName ) throws RmsException ;
+
+    /**
+     * Gets the grants bit permission vector associated with a role.
+     *
+     * @param appName the name of the application
+     * @param roleName the name of the role
+     * @param grants byte array representing the permission grants bit vector
+     * @throws RmsException if there is a failure accessing the underlying
+     * database, or the role does not exist, or the application does not exist
+     */
+    void setGrants( String appName, String roleName, byte[] grants ) throws RmsException
;
+
+    /**
+     * Checks to see if a role exists within the database for an application.
+     *
+     * @param appName the name of the application
+     * @param roleName the name of the role
+     * @return true if the role exists false if it does not
+     * @throws RmsException if there is a failure accessing the underlying
+     * database
+     */
+    boolean has( String appName, String roleName ) throws RmsException ;
+
+    /**
+     * Lists all the roles within the entire database for all applications.
+     *
+     * @return an iterator listing all the Role objects within the database
+     * @throws RmsException if there is a failure accessing the underlying
+     * database
+     */
+    Iterator list() throws RmsException ;
+
+    /**
+     * Lists all the roles within the database defined for an application.
+     *
+     * @param appName the name of the application
+     * @return an iterator listing all the Role objects for the application
+     * @throws RmsException if there is a failure accessing the underlying
+     * database, or if the application does not exist
+     */
+    Iterator list( String appName ) throws RmsException ;
+
+    /**
+     * Lists the role names within the database for all applications.
+     *
+     * @return an iterator listing all names of roles within the database
+     * @throws RmsException if there is a failure accessing the underlying
+     * database
+     */
+    Iterator listNames() throws RmsException ;
+
+    /**
+     * Lists the role names within the database defined for an application.
+     *
+     * @param appName the name of the application
+     * @return an iterator listing the role names defined for an application
+     * @throws RmsException if there is a failure accessing the underlying
+     * database, or if the application does not exist
+     */
+    Iterator listNames( String appName ) throws RmsException ;
+
+}

Added: incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/role/RoleDAOMonitor.java
==============================================================================
--- (empty file)
+++ incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/role/RoleDAOMonitor.java	Tue
Apr 27 22:29:57 2004
@@ -0,0 +1,49 @@
+/*
+ *   Copyright 2004 The Apache Software Foundation
+ *
+ *   Licensed under the Apache License, Version 2.0 (the "License");
+ *   you may not use this file except in compliance with the License.
+ *   You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *   limitations under the License.
+ *
+ */
+package org.apache.rms.je.role ;
+
+
+/**
+ * A monitor interface for Role data access objects.
+ * 
+ * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory Project</a>
+ * @version $Rev$
+ */
+public interface RoleDAOMonitor
+{
+    /**
+     * Monitors events where the DAO cleans up resources using specific
+     * operations.
+     *
+     * @param dao the data access object
+     * @param op the operation performed on the resource to 'cleanup'
+     * @param resource the resource being cleaned up
+     */
+    void cleanedUp( RoleDAO dao, String op, Object resource ) ;
+
+    /**
+     * Monitors events where the DAO attempts to cleanup a resource but
+     * failes due to some fault.
+     *
+     * @param dao the data access object
+     * @param op the operation performed on the resource to 'cleanup'
+     * @param resource the resource being cleaned up
+     * @param fault the fault that caused the failure
+     */
+    void failedOnCleanupOperation( RoleDAO dao, String op, Object resource,
+                                   Throwable fault ) ;
+}

Added: incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/role/RoleDAOMonitorAdapter.java
==============================================================================
--- (empty file)
+++ incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/role/RoleDAOMonitorAdapter.java
Tue Apr 27 22:29:57 2004
@@ -0,0 +1,57 @@
+/*
+ *   Copyright 2004 The Apache Software Foundation
+ *
+ *   Licensed under the Apache License, Version 2.0 (the "License");
+ *   you may not use this file except in compliance with the License.
+ *   You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *   limitations under the License.
+ *
+ */
+package org.apache.rms.je.role;
+
+
+/**
+ * Put some documentation here.
+ * 
+ * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class RoleDAOMonitorAdapter implements RoleDAOMonitor
+{
+    /**
+     * Monitors events where the DAO cleans up resources using specific operations
+     * .
+     *
+     * @param dao      the data access object
+     * @param op       the operation performed on the resource to 'cleanup'
+     * @param resource the resource being cleaned up
+     */
+    public void cleanedUp( RoleDAO dao, String op, Object resource )
+    {
+    }
+
+    /**
+     * Monitors events where the DAO attempts to cleanup a resource but fails
+     * due to some fault.
+     *
+     * @param dao      the data access object
+     * @param op       the operation performed on the resource to 'cleanup'
+     * @param resource the resource being cleaned up
+     * @param fault    the fault that caused the failure
+     */
+    public void failedOnCleanupOperation( RoleDAO dao, String op,
+                                          Object resource, Throwable fault )
+    {
+        if ( fault != null )
+        {
+            fault.printStackTrace() ; 
+        }
+    }
+}

Mime
View raw message