arlut.csd.ganymede
Class DBSchemaEdit

java.lang.Object
  |
  +--java.rmi.server.RemoteObject
        |
        +--java.rmi.server.RemoteServer
              |
              +--java.rmi.server.UnicastRemoteObject
                    |
                    +--arlut.csd.ganymede.DBSchemaEdit
All Implemented Interfaces:
java.rmi.Remote, SchemaEdit, java.io.Serializable, java.rmi.server.Unreferenced

public class DBSchemaEdit
extends java.rmi.server.UnicastRemoteObject
implements java.rmi.server.Unreferenced, SchemaEdit

Server-side schema editing class. This class implements the SchemaEdit remote interface to support schema editing by the admin console.

Only one DBSchemaEdit object may be active in the server at a time; only one admin console can edit the server's schema at a time. While the server's schema is being edited, no users may be logged on to the system. An admin console puts the server into schema-editing mode by calling the editSchema() method on a server-side GanymedeAdmin object.

When the DBSchemaEdit object is created, it makes copies of all of the DBObjectBase type definition objects in the server. The admin console can then talk to those DBObjectBase objects remotely by way of the Base remote interface, accessing data fields, reordering the type tree visible in the client, and so forth.

When the user has made the desired changes, the commit() method is called, which replaces the set of DBObjectBase objects held in the server's DBStore with the modified set that was created and modified by DBSchemaEdit.

The schema editing code in the server currently has only a limited ability to verify that changes made in the schema editor will not break the database's consistency constraints in some fashion. Generally speaking, you should be using the schema editor to define new fields, or to change field definitions for fields that are not yet in use in the database, not to try to redefine parts of the database that are in actual use and which hold actual data.

The schema editing system is really the most fragile thing in the Ganymede server. It generally works, but it is not as robust as it ought to be. It's always a good idea to make a backup copy of your ganymede.db file before going in and editing your database schema.

See Also:
Serialized Form

Field Summary
(package private)  Admin console
          remote client handle
(package private) static boolean debug
           
private  boolean locked
          if true, this DBSchemaEdit object has already been committed or aborted
(package private)  java.util.Hashtable newBases
          this holds a copy of the DBObjectBase objects comprising the DBStore's database.
(package private)  java.util.Vector oldNameSpaces
          this holds the original vector of namespace objects extant at the time the DBSchemaEdit editing session is established.
(package private)  DBBaseCategory rootCategory
          root node of the working DBBaseCategory tree..
(package private)  DBStore store
          the DBStore object whose DBObjectBases are being edited
 
Fields inherited from class java.rmi.server.UnicastRemoteObject
csf, port, portFactoryParamTypes, portParamTypes, serialVersionUID, ssf
 
Fields inherited from class java.rmi.server.RemoteServer
log, logname
 
Fields inherited from class java.rmi.server.RemoteObject
ref
 
Constructor Summary
DBSchemaEdit(Admin console)
          Constructor.
 
Method Summary
 void commit()
          Commit this schema edit, instantiate the modified schema
 Base createNewBase(Category category, boolean embedded, boolean lowRange)
          This method creates a new DBObjectBase object and returns a remote handle to it so that the admin client can set fields on the base, set attributes, and generally make a nuisance of itself.
 Base createNewBase(Category category, boolean embedded, short id)
          This method creates a new DBObjectBase object and returns a remote handle to it so that the admin client can set fields on the base, set attributes, and generally make a nuisance of itself.
 NameSpace createNewNameSpace(java.lang.String name, boolean caseInsensitive)
          This method creates a new DBNameSpace object and returns a remote handle to it so that the admin client can set attributes on the DBNameSpace, and generally make a nuisance of itself.
 ReturnVal deleteBase(java.lang.String baseName)
          This method deletes a DBObjectBase, removing it from the Schema Editor's working set of bases.
 ReturnVal deleteNameSpace(java.lang.String name)
          This method deletes a DBNameSpace object, returning true if the deletion could be carried out, false otherwise.
 Base getBase(short id)
          Returns a Base reference to match the id, or null if no match.
 Base getBase(java.lang.String baseName)
          Returns a Base reference to match the baseName, or null if no match.
 Base[] getBases()
          Returns a list of bases from the current (non-committed) state of the system.
 Base[] getBases(boolean embedded)
          Returns a list of bases from the current (non-committed) state of the system.
 CategoryNode getCategoryNode(java.lang.String pathName)
          Method to get a category from the category list, by it's full path name.
 NameSpace getNameSpace(java.lang.String name)
          This method returns a NameSpace by matching name, or null if no match is found.
 NameSpace[] getNameSpaces()
          This method returns an array of defined NameSpace objects.
 Category getRootCategory()
          Returns the root category node from the server
 void release()
          Abort this schema edit, return the schema to its prior state.
 void unreferenced()
          This method is called when the client loses connection.
 
Methods inherited from class java.rmi.server.UnicastRemoteObject
, clone, exportObject, exportObject, exportObject, exportObject, readObject, reexport, unexportObject
 
Methods inherited from class java.rmi.server.RemoteServer
getClientHost, getLog, setLog
 
Methods inherited from class java.rmi.server.RemoteObject
equals, getRef, hashCode, toString, toStub, writeObject
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, registerNatives, wait, wait, wait
 

Field Detail

debug

static final boolean debug

locked

private boolean locked
if true, this DBSchemaEdit object has already been committed or aborted

store

DBStore store
the DBStore object whose DBObjectBases are being edited

newBases

java.util.Hashtable newBases
this holds a copy of the DBObjectBase objects comprising the DBStore's database. All changes made during Base editing are performed on the copies held in this hashtable.. if the DBSchemaEdit session is aborted, newBases is thrown away. If the DBSchemaEdit session is confirmed, newBases replaces store.db.objectBases.

oldNameSpaces

java.util.Vector oldNameSpaces
this holds the original vector of namespace objects extant at the time the DBSchemaEdit editing session is established.

rootCategory

DBBaseCategory rootCategory
root node of the working DBBaseCategory tree.. if the DBSchemaEdit session is committed, this DBBaseCategory tree will replace store.rootCategory.

console

Admin console
remote client handle
Constructor Detail

DBSchemaEdit

public DBSchemaEdit(Admin console)
             throws java.rmi.RemoteException

Constructor. This constructor should only be called in a critical section synchronized on the primary DBStore object.

Method Detail

getRootCategory

public Category getRootCategory()

Returns the root category node from the server

Specified by:
getRootCategory in interface SchemaEdit
See Also:
SchemaEdit

getCategoryNode

public CategoryNode getCategoryNode(java.lang.String pathName)
Method to get a category from the category list, by it's full path name.

getBases

public Base[] getBases(boolean embedded)

Returns a list of bases from the current (non-committed) state of the system.

Specified by:
getBases in interface SchemaEdit
Parameters:
embedded - If true, getBases() will only show bases that are intended for embedding in other objects. If false, getBases() will only show bases that are not to be embedded.
See Also:
SchemaEdit

getBases

public Base[] getBases()

Returns a list of bases from the current (non-committed) state of the system.

Specified by:
getBases in interface SchemaEdit
See Also:
SchemaEdit

getBase

public Base getBase(short id)

Returns a Base reference to match the id, or null if no match.

Specified by:
getBase in interface SchemaEdit
See Also:
SchemaEdit

getBase

public Base getBase(java.lang.String baseName)

Returns a Base reference to match the baseName, or null if no match.

Specified by:
getBase in interface SchemaEdit
See Also:
SchemaEdit

createNewBase

public Base createNewBase(Category category,
                          boolean embedded,
                          boolean lowRange)

This method creates a new DBObjectBase object and returns a remote handle to it so that the admin client can set fields on the base, set attributes, and generally make a nuisance of itself.

Specified by:
createNewBase in interface SchemaEdit
See Also:
SchemaEdit

createNewBase

public Base createNewBase(Category category,
                          boolean embedded,
                          short id)

This method creates a new DBObjectBase object and returns a remote handle to it so that the admin client can set fields on the base, set attributes, and generally make a nuisance of itself.


deleteBase

public ReturnVal deleteBase(java.lang.String baseName)
                     throws java.rmi.RemoteException

This method deletes a DBObjectBase, removing it from the Schema Editor's working set of bases. The removal won't take place for real unless the SchemaEdit is committed.

Specified by:
deleteBase in interface SchemaEdit
See Also:
SchemaEdit

getNameSpaces

public NameSpace[] getNameSpaces()

This method returns an array of defined NameSpace objects.

Specified by:
getNameSpaces in interface SchemaEdit
See Also:
SchemaEdit

getNameSpace

public NameSpace getNameSpace(java.lang.String name)

This method returns a NameSpace by matching name, or null if no match is found.

Specified by:
getNameSpace in interface SchemaEdit
See Also:
NameSpace, SchemaEdit

createNewNameSpace

public NameSpace createNewNameSpace(java.lang.String name,
                                    boolean caseInsensitive)

This method creates a new DBNameSpace object and returns a remote handle to it so that the admin client can set attributes on the DBNameSpace, and generally make a nuisance of itself.

Specified by:
createNewNameSpace in interface SchemaEdit
See Also:
SchemaEdit

deleteNameSpace

public ReturnVal deleteNameSpace(java.lang.String name)

This method deletes a DBNameSpace object, returning true if the deletion could be carried out, false otherwise.

Specified by:
deleteNameSpace in interface SchemaEdit
See Also:
SchemaEdit

commit

public void commit()

Commit this schema edit, instantiate the modified schema

It is an error to attempt any schema editing operations after this method has been called.

Specified by:
commit in interface SchemaEdit

release

public void release()

Abort this schema edit, return the schema to its prior state.

It is an error to attempt any schema editing operations after this method has been called.

Specified by:
release in interface SchemaEdit

unreferenced

public void unreferenced()
This method is called when the client loses connection. unreferenced() should do cleanup.
Specified by:
unreferenced in interface java.rmi.server.Unreferenced