com.centrasite.registry.versionmanagementservices
Class VersionManagerImpl

java.lang.Object
  extended by com.centrasite.registry.versionmanagementservices.VersionManagerImpl
All Implemented Interfaces:
VersionManager

public class VersionManagerImpl
extends java.lang.Object
implements VersionManager

The implementation of the VersionManager.


Constructor Summary
VersionManagerImpl(com.centrasite.jaxr.JAXRAccessor jaxr)
          Construct the Version Manager Implementation.
 
Method Summary
 void addVersionObjectListener(VersionObjectListener versionObjectListener)
          Add a listener which is notified at registry objects updates.
 java.util.Collection copy(javax.xml.registry.infomodel.RegistryObject registryObject)
          Copy the specified registry object (RegistryEntry or RegistryObject).
 java.util.Collection copy(javax.xml.registry.infomodel.RegistryObject registryObject, VersionCopyMode copyMode)
          Copy the specified registry object (RegistryEntry or RegistryObject).
 java.util.Collection copy(javax.xml.registry.infomodel.RegistryObject registryObject, VersionCopyMode copyMode, java.util.Collection ignoreCopyObjects)
          Copy the specified registry object (RegistryEntry or RegistryObject).
 java.util.Collection createVersion(javax.xml.registry.infomodel.ExternalLink elink)
          Create a new version of an External Link.
 java.util.Collection createVersion(javax.xml.registry.infomodel.ExternalLink elink, VersionCopyMode copyMode)
          A new Version of an External link is created with the copy modes described below.
 java.util.Collection createVersion(javax.xml.registry.infomodel.RegistryObject registryObject)
          Create a new version of a registry object (RegistryEntry or RegistryObject).
 java.util.Collection createVersion(javax.xml.registry.infomodel.RegistryObject registryObject, VersionCopyMode copyMode)
          Create a new version of a any registry object (all implementations of RegistryObject).
 java.util.Collection createVersion(javax.xml.registry.infomodel.RegistryObject registryObject, VersionCopyMode copyMode, java.util.Collection ignoreCopyObjects)
          Create a new version of a registry object (RegistryEntry or RegistryObject).
 java.util.Collection createVersion(javax.xml.registry.infomodel.Service serviceObject, java.util.Collection ignoreCopyObjects)
          Create a new version of a Service object.
 java.util.Collection createVersion(javax.xml.registry.infomodel.Service serviceObject, VersionCopyMode copyMode, java.util.Collection ignoreCopyObjects)
          Create a new version of a Service object.
 java.util.Collection getAllIgnoredObjects(java.util.Collection ignoredObjects)
          Get the entire list of objects to be ignored.
 javax.xml.registry.infomodel.RegistryObject getMaxVersionObject(javax.xml.registry.infomodel.RegistryObject regObj)
          Get the maximum version object of an arbitrary given object in a versioning row.
 java.util.List getNewerVersionObjects(javax.xml.registry.infomodel.RegistryObject registryObject, java.util.Collection<javax.xml.registry.infomodel.Classification> classifications)
          Get all older versioned objects based on the object given.
 javax.xml.registry.infomodel.RegistryObject getNewVersionObject(javax.xml.registry.infomodel.RegistryObject registryObject, java.util.Collection<javax.xml.registry.infomodel.RegistryObject> newObjects)
          Get the new version object of the original object out of the collection of new objects
 java.util.List getOlderVersionObjects(javax.xml.registry.infomodel.RegistryObject registryObject, java.util.Collection<javax.xml.registry.infomodel.Classification> classifications)
          Get all newer versioned objects based on the object given.
 java.util.Collection getPurgedWebDAVResources()
          Deliver the list of resources purging in WebDAV
 ICollectorVersioning getVersionCollector(javax.xml.registry.infomodel.RegistryObject oldRegistryObj, boolean recursiveCall)
          Get the version collector depending on the object's type.
 java.util.Collection getVersionObjects(javax.xml.registry.infomodel.RegistryObject registryObject)
          Get all versioned objects based on the object given.
 VersionResult getVersionResult()
          Get the version result.
 boolean isForceTargetPurge()
           
 boolean isMaxVersionObject(javax.xml.registry.infomodel.RegistryObject regObj)
          Checks if the given object is the maximum (or only) version object
 boolean isOnlyComponentObjects()
           
 void overwriteCopyRule(CopyRule copyRule)
          Overwrite a default copy rule.
 java.util.Collection purge(java.util.Collection registryObjects, int keepCount)
          Purge the list of registry objects with the same keep count.
 java.util.Collection purge(javax.xml.registry.infomodel.RegistryObject registryObject)
          Purge older version registry entries and keep only the actual one.
 java.util.Collection purge(javax.xml.registry.infomodel.RegistryObject purgeObject, int keepCount)
          Purge older version registry entries.
 void removeRepositoryResources()
          Remove repository resources, collected during purge() methods.
 void removeVersionObjectListener(VersionObjectListener versionObjectListener)
          Remove a registered listener.
 void setForceTargetPurge(boolean forceTargetPurge)
          Indicates for the purge methods whether to delete objects although they are target of associations.
 void setOnlyComponentObjects()
          Is equivilant to setOnlyComponentObjects(true)
 void setOnlyComponentObjects(boolean onlyComponentObjects)
          Implemented in this way: Service: true: Service+related - false: Service + related + schemas Schema: true: Schema - false: Schema + all referenced schemas
 void setOrganization(javax.xml.registry.infomodel.Organization versionOrg)
          Specify the organization which the versioned objects receive.
 void setUserVersion(java.lang.String userVersion)
          Specify a user version for versioned assets.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

VersionManagerImpl

public VersionManagerImpl(com.centrasite.jaxr.JAXRAccessor jaxr)
Construct the Version Manager Implementation.

Parameters:
jaxr - opened JAXR connection
Method Detail

overwriteCopyRule

public void overwriteCopyRule(CopyRule copyRule)
Overwrite a default copy rule. Can be used prior to 'createVersion' to change the DEEP copy behaviour for individual associations.

Specified by:
overwriteCopyRule in interface VersionManager
Parameters:
copyRule - the copy rule to be used

addVersionObjectListener

public void addVersionObjectListener(VersionObjectListener versionObjectListener)
Add a listener which is notified at registry objects updates.

Specified by:
addVersionObjectListener in interface VersionManager
Parameters:
versionObjectListener - a implementation of VersionObjectListener

removeVersionObjectListener

public void removeVersionObjectListener(VersionObjectListener versionObjectListener)
Remove a registered listener.

Specified by:
removeVersionObjectListener in interface VersionManager
Parameters:
versionObjectListener - a registered VersionObjectListener

setUserVersion

public final void setUserVersion(java.lang.String userVersion)
Specify a user version for versioned assets.

Specified by:
setUserVersion in interface VersionManager
Parameters:
userVersion - the user version (null: not used)

setOrganization

public final void setOrganization(javax.xml.registry.infomodel.Organization versionOrg)
Specify the organization which the versioned objects receive. Default: the organization of the origin object.

Specified by:
setOrganization in interface VersionManager
Parameters:
versionOrg - the organization for the versioned objects (null: not used)

getVersionResult

public VersionResult getVersionResult()
Get the version result. Contains denied object info after any of the createVersion() methods.

Specified by:
getVersionResult in interface VersionManager
Returns:
the version result values

setOnlyComponentObjects

public void setOnlyComponentObjects()
Description copied from interface: VersionManager
Is equivilant to setOnlyComponentObjects(true)

Specified by:
setOnlyComponentObjects in interface VersionManager
See Also:
setOnlyComponentObjects(boolean)

setOnlyComponentObjects

public void setOnlyComponentObjects(boolean onlyComponentObjects)
Implemented in this way:
  • Service: true: Service+related - false: Service + related + schemas
  • Schema: true: Schema - false: Schema + all referenced schemas

    Specified by:
    setOnlyComponentObjects in interface VersionManager
    Parameters:
    onlyComponentObjects -

  • isOnlyComponentObjects

    public boolean isOnlyComponentObjects()
    Returns:
    true: only component object ; false: everything of the composite object

    createVersion

    public java.util.Collection createVersion(javax.xml.registry.infomodel.RegistryObject registryObject)
                                       throws VersionException
    Create a new version of a registry object (RegistryEntry or RegistryObject). If this object is associated with other objects and the copy mode is DEEP, then those objects get duplicated if the association rules say this. The object to be versioned must be a top-level versioned and not an intermediate one. The copy mode defaults to NONE.

    Specified by:
    createVersion in interface VersionManager
    Parameters:
    registryObject - a versionable (or non-versionable) registry object (version top level)
    Returns:
    a collection of new version objects
    Throws:
    VersionException

    createVersion

    public java.util.Collection createVersion(javax.xml.registry.infomodel.RegistryObject registryObject,
                                              VersionCopyMode copyMode)
                                       throws VersionException
    Create a new version of a any registry object (all implementations of RegistryObject). The copy mode triggers actions on this and associated objects. If this object is associated with other objects and the copy mode is DEEP, then those objects get duplicated if the association rules defines this.

    Specials for certain registry objects:

    The version number of the duplicated object will be increased and a 'Supersedes' association will be set to its predecessor.

    Depending on the copy mode, the following picture exists:

     1) None:
    
        +---------------+                 +---------------+
        | RegistryEntry |   <----------   | RegistryEntry |
        |   vers=n      |    Supersedes   |   vers=n+1    |
        +---------------+                 +---------------+
                   |
             assoc |
                   V
                object
    
    
     2) Shallow:
    
        +---------------+                 +---------------+
        | RegistryEntry |   <----------   | RegistryEntry |
        |   vers=n      |    Supersedes   |   vers=n+1    |
        +---------------+                 +---------------+
                   |                        |
             assoc |                        |
                   V                        |
                object  <-------------------'
    
    
     3) Deep:
    
        Depending on the association type the referenced objects get pointed as shown in 'Shallow',
        or will be also versioned:
    
        +---------------+                 +---------------+
        | RegistryEntry |   <----------   | RegistryEntry |
        |   vers=n      |    Supersedes   |   vers=n+1    |
        +---------------+                 +---------------+
                   |                        |
             assoc |                        |
                   V                        V
                object (n)               object (n+1)
    
    
        Also duplicates associated external links if they are bound to WebDAV resources and the resource
        itself.
    
    
     4) Remove
    
        Same as 'None' but if the object contains ExternalLink objects they will be removed from
        the object.
    
     

    Specified by:
    createVersion in interface VersionManager
    Parameters:
    registryObject - a versionable registry entry or a usual registry object
    copyMode - the copy mode (NONE, SHALLOW, DEEP, REMOVE)
    Returns:
    a collection of new version objects (RegistryObject)
    Throws:
    VersionException

    createVersion

    public java.util.Collection createVersion(javax.xml.registry.infomodel.RegistryObject registryObject,
                                              VersionCopyMode copyMode,
                                              java.util.Collection ignoreCopyObjects)
                                       throws VersionException
    Create a new version of a registry object (RegistryEntry or RegistryObject). If this object is associated with other objects and the copy mode is DEEP, then those objects get duplicated if the association rules say. The object to be versioned must be a top-level versioned and not an intermediate one. The 'ignoreCopyObjects' may contain RegistryObjects (currently only ExternalLink supported) which shouldn't be copied with the DEEP behaviour, but just reused.

    Specified by:
    createVersion in interface VersionManager
    Parameters:
    registryObject - a versionable (or non-versionable) registry object (version top level)
    copyMode - the copy mode (SHALLOW, DEEP, ...)
    ignoreCopyObjects - list of RegistryObject which shouldn't get a new version
    Returns:
    a collection of new version objects
    Throws:
    VersionException

    createVersion

    public java.util.Collection createVersion(javax.xml.registry.infomodel.Service serviceObject,
                                              java.util.Collection ignoreCopyObjects)
                                       throws VersionException
    Create a new version of a Service object. The object to be versioned must be a top-level versioned and not an intermediate one. The copy mode defaults to NONE. The 'ignoreCopyObjects' may contain service-embedded RegistryObjects (currently only ExternalLink supported) which shouldn't be copied with the DEEP behaviour, but just reused.

    Specified by:
    createVersion in interface VersionManager
    Parameters:
    serviceObject - a Service object (version top level)
    ignoreCopyObjects - list of RegistryObject which shouldn't get a new version
    Returns:
    a collection of new version objects
    Throws:
    VersionException

    createVersion

    public java.util.Collection createVersion(javax.xml.registry.infomodel.Service serviceObject,
                                              VersionCopyMode copyMode,
                                              java.util.Collection ignoreCopyObjects)
                                       throws VersionException
    Create a new version of a Service object. The object to be versioned must be a top-level versioned and not an intermediate one. The 'ignoreCopyObjects' may contain service-embedded RegistryObjects (currently only ExternalLink supported) which shouldn't be copied with the DEEP behaviour, but just reused.

    Specified by:
    createVersion in interface VersionManager
    Parameters:
    serviceObject - a Service object (version top level)
    copyMode - the copy mode (SHALLOW, DEEP, ...)
    ignoreCopyObjects - list of RegistryObject which shouldn't get a new version
    Returns:
    a collection of new version objects
    Throws:
    VersionException

    createVersion

    public java.util.Collection createVersion(javax.xml.registry.infomodel.ExternalLink elink)
                                       throws VersionException
    Create a new version of an External Link. The copy mode defaults to NONE.

    Specified by:
    createVersion in interface VersionManager
    Parameters:
    elink - the external link
    Returns:
    a collection of new version objects
    Throws:
    VersionException

    createVersion

    public java.util.Collection createVersion(javax.xml.registry.infomodel.ExternalLink elink,
                                              VersionCopyMode copyMode)
                                       throws VersionException
    A new Version of an External link is created with the copy modes described below.

    Specified by:
    createVersion in interface VersionManager
    Parameters:
    elink - external link to be duplicated
    copyMode - copy mode
    Returns:
    a collection of new version objects (the new ExternalLink is inside)
    Throws:
    VersionException
    See Also:
    ExternalLinkVersion

    copy

    public java.util.Collection copy(javax.xml.registry.infomodel.RegistryObject registryObject)
                              throws VersionException
    Copy the specified registry object (RegistryEntry or RegistryObject). If this object is associated with other objects and the copy mode is DEEP, then those objects get duplicated if the association rules say this. The copy mode defaults to NONE.

    Specified by:
    copy in interface VersionManager
    Parameters:
    registryObject - registry object to copy
    Returns:
    a collection of new version objects
    Throws:
    VersionException

    copy

    public java.util.Collection copy(javax.xml.registry.infomodel.RegistryObject registryObject,
                                     VersionCopyMode copyMode)
                              throws VersionException
    Copy the specified registry object (RegistryEntry or RegistryObject). If this object is associated with other objects and the copy mode is DEEP, then those objects get duplicated if the association rules say this. The copy mode defaults to NONE.

    Specified by:
    copy in interface VersionManager
    Parameters:
    registryObject - registry object to copy
    copyMode - the copy mode (SHALLOW, DEEP, ...)
    Returns:
    a collection of new version objects
    Throws:
    VersionException

    copy

    public java.util.Collection copy(javax.xml.registry.infomodel.RegistryObject registryObject,
                                     VersionCopyMode copyMode,
                                     java.util.Collection ignoreCopyObjects)
                              throws VersionException
    Copy the specified registry object (RegistryEntry or RegistryObject). If this object is associated with other objects and the copy mode is DEEP, then those objects get duplicated if the association rules say this. The copy mode defaults to NONE. The 'ignoreCopyObjects' may contain RegistryObjects (currently only ExternalLink supported) which shouldn't be copied.

    Specified by:
    copy in interface VersionManager
    Parameters:
    registryObject - registry object to copy
    copyMode - the copy mode (SHALLOW, DEEP, ...)
    ignoreCopyObjects - list of RegistryObject which shouldn't get a new version
    Returns:
    a collection of new version objects
    Throws:
    VersionException

    purge

    public java.util.Collection purge(java.util.Collection registryObjects,
                                      int keepCount)
                               throws VersionException
    Purge the list of registry objects with the same keep count.

    Specified by:
    purge in interface VersionManager
    Parameters:
    registryObjects - list of registry objects to be deleted
    keepCount - > 0 : number of version objects to keep; < 0 : number of old object version to delete; 0 : delete all objects
    Returns:
    list of Keys of objects to delete
    Throws:
    VersionException

    purge

    public java.util.Collection purge(javax.xml.registry.infomodel.RegistryObject registryObject)
                               throws VersionException
    Purge older version registry entries and keep only the actual one. The entry specified could be any in the version chain.

    Specified by:
    purge in interface VersionManager
    Parameters:
    registryObject - a registry object to be purged
    Returns:
    list of Keys of objects to delete
    Throws:
    VersionException

    purge

    public java.util.Collection purge(javax.xml.registry.infomodel.RegistryObject purgeObject,
                                      int keepCount)
                               throws VersionException
    Purge older version registry entries. The entry specified could be any in the version chain. The user can specify how much object versions to purge or how much to keep.

    Specified by:
    purge in interface VersionManager
    Parameters:
    purgeObject - a registry object to be purged
    keepCount - > 0 : number of version objects to keep; < 0 : number of old object version to delete; 0 : delete all objects
    Returns:
    list of Keys of objects to delete
    Throws:
    VersionException

    removeRepositoryResources

    public void removeRepositoryResources()
    Remove repository resources, collected during purge() methods. All the files get removed from repository (unless they are references with other external links) and the lists itself get reset. This method should be called after one or more purge() calls to cleanup certain resources:

    Specified by:
    removeRepositoryResources in interface VersionManager

    getVersionObjects

    public java.util.Collection getVersionObjects(javax.xml.registry.infomodel.RegistryObject registryObject)
                                           throws VersionException
    Get all versioned objects based on the object given. There is no matter which version the given object has. If the registryEntry has no further version objects, then the result contains only this object.
     Example:
                  +-------------+     supersedes  +-------------+
                  | object (v0) |    <----------  | object (v1) |
                  +-------------+                 +-------------+
     

    Specified by:
    getVersionObjects in interface VersionManager
    Parameters:
    registryObject - a registry object (any version)
    Returns:
    list of all version registry objects
    Throws:
    VersionException

    getNewVersionObject

    public javax.xml.registry.infomodel.RegistryObject getNewVersionObject(javax.xml.registry.infomodel.RegistryObject registryObject,
                                                                           java.util.Collection<javax.xml.registry.infomodel.RegistryObject> newObjects)
                                                                    throws VersionException
    Get the new version object of the original object out of the collection of new objects

    Specified by:
    getNewVersionObject in interface VersionManager
    Parameters:
    registryObject - the original object which was versioned
    newObjects - collection of new objects
    Returns:
    the new object, derived from registryObject; null: not found
    Throws:
    VersionException

    getNewerVersionObjects

    public java.util.List getNewerVersionObjects(javax.xml.registry.infomodel.RegistryObject registryObject,
                                                 java.util.Collection<javax.xml.registry.infomodel.Classification> classifications)
                                          throws VersionException
    Get all older versioned objects based on the object given. The returned list is sorted by the version number in descending order. This means the newest version is the first in the list. If the registry object has no older versions, then an empty list will be returned.

    Specified by:
    getNewerVersionObjects in interface VersionManager
    Parameters:
    registryObject - a (versioned) registry object
    classifications - collection of classifications; if not null and not empty then at least one of the classification must match
    Returns:
    list of all newer versions sorted by version number ascending
    Throws:
    VersionException

    getOlderVersionObjects

    public java.util.List getOlderVersionObjects(javax.xml.registry.infomodel.RegistryObject registryObject,
                                                 java.util.Collection<javax.xml.registry.infomodel.Classification> classifications)
                                          throws VersionException
    Get all newer versioned objects based on the object given. The returned list is sorted by the version number in ascending order. This means the oldest version is the first in the list. If the registry object has no newer versions, then an empty list will be returned.

    Specified by:
    getOlderVersionObjects in interface VersionManager
    Parameters:
    registryObject - a (versioned) registry object
    classifications - collection of classifications; if not null and not empty then at least one of the classification must match
    Returns:
    list of all older versions sorted by version number descending
    Throws:
    VersionException

    getMaxVersionObject

    public javax.xml.registry.infomodel.RegistryObject getMaxVersionObject(javax.xml.registry.infomodel.RegistryObject regObj)
                                                                    throws VersionException
    Get the maximum version object of an arbitrary given object in a versioning row.

    Specified by:
    getMaxVersionObject in interface VersionManager
    Parameters:
    regObj - any registry object in a versioning row
    Returns:
    the object with the highest version regObj: if no versioning (or already the highest one)
    Throws:
    VersionException

    isMaxVersionObject

    public boolean isMaxVersionObject(javax.xml.registry.infomodel.RegistryObject regObj)
                               throws VersionException
    Checks if the given object is the maximum (or only) version object

    Specified by:
    isMaxVersionObject in interface VersionManager
    Parameters:
    regObj - a registry object
    Returns:
    true: is the maximum (or only) version object
    false: its an intermediate version object
    Throws:
    VersionException

    getAllIgnoredObjects

    public java.util.Collection getAllIgnoredObjects(java.util.Collection ignoredObjects)
                                              throws VersionException
    Get the entire list of objects to be ignored. Main task is to check external link entries for associated ones, and if there are some then add them to the resulting list.
    Note: at the moment only External Links are considered!

    Specified by:
    getAllIgnoredObjects in interface VersionManager
    Parameters:
    ignoredObjects - list of RegistryObject to be ignored
    Returns:
    list of RegistryObject to be ignored + evtl. more
    Throws:
    VersionException

    getPurgedWebDAVResources

    public java.util.Collection getPurgedWebDAVResources()
    Deliver the list of resources purging in WebDAV

    Returns:
    list of String of webdav URIs

    setForceTargetPurge

    public final void setForceTargetPurge(boolean forceTargetPurge)
    Indicates for the purge methods whether to delete objects although they are target of associations. The default is false.

    Specified by:
    setForceTargetPurge in interface VersionManager
    Parameters:
    forceTargetPurge - true: delete objects no matter of target associations; false: reject object delete (implicitely by JAXR) if they are target of associations

    isForceTargetPurge

    public boolean isForceTargetPurge()
    Returns:
    true if target associations of purged objects to be removed

    getVersionCollector

    public ICollectorVersioning getVersionCollector(javax.xml.registry.infomodel.RegistryObject oldRegistryObj,
                                                    boolean recursiveCall)
                                             throws javax.xml.registry.JAXRException,
                                                    VersionException
    Get the version collector depending on the object's type.

    Parameters:
    oldRegistryObj - the (old - to be versioned) registry object
    recursiveCall - true: within recursion
    Returns:
    the implemented ICollectorVersioning (null: no collector for this type)
    Throws:
    javax.xml.registry.JAXRException
    VersionException