directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: rev 10406 - incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/application
Date Thu, 29 Apr 2004 04:47:32 GMT
Author: akarasulu
Date: Wed Apr 28 21:47:31 2004
New Revision: 10406

Modified:
   incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/application/ApplicationDAOMonitor.java
   incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/application/ApplicationDAOMonitorAdapter.java
   incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/application/JeApplicationDAO.java
Log:
Commit changes ...

 o completed the JeApplicationDAO.rename() method
 o added new monitor interface methods for JeApplicationDAO.rename()
 o implemented new monitor methods in no-op adapter for rename()



Modified: incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/application/ApplicationDAOMonitor.java
==============================================================================
--- incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/application/ApplicationDAOMonitor.java
(original)
+++ incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/application/ApplicationDAOMonitor.java
Wed Apr 28 21:47:31 2004
@@ -16,6 +16,8 @@
  */
 package org.apache.rms.je.application ;
 
+import java.io.IOException;
+
 
 /**
  * A monitor for an Application data access object.
@@ -78,6 +80,70 @@
     void failedOnDelete( ApplicationDAO dao, Object info, String appName,
                          Throwable fault ) ;
 
+    /**
+     * Monitor callback for events where the dao failed to delete
+     * an application.
+     *
+     * @param dao the data access object that failed
+     * @param appName the name of the application
+     * @param fault the fault that caused the failure
+     */
     void failedOnDelete( ApplicationDAO dao, String appName, Throwable fault ) ;
+
+    /**
+     * Monitor callback for events where the dao failed to delete
+     * an application.
+     *
+     * @param dao the data access object that failed
+     * @param info extra implementation specific information
+     * @param appName the name of the application
+     */
+    void failedOnDelete( ApplicationDAO dao, Object info, String appName ) ;
+
+    /**
+     * Monitors callbacks for events where the dao failed to perform some
+     * operation on an application because of the existance of an application.
+     *
+     * @param dao the data access object that failed
+     * @param op the operation performed by the dao
+     * @param appName the name of the application
+     */
+    void applicationDoesNotExist( ApplicationDAO dao, String op,
+                                  String appName ) ;
+
+    /**
+     * Monitors callbacks for events where the dao failed to rename an
+     * application.
+     *
+     * @param dao the data access object that failed
+     * @param info extra implementation specific information
+     * @param oldName the original name of the application
+     * @param newName the new name of the application
+     * @param fault the fault that caused the failure
+     */
+    void failedOnRename( ApplicationDAO dao, Object info, String oldName,
+                         String newName, Throwable fault ) ;
+
+    /**
+     * Monitors callbacks for events where the dao failed to rename an
+     * application.
+     *
+     * @param dao the data access object that failed
+     * @param oldName the original name of the application
+     * @param newName the new name of the application
+     * @param fault the fault that caused the failure
+     */
+    void failedOnRename( ApplicationDAO dao, String oldName, String newName,
+                         Throwable fault ) ;
+
+    /**
+     * Monitors callbacks for events where the dao failed to rename an
+     * application.
+     *
+     * @param dao the data access object that failed
+     * @param oldName the original name of the application
+     * @param newName the new name of the application
+     */
+    void failedOnRename( ApplicationDAO dao, String oldName, String newName ) ;
 
 }

Modified: incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/application/ApplicationDAOMonitorAdapter.java
==============================================================================
--- incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/application/ApplicationDAOMonitorAdapter.java
(original)
+++ incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/application/ApplicationDAOMonitorAdapter.java
Wed Apr 28 21:47:31 2004
@@ -16,6 +16,8 @@
  */
 package org.apache.rms.je.application ;
 
+import org.apache.commons.lang.NotImplementedException;
+
 
 /**
  * A no-op application data access object monitor adapter.  At a bare minimum
@@ -122,5 +124,85 @@
         {
             fault.printStackTrace() ;
         }
+    }
+
+
+    /**
+     * Monitor callback for events where the dao failed to delete an application.
+     *
+     * @param dao     the data access object that failed
+     * @param info    extra implementation specific information
+     * @param appName the name of the application
+     */
+    public void failedOnDelete( ApplicationDAO dao, Object info, String appName )
+    {
+    }
+
+
+    /**
+     * Monitors callbacks for events where the dao failed to perform some
+     * operation on an application because of the existance of an application.
+     *
+     * @param dao     the data access object that failed
+     * @param op      the operation performed by the dao
+     * @param appName the name of the application
+     */
+    public void applicationDoesNotExist( ApplicationDAO dao, String op,
+                                         String appName )
+    {
+    }
+
+
+    /**
+     * Monitors callbacks for events where the dao failed to rename an
+     * application.
+     *
+     * @param dao     the data access object that failed
+     * @param info    extra implementation specific information
+     * @param oldName the original name of the application
+     * @param newName the new name of the application
+     * @param fault   the fault that caused the failure
+     */
+    public void failedOnRename( ApplicationDAO dao, Object info,
+                                String oldName, String newName,
+                                Throwable fault )
+    {
+        if ( fault != null )
+        {
+            fault.printStackTrace() ;
+        }
+    }
+
+
+    /**
+     * Monitors callbacks for events where the dao failed to rename
+     * an application.
+     *
+     * @param dao     the data access object that failed
+     * @param oldName the original name of the application
+     * @param newName the new name of the application
+     * @param fault   the fault that caused the failure
+     */
+    public void failedOnRename( ApplicationDAO dao, String oldName,
+                                String newName, Throwable fault )
+    {
+        if ( fault != null )
+        {
+            fault.printStackTrace() ;
+        }
+    }
+
+
+    /**
+     * Monitors callbacks for events where the dao failed to rename
+     * an application.
+     *
+     * @param dao     the data access object that failed
+     * @param oldName the original name of the application
+     * @param newName the new name of the application
+     */
+    public void failedOnRename( ApplicationDAO dao, String oldName,
+                                String newName )
+    {
     }
 }

Modified: incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/application/JeApplicationDAO.java
==============================================================================
--- incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/application/JeApplicationDAO.java
(original)
+++ incubator/directory/rms/trunk/je/src/java/org/apache/rms/je/application/JeApplicationDAO.java
Wed Apr 28 21:47:31 2004
@@ -210,7 +210,6 @@
      */
     public void delete( String appName ) throws RmsException
     {
-        DatabaseEntry key ;
         DatabaseEntry rowId ;
         OperationStatus status = null ;
         DatabaseEntry value = new DatabaseEntry() ;
@@ -227,18 +226,22 @@
 
         try
         {
-            BINDING.objectToEntry( value, appName ) ;
             status = db.delete( null, rowId ) ;
         }
-        catch ( IOException e )
+        catch ( DatabaseException e )
         {
             monitor.failedOnDelete( this, appName, e ) ;
             throw new RmsException( e ) ;
         }
-        catch ( DatabaseException e )
+
+        if ( status == OperationStatus.NOTFOUND )
         {
-            monitor.failedOnDelete( this, appName, e ) ;
-            throw new RmsException( e ) ;
+            monitor.applicationDoesNotExist( this, status, "delete", appName ) ;
+            throw new JeRmsException( status ) ;
+        }
+        else if ( status != OperationStatus.SUCCESS )
+        {
+            monitor.failedOnDelete( this, status, appName ) ;
         }
     }
 
@@ -254,7 +257,53 @@
      */
     public void rename( String oldName, String newName ) throws RmsException
     {
-        throw new NotImplementedException( "STUB" ) ;
+        DatabaseEntry rowId ;
+        OperationStatus status = null ;
+        DatabaseEntry value = new DatabaseEntry() ;
+
+        if ( has( newName ) )
+        {
+            monitor.applicationDoesNotExist( this, "rename", oldName ) ;
+            throw new RmsException( "Cannot rename " + oldName + " to "
+                    + newName + ": An application by the name of " + newName
+                    + " already exists" ) ;
+        }
+
+        try
+        {
+            rowId = getRowId( oldName ) ;
+        }
+        catch ( JeRmsException e )
+        {
+            monitor.failedOnRename( this, e.getStatus(), oldName, newName, e ) ;
+            throw e ;
+        }
+
+        try
+        {
+            BINDING.objectToEntry( value, newName ) ;
+            status = db.put( null, rowId, value ) ;
+        }
+        catch ( IOException e )
+        {
+            monitor.failedOnRename( this, oldName, newName, e ) ;
+            throw new RmsException( e ) ;
+        }
+        catch ( DatabaseException e )
+        {
+            monitor.failedOnRename( this, oldName, newName, e ) ;
+            throw new RmsException( e ) ;
+        }
+
+        if ( status == OperationStatus.NOTFOUND )
+        {
+            monitor.applicationDoesNotExist( this, status, "rename", oldName ) ;
+            throw new JeRmsException( status ) ;
+        }
+        else if ( status != OperationStatus.SUCCESS )
+        {
+            monitor.failedOnRename( this, oldName, newName ) ;
+        }
     }
 
 

Mime
View raw message