use of org.olat.core.commons.services.license.LicenseService in project openolat by klemens.
the class RepositoryEntryImportExport method addLicenseInformations.
private void addLicenseInformations(RepositoryEntryImport imp, RepositoryEntry re) {
LicenseService licenseService = CoreSpringFactory.getImpl(LicenseService.class);
ResourceLicense license = licenseService.loadLicense(re.getOlatResource());
if (license != null) {
imp.setLicenseTypeKey(String.valueOf(license.getLicenseType().getKey()));
imp.setLicenseTypeName(license.getLicenseType().getName());
imp.setLicensor(license.getLicensor());
imp.setLicenseText(LicenseUIFactory.getLicenseText(license));
}
}
use of org.olat.core.commons.services.license.LicenseService in project openolat by klemens.
the class MetaInfoFactory method getOrCreateLicense.
/**
* Get the license of the MetaInfo or create a new default license:
*
* @param meta
* @param itentity the current user
* @return
*/
public License getOrCreateLicense(MetaInfo meta, Identity itentity) {
LicenseHandler licenseHandler = CoreSpringFactory.getImpl(FolderLicenseHandler.class);
LicenseService licenseService = CoreSpringFactory.getImpl(LicenseService.class);
License license = getLicense(meta);
if (license == null) {
license = licenseService.createDefaultLicense(licenseHandler, itentity);
}
return license;
}
use of org.olat.core.commons.services.license.LicenseService in project openolat by klemens.
the class VFSResourceRoot method addLicense.
private void addLicense(MetaInfo meta, Identity identity) {
LicenseService licenseService = CoreSpringFactory.getImpl(LicenseService.class);
LicenseModule licenseModule = CoreSpringFactory.getImpl(LicenseModule.class);
FolderLicenseHandler licenseHandler = CoreSpringFactory.getImpl(FolderLicenseHandler.class);
if (licenseModule.isEnabled(licenseHandler)) {
License license = licenseService.createDefaultLicense(licenseHandler, identity);
meta.setLicenseTypeKey(String.valueOf(license.getLicenseType().getKey()));
meta.setLicenseTypeName(license.getLicenseType().getName());
meta.setLicensor(license.getLicensor());
meta.setLicenseText(LicenseUIFactory.getLicenseText(license));
}
}
use of org.olat.core.commons.services.license.LicenseService in project openolat by klemens.
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 klemens.
the class QTIMetadataConverter method addLicenseMetadataField.
private void addLicenseMetadataField(String label, QuestionItemFull fullItem, Element metadata) {
LicenseService lService = CoreSpringFactory.getImpl(LicenseService.class);
ResourceLicense license = lService.loadLicense(fullItem);
if (license != null) {
String licenseText = null;
LicenseType licenseType = license.getLicenseType();
if (lService.isFreetext(licenseType)) {
licenseText = license.getFreetext();
} else if (!lService.isNoLicense(licenseType)) {
licenseText = license.getLicenseType().getName();
}
if (StringHelper.containsNonWhitespace(licenseText)) {
addMetadataField(label, licenseText, metadata);
}
}
}
Aggregations