Search in sources :

Example 11 with LicenseService

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

Example 12 with LicenseService

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

Example 13 with LicenseService

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

Example 14 with LicenseService

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

Example 15 with LicenseService

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