public final class DBSchemaEdit extends java.lang.Object 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.
| Modifier and Type | Field and Description |
|---|---|
private java.lang.String |
adminName
The name of the admin who is editing the schema.
|
(package private) static boolean |
debug |
private java.lang.String |
disableToken
The token that was used to lock the server for schema edit.
|
private boolean |
locked
if true, this DBSchemaEdit object has already been
committed or aborted
|
(package private) java.util.Hashtable<java.lang.Short,DBObjectBase> |
newBases
A copy of the DBObjectBase objects comprising the DBStore's
database.
|
(package private) java.util.Vector<DBNameSpace> |
oldNameSpaces
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.. if the
DBSchemaEdit session is committed, this DBBaseCategory tree
will replace store.rootCategory.
|
private DBStore |
store
the DBStore object whose DBObjectBases are being edited
|
(package private) static TranslationService |
ts
TranslationService object for handling string localization in the
Ganymede server.
|
| Constructor and Description |
|---|
DBSchemaEdit(java.lang.String adminName)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
private ReturnVal |
checkCommitState()
This private helper method verifies that the proposed schema is
acceptable to be committed.
|
ReturnVal |
commit()
Commits this schema edit, replaces the server's schema with
the modified schema produced by this DBSchemaEdit session.
|
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. |
ReturnVal |
deleteUnusedNameSpaces()
This method deletes all
DBNameSpace objects in the
server's schema that are not currently attached to any
namespace-constrained field. |
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 an array of Base references from the current
(non-committed) state of the system.
|
Base[] |
getBases(boolean embedded)
Returns an array of Base references from the current
(non-committed) state of the system.
|
CategoryNode |
getCategoryNode(java.lang.String pathName)
Gets a category from the category list, by it's fully qualified
path name.
|
DBObjectBase[] |
getDBBases()
Returns an array of DBObjectBases from the current
(non-committed) state of the system.
|
DBObjectBase[] |
getDBBases(boolean embedded)
Returns an array of DBObjectBase from the current
(non-committed) state of the system.
|
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.
|
private void |
unexportNameSpaces() |
void |
unreferenced()
This method is called when the client loses connection.
|
static final boolean debug
static final TranslationService ts
private boolean locked
private final DBStore store
private final java.lang.String adminName
private final java.lang.String disableToken
java.util.Hashtable<java.lang.Short,DBObjectBase> newBases
java.util.Vector<DBNameSpace> oldNameSpaces
DBBaseCategory rootCategory
public DBSchemaEdit(java.lang.String adminName)
throws java.rmi.RemoteException
java.rmi.RemoteExceptionpublic Category getRootCategory()
getRootCategory in interface SchemaEditSchemaEditpublic CategoryNode getCategoryNode(java.lang.String pathName)
public Base[] getBases(boolean embedded)
Returns an array of Base references from the current (non-committed) state of the system.
getBases in interface SchemaEditembedded - 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.SchemaEditpublic DBObjectBase[] getDBBases(boolean embedded)
Returns an array of DBObjectBase from the current (non-committed) state of the system.
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.public Base[] getBases()
Returns an array of Base references from the current (non-committed) state of the system.
getBases in interface SchemaEditSchemaEditpublic DBObjectBase[] getDBBases()
Returns an array of DBObjectBases from the current (non-committed) state of the system.
public Base getBase(short id)
Base reference to match the id, or
null if no match.getBase in interface SchemaEditSchemaEditpublic Base getBase(java.lang.String baseName)
Base reference to match the baseName,
or null if no match.getBase in interface SchemaEditSchemaEditpublic Base createNewBase(Category category, boolean embedded, boolean lowRange)
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.createNewBase in interface SchemaEditSchemaEditpublic Base createNewBase(Category category, boolean embedded, short id)
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.public ReturnVal deleteBase(java.lang.String baseName) throws java.rmi.RemoteException
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.deleteBase in interface SchemaEditjava.rmi.RemoteExceptionSchemaEditpublic NameSpace[] getNameSpaces()
NameSpace objects.getNameSpaces in interface SchemaEditSchemaEditpublic NameSpace getNameSpace(java.lang.String name)
NameSpace by matching name,
or null if no match is found.getNameSpace in interface SchemaEditNameSpace,
SchemaEditpublic 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.
createNewNameSpace in interface SchemaEditSchemaEditpublic ReturnVal deleteNameSpace(java.lang.String name)
This method deletes a DBNameSpace object,
returning true if the deletion could be carried out, false
otherwise.
deleteNameSpace in interface SchemaEditSchemaEditpublic ReturnVal deleteUnusedNameSpaces() throws java.rmi.RemoteException
This method deletes all DBNameSpace objects in the
server's schema that are not currently attached to any
namespace-constrained field.
deleteUnusedNameSpaces in interface SchemaEditjava.rmi.RemoteExceptionpublic ReturnVal commit()
Commits this schema edit, replaces the server's schema with the modified schema produced by this DBSchemaEdit session.
It is an error to attempt any schema editing operations after this method has been called.
commit in interface SchemaEditprivate ReturnVal checkCommitState()
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.
release in interface SchemaEditprivate void unexportNameSpaces()
public void unreferenced()
unreferenced in interface java.rmi.server.Unreferenced