use of org.olat.core.commons.services.license.LicenseType in project OpenOLAT by OpenOLAT.
the class MetaInfoFactory method getLicense.
/**
* Get the license of the MetaInfo
*
* @param meta
* @return the license or null if no license is stored in the MetaInfo
*/
public License getLicense(MetaInfo meta) {
LicenseService licenseService = CoreSpringFactory.getImpl(LicenseService.class);
License license = null;
boolean hasLicense = meta != null && StringHelper.containsNonWhitespace(meta.getLicenseTypeName());
if (hasLicense) {
String licenseTypeName = meta.getLicenseTypeName();
LicenseType licenseType = licenseService.loadLicenseTypeByName(licenseTypeName);
if (licenseType == null) {
licenseType = licenseService.createLicenseType(licenseTypeName);
licenseType.setText(meta.getLicenseText());
licenseService.saveLicenseType(licenseType);
}
license = licenseService.createLicense(licenseType);
license.setLicensor(meta.getLicensor());
if (licenseService.isFreetext(licenseType)) {
license.setFreetext(meta.getLicenseText());
}
}
return license;
}
use of org.olat.core.commons.services.license.LicenseType in project OpenOLAT by OpenOLAT.
the class MetaInfoFormController method getLicenseFromFormItems.
private License getLicenseFromFormItems() {
License license = licenseService.createLicense(null);
String licensor = "";
String freetext = "";
if (licenseModule.isEnabled(licenseHandler)) {
if (licenseEl != null && licenseEl.isOneSelected()) {
String licenseTypeKey = licenseEl.getSelectedKey();
LicenseType licneseType = licenseService.loadLicenseTypeByKey(licenseTypeKey);
license.setLicenseType(licneseType);
}
if (licensorEl != null && licensorEl.isVisible() && StringHelper.containsNonWhitespace(licensorEl.getValue())) {
licensor = licensorEl.getValue();
}
if (licenseFreetextEl != null && licenseFreetextEl.isVisible() && StringHelper.containsNonWhitespace(licenseFreetextEl.getValue())) {
freetext = licenseFreetextEl.getValue();
}
licensorEl.setValue(license.getLicensor());
licenseFreetextEl.setValue(license.getFreetext());
}
license.setLicensor(licensor);
license.setFreetext(freetext);
return license;
}
use of org.olat.core.commons.services.license.LicenseType in project OpenOLAT by OpenOLAT.
the class LicenseAdminConfigController method getLicenseTypeValues.
private String[] getLicenseTypeValues(List<LicenseType> licenseTypes) {
String[] handlerNames = new String[licenseTypes.size()];
int count = 0;
for (LicenseType licenseType : licenseTypes) {
handlerNames[count++] = LicenseUIFactory.translate(licenseType, getLocale());
}
return handlerNames;
}
use of org.olat.core.commons.services.license.LicenseType in project OpenOLAT by OpenOLAT.
the class LicenseAdminConfigController method reloadDefaultLicenseTypeEl.
private void reloadDefaultLicenseTypeEl(LicenseHandler handler) {
SingleSelection defaultLicenseTypeEl = defaultLicenseTypeEls.get(handler.getType());
if (defaultLicenseTypeEl != null) {
List<LicenseType> activatedLicenseTypes = licenseService.loadActiveLicenseTypes(handler);
Collections.sort(activatedLicenseTypes);
String[] licenseTypeKeys = getLicenseTypeKeys(activatedLicenseTypes);
String[] licenseTypeValues = getLicenseTypeValues(activatedLicenseTypes);
defaultLicenseTypeEl.setKeysAndValues(licenseTypeKeys, licenseTypeValues, null);
String defaultLicenseTypeKey = licenseModule.getDefaultLicenseTypeKey(handler);
if (Arrays.asList(licenseTypeKeys).contains(defaultLicenseTypeKey)) {
defaultLicenseTypeEl.select(defaultLicenseTypeKey, true);
}
}
}
use of org.olat.core.commons.services.license.LicenseType in project OpenOLAT by OpenOLAT.
the class LicenseSelectionConfig method getLicenseTypeValues.
public String[] getLicenseTypeValues(Locale locale) {
String[] values = new String[selectableLicenseTypes.size()];
int count = 0;
for (LicenseType licenseType : selectableLicenseTypes) {
String translation = LicenseUIFactory.translate(licenseType, locale);
translation = setSpecialTranslation(translation, licenseType, locale);
values[count++] = translation;
}
return values;
}
Aggregations