
net.customware.license.confluence.ConfluenceLicenseParam Maven / Gradle / Ivy
package net.customware.license.confluence;
import com.atlassian.confluence.setup.ConfluenceBootstrapConstants;
import com.atlassian.license.LicenseType;
import com.atlassian.license.applications.confluence.ConfluenceLicenseTypeStore;
import net.customware.license.atlassian.AtlassianLicenseParam;
import net.customware.license.atlassian.DefaultLicenseContext;
import net.customware.license.atlassian.LicenseContext;
import net.customware.license.atlassian.ao.manager.LicenseManager;
import net.customware.license.confluence.prefs.ConfluenceSystemPreferences;
import net.customware.license.confluence.prefs.ConfluenceUserPreferences;
import java.util.Collection;
import java.util.List;
/**
* An implementation of the {@link net.customware.license.atlassian.AtlassianLicenseManager} with defaults
* appropriate for most Confluence plugins. Specifically:
*
*
* - Require one license for the whole server (including clusters if
* available).
* - Store the license key in Bandana.
*
*
* @author David Peterson
*/
public abstract class ConfluenceLicenseParam extends AtlassianLicenseParam {
private static final List LICENSE_TYPES;
static {
LICENSE_TYPES = new java.util.ArrayList();
LICENSE_TYPES.addAll(new ConfluenceLicenseTypeStore().getAllLicenses());
// LICENSE_TYPES.add( ConfluenceLicenseTypeStore.ACADEMIC );
// LICENSE_TYPES.add( ConfluenceLicenseTypeStore.COMMUNITY );
// LICENSE_TYPES.add( ConfluenceLicenseTypeStore.DEMONSTRATION );
// LICENSE_TYPES.add( ConfluenceLicenseTypeStore.DEVELOPER );
// LICENSE_TYPES.add( ConfluenceLicenseTypeStore.EVALUATION );
// LICENSE_TYPES.add( ConfluenceLicenseTypeStore.FULL_LICENSE );
// LICENSE_TYPES.add( ConfluenceLicenseTypeStore.HOSTED );
// LICENSE_TYPES.add( ConfluenceLicenseTypeStore.HOSTED_EVALUATION );
// LICENSE_TYPES.add( ConfluenceLicenseTypeStore.NON_PROFIT );
// LICENSE_TYPES.add( ConfluenceLicenseTypeStore.OPEN_SOURCE );
// LICENSE_TYPES.add( ConfluenceLicenseTypeStore.PERSONAL );
// LICENSE_TYPES.add( ConfluenceLicenseTypeStore.TESTING );
}
protected final LicenseManager licenseManager;
public ConfluenceLicenseParam(LicenseManager licenseManager) {
this.licenseManager = licenseManager;
}
public static LicenseType findLicenseType(int id) {
for (LicenseType type : LICENSE_TYPES) {
if (type.getType() == id)
return type;
}
return null;
}
public static Collection findLicenseTypes() {
return LICENSE_TYPES;
}
private static LicenseContext LICENSE_CONTEXT = new DefaultLicenseContext(ConfluenceBootstrapConstants.DEFAULT_LICENSE_REGISTRY_KEY);
/**
* Returns the LicenseContext for
*
* @return
*/
public static LicenseContext getLicenseContext() {
return LICENSE_CONTEXT;
}
@Override
public LicenseType getLicenseType(int id) {
return findLicenseType(id);
}
protected void requireLicensePerServer() {
setPreferences(new ConfluenceSystemPreferences(licenseManager).nodeForPackage(getClass()));
}
protected void requireLicensePerUser() {
setPreferences(new ConfluenceUserPreferences().nodeForPackage(getClass()));
}
/**
* Returns the Confluence {@link LicenseContext}.
*
* @see #getLicenseContext()
*/
@Override
public Object getContext() {
return getLicenseContext();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy