use of org.olat.core.commons.services.license.LicenseService in project openolat by klemens.
the class RepositoryEntryImportExport method importLicense.
private void importLicense(RepositoryEntry newEntry) {
if (!propertiesLoaded) {
loadConfiguration();
}
LicenseService licenseService = CoreSpringFactory.getImpl(LicenseService.class);
boolean hasLicense = StringHelper.containsNonWhitespace(repositoryProperties.getLicenseTypeName());
if (hasLicense) {
String licenseTypeName = repositoryProperties.getLicenseTypeName();
LicenseType licenseType = licenseService.loadLicenseTypeByName(licenseTypeName);
if (licenseType == null) {
licenseType = licenseService.createLicenseType(licenseTypeName);
licenseType.setText(repositoryProperties.getLicenseText());
licenseService.saveLicenseType(licenseType);
}
ResourceLicense license = licenseService.loadOrCreateLicense(newEntry.getOlatResource());
license.setLicenseType(licenseType);
license.setLicensor(repositoryProperties.getLicensor());
if (licenseService.isFreetext(licenseType)) {
license.setFreetext(repositoryProperties.getLicenseText());
}
licenseService.update(license);
}
}
use of org.olat.core.commons.services.license.LicenseService in project openolat by klemens.
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.LicenseService in project OpenOLAT by OpenOLAT.
the class RepositoryEntryImportExport method importLicense.
private void importLicense(RepositoryEntry newEntry) {
if (!propertiesLoaded) {
loadConfiguration();
}
LicenseService licenseService = CoreSpringFactory.getImpl(LicenseService.class);
boolean hasLicense = StringHelper.containsNonWhitespace(repositoryProperties.getLicenseTypeName());
if (hasLicense) {
String licenseTypeName = repositoryProperties.getLicenseTypeName();
LicenseType licenseType = licenseService.loadLicenseTypeByName(licenseTypeName);
if (licenseType == null) {
licenseType = licenseService.createLicenseType(licenseTypeName);
licenseType.setText(repositoryProperties.getLicenseText());
licenseService.saveLicenseType(licenseType);
}
ResourceLicense license = licenseService.loadOrCreateLicense(newEntry.getOlatResource());
license.setLicenseType(licenseType);
license.setLicensor(repositoryProperties.getLicensor());
if (licenseService.isFreetext(licenseType)) {
license.setFreetext(repositoryProperties.getLicenseText());
}
licenseService.update(license);
}
}
use of org.olat.core.commons.services.license.LicenseService in project OpenOLAT by OpenOLAT.
the class LicenseUIFactory method validateLicenseTypeMandatoryButNonSelected.
public static boolean validateLicenseTypeMandatoryButNonSelected(SingleSelection licenseEl) {
if (licenseEl == null)
return false;
if (!licenseEl.isMandatory())
return false;
LicenseService licenseService = CoreSpringFactory.getImpl(LicenseService.class);
boolean isNoLicenseSelected = false;
if (licenseEl.isOneSelected()) {
String selectedKey = licenseEl.getSelectedKey();
LicenseType selectedLicenseType = licenseService.loadLicenseTypeByKey(selectedKey);
isNoLicenseSelected = licenseService.isNoLicense(selectedLicenseType);
}
return isNoLicenseSelected;
}
use of org.olat.core.commons.services.license.LicenseService in project OpenOLAT by OpenOLAT.
the class LicenseUIFactory method getLicenseText.
public static String getLicenseText(License license) {
LicenseService licenseService = CoreSpringFactory.getImpl(LicenseService.class);
String licenseText = "";
if (license != null && license.getLicenseType() != null) {
LicenseType licenseType = license.getLicenseType();
if (licenseService.isFreetext(licenseType) && StringHelper.containsNonWhitespace(license.getFreetext())) {
licenseText = license.getFreetext();
} else if (StringHelper.containsNonWhitespace(licenseType.getText())) {
licenseText = licenseType.getText();
}
}
return licenseText;
}
Aggregations