use of org.olat.core.commons.services.license.LicenseHandler 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.LicenseHandler in project openolat by klemens.
the class LicenseAdminConfigController method doSetLicensorCreator.
private void doSetLicensorCreator(FormItem source, SingleSelection singleSelection) {
if (singleSelection.isOneSelected()) {
String creatorType = singleSelection.getSelectedKey();
LicenseHandler handler = (LicenseHandler) source.getUserObject();
licenseModule.setLicensorCreatorType(handler, creatorType);
initHandlerConfigs();
}
}
use of org.olat.core.commons.services.license.LicenseHandler in project openolat by klemens.
the class LicenseAdminConfigController method formInnerEvent.
@Override
protected void formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) {
if (enabledEl == source) {
doEnableHandlers();
} else if (addLicenseTypeButton == source) {
doAddLicenseType(ureq);
} else if (tableEl == source) {
if (event instanceof SelectionEvent) {
SelectionEvent se = (SelectionEvent) event;
String cmd = se.getCommand();
LicenseTypeRow licenseTypeRow = dataModel.getObject(se.getIndex());
if (CMD_UP.equals(cmd)) {
doUp(se.getIndex());
} else if (CMD_DOWN.equals(cmd)) {
doDown(se.getIndex());
} else if (CMD_TRANSLATE.equals(cmd)) {
doOpenTranslator(ureq, licenseTypeRow.getLicenseType());
} else if (CMD_EDIT.equals(cmd)) {
doEditLicenseType(ureq, licenseTypeRow.getLicenseType());
}
}
} else if (source instanceof MultipleSelectionElement) {
MultipleSelectionElement multipleSelectionElement = (MultipleSelectionElement) source;
doActivateLicenseType(multipleSelectionElement);
} else if (source instanceof SingleSelection) {
SingleSelection singleSelection = (SingleSelection) source;
String name = singleSelection.getName();
if (name.startsWith(DEFAULT_LICENSE_TYPE_PREFIX)) {
doSetDefaultLicenceType(source, singleSelection);
} else if (name.startsWith(LICENSOR_CREATOR_TYPE_PREFIX)) {
doSetLicensorCreator(source, singleSelection);
}
} else if (source instanceof FormLink) {
Object userObject = source.getUserObject();
if (userObject instanceof LicenseHandler) {
LicenseHandler handler = (LicenseHandler) userObject;
doEditLicensorConstant(ureq, handler);
}
}
super.formInnerEvent(ureq, source, event);
}
use of org.olat.core.commons.services.license.LicenseHandler in project openolat by klemens.
the class LicenseAdminConfigController method initGeneralElements.
private void initGeneralElements() {
FormLayoutContainer generalCont = FormLayoutContainer.createDefaultFormLayout("general", getTranslator());
generalCont.setFormTitle(translate("admin.menu.title"));
generalCont.setRootForm(mainForm);
generalCont.setElementCssClass("o_sel_license_general");
flc.add("general", generalCont);
String[] enabledHandlerKeys = licenseHandlers.stream().map(LicenseHandler::getType).toArray(String[]::new);
String[] enabledHandlerValues = licenseHandlers.stream().map(handler -> handler.getTitle(getLocale())).toArray(String[]::new);
enabledEl = uifactory.addCheckboxesVertical("handler.enabled", "admin.enabled", generalCont, enabledHandlerKeys, enabledHandlerValues, 1);
enabledEl.addActionListener(FormEvent.ONCHANGE);
for (LicenseHandler handler : licenseHandlers) {
boolean handlerEnabled = licenseModule.isEnabled(handler);
enabledEl.select(handler.getType(), handlerEnabled);
}
}
Aggregations