public class WGHierarchicalDatabase
extends java.lang.Object
wraps a wga content store to use it as hierarchical database
simplifies creating content documents for data storage use
creation of ContentTypes, Languages, Areas is encapsulated
WGHierarchicalDatabase automatical create the following areas:
- HDB-Content (used for content)
- HDB-System (used for meta information about the db)
WGHierarchicalDatabase automatical create the following content types:
- HDB-ContentType with outer-layout HDB-Layout
The hdb structure contains WGContents. Each WGContent is of type HDB-ContentType
and created in the default language of the database. All neccessary WGStructEntries are handled and created
by the hdb automatically.
A WGContent in the hdb can either be used as a storage or as a content. A storage has a special struct-entry
which is by default write/edit-protected with the role ($HDBAdmin). Therefore normal users cannot delete a
whole hdb structure. A storage contains contents and might contains substorages. When a storage is created the user
should give an id for it. This id is used to create a unique id for the storage, based on the hierarchical storage
structure. The unique id of a storage contains all parent storage ids concated by "."
for e.g.: storageA
|- storageB
|- storageC
unique id of A is: "storageA"
unique id of B is: "storageA.storageB"
unique id of C is: "storageA.storageB.storageC"
The unique id of a storage is set as unique name for the WGContent object, so the unique storage id can be used
directly for e.g. in context expressions.
A startup script can be defined with the publisher option "de.innovationgate.wgpublisher.WGACore.DBATTRIB_HDBInit"
This can be either a class name of a class which implements
WGHierarchicalDatabaseStartup
or a name of a tmlsscript module within this db.
The startup script is executed when an hdb instance gets connected.
It can be used to create storages and define the initial db-structure.
Modifier and Type | Class and Description |
---|---|
static class |
WGHierarchicalDatabase.PostUpdateEventBehaviour
Behaviour regarding the post update event
|
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
AREA_CONTENT
Name of the area in which HDB content is to be stored
|
static java.lang.String |
CONTENT_TYPE
Name of the content type which HDB content pages belong to
|
static java.lang.String |
DBATTRIB_HDB_USE_VERSIONING
Attribute to control if HDB should use versioning when updating contents.
|
static java.lang.String |
ITEMNAME_LISTENER_CLASS_OR_MODULE
Item name in which the name of a HDB listener class or module for a content is stored
|
static java.lang.String |
SESSIONPARAM_HDBPARAMETER
Name under which the HDB event parameter is stored as attribute of the
WGSessionContext |
static java.lang.String |
STORAGE_ADMIN_ROLE
ACL Role name which is granted administrative HDB rights, like editing rights to HDB storage documents.
|
static java.lang.String |
STORAGE_DELIMITER
Character by which the name parts of HDB storage ids are divided
|
Modifier and Type | Method and Description |
---|---|
static void |
addCoreListener(WGHierarchicalDatabaseCoreListener listener)
Adds a HDB core listener
|
java.lang.String |
assignContentUID(WGContent con,
java.lang.String id)
Issues an UID to a content document.
|
WGContent |
createContent(WGContent parent)
creates a child content of the given parent with a generated title
|
WGContent |
createContent(WGContent parent,
java.lang.String title)
creates a child content of the given parent with the given title,
|
WGContent |
createContent(WGContent parent,
java.lang.String title,
java.lang.Object parameter)
creates a child content of the given parent with the given title,
parameter is delivered within the contentCreatedEvent
|
static void |
createInstance(WGDatabase database,
WGHierarchicalDatabaseStartup startupImpl)
creates a new hdb instance for the given WGDatabase
|
static void |
createInstance(WGDatabase database,
WGHierarchicalDatabaseStartup startupImpl,
WGHierarchicalDatabaseListenerFactory listenerFactory)
creates a new hdb instance for the given WGDatabase
|
WGContent |
createStorage(java.lang.String id)
creates a storage with the given id
|
WGContent |
createStorage(java.lang.String id,
java.lang.Object parameter)
creates a storage with the given id
|
WGContent |
createStorage(WGContent parent,
java.lang.String id)
creates a storage with the given id as child of the given parent storage
|
WGContent |
createStorage(WGContent parent,
java.lang.String id,
java.lang.Object parameter)
creates a storage with the given id as child of the given parent storage
|
java.lang.String |
createStorageUID(WGContent parent,
java.lang.String id) |
void |
deleteContent(java.lang.String key)
deletes the content determined by the given key
|
void |
deleteContent(java.lang.String key,
java.lang.Object parameter)
deletes the content determined by the given key
|
void |
deleteContent(WGContent content)
deletes the given content
|
void |
deleteContent(WGContent content,
java.lang.Object parameter)
deletes the given content
|
void |
deleteStorage(java.lang.String uid)
deletes the storage with the given id
|
WGContent |
getContent(java.lang.String key)
returns currently published content object for the given key
|
WGContentType |
getContentType()
Retrieves the WGAPI Content Type that this HDB uses to construct contents
|
static WGHierarchicalDatabaseListenerFactory |
getDefaultListenerFactory()
Returns the default listener factory for all HDB instances
|
static WGHierarchicalDatabaseStartup |
getDefaultStartupImpl()
Returns the default startup implementation for all HDB instances
|
WGContent |
getDummyContent()
Returns a dummy content object for the current database in the language that the HDB uses
|
static WGHierarchicalDatabase |
getInstance(java.lang.String dbKey)
returns the requested hdb for the given dbKey, instance have to be create prior by using createInstance(...)
|
java.lang.String |
getKey(WGContent content)
returns a db wide unique key for the given content
|
WGLanguage |
getLanguage()
Returns the language that the HDB uses to create content
|
static WGHierarchicalDatabase |
getOrCreateInstance(WGDatabase db)
returns the requested hdb for the given db, instance is created if not existing using the default startup and listenerFactory implementations
|
WGContent |
getOrCreateStorage(java.lang.String id)
creates the storage with the given id if not exists
|
WGContent |
getOrCreateStorage(java.lang.String id,
java.lang.Object parameter)
creates the storage with the given id if not exists
|
WGContent |
getOrCreateStorage(WGContent parent,
java.lang.String id)
creates the storage with the given id as child of the given parent storage
|
WGContent |
getOrCreateStorage(WGContent parent,
java.lang.String id,
java.lang.Object parameter)
creates the storage with the given id as child of the given parent storage
|
WGContent |
getOrCreateUIDContent(WGContent parent,
java.lang.String id)
creates the content with the given uid as child of the given parent document, if not yet existent
|
WGContent |
getOrCreateUIDContent(WGContent parent,
java.lang.String id,
java.lang.Object parameter)
creates the content with the given uid as child of the given parent document, if not yet existent
|
WGHierarchicalDatabase.PostUpdateEventBehaviour |
getPostUpdateEventBehaviour()
Returns the behaviour of this HDB instance regarding post update events
|
java.util.List |
getRootDocuments()
Returns all root documents in this Database
|
WGContent |
getStorage(java.lang.String uid)
returns the storage with the given uid
|
WGDatabase |
getWrappedDB()
Returns the
WGDatabase object wrapped by this hdb |
boolean |
isHdbModelMode()
Returns if this HDB instance is in HDBModel model.
|
boolean |
isStorage(WGContent content)
Determines if the given content document is a HDB storage
|
boolean |
isUseVersioning()
Determines if this HDB instance uses versioning.
|
void |
moveContent(WGContent content,
WGContent newParent)
moves the given content under the given parent content
pre- and post-move events are first fired on the old hierarchy and then on the new hierarchy
if target parent is null the content will be moved to the db root
|
void |
moveContent(WGContent content,
WGContent newParent,
java.lang.Object parameter)
moves the given content under the given parent content
pre- and post-move events are first fired on the old hierarchy and then on the new hierarchy
if target parent is null the content will be moved to the db root
|
static void |
removeCoreListener(WGHierarchicalDatabaseCoreListener listener)
Removes a HDB core listener
|
static void |
removeInstance(java.lang.String dbKey)
removes an created instance
|
void |
removeListener(WGContent content)
removes the stored listener reference from the given storage or content
|
static void |
setDefaultListenerFactory(WGHierarchicalDatabaseListenerFactory listenerFactory)
Sets the default listener factory for all HDB instances
|
static void |
setDefaultStartupImpl(WGHierarchicalDatabaseStartup startupImpl)
Sets the default startup implementation for all HDB instances
|
void |
setHdbModelMode(boolean hdbModelMode)
Sets if this HDB instance is in HDBModel mode.
|
void |
setListener(WGContent content,
java.lang.String moduleOrClassname)
sets the given module (tmlscriptmodule) or classname (implementation of WGHierarchicalContentListener)
on the given storage or content
|
void |
setPostUpdateEventBehaviour(WGHierarchicalDatabase.PostUpdateEventBehaviour postUpdateEventBehaviour)
Sets a behaviour for post update events
|
void |
setUseVersioning(boolean useVersioning)
Sets if this HDB instance should use versioning.
|
void |
updateContent(WGContent content)
updates the given content within the listener, parameter will be null, leaves the title unchanged
|
void |
updateContent(WGContent content,
java.lang.Object parameter)
updates the given content within the listener using parameter, leaves the title unchanged
|
WGContent |
updateContent(WGContent content,
java.lang.String title,
java.lang.Object parameter)
updates the title on the given content and optional further fields within the listener using parameter
if versioning is enabled the post_update_event is executed on a draft copy
|
public static final java.lang.String SESSIONPARAM_HDBPARAMETER
WGSessionContext
public static final java.lang.String AREA_CONTENT
public static final java.lang.String CONTENT_TYPE
public static final java.lang.String STORAGE_ADMIN_ROLE
public static final java.lang.String DBATTRIB_HDB_USE_VERSIONING
public static final java.lang.String ITEMNAME_LISTENER_CLASS_OR_MODULE
public static final java.lang.String STORAGE_DELIMITER
public static void createInstance(WGDatabase database, WGHierarchicalDatabaseStartup startupImpl) throws WGAPIException
database
- WGDatabase to use as backendstoragestartupImpl
- StartupScript to execute, can be 'null'WGAPIException
public static void createInstance(WGDatabase database, WGHierarchicalDatabaseStartup startupImpl, WGHierarchicalDatabaseListenerFactory listenerFactory) throws WGAPIException
database
- WGDatabase to use as backendstoragestartupImpl
- StartupScript to execute, can be 'null'listenerFactory
- WGHierarchicalDatabaseListenerFactory implementation to use for listener creationWGAPIException
public static void removeInstance(java.lang.String dbKey)
dbKey
- public static WGHierarchicalDatabase getInstance(java.lang.String dbKey) throws WGAPIException
dbKey
- WGAPIException
public static WGHierarchicalDatabase getOrCreateInstance(WGDatabase db) throws WGAPIException
db
- WGDatabase to use as backendstorageWGAPIException
public boolean isStorage(WGContent content) throws WGAPIException
content
- The content documentWGAPIException
public WGContentType getContentType() throws WGAPIException
WGAPIException
public WGLanguage getLanguage() throws WGAPIException
WGAPIException
public WGContent getDummyContent() throws WGAPIException
WGAPIException
public WGDatabase getWrappedDB()
WGDatabase
object wrapped by this hdbpublic WGContent createContent(WGContent parent, java.lang.String title, java.lang.Object parameter) throws WGAPIException, WGHierarchicalDatabaseEventException
parent
- either a storage or a contenttitle
- if 'null' a title is generatedparameter
- can be retrieved in the event listener by event.getParameter()WGAPIException
WGHierarchicalDatabaseEventException
- - if a listener cancel the processpublic WGContent createContent(WGContent parent, java.lang.String title) throws WGAPIException, WGHierarchicalDatabaseEventException
parent
- either a storage or a contenttitle
- if 'null' a title is generatedWGAPIException
WGHierarchicalDatabaseEventException
- - if a listener cancel the processpublic WGContent createContent(WGContent parent) throws WGAPIException, WGHierarchicalDatabaseEventException
parent
- either a storage or a contentWGAPIException
WGHierarchicalDatabaseEventException
- - if a listener cancel the processpublic void deleteContent(WGContent content, java.lang.Object parameter) throws WGAPIException, WGHierarchicalDatabaseEventException
content
- WGContentparameter
- can be retrieved in the event listener by event.getParameter()WGAPIException
WGHierarchicalDatabaseEventException
- - if a listener cancel the processpublic void deleteContent(WGContent content) throws WGAPIException, WGHierarchicalDatabaseEventException
content
- WGContentWGAPIException
WGHierarchicalDatabaseEventException
public WGContent updateContent(WGContent content, java.lang.String title, java.lang.Object parameter) throws WGAPIException, WGHierarchicalDatabaseEventException
content
- the content to updatetitle
- the new value for the title, 'null' will leave the title unchangedparameter
- can be retrieved in the event listener by event.getParameter()WGAPIException
WGHierarchicalDatabaseEventException
- if a listener has canceled the processpublic void moveContent(WGContent content, WGContent newParent, java.lang.Object parameter) throws WGHierarchicalDatabaseEventException, WGAPIException
content
- the content to movenewParent
- the new parent to move the content toparameter
- can be retrieved in the event listener by event.getParameter()WGHierarchicalDatabaseEventException
- if a listener has canceled the processWGAPIException
public void moveContent(WGContent content, WGContent newParent) throws WGHierarchicalDatabaseEventException, WGAPIException
content
- the content to movenewParent
- the new parent to move the content toWGHierarchicalDatabaseEventException
- if a listener has canceled the processWGAPIException
public void updateContent(WGContent content) throws WGAPIException, WGHierarchicalDatabaseEventException
content
- the content to updateWGAPIException
WGHierarchicalDatabaseEventException
- if a listener has canceled the processpublic void updateContent(WGContent content, java.lang.Object parameter) throws WGAPIException, WGHierarchicalDatabaseEventException
content
- the content to updateparameter
- can be retrieved in the event listener by event.getParameter()WGAPIException
WGHierarchicalDatabaseEventException
- if a listener has canceled the processpublic void deleteContent(java.lang.String key) throws WGAPIException, WGHierarchicalDatabaseEventException
key
- determined by getKey(WGContent)WGAPIException
WGHierarchicalDatabaseEventException
- if a listener has canceled the processpublic void deleteContent(java.lang.String key, java.lang.Object parameter) throws WGAPIException, WGHierarchicalDatabaseEventException
key
- determined by getKey(WGContent)parameter
- can be retrieved in the event listener by event.getParameter()WGHierarchicalDatabaseEventException
- if a listener has canceled the processWGAPIException
public WGContent getContent(java.lang.String key) throws WGAPIException
key
- determined by getKey(WGContent)WGAPIException
public java.lang.String getKey(WGContent content) throws WGAPIException
content
- WGAPIException
public void setListener(WGContent content, java.lang.String moduleOrClassname) throws WGAPIException
content
- moduleOrClassname
- WGAPIException
public void removeListener(WGContent content) throws WGAPIException
content
- WGAPIException
public WGContent createStorage(java.lang.String id, java.lang.Object parameter) throws WGAPIException
id
- parameter
- WGAPIException
WGDuplicateKeyException
- if storage already existspublic WGContent createStorage(java.lang.String id) throws WGAPIException
id
- WGAPIException
WGDuplicateKeyException
- if storage already existspublic WGContent createStorage(WGContent parent, java.lang.String id, java.lang.Object parameter) throws WGAPIException
parent
- - parent storageid
- parameter
- WGAPIException
WGDuplicateKeyException
- if storage already existspublic WGContent createStorage(WGContent parent, java.lang.String id) throws WGAPIException
parent
- - parent storageid
- WGAPIException
WGDuplicateKeyException
- if storage already existspublic WGContent getStorage(java.lang.String uid) throws WGAPIException
uid
- WGAPIException
public WGContent getOrCreateStorage(java.lang.String id, java.lang.Object parameter) throws WGAPIException
id
- parameter
- WGAPIException
public WGContent getOrCreateStorage(java.lang.String id) throws WGAPIException
id
- WGAPIException
public WGContent getOrCreateStorage(WGContent parent, java.lang.String id, java.lang.Object parameter) throws WGAPIException
parent
- the parent storageid
- parameter
- WGAPIException
public WGContent getOrCreateStorage(WGContent parent, java.lang.String id) throws WGAPIException
parent
- the parent storageid
- WGAPIException
public WGContent getOrCreateUIDContent(WGContent parent, java.lang.String id, java.lang.Object parameter) throws WGAPIException
parent
- the parent documentid
- The uid of the contentparameter
- An optional parameter for HDB listenersWGAPIException
public WGContent getOrCreateUIDContent(WGContent parent, java.lang.String id) throws WGAPIException
parent
- the parent documentid
- The uid of the contentWGAPIException
public void deleteStorage(java.lang.String uid) throws WGAPIException
uid
- WGAPIException
public java.lang.String createStorageUID(WGContent parent, java.lang.String id) throws WGAPIException
WGAPIException
public java.lang.String assignContentUID(WGContent con, java.lang.String id) throws WGAPIException
con
- The content that should be issued a UIDid
- The local id of this contentWGAPIException
public java.util.List getRootDocuments() throws WGAPIException
WGAPIException
public static WGHierarchicalDatabaseListenerFactory getDefaultListenerFactory()
public static void setDefaultListenerFactory(WGHierarchicalDatabaseListenerFactory listenerFactory)
public static WGHierarchicalDatabaseStartup getDefaultStartupImpl()
public static void setDefaultStartupImpl(WGHierarchicalDatabaseStartup startupImpl)
public static void addCoreListener(WGHierarchicalDatabaseCoreListener listener)
public static void removeCoreListener(WGHierarchicalDatabaseCoreListener listener)
public WGHierarchicalDatabase.PostUpdateEventBehaviour getPostUpdateEventBehaviour()
public void setPostUpdateEventBehaviour(WGHierarchicalDatabase.PostUpdateEventBehaviour postUpdateEventBehaviour)
public boolean isUseVersioning()
public void setUseVersioning(boolean useVersioning)
public boolean isHdbModelMode()
public void setHdbModelMode(boolean hdbModelMode)