com.jp.protection.pub.pro.ls
Class BasicLicenseStorage

java.lang.Object
  extended by com.jp.protection.pub.pro.ls.BasicLicenseStorage
All Implemented Interfaces:
LicenseStorage, java.beans.PropertyChangeListener, java.util.EventListener
Direct Known Subclasses:
JarLicenseStorage

public abstract class BasicLicenseStorage
extends java.lang.Object
implements LicenseStorage, java.beans.PropertyChangeListener

Basic implementation of the LicenseStorage interface that can be used to build actual LicenseStorage implementations.

Since:
3.0

Nested Class Summary
static class BasicLicenseStorage.BasicLicenseEntry
          Basic implementation of the LicenseEntry interface
static class BasicLicenseStorage.EntryLicenseReader
          License Reader implementation to allow license reading from the license storage
 
Nested classes/interfaces inherited from interface com.jp.protection.pub.pro.ls.LicenseStorage
LicenseStorage.LicenseEntry
 
Field Summary
protected  java.util.HashMap fLicenseEntryIDMap
           
protected  dev.util.HashDualMap fLicenseEntryMap
           
protected  java.util.Vector fLicenseStorageListeners
           
protected  boolean fModified
           
 
Fields inherited from interface com.jp.protection.pub.pro.ls.LicenseStorage
ANY_LICENSE_TYPE, ANY_MAJOR_VERSION, ANY_MINOR_VERSION, ANY_PRODUCT, ANY_PRODUCT_EDITION, ANY_USER_LICENSING_MODEL
 
Constructor Summary
BasicLicenseStorage()
           
 
Method Summary
 void addLicenseEntry(LicenseStorage.LicenseEntry anEntry, java.lang.String aName)
          Adds a license entry into the license storage
protected  void addLicenseEntryImpl(LicenseStorage.LicenseEntry anEntry, java.lang.String aName)
           
 void addLicenseStorageListener(LicenseStorageListener l)
          Adds a listener to the listeners list
 void assignNewID(LicenseStorage.LicenseEntry aLicenseEntry)
          Assigns new unique identifier for the license entry
protected  void calculateCurrentID()
           
protected  void checkLicenseExistence(LicenseStorage.LicenseEntry anEntry, byte[] aLicenseBytes)
           
 LicenseStorage.LicenseEntry createLicenseEntry()
          Creates a new instance of LicenseEntry
protected  void fireBeforeLicenseStorageLoad()
           
protected  void fireBeforeLicenseStorageSave()
           
protected  void fireLicenseEntryAdded(LicenseStorage.LicenseEntry aLicenseEntry)
           
protected  void fireLicenseEntryRemoved(LicenseStorage.LicenseEntry aLicenseEntry)
           
protected  void fireLicenseEntryUpdated(LicenseStorage.LicenseEntry aLicenseEntry)
           
protected  void fireLicenseStorageLoaded(boolean isSuccess)
           
protected  void fireLicenseStorageSaved(boolean isSuccess)
           
 java.util.Collection getLicenseEntries(java.lang.String aPath, boolean isIncludeSubPaths)
          Returns collection of the license entries for the given path
 java.util.Collection getLicenseEntries(java.lang.String aProduct, java.lang.String aProductEdition, int aMajorVersion, int aMinorVersion, int aLicenseType)
          Returns collection of the mathced license entries for the given parameters
 java.util.Collection getLicenseEntries(java.lang.String aProduct, java.lang.String aProductEdition, int aMajorVersion, int aMinorVersion, int aLicenseType, boolean isExactMatch)
          Returns collection of the license entries those match for the given parameters
 LicenseStorage.LicenseEntry getLicenseEntry(int anID)
          Returns the license entry for the given unique identifier
 LicenseStorage.LicenseEntry getLicenseEntry(java.lang.String aName)
          Returns license entry for the given name
 LicenseStorage.LicenseEntry getLicenseEntryForLicenseNumber(java.lang.String aLicenseNumber)
          Returns license entry for the given license number
static java.lang.String getLicenseEntryPath(java.lang.String aName)
          Returns path component for the given license entry name
static java.lang.String getLicenseEntryShortName(java.lang.String aName)
          Returns short name for given full one
 java.lang.String getName(LicenseStorage.LicenseEntry anEntry)
          Returns the name for the given license entry
 int getNewID()
          Calculates and returns new unique identifier
static java.lang.String getNewLicenseEntryName(LicenseStorage.LicenseEntry aLicenseEntry)
           
 boolean isModified()
          Returns whether this license storage has been modified
 void propertyChange(java.beans.PropertyChangeEvent evt)
           
 void removeLicenseEntry(LicenseStorage.LicenseEntry anEntry)
          Removes a license entry from the license storage
 void removeLicenseStorageListener(LicenseStorageListener l)
          Removes a listener from the listeners list
 void setModified(boolean aModified)
          Specifies that this license storage is modified
 void updateLicenseEntry(LicenseStorage.LicenseEntry anEntry, java.lang.String aName)
          Updates a license entry in the license storage
protected  void updateLicenseEntryImpl(LicenseStorage.LicenseEntry anEntry, java.lang.String aName)
           
static void updateLicenseEntryProperties(License aLicense, LicenseStorage.LicenseEntry aLicenseEntry)
          Updates license entry properties from the given license
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.jp.protection.pub.pro.ls.LicenseStorage
createLicenseReader, load, store
 

Field Detail

fLicenseEntryIDMap

protected java.util.HashMap fLicenseEntryIDMap

fLicenseEntryMap

protected dev.util.HashDualMap fLicenseEntryMap

fLicenseStorageListeners

protected transient java.util.Vector fLicenseStorageListeners

fModified

protected boolean fModified
Constructor Detail

BasicLicenseStorage

public BasicLicenseStorage()
Method Detail

getNewID

public int getNewID()
Calculates and returns new unique identifier

Returns:
unique identifier

calculateCurrentID

protected void calculateCurrentID()

assignNewID

public void assignNewID(LicenseStorage.LicenseEntry aLicenseEntry)
Description copied from interface: LicenseStorage
Assigns new unique identifier for the license entry

Specified by:
assignNewID in interface LicenseStorage
Parameters:
aLicenseEntry - license entry to assign unique identifier to

propertyChange

public void propertyChange(java.beans.PropertyChangeEvent evt)
Specified by:
propertyChange in interface java.beans.PropertyChangeListener

createLicenseEntry

public LicenseStorage.LicenseEntry createLicenseEntry()
Description copied from interface: LicenseStorage
Creates a new instance of LicenseEntry

Specified by:
createLicenseEntry in interface LicenseStorage
Returns:
a new instance of LicenseEntry

addLicenseEntry

public void addLicenseEntry(LicenseStorage.LicenseEntry anEntry,
                            java.lang.String aName)
Description copied from interface: LicenseStorage
Adds a license entry into the license storage

Specified by:
addLicenseEntry in interface LicenseStorage
Parameters:
anEntry - license entry to add
aName - license entry name. The name may contain slashes to denote path components

addLicenseEntryImpl

protected void addLicenseEntryImpl(LicenseStorage.LicenseEntry anEntry,
                                   java.lang.String aName)
                            throws java.lang.IllegalArgumentException
Throws:
java.lang.IllegalArgumentException

updateLicenseEntry

public void updateLicenseEntry(LicenseStorage.LicenseEntry anEntry,
                               java.lang.String aName)
Description copied from interface: LicenseStorage
Updates a license entry in the license storage

Specified by:
updateLicenseEntry in interface LicenseStorage
Parameters:
anEntry - license entry to update
aName - license entry name. The name may contain slashes to denote path components

updateLicenseEntryImpl

protected void updateLicenseEntryImpl(LicenseStorage.LicenseEntry anEntry,
                                      java.lang.String aName)

checkLicenseExistence

protected void checkLicenseExistence(LicenseStorage.LicenseEntry anEntry,
                                     byte[] aLicenseBytes)

getLicenseEntries

public java.util.Collection getLicenseEntries(java.lang.String aPath,
                                              boolean isIncludeSubPaths)
Description copied from interface: LicenseStorage
Returns collection of the license entries for the given path

Specified by:
getLicenseEntries in interface LicenseStorage
Parameters:
aPath - path value. Only absolute paths are supported so each path should start with \ so "\" path denotes root.
isIncludeSubPaths - defines that sub paths should be searched too
Returns:
collection of the license entries

getLicenseEntryForLicenseNumber

public LicenseStorage.LicenseEntry getLicenseEntryForLicenseNumber(java.lang.String aLicenseNumber)
Description copied from interface: LicenseStorage
Returns license entry for the given license number

Specified by:
getLicenseEntryForLicenseNumber in interface LicenseStorage
Parameters:
aLicenseNumber - license number
Returns:
license entry or null of no license entry found

getLicenseEntries

public java.util.Collection getLicenseEntries(java.lang.String aProduct,
                                              java.lang.String aProductEdition,
                                              int aMajorVersion,
                                              int aMinorVersion,
                                              int aLicenseType,
                                              boolean isExactMatch)
Returns collection of the license entries those match for the given parameters

Parameters:
aProduct - product identifier or ANY_PRODUCT constant if any product is acceptable
aProductEdition - product edition identifier or ANY_PRODUCT_EDITION constant if any product edition is acceptable
aMajorVersion - major version or ANY_MAJOR_VERSION constant if any major version is acceptable
aMinorVersion - minor version or ANY_MINOR_VERSION constant if any minor version is acceptable
aLicenseType - license type as one of the License.TYPE_ constants or ANY_LICENSE_TYPE constant if any license type is acceptable
isExactMatch - specifies whether only the license entries that matches the given criteria exactly should be returned. If no license entries were found and the exact match is not required then the method will try to find the license entries by sequentially applying ANY_* constants’ values to the method parameters (from right to left).
Returns:
collection of the license entries

getLicenseEntries

public java.util.Collection getLicenseEntries(java.lang.String aProduct,
                                              java.lang.String aProductEdition,
                                              int aMajorVersion,
                                              int aMinorVersion,
                                              int aLicenseType)
Description copied from interface: LicenseStorage
Returns collection of the mathced license entries for the given parameters

Specified by:
getLicenseEntries in interface LicenseStorage
Parameters:
aProduct - product identifier or the ANY_PRODUCT constant if any product is acceptable
aProductEdition - product edition identifier or ANY_PRODUCT_EDITION constant if any product edition is acceptable
aMajorVersion - major version or the ANY_MAJOR_VERSION constant if any major version is acceptable
aMinorVersion - minor version or the ANY_MINOR_VERSION constant if any minor version is acceptable
aLicenseType - license type as one of the License.TYPE_ constants or the ANY_LICENSE_TYPE constant if any license type is acceptable
Returns:
collection of the license entries

getLicenseEntry

public LicenseStorage.LicenseEntry getLicenseEntry(java.lang.String aName)
Description copied from interface: LicenseStorage
Returns license entry for the given name

Specified by:
getLicenseEntry in interface LicenseStorage
Parameters:
aName - license entry name
Returns:
license entry or null of no license entry found

getName

public java.lang.String getName(LicenseStorage.LicenseEntry anEntry)
Description copied from interface: LicenseStorage
Returns the name for the given license entry

Specified by:
getName in interface LicenseStorage
Parameters:
anEntry - license entry to get name for
Returns:
name of the license entry

getLicenseEntryShortName

public static java.lang.String getLicenseEntryShortName(java.lang.String aName)
Returns short name for given full one

Parameters:
aName - full name of license entry
Returns:
short name by removing path components

getLicenseEntryPath

public static java.lang.String getLicenseEntryPath(java.lang.String aName)
Returns path component for the given license entry name

Parameters:
aName - license entry name
Returns:
path component

removeLicenseEntry

public void removeLicenseEntry(LicenseStorage.LicenseEntry anEntry)
Description copied from interface: LicenseStorage
Removes a license entry from the license storage

Specified by:
removeLicenseEntry in interface LicenseStorage
Parameters:
anEntry - license entry to remove

getLicenseEntry

public LicenseStorage.LicenseEntry getLicenseEntry(int anID)
Description copied from interface: LicenseStorage
Returns the license entry for the given unique identifier

Specified by:
getLicenseEntry in interface LicenseStorage
Parameters:
anID - unique identifier
Returns:
license entry or null of no license entry found

addLicenseStorageListener

public void addLicenseStorageListener(LicenseStorageListener l)
Description copied from interface: LicenseStorage
Adds a listener to the listeners list

Specified by:
addLicenseStorageListener in interface LicenseStorage
Parameters:
l - listener to add

removeLicenseStorageListener

public void removeLicenseStorageListener(LicenseStorageListener l)
Description copied from interface: LicenseStorage
Removes a listener from the listeners list

Specified by:
removeLicenseStorageListener in interface LicenseStorage
Parameters:
l - listener to remove

fireLicenseEntryAdded

protected void fireLicenseEntryAdded(LicenseStorage.LicenseEntry aLicenseEntry)

fireLicenseEntryUpdated

protected void fireLicenseEntryUpdated(LicenseStorage.LicenseEntry aLicenseEntry)

fireLicenseEntryRemoved

protected void fireLicenseEntryRemoved(LicenseStorage.LicenseEntry aLicenseEntry)

fireBeforeLicenseStorageLoad

protected void fireBeforeLicenseStorageLoad()

fireLicenseStorageLoaded

protected void fireLicenseStorageLoaded(boolean isSuccess)

fireBeforeLicenseStorageSave

protected void fireBeforeLicenseStorageSave()

fireLicenseStorageSaved

protected void fireLicenseStorageSaved(boolean isSuccess)

isModified

public boolean isModified()
Description copied from interface: LicenseStorage
Returns whether this license storage has been modified

Specified by:
isModified in interface LicenseStorage
Returns:
true if this license storage is modified; false otherwise

setModified

public void setModified(boolean aModified)
Description copied from interface: LicenseStorage
Specifies that this license storage is modified

Specified by:
setModified in interface LicenseStorage
Parameters:
aModified - true if this license storage should be modified; false otherwise

updateLicenseEntryProperties

public static void updateLicenseEntryProperties(License aLicense,
                                                LicenseStorage.LicenseEntry aLicenseEntry)
Updates license entry properties from the given license

Parameters:
aLicense - license to get properties from
aLicenseEntry - license entry to update properties for

getNewLicenseEntryName

public static java.lang.String getNewLicenseEntryName(LicenseStorage.LicenseEntry aLicenseEntry)