Search in sources :

Example 16 with LicenseService

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));
    }
}
Also used : LicenseService(org.olat.core.commons.services.license.LicenseService) ResourceLicense(org.olat.core.commons.services.license.ResourceLicense)

Example 17 with LicenseService

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;
}
Also used : FolderLicenseHandler(org.olat.core.commons.modules.bc.FolderLicenseHandler) LicenseHandler(org.olat.core.commons.services.license.LicenseHandler) LicenseService(org.olat.core.commons.services.license.LicenseService) License(org.olat.core.commons.services.license.License)

Example 18 with LicenseService

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));
    }
}
Also used : FolderLicenseHandler(org.olat.core.commons.modules.bc.FolderLicenseHandler) LicenseService(org.olat.core.commons.services.license.LicenseService) License(org.olat.core.commons.services.license.License) LicenseModule(org.olat.core.commons.services.license.LicenseModule)

Example 19 with LicenseService

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;
}
Also used : LicenseService(org.olat.core.commons.services.license.LicenseService) LicenseType(org.olat.core.commons.services.license.LicenseType)

Example 20 with LicenseService

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);
        }
    }
}
Also used : LicenseService(org.olat.core.commons.services.license.LicenseService) ResourceLicense(org.olat.core.commons.services.license.ResourceLicense) LicenseType(org.olat.core.commons.services.license.LicenseType)

Aggregations

LicenseService (org.olat.core.commons.services.license.LicenseService)20 LicenseType (org.olat.core.commons.services.license.LicenseType)14 ResourceLicense (org.olat.core.commons.services.license.ResourceLicense)8 License (org.olat.core.commons.services.license.License)6 FolderLicenseHandler (org.olat.core.commons.modules.bc.FolderLicenseHandler)4 ArrayList (java.util.ArrayList)2 LicenseHandler (org.olat.core.commons.services.license.LicenseHandler)2 LicenseModule (org.olat.core.commons.services.license.LicenseModule)2 Interaction (uk.ac.ed.ph.jqtiplus.node.item.interaction.Interaction)2