@PublicApi
public interface LicenseHandler
Licenses and products across Atlassian vary considerably with respect to the number of licenses that any given
product may accept (1-many), but also in terms of the number of products that may be granted within license (also
1-many). This interface provides both a single
product view
of license details (regardless of the actual number of licenses and products present), as well as a
MultiProductLicenseDetails
.
MultiProductLicenseDetails
Modifier and Type | Method and Description |
---|---|
void |
addProductLicense(String productKey,
String license)
Adds the given product license to the host application.
|
MultiProductLicenseDetails |
decodeLicenseDetails(String license)
Decodes a Platform Product License from the raw license String.
|
Collection<MultiProductLicenseDetails> |
getAllProductLicenses()
Returns all the product licenses on a platform.
|
SortedSet<String> |
getAllSupportEntitlementNumbers()
Gets the Support Entitlement Numbers (SENs) for all licenses in the currently running application.
|
Set<String> |
getProductKeys()
Returns the list of currently available products in this host application whether these products are currently
licensed or not.
|
SingleProductLicenseDetailsView |
getProductLicenseDetails(String productKey)
Returns an individual product view of the license details for the product identified by the given product key, or
null if the product does not exist in any license.
|
String |
getRawProductLicense(String productKey)
Returns the raw license String for a given product on a platform.
|
String |
getServerId()
Gets the server ID of the currently running application.
|
String |
getSupportEntitlementNumber()
Deprecated.
Get the license details and call
BaseLicenseDetails.getSupportEntitlementNumber() . Since 3.0. |
boolean |
hostAllowsCustomProducts()
Returns true if it is possible to add custom products on top of this platform.
|
boolean |
hostAllowsMultipleLicenses()
Use this to figure out if this host application uses a single global license, or if it is a platform that can take
multiple Product licenses.
|
void |
removeProductLicense(String productKey)
Removes the product license for the given productKey.
|
void |
setLicense(String license)
Deprecated.
Use
addProductLicense(String, String) instead. Since 3.0. |
ValidationResult |
validateProductLicense(String productKey,
String license,
Locale locale)
Validates that the given license is valid to add for the given product.
|
@Deprecated void setLicense(String license)
addProductLicense(String, String)
instead. Since 3.0.LicenseChangedEvent
upon successfully setting
the license.
This method is not suitable for platforms.
license
- The raw license stringIllegalArgumentException
- if the license string is not a valid licenseUnsupportedOperationException
- if this is a platform that allows multiple licensesboolean hostAllowsMultipleLicenses()
Most applications would return false here but Fisheye/Crucible will return true, and JIRA 7.0 will return true.
true
if this application is a platform that accepts multiple product licenses, false
if
it just takes a single global license.hostAllowsCustomProducts()
boolean hostAllowsCustomProducts()
Most applications would return false here. Confluence returns true because it has Spaces and Questions, JIRA 7.0 will return true, but Fisheye/Crucible will return false - although it has separate licenses for FishEye and Crucible, you cannot add new custom products.
true
if this application is a platform that accepts multiple product licenses, false
if
it just takes a single global license.hostAllowsMultipleLicenses()
Set<String> getProductKeys()
For FishEye/Crucible this will return both "fisheye" and "crucible".
For JIRA, it will return the list of products that are currently installed (eg "com.atlassian.servicedesk").
For simple applications that only take a single license, it will return a single application name where that
name is the ID used by HAMS to define the application in the license eg "bamboo", "conf".
void addProductLicense(@Nonnull String productKey, @Nonnull String license) throws InvalidOperationException
For a platform that can take multiple license, the platform will figure out which product this is for and replace the current license for that product if one exists.
This method will fire aLicenseChangedEvent
upon successfully adding
the license.productKey
- The product to add this license tolicense
- The license stringInvalidOperationException
- if the license string is not valid for any reason.
The InvalidOperationException should be localised for the currently logged in user and consumers are
encouraged to call InvalidOperationException.getLocalizedMessage()
void removeProductLicense(@Nonnull String productKey) throws InvalidOperationException
If the given product is in a multi-product license, it will remove that license and so all those products will
become unlicensed.
You can use #getAllProductLicenses
to find multi-product licenses.
This method will fire a LicenseChangedEvent
upon successfully removing
the license.
If the passed productKey does not exist or is not licensed, the method will no-op and return successfully.
productKey
- The product to remove the license ofInvalidOperationException
- if the host application vetoes this operation - eg JIRA will not let you remove
the very last license. The InvalidOperationException should be localised for the currently logged in
user and consumers are encouraged to call InvalidOperationException.getLocalizedMessage()
@Nonnull ValidationResult validateProductLicense(@Nonnull String productKey, @Nonnull String license, @Nullable Locale locale)
productKey
- The product to add this license tolicense
- the raw license Stringlocale
- locale of the end user - this is used to internationalise the error messages if any.@Nullable String getServerId()
null
if the server ID has not yet
been set for the currently running application.@Nullable @Deprecated String getSupportEntitlementNumber()
BaseLicenseDetails.getSupportEntitlementNumber()
. Since 3.0.This method is not suitable for platforms because these may have multiple licenses and hence multiple SENs.
null
if there is no current support entitlement.UnsupportedOperationException
- if this is a platform that allows multiple licenses@Nonnull SortedSet<String> getAllSupportEntitlementNumbers()
Note that licensed plugin SENs are not included in the results, unless they are being treated as application licenses.
@Nullable String getRawProductLicense(String productKey)
productKey
- the product key.getProductLicenseDetails(String)
@Nullable SingleProductLicenseDetailsView getProductLicenseDetails(@Nonnull String productKey)
productKey
- the product key.getRawProductLicense(String)
,
decodeLicenseDetails(String)
,
getAllProductLicenses()
@Nonnull Collection<MultiProductLicenseDetails> getAllProductLicenses()
A platform may return multiple licenses, a simple application will return 0 or 1.
getProductLicenseDetails(String)
@Nonnull MultiProductLicenseDetails decodeLicenseDetails(@Nonnull String license)
license
- the raw license StringIllegalArgumentException
- if the license string is not able to be decoded in this host applicationgetProductLicenseDetails(String)
Copyright © 2015 Atlassian. All rights reserved.