com.ibm.datapower.wamt.dataAPI.local.filesystem
Class RepositoryImpl

java.lang.Object
  extended by com.ibm.datapower.wamt.dataAPI.local.filesystem.RepositoryImpl
All Implemented Interfaces:
Repository

public class RepositoryImpl
extends java.lang.Object
implements Repository

The Repository object used for executing persistence operations such as reading and writing Stored objects to the local file system

This implementation provides a public static Repository getInstance() method to return the singleton instance of Repository object. The clientAPI starts up the repository when the Manager is initialized. It obtains an instance of the singleton Repository in order to make make modifications to persisted data.

The data to be persisted is written to a directory configured by the caller.

The Repository objects transforms all the Stored objects to XML Objects before saving them in the local file system. It also determines the WAMT.Repository.xml and loads all all persisted XMLobjects and transforms them to Java objects.

See Also:
Repository

Field Summary
 
Fields inherited from interface com.ibm.datapower.wamt.dataAPI.Repository
COPYRIGHT_2009_2010, SCM_REVISION
 
Method Summary
 StoredDeploymentPolicyImpl createDeploymentPolicy(StoredDomain domain, java.lang.String name, URLSource policyURL, java.lang.String policyDomainName, DeploymentPolicyType policyType)
           Note: The Local File System implementation adds an element to the WAMT.repository.xml file during create operation to save all information related to the policy version within the containing domain element.
 StoredDeploymentPolicyVersion createDeploymentPolicyVersion(StoredDeploymentPolicy policy, Blob blob, java.lang.String comment, java.util.Date timestamp)
           Note: The Local File System implementation adds an element to the WAMT.repository.xml file during create operation to save all information related to the policy version within the containing deployment policy element.
 StoredDevice createDevice(java.lang.String deviceID, java.lang.String serialNumber, java.lang.String name, DeviceType deviceType, ModelType modelType, java.lang.String hostname, java.lang.String userid, java.lang.String password, int HLMport, int guiPort, java.lang.String ampVersion)
           Note: The Local File System implementation adds a device element to the WAMT.repository.xml file during a save operation to save all information related to the device.
 StoredDomain createDomain(StoredDevice device, java.lang.String domainName)
           Note: The Local File System implementation adds an element to the WAMT.repository.xml file during create operation to save all information related to the domain within the containing device element.
 StoredDomainVersion createDomainVersion(StoredDomain versionedObject, Blob blob, java.lang.String userComment, java.util.Date timeStamp)
           Note: The Local File System implementation adds an element to the WAMT.repository.xml file during create operation to save all information related to the StoredDomainVersion within the containing Domain element.
 StoredFirmware createFirmware(DeviceType deviceType, ModelType modelType, StringCollection strictFeatures, StringCollection nonstrictFeatures)
           Note: The Local File System implementation adds an element to the WAMT.repository.xml file during create operation to save all information related to the firmware within the containing manager element.
 StoredFirmwareVersion createFirmwareVersion(StoredFirmware versionedObject, Blob blob, java.lang.String level, java.util.Date manufactureDate, java.lang.String userComment, java.util.Date timeStamp)
           Note: The Local File System implementation adds an element to the WAMT.repository.xml file during create operation to save all information related to the firmware version within the containing firmware element.
 StoredManagedSet createManagedSet(java.lang.String name)
           Note: The Local File System implementation adds an element to the WAMT.repository.xml file during create operation to save all information related to the managed set within the containing manager element.
 StoredTagImpl createTag(java.lang.String name, java.lang.String value)
           
 void exportAll(java.io.OutputStream outputStream)
           Note: The Local File System implementation does not implement this method.
 StoredDevice getDevice(java.lang.String serialNumber)
          Retrieves a device from the repository that has the specified serialNumber.
 StoredDevice[] getDeviceBySerialNumber(java.lang.String serialNumber)
          Retrieves all devices from the repository that has the specified serialNumber.
 StoredDevice[] getDevices()
          Retrieves all known devices in the repository.
 StoredFirmware getFirmware(DeviceType deviceType, ModelType modelType, StringCollection strictFeatures, StringCollection nonstrictFeatures)
          Gets an existing firmware with the specified attributes from the repository.
 StoredFirmware[] getFirmwares()
          Gets all the firmwares that are in the repository.
static RepositoryImpl getInstance(Credential cred)
          This method must be implemented to return the singleton instance of Repository.
 StoredManagedSet getManagedSet(java.lang.String name)
          Gets the existing StoredManagedSet that has the specified name from the repository.
 StoredManagedSet[] getManagedSets()
          Gets all the ManagedSets in the repository.
 int getMaxVersionsToStore()
          Gets the maximum number of versions of any one object that the repository will try to keep.
 StoredTag getTag(java.lang.String name)
           
 StoredTag[] getTags()
           
 StoredDevice[] getUnmanagedDevices(DeviceType desiredDeviceType)
           
 void importAll(java.io.InputStream inputStream)
           Note: The Local File System implementation does not implement this method.
 void save(boolean forceSave)
           Note: The Local File System implementation adds or changes elements in the WAMT.Repository.xml file during a save operation.
 void setMaxVersionsToStore(int maxVersions)
          Sets the maximum number of versions of any one object that should be kept in the repository.
 void shutdown()
          Shuts down the Repository.
 void startup()
          Starts up the Repository.
 StoredDomain updateDomain(StoredDomain domain)
          Updates an existing domain object.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static final RepositoryImpl getInstance(Credential cred)
This method must be implemented to return the singleton instance of Repository. This is invoked when the Manager is first initialized. Refer to the package overview for the specific parameters used by this implementation.

Parameters:
cred - The credential to use for this implementation

exportAll

public void exportAll(java.io.OutputStream outputStream)

Note: The Local File System implementation does not implement this method. To backup the repository, make copies of all the files in configured repository directory.

Specified by:
exportAll in interface Repository
Parameters:
outputStream - where the exported data will be written
See Also:
Repository.importAll(InputStream)

importAll

public void importAll(java.io.InputStream inputStream)
               throws DatastoreException

Note: The Local File System implementation does not implement this method.

Specified by:
importAll in interface Repository
Parameters:
inputStream - where to read the previously exported data from
See Also:
Repository.exportAll(OutputStream)

save

public void save(boolean forceSave)
          throws DirtySaveException

Note: The Local File System implementation adds or changes elements in the WAMT.Repository.xml file during a save operation. It may also persist separate bin files for deployed firmware versions and domain configurations. This implementation ignores the forceSave parameter.

Specified by:
save in interface Repository
Parameters:
forceSave - If true, do not throw DirtySaveException, even if other changes have been saved to the repository while the unsaved changes were taking place.

createDevice

public StoredDevice createDevice(java.lang.String deviceID,
                                 java.lang.String serialNumber,
                                 java.lang.String name,
                                 DeviceType deviceType,
                                 ModelType modelType,
                                 java.lang.String hostname,
                                 java.lang.String userid,
                                 java.lang.String password,
                                 int HLMport,
                                 int guiPort,
                                 java.lang.String ampVersion)
                          throws AlreadyExistsInRepositoryException,
                                 DatastoreException

Note: The Local File System implementation adds a device element to the WAMT.repository.xml file during a save operation to save all information related to the device.

Specified by:
createDevice in interface Repository
serialNumber - the serialNumber for this device
name - the human-consumable symbolic name for this object
deviceType - the device type of the device
modelType - the model type of the device
hostname - the host name or IP address of the device
userid - the administrative user id of the device
password - the administrative password of the device
HLMport - the device port for AMP communications
guiPort - the device port for the WebGUI
ampVersion - the device's current AMP version
Returns:
a new StoredDevice object
See Also:
StoredManagedSet.add(StoredDevice), Repository.getDevice(String), StoredDevice.delete()

createDomain

public StoredDomain createDomain(StoredDevice device,
                                 java.lang.String domainName)
                          throws AlreadyExistsInRepositoryException,
                                 DatastoreException

Note: The Local File System implementation adds an element to the WAMT.repository.xml file during create operation to save all information related to the domain within the containing device element.

Specified by:
createDomain in interface Repository
Parameters:
device - The StoredDevice that contains this StoredDomain
domainName - The name of this StoredDomain
Returns:
a new StoredDomain object
See Also:
StoredDeployableConfiguration.delete()

updateDomain

public StoredDomain updateDomain(StoredDomain domain)
                          throws AlreadyExistsInRepositoryException,
                                 DatastoreException
Description copied from interface: Repository
Updates an existing domain object. Domain object attributes values can be modified by calling the following methods: Domain.setSourceConfiguration(URLSource), Domain.setQuiesceTimeout(int), and Domain.setSynchronizationMode(com.ibm.datapower.wamt.clientAPI.DomainSynchronizationMode). These changes have to be persisted in the repository.

Specified by:
updateDomain in interface Repository
See Also:
Domain.setDeploymentPolicy(URLSource, String, String), Domain.setQuiesceTimeout(int), Domain.setSynchronizationMode(com.ibm.datapower.wamt.clientAPI.DomainSynchronizationMode)

createDeploymentPolicyVersion

public StoredDeploymentPolicyVersion createDeploymentPolicyVersion(StoredDeploymentPolicy policy,
                                                                   Blob blob,
                                                                   java.lang.String comment,
                                                                   java.util.Date timestamp)
                                                            throws AlreadyExistsInRepositoryException,
                                                                   DatastoreException

Note: The Local File System implementation adds an element to the WAMT.repository.xml file during create operation to save all information related to the policy version within the containing deployment policy element.

Specified by:
createDeploymentPolicyVersion in interface Repository
Parameters:
policy - The StoredDeploymentPolicyVersion object
blob - The policy blob that will be deployed
comment - The user provided comment for the deployment policy object
timestamp - creation timestamp
Returns:
a new StoredDeploymentPolicyVersion object
See Also:
StoredVersion.delete()

createDeploymentPolicy

public StoredDeploymentPolicyImpl createDeploymentPolicy(StoredDomain domain,
                                                         java.lang.String name,
                                                         URLSource policyURL,
                                                         java.lang.String policyDomainName,
                                                         DeploymentPolicyType policyType)
                                                  throws AlreadyExistsInRepositoryException,
                                                         DatastoreException

Note: The Local File System implementation adds an element to the WAMT.repository.xml file during create operation to save all information related to the policy version within the containing domain element.

???

Specified by:
createDeploymentPolicy in interface Repository
Parameters:
domain - The stored Domain object
name - - this is the first piece of information used to find the deployment policy within the URLSource specified
policyURL - - is a URLSource that points to a configuration containing the policy to be used during deployment.
policyDomainName - - this is the second piece of information used to find the deployment domain within the URLSource specified
policyType - - the policy type used during configuration deployment
Returns:
a new StoredDeploymentPolicy object
See Also:
StoredDeployablePolicy.delete(), DeploymentPolicyType.EXPORT, DeploymentPolicyType.XML

getDevice

public StoredDevice getDevice(java.lang.String serialNumber)
Description copied from interface: Repository
Retrieves a device from the repository that has the specified serialNumber. This is a convenience method that is invoked from the The clientAPI Manager.getDeviceBySerialNumber(String)

Specified by:
getDevice in interface Repository
Parameters:
serialNumber - serialNumber of the device to retrieve from the repository
Returns:
the StoredDevice object

getDeviceBySerialNumber

public StoredDevice[] getDeviceBySerialNumber(java.lang.String serialNumber)
Description copied from interface: Repository
Retrieves all devices from the repository that has the specified serialNumber.

Specified by:
getDeviceBySerialNumber in interface Repository
Parameters:
serialNumber - serialNumber of the device to retrieve from the repository
Returns:
the array of StoredDevice object

getDevices

public StoredDevice[] getDevices()
Description copied from interface: Repository
Retrieves all known devices in the repository. The returned Devices may be managed or unmanaged, i.e they may or may not be members of a ManagedSet. This is a convenience method that is invoked from the The clientAPI Manager.getAllDevices()

Specified by:
getDevices in interface Repository
Returns:
an array of Devices

getUnmanagedDevices

public StoredDevice[] getUnmanagedDevices(DeviceType desiredDeviceType)

getTag

public StoredTag getTag(java.lang.String name)
Specified by:
getTag in interface Repository

getTags

public StoredTag[] getTags()
Specified by:
getTags in interface Repository

getManagedSet

public StoredManagedSet getManagedSet(java.lang.String name)
Description copied from interface: Repository
Gets the existing StoredManagedSet that has the specified name from the repository. This is is invoked from the The clientAPI Manager.getManagedSet(String)

Specified by:
getManagedSet in interface Repository
Parameters:
name - name of the StoredManagedSet as stored in the repository
Returns:
a reference to the StoredManagedSet object that is populated from the repository

getManagedSets

public StoredManagedSet[] getManagedSets()
Description copied from interface: Repository
Gets all the ManagedSets in the repository. This is a convenience method that is invoked internally in many places from the The clientAPI and is also call from Manager.getManagedSets()

Specified by:
getManagedSets in interface Repository
Returns:
a array of ManagedSets

getFirmwares

public StoredFirmware[] getFirmwares()
Description copied from interface: Repository
Gets all the firmwares that are in the repository. This is a convenience method that is invoked internally in many places within the clientAPI and also from public API Manager.getFirmwares()

Specified by:
getFirmwares in interface Repository
Returns:
a array of StoredFirmware object
See Also:
"useCases section 4.3, 4.4"

getFirmware

public StoredFirmware getFirmware(DeviceType deviceType,
                                  ModelType modelType,
                                  StringCollection strictFeatures,
                                  StringCollection nonstrictFeatures)
Description copied from interface: Repository
Gets an existing firmware with the specified attributes from the repository. This is a convenience method that is invoked internally in many places within the clientAPI.

Specified by:
getFirmware in interface Repository
Parameters:
deviceType - the deviceType the firmware supports
modelType - the modelType the firmware supports
strictFeatures - The strict features supported by this firmware.
nonstrictFeatures - The nonstrict features supported by this firmware.
Returns:
a firmware object populated by the repository

createManagedSet

public StoredManagedSet createManagedSet(java.lang.String name)
                                  throws AlreadyExistsInRepositoryException,
                                         DatastoreException

Note: The Local File System implementation adds an element to the WAMT.repository.xml file during create operation to save all information related to the managed set within the containing manager element.

Specified by:
createManagedSet in interface Repository
Parameters:
name - a human-consumable symbolic name for this StoredManagedSet
Returns:
a new StoredManagedSet object.

createTag

public StoredTagImpl createTag(java.lang.String name,
                               java.lang.String value)
                        throws AlreadyExistsInRepositoryException,
                               DatastoreException
Specified by:
createTag in interface Repository

createFirmware

public StoredFirmware createFirmware(DeviceType deviceType,
                                     ModelType modelType,
                                     StringCollection strictFeatures,
                                     StringCollection nonstrictFeatures)
                              throws AlreadyExistsInRepositoryException,
                                     DatastoreException

Note: The Local File System implementation adds an element to the WAMT.repository.xml file during create operation to save all information related to the firmware within the containing manager element. It will also contain firmware version elements for each level of firmware deployed.

Specified by:
createFirmware in interface Repository
Parameters:
deviceType - The type of device this firmware must run on.
modelType - The model type this firmware must run on.
strictFeatures - The strict features supported by this firmware.
nonstrictFeatures - The nonstrict features supported by this firmware.
Returns:
a new firmware object. *

createFirmwareVersion

public StoredFirmwareVersion createFirmwareVersion(StoredFirmware versionedObject,
                                                   Blob blob,
                                                   java.lang.String level,
                                                   java.util.Date manufactureDate,
                                                   java.lang.String userComment,
                                                   java.util.Date timeStamp)
                                            throws AlreadyExistsInRepositoryException,
                                                   DatastoreException

Note: The Local File System implementation adds an element to the WAMT.repository.xml file during create operation to save all information related to the firmware version within the containing firmware element.

Specified by:
createFirmwareVersion in interface Repository
Parameters:
versionedObject - a reference to the StoredFirmware object that this StoredVersion object is a version of.
blob - a reference to the Blob that contains the binary image for this firmware image as down loaded from the manufacturer's web site
level - The level of the firmware extracted from the blob
manufactureDate - The date the firmware was created. Extracted from the blob.
userComment - The user's comment for the action that is creating the StoredFirmware version
timeStamp - The time to record for the creation of the StoredFirmwareVersion
Returns:
a StoredFirmwareVersion object populated by the repository

createDomainVersion

public StoredDomainVersion createDomainVersion(StoredDomain versionedObject,
                                               Blob blob,
                                               java.lang.String userComment,
                                               java.util.Date timeStamp)
                                        throws AlreadyExistsInRepositoryException,
                                               DatastoreException

Note: The Local File System implementation adds an element to the WAMT.repository.xml file during create operation to save all information related to the StoredDomainVersion within the containing Domain element.

Specified by:
createDomainVersion in interface Repository
Parameters:
versionedObject - a reference to the StoredDomain object that this StoredVersion object is a version of.
blob - a reference to the Blob that contains the binary image for this StoredDomainVersion
userComment - The user's comment for the action that is creating the StoredDomainVersion
timeStamp - The time to record for the creation of the StoredDomainVersion
Returns:
a StoredDomainVersion object populated by the repository

getMaxVersionsToStore

public int getMaxVersionsToStore()
Description copied from interface: Repository
Gets the maximum number of versions of any one object that the repository will try to keep. The Manager.getMaxVersionsToStore() uses this interface to query the maximum versions that can currently be persisted. This is the value set in Repository.setMaxVersionsToStore(int). This allows the version data for objects to be trimmed by users when they want to purge their older data.

Specified by:
getMaxVersionsToStore in interface Repository
Returns:
the maximum number of versions of any one object to keep in the repository. This will likely apply to StoredFirmwareVersions, StoredSettingsVersions, and StoredDomainVersions. If this value is not initialized (previously set to a specific value via Repository.setMaxVersionsToStore(int)) then it should return 0 so that the Manager can set it to a usable default.
See Also:
Repository.setMaxVersionsToStore(int)

setMaxVersionsToStore

public void setMaxVersionsToStore(int maxVersions)
Description copied from interface: Repository
Sets the maximum number of versions of any one object that should be kept in the repository. This is used to trim the repository to a reasonable size. If any object has more than maxVersions in the repository, then the repository will automatically delete the oldest versions until this threshold is no longer exceeded. The repository will not delete any versions that are currently desired versions, even if that results in storing more than maxVersions.

Specified by:
setMaxVersionsToStore in interface Repository
Parameters:
maxVersions - the maximum number of versions of any one object to keep in the repository. For example, is set to 4 then the repository will limit itself to keeping 4 versions of firmware, 4 settings of each managedSet, and 4 versions of each domain in each managedSet. This applies to all versioned objects: firmware, domains, and settings. A value that is less than 1 (0 or negative) means that there is no limit and the repository will never delete versions.
See Also:
Repository.getMaxVersionsToStore()

shutdown

public void shutdown()
Description copied from interface: Repository
Shuts down the Repository. This instance of Repository should no longer be used after shutdown is invoked. This invoked by Manager.shutdown()

Specified by:
shutdown in interface Repository
See Also:
Repository.startup()

startup

public void startup()
             throws DatastoreException
Description copied from interface: Repository
Starts up the Repository. This instance of Repository is available for use after startup is invoked. This invoked by Manager.getInstance(java.util.Map)

Specified by:
startup in interface Repository
See Also:
Repository.shutdown()


© Copyright IBM Corp. 2006, 2010 All Rights Reserved.