Search in sources :

Example 31 with LicenseType

use of org.olat.core.commons.services.license.LicenseType in project openolat by klemens.

the class LicenseAdminConfigController method doActivateLicenseType.

private void doActivateLicenseType(MultipleSelectionElement multipleSelectionElement) {
    boolean doActivate = multipleSelectionElement.isAtLeastSelected(1) ? true : false;
    HandlerLicenseType handlerLicenseType = (HandlerLicenseType) multipleSelectionElement.getUserObject();
    LicenseHandler handler = handlerLicenseType.getHandler();
    LicenseType licenseType = handlerLicenseType.getLicenseType();
    if (doActivate) {
        licenseService.activate(handler, licenseType);
        reloadDefaultLicenseTypeEl(handler);
    } else {
        if (isDefaultLicenseType(handler, licenseType)) {
            showWarning("error.is.default.license.type");
            loadModel();
        } else {
            licenseService.deactivate(handler, licenseType);
            reloadDefaultLicenseTypeEl(handler);
        }
    }
    // checkboxes of enabled handlers was deactivated after deactivating a license type.
    initGeneralElements();
}
Also used : LicenseHandler(org.olat.core.commons.services.license.LicenseHandler) LicenseType(org.olat.core.commons.services.license.LicenseType)

Example 32 with LicenseType

use of org.olat.core.commons.services.license.LicenseType in project openolat by klemens.

the class LicenseRenderer method renderLicense.

private void renderLicense(StringOutput sb, License license, boolean small) {
    LicenseType licenseType = license.getLicenseType();
    long id = CodeHelper.getRAMUniqueID();
    // license text link
    sb.append("<a id='o_lic_").append(id).append("' href='javascript:;'><span");
    if (small) {
        sb.append(" class='small'");
    }
    sb.append(">");
    sb.append(LicenseUIFactory.translate(licenseType, locale));
    sb.append("</span></a>");
    // popup with license informations
    sb.append("<div id='o_lic_pop_").append(id).append("' style='display:none;' class='o_lic_popup'><div>");
    appendStaticControl(sb, "license.popup.type", LicenseUIFactory.translate(licenseType, locale), LicenseUIFactory.getCssOrDefault(licenseType));
    String licensor = license.getLicensor() != null ? license.getLicensor() : "";
    appendStaticControl(sb, "license.popup.licensor", licensor);
    appendStaticControl(sb, "license.popup.text", LicenseUIFactory.getFormattedLicenseText(license));
    sb.append("</div>");
    // JavaScript to pup up the popup
    sb.append("<script type='text/javascript'>").append("/* <![CDATA[ */").append("jQuery(function() {\n").append("  o_popover('o_lic_").append(id).append("','o_lic_pop_").append(id).append("','top');\n").append("});").append("/* ]]> */").append("</script>");
}
Also used : LicenseType(org.olat.core.commons.services.license.LicenseType)

Example 33 with LicenseType

use of org.olat.core.commons.services.license.LicenseType in project openolat by klemens.

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

Example 34 with LicenseType

use of org.olat.core.commons.services.license.LicenseType in project openolat by klemens.

the class LicenseServiceImpl method loadOrCreateLicense.

@Override
public ResourceLicense loadOrCreateLicense(OLATResourceable ores) {
    ResourceLicense license = licenseDao.loadByResource(ores);
    if (license == null) {
        LicenseType licenseType = licenseTypeDao.loadNoLicenseType();
        license = licenseDao.createAndPersist(ores, licenseType);
    }
    return license;
}
Also used : ResourceLicense(org.olat.core.commons.services.license.ResourceLicense) LicenseType(org.olat.core.commons.services.license.LicenseType)

Example 35 with LicenseType

use of org.olat.core.commons.services.license.LicenseType in project openolat by klemens.

the class LicenseServiceImpl method getDefaultLicenseType.

private LicenseType getDefaultLicenseType(LicenseHandler handler) {
    String defaultLicenseTypeKey = licenseModule.getDefaultLicenseTypeKey(handler);
    LicenseType defautlLicenseType = loadLicenseTypeByKey(defaultLicenseTypeKey);
    if (defautlLicenseType == null) {
        defautlLicenseType = licenseTypeDao.loadNoLicenseType();
    }
    return defautlLicenseType;
}
Also used : LicenseType(org.olat.core.commons.services.license.LicenseType)

Aggregations

LicenseType (org.olat.core.commons.services.license.LicenseType)106 Test (org.junit.Test)40 ResourceLicense (org.olat.core.commons.services.license.ResourceLicense)28 LicenseService (org.olat.core.commons.services.license.LicenseService)14 License (org.olat.core.commons.services.license.License)12 OLATResourceable (org.olat.core.id.OLATResourceable)12 File (java.io.File)6 ArrayList (java.util.ArrayList)4 LicenseHandler (org.olat.core.commons.services.license.LicenseHandler)4 FormLayoutContainer (org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)4 QLicense (org.olat.modules.qpool.model.QLicense)4 Date (java.util.Date)2 Random (java.util.Random)2 IdentityShort (org.olat.basesecurity.IdentityShort)2 LicenseImpl (org.olat.core.commons.services.license.model.LicenseImpl)2 MultipleSelectionElement (org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement)2 SingleSelection (org.olat.core.gui.components.form.flexible.elements.SingleSelection)2 Translator (org.olat.core.gui.translator.Translator)2 MultiUserEvent (org.olat.core.util.event.MultiUserEvent)2 LocalFileImpl (org.olat.core.util.vfs.LocalFileImpl)2