Package de.xima.fc.license
Class LicenseAccess
- java.lang.Object
-
- de.xima.fc.license.LicenseAccess
-
- All Implemented Interfaces:
ILicenseAccess
public class LicenseAccess extends Object implements ILicenseAccess
Model that combines a system and a client license. When querying afeature
, first it checks whether that feature exists in the client license. If not, it falls back to the system license. Otherwise, an appropriate default value is returned.- Since:
- 7.0.0
- Author:
- XIMA MEDIA GmbH, Dresden
-
-
Constructor Summary
Constructors Constructor Description LicenseAccess(LicenseModel systemLicense)
LicenseAccess(LicenseModel systemLicense, LicenseModel clientLicense)
Creates a new license wrapper with a client and system license.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
getBooleanFeature(ELicenseFeature feature)
boolean
getBooleanFeature(ELicenseFeature feature, boolean defaultValue)
boolean
getBooleanFeature(String featureName, boolean defaultValue)
LicenseModel
getClientLicense()
Gets the clientLicenseint
getIntFeature(ELicenseFeature feature)
Gets the value of the given feature as an integer.int
getIntFeature(ELicenseFeature feature, int defaultValue)
Gets the value of the given feature as an integer.int
getIntFeature(String feature)
Gets the value of the given feature as an integer.int
getIntFeature(String feature, int defaultValue)
Gets the value of the given feature as an integer.Number
getNumberFeature(ELicenseFeature feature)
Number
getNumberFeature(ELicenseFeature feature, Number defaultValue)
Number
getNumberFeature(String featureName, Number defaultValue)
String
getStringFeature(ELicenseFeature feature)
String
getStringFeature(ELicenseFeature feature, String defaultValue)
String
getStringFeature(String featureName, String defaultValue)
int
getSublicenseCount(String subLicenseItemKey)
List<IItemLicenseModel>
getSubLicensesByItem(String subLicenseItemKey)
LicenseModel
getSystemLicense()
Gets the systemLicenseboolean
hasAccess(EAccessProperty property)
boolean
hasFeature(ELicenseFeature feature)
Checks if the license has the given license feature.boolean
hasPortalFeature()
Whether either the client or the system license has a portal count greater than 0.boolean
hasSublicense(String subLicenseItemKey)
boolean
isClientLicenseValid()
boolean
isSystemLicenseValid()
-
-
-
Constructor Detail
-
LicenseAccess
public LicenseAccess(LicenseModel systemLicense)
- Parameters:
systemLicense
- the system license
-
LicenseAccess
public LicenseAccess(LicenseModel systemLicense, LicenseModel clientLicense)
Creates a new license wrapper with a client and system license. When querying a feature, first it tries the client license, then the system license.- Parameters:
systemLicense
- The system license, may benull
(which is treated as an empty license without any features).clientLicense
- The client license, may benull
(which is treated as an empty license without any features).
-
-
Method Detail
-
getClientLicense
public LicenseModel getClientLicense()
Gets the clientLicense- Returns:
- the clientLicense
-
isClientLicenseValid
public boolean isClientLicenseValid()
- Returns:
true
if the combination of client and system license is valid,false
otherwise
-
isSystemLicenseValid
public boolean isSystemLicenseValid()
- Returns:
true
if the system license is valid,false
otherwise
-
getSystemLicense
public LicenseModel getSystemLicense()
Gets the systemLicense- Returns:
- the systemLicense
-
getBooleanFeature
public boolean getBooleanFeature(ELicenseFeature feature)
- Parameters:
feature
- the feature to get the value of- Returns:
- the value of the feature,
false
if the feature is not defined
-
getBooleanFeature
public boolean getBooleanFeature(ELicenseFeature feature, boolean defaultValue)
- Parameters:
feature
- the feature to get the value ofdefaultValue
- the default value to return if the feature is not defined- Returns:
- the value of the feature or the defaultValue if the feature is not defined
-
getBooleanFeature
public boolean getBooleanFeature(String featureName, boolean defaultValue)
- Parameters:
featureName
- the name of the feature to get the value ofdefaultValue
- the default value to return if the feature is not defined- Returns:
- the value of the feature or the defaultValue if the feature is not defined
-
getIntFeature
public int getIntFeature(ELicenseFeature feature)
Gets the value of the given feature as an integer. If the feature is not defined, 0 is returned.- Parameters:
feature
- The feature to get the value of- Returns:
- The value of the feature, 0 if the feature is not defined
-
getIntFeature
public int getIntFeature(ELicenseFeature feature, int defaultValue)
Gets the value of the given feature as an integer. If the feature is not defined, the given default is returned.- Parameters:
feature
- The feature to get the value of- Returns:
- The value of the feature, default value if the feature is not defined
-
getIntFeature
public int getIntFeature(String feature)
Gets the value of the given feature as an integer. If the feature is not defined, 0 is returned.- Parameters:
feature
- The feature to get the value of- Returns:
- The value of the feature, 0 if the feature is not defined
-
getIntFeature
public int getIntFeature(String feature, int defaultValue)
Gets the value of the given feature as an integer. If the feature is not defined, the given default is returned.- Parameters:
feature
- The feature to get the value of- Returns:
- The value of the feature, default value if the feature is not defined
-
getNumberFeature
public Number getNumberFeature(ELicenseFeature feature)
- Parameters:
feature
- the feature to get the value of- Returns:
- the value of the feature, 0 if the feature is not defined
-
getNumberFeature
public Number getNumberFeature(ELicenseFeature feature, Number defaultValue)
- Parameters:
feature
- the feature to get the value ofdefaultValue
- the default value to return if the feature is not defined- Returns:
- The value of the feature or the default value if the feature is not defined
-
getNumberFeature
public Number getNumberFeature(String featureName, Number defaultValue)
- Parameters:
featureName
- the name of the feature to get the value ofdefaultValue
- the default value to return if the feature is not defined- Returns:
- the value of the feature or the defaultValue if the feature is not defined
-
getStringFeature
public String getStringFeature(ELicenseFeature feature)
- Parameters:
feature
- the feature to get the value of- Returns:
- the value of the feature, empty string if the feature does not exist.
-
getStringFeature
public String getStringFeature(ELicenseFeature feature, String defaultValue)
- Parameters:
feature
- the feature to get the value ofdefaultValue
- the default value to return if the feature is not defined- Returns:
- the value of the feature or the defaultValue if the feature does not exist.
-
getStringFeature
public String getStringFeature(String featureName, String defaultValue)
- Parameters:
featureName
- the name of the feature to get the value ofdefaultValue
- the default value to return if the feature is not defined- Returns:
- the value of the feature or the defaultValue if the feature is not defined
-
getSubLicensesByItem
public List<IItemLicenseModel> getSubLicensesByItem(String subLicenseItemKey)
-
getSublicenseCount
public int getSublicenseCount(String subLicenseItemKey)
-
hasAccess
public boolean hasAccess(EAccessProperty property)
- Parameters:
property
- theEAccessProperty
to check- Returns:
- the value of the
EAccessProperty
in the license ortrue
if theEAccessProperty
is not defined
-
hasFeature
public boolean hasFeature(ELicenseFeature feature)
Description copied from interface:ILicenseAccess
Checks if the license has the given license feature.- Specified by:
hasFeature
in interfaceILicenseAccess
- Parameters:
feature
- The feature to check.- Returns:
true
if the license has the license feature,false
otherwise.
-
hasPortalFeature
public boolean hasPortalFeature()
Whether either the client or the system license has a portal count greater than 0.- Returns:
true
if either the client or the system license has a portal count greater than 0,
-
hasSublicense
public boolean hasSublicense(String subLicenseItemKey)
-
-