Class XMLClusterStorage

java.lang.Object
org.cristalise.kernel.persistency.ClusterStorage
org.cristalise.storage.XMLClusterStorage

public class XMLClusterStorage extends ClusterStorage
Implementation of ClusterStorage providing the XML file based persistence.
  • Constructor Details

    • XMLClusterStorage

      public XMLClusterStorage()
    • XMLClusterStorage

      public XMLClusterStorage(String root)
      Create new XMLClusterStorage with specific setup, Used in predefined step BulkImport
      Parameters:
      root - specify the root directory
    • XMLClusterStorage

      public XMLClusterStorage(String root, String ext, Boolean useDir)
      Create new XMLClusterStorage with specific setup, Used in predefined step BulkImport
      Parameters:
      root - specify the root directory
      ext - the extension of the files with dot, e.g. '.xml', used to save the cluster content. If it is null the default '.xml' extension is used.
      useDir - specify if the files should be stored in directories or in single files, e.g. Property.Type,xml If it is null the default is true.
  • Method Details

    • open

      public void open() throws PersistencyException
      Description copied from class: ClusterStorage
      Connects to the storage. It must be possible to retrieve CRISTAL local objects after this method returns.
      Specified by:
      open in class ClusterStorage
      Throws:
      PersistencyException - If storage initialization failed
    • close

      public void close()
      Description copied from class: ClusterStorage
      Shuts down the storage. Data must be completely written to disk before this method returns, so the process can exit. No further gets or puts should follow.
      Specified by:
      close in class ClusterStorage
    • postBoostrap

      public void postBoostrap()
      Description copied from class: ClusterStorage
      Informs the ClusterSorage that the Boostrap process has finished. It enables the implementation to perform domain specific tasks
      Specified by:
      postBoostrap in class ClusterStorage
    • postStartServer

      public void postStartServer()
      Description copied from class: ClusterStorage
      Informs the ClusterSorage that the start server process has finished. It enables the implementation to perform domain specific tasks
      Specified by:
      postStartServer in class ClusterStorage
    • postConnect

      public void postConnect()
      Description copied from class: ClusterStorage
      Informs the ClusterSorage that connect was done. It enables the implementation to perform domain specific tasks
      Specified by:
      postConnect in class ClusterStorage
    • queryClusterSupport

      public short queryClusterSupport(ClusterType clusterType)
      Description copied from class: ClusterStorage
      Declares whether or not this ClusterStorage can read or write a particular CRISTAL local object type.
      Specified by:
      queryClusterSupport in class ClusterStorage
      Parameters:
      clusterType - The Cluster type requested
      Returns:
      A ClusterStorage constant: NONE, READ, WRITE, or READWRITE
    • getName

      public String getName()
      Specified by:
      getName in class ClusterStorage
      Returns:
      A full name of this storage for logging
    • getId

      public String getId()
      Specified by:
      getId in class ClusterStorage
      Returns:
      A short code for this storage for reference
    • checkQuerySupport

      public boolean checkQuerySupport(String language)
      Description copied from class: ClusterStorage
      Checks whether the storage support the given type of query or not
      Specified by:
      checkQuerySupport in class ClusterStorage
      Parameters:
      language - type of the query (e.g. SQL/XQuery/XPath/....)
      Returns:
      whether the Storage supports the type of the query or not
    • executeQuery

      public String executeQuery(Query query, TransactionKey transactionKey) throws PersistencyException
      Description copied from class: ClusterStorage
      Executes an SQL/OQL/XQuery/XPath/etc query in the target database.
      Specified by:
      executeQuery in class ClusterStorage
      Parameters:
      query - the query to be executed
      transactionKey - the key of the transaction, can be null
      Returns:
      the xml result of the query
      Throws:
      PersistencyException
    • get

      public C2KLocalObject get(ItemPath itemPath, String path, TransactionKey transactionKey) throws PersistencyException
      Description copied from class: ClusterStorage
      Fetches a CRISTAL local object from storage by path
      Specified by:
      get in class ClusterStorage
      Parameters:
      itemPath - The ItemPath of the containing Item
      path - The path of the local object
      transactionKey - the key of the transaction, can be null
      Returns:
      The C2KLocalObject, or null if the object was not found
      Throws:
      PersistencyException - when retrieval failed
    • put

      public void put(ItemPath itemPath, C2KLocalObject obj, TransactionKey transactionKey) throws PersistencyException
      Description copied from class: ClusterStorage
      Stores a CRISTAL local object. The path is automatically generated.
      Specified by:
      put in class ClusterStorage
      Parameters:
      itemPath - The Item that the object will be stored under
      obj - The C2KLocalObject to store
      transactionKey - the key of the transaction, cannot be null
      Throws:
      PersistencyException - When storage fails
    • delete

      public void delete(ItemPath itemPath, ClusterType cluster, TransactionKey transactionKey) throws PersistencyException
      Description copied from class: ClusterStorage
      Remove all CRISTAL local object of the given ClusterType from storage. This should be used sparingly and responsibly, as it violated traceability. Objects removed in this way cannot be recovered.
      Specified by:
      delete in class ClusterStorage
      Parameters:
      itemPath - The containing Item
      cluster - The type of the object to be removed
      transactionKey - the key of the transaction, cannot be null
      Throws:
      PersistencyException - When deletion fails or is not allowed
    • delete

      public void delete(ItemPath itemPath, TransactionKey transactionKey) throws PersistencyException
      Description copied from class: ClusterStorage
      Removes all data of an Item. This should be used sparingly and responsibly, as it violated traceability. Objects removed in this way are not expected to be recoverable.
      Specified by:
      delete in class ClusterStorage
      Parameters:
      itemPath - The containing Item
      transactionKey - the key of the transaction, cannot be null
      Throws:
      PersistencyException - When deletion fails or is not allowed
    • delete

      public void delete(ItemPath itemPath, String path, TransactionKey transactionKey) throws PersistencyException
      Description copied from class: ClusterStorage
      Remove a CRISTAL local object from storage. This should be used sparingly and responsibly, as it violated traceability. Objects removed in this way cannot be recovered.
      Specified by:
      delete in class ClusterStorage
      Parameters:
      itemPath - The containing Item
      path - The path of the object to be removed
      transactionKey - the key of the transaction, cannot be null
      Throws:
      PersistencyException - When deletion fails or is not allowed
    • getClusterContents

      public String[] getClusterContents(ItemPath itemPath, String path, TransactionKey transactionKey) throws PersistencyException
      Description copied from class: ClusterStorage
      Queries the local path below of the item and returns the possible next elements.
      Specified by:
      getClusterContents in class ClusterStorage
      Parameters:
      itemPath - The Item to query
      path - The path within that Item to query. May be ClusterStorage.ROOT (empty String)
      transactionKey - the key of the transaction, can be null
      Returns:
      A String array of the possible next path elements
      Throws:
      PersistencyException - When an error occurred during the query
    • getFilePath

      protected String getFilePath(ItemPath itemPath, String path)
    • getResourceName

      protected String getResourceName(String path)
    • getLastIntegerId

      public int getLastIntegerId(ItemPath itemPath, String path, TransactionKey transactionKey) throws PersistencyException
      Description copied from class: ClusterStorage
      History and JobList based on a integer id that is incremented each tome a new Event or Job is stored
      Specified by:
      getLastIntegerId in class ClusterStorage
      Parameters:
      itemPath - The ItemPath (UUID) of the containing Item
      path - the cluster patch, either equals to 'AuditTrail' or 'Job'
      transactionKey - the key of the transaction, can be null
      Returns:
      returns the last found integer id (zero based), or -1 if not found
      Throws:
      PersistencyException - When storage fails
    • begin

      public void begin(TransactionKey transactionKey) throws PersistencyException
      Specified by:
      begin in class ClusterStorage
      Throws:
      PersistencyException
    • commit

      public void commit(TransactionKey transactionKey) throws PersistencyException
      Specified by:
      commit in class ClusterStorage
      Throws:
      PersistencyException
    • abort

      public void abort(TransactionKey transactionKey) throws PersistencyException
      Specified by:
      abort in class ClusterStorage
      Throws:
      PersistencyException