use of org.olat.ims.cp.ui.CPPackageConfig in project openolat by klemens.
the class ImsCPHandler method copy.
@Override
public RepositoryEntry copy(Identity author, RepositoryEntry source, RepositoryEntry target) {
final CPManager cpManager = CPManager.getInstance();
OLATResource sourceResource = source.getOlatResource();
OLATResource targetResource = target.getOlatResource();
File sourceFileroot = FileResourceManager.getInstance().getFileResourceRootImpl(sourceResource).getBasefile();
File zipRoot = new File(sourceFileroot, FileResourceManager.ZIPDIR);
File targetFileroot = FileResourceManager.getInstance().getFileResourceRootImpl(targetResource).getBasefile();
FileUtils.copyFileToDir(zipRoot, targetFileroot, "add file resource");
// copy packaging info
CPPackageConfig cpConfig = cpManager.getCPPackageConfig(sourceResource);
if (cpConfig != null) {
cpManager.setCPPackageConfig(targetResource, cpConfig);
}
CPOfflineReadableManager.getInstance().makeCPOfflineReadable(targetResource, target.getDisplayname() + ".zip");
return target;
}
use of org.olat.ims.cp.ui.CPPackageConfig in project openolat by klemens.
the class CPCourseNode method updateModuleConfigDefaults.
/**
* Update the module configuration to have all mandatory configuration flags
* set to usefull default values
*
* @param isNewNode true: an initial configuration is set; false: upgrading
* from previous node configuration version, set default to maintain
* previous behaviour
*/
@Override
public void updateModuleConfigDefaults(boolean isNewNode) {
int CURRENTVERSION = 7;
ModuleConfiguration config = getModuleConfiguration();
if (isNewNode) {
// use defaults for new course building blocks
config.setBooleanEntry(NodeEditController.CONFIG_STARTPAGE, Boolean.FALSE.booleanValue());
config.setBooleanEntry(NodeEditController.CONFIG_COMPONENT_MENU, Boolean.TRUE.booleanValue());
// how to render files (include jquery etc)
DeliveryOptions nodeDeliveryOptions = DeliveryOptions.defaultWithGlossary();
nodeDeliveryOptions.setInherit(Boolean.TRUE);
config.set(CPEditController.CONFIG_DELIVERYOPTIONS, nodeDeliveryOptions);
config.setConfigurationVersion(CURRENTVERSION);
} else {
config.remove(NodeEditController.CONFIG_INTEGRATION);
if (config.getConfigurationVersion() < 2) {
// update new configuration options using default values for existing
// nodes
config.setBooleanEntry(NodeEditController.CONFIG_STARTPAGE, Boolean.TRUE.booleanValue());
Boolean componentMenu = config.getBooleanEntry(NodeEditController.CONFIG_COMPONENT_MENU);
if (componentMenu == null) {
config.setBooleanEntry(NodeEditController.CONFIG_COMPONENT_MENU, Boolean.TRUE.booleanValue());
}
config.setConfigurationVersion(2);
}
if (config.getConfigurationVersion() < 3) {
config.set(NodeEditController.CONFIG_CONTENT_ENCODING, NodeEditController.CONFIG_CONTENT_ENCODING_AUTO);
config.set(NodeEditController.CONFIG_JS_ENCODING, NodeEditController.CONFIG_JS_ENCODING_AUTO);
config.setConfigurationVersion(3);
}
// save it as version 6
if (config.getConfigurationVersion() < 7) {
String contentEncoding = (String) config.get(NodeEditController.CONFIG_CONTENT_ENCODING);
if (contentEncoding != null && contentEncoding.equals("auto")) {
// new style for auto
contentEncoding = null;
}
String jsEncoding = (String) config.get(NodeEditController.CONFIG_JS_ENCODING);
if (jsEncoding != null && jsEncoding.equals("auto")) {
// new style for auto
jsEncoding = null;
}
CPPackageConfig reConfig = null;
DeliveryOptions nodeDeliveryOptions = (DeliveryOptions) config.get(CPEditController.CONFIG_DELIVERYOPTIONS);
if (nodeDeliveryOptions == null) {
// Update missing delivery options now, inherit from repo by default
nodeDeliveryOptions = DeliveryOptions.defaultWithGlossary();
nodeDeliveryOptions.setInherit(Boolean.TRUE);
RepositoryEntry re = getReferencedRepositoryEntry();
// Check if delivery options are set for repo entry, if not create default
if (re != null) {
reConfig = CPManager.getInstance().getCPPackageConfig(re.getOlatResource());
if (reConfig == null) {
reConfig = new CPPackageConfig();
}
DeliveryOptions repoDeliveryOptions = reConfig.getDeliveryOptions();
if (repoDeliveryOptions == null) {
// migrate existing config back to repo entry using the default as a base
repoDeliveryOptions = DeliveryOptions.defaultWithGlossary();
reConfig.setDeliveryOptions(repoDeliveryOptions);
repoDeliveryOptions.setContentEncoding(contentEncoding);
repoDeliveryOptions.setJavascriptEncoding(jsEncoding);
CPManager.getInstance().setCPPackageConfig(re.getOlatResource(), reConfig);
} else {
// see if we have any different settings than the repo. if so, don't use inherit mode
if (contentEncoding != repoDeliveryOptions.getContentEncoding() || jsEncoding != repoDeliveryOptions.getJavascriptEncoding()) {
nodeDeliveryOptions.setInherit(Boolean.FALSE);
nodeDeliveryOptions.setContentEncoding(contentEncoding);
nodeDeliveryOptions.setJavascriptEncoding(jsEncoding);
}
}
}
// remove old config parameters
config.remove(NodeEditController.CONFIG_CONTENT_ENCODING);
config.remove(NodeEditController.CONFIG_JS_ENCODING);
// replace with new delivery options
config.set(CPEditController.CONFIG_DELIVERYOPTIONS, nodeDeliveryOptions);
}
config.setConfigurationVersion(7);
}
// else node is up-to-date - nothing to do
}
if (config.getConfigurationVersion() != CURRENTVERSION) {
OLog logger = Tracing.createLoggerFor(CPCourseNode.class);
logger.error("CP course node version not updated to lastest version::" + CURRENTVERSION + ", was::" + config.getConfigurationVersion() + ". Check the code, programming error.");
}
}
use of org.olat.ims.cp.ui.CPPackageConfig in project OpenOLAT by OpenOLAT.
the class ImsCPHandler method createLaunchController.
@Override
public MainLayoutController createLaunchController(RepositoryEntry re, RepositoryEntrySecurity reSecurity, UserRequest ureq, WindowControl wControl) {
OLATResource res = re.getOlatResource();
File cpRoot = FileResourceManager.getInstance().unzipFileResource(res);
final LocalFolderImpl vfsWrapper = new LocalFolderImpl(cpRoot);
CPPackageConfig packageConfig = CPManager.getInstance().getCPPackageConfig(res);
final DeliveryOptions deliveryOptions = (packageConfig == null ? null : packageConfig.getDeliveryOptions());
return new CPRuntimeController(ureq, wControl, re, reSecurity, new RuntimeControllerCreator() {
@Override
public Controller create(UserRequest uureq, WindowControl wwControl, TooledStackedPanel toolbarPanel, RepositoryEntry entry, RepositoryEntrySecurity security, AssessmentMode assessmentMode) {
boolean activateFirstPage = true;
String initialUri = null;
CoreSpringFactory.getImpl(UserCourseInformationsManager.class).updateUserCourseInformations(entry.getOlatResource(), uureq.getIdentity());
CPDisplayController cpCtr = new CPDisplayController(uureq, wwControl, vfsWrapper, true, true, activateFirstPage, true, deliveryOptions, initialUri, entry.getOlatResource(), "", false);
MainLayout3ColumnsController ctr = new LayoutMain3ColsController(uureq, wwControl, cpCtr.getMenuComponent(), cpCtr.getInitialComponent(), vfsWrapper.getName());
ctr.addDisposableChildController(cpCtr);
return ctr;
}
});
}
use of org.olat.ims.cp.ui.CPPackageConfig in project OpenOLAT by OpenOLAT.
the class CPRunController method doLaunch.
private void doLaunch(UserRequest ureq) {
DeliveryOptions deliveryOptions = (DeliveryOptions) config.get(CPEditController.CONFIG_DELIVERYOPTIONS);
if (cpRoot == null) {
// it is the first time we start the contentpackaging from this instance
// of this controller.
// need to be strict when launching -> "true"
RepositoryEntry re = CPEditController.getCPReference(config, false);
if (re == null) {
showError(CPEditController.NLS_ERROR_CPREPOENTRYMISSING);
return;
}
cpRoot = FileResourceManager.getInstance().unzipFileResource(re.getOlatResource());
// nodes reference them
if (cpRoot == null) {
showError(CPEditController.NLS_ERROR_CPREPOENTRYMISSING);
return;
}
if (deliveryOptions != null && deliveryOptions.getInherit() != null && deliveryOptions.getInherit().booleanValue()) {
CPPackageConfig packageConfig = CPManager.getInstance().getCPPackageConfig(re.getOlatResource());
if (packageConfig != null && packageConfig.getDeliveryOptions() != null) {
deliveryOptions = packageConfig.getDeliveryOptions();
}
}
}
// else cpRoot is already set (save some db access if the user opens /
// closes / reopens the cp from the same CPRuncontroller instance)
boolean activateFirstPage = true;
if ((nodecmd != null) && !nodecmd.equals("")) {
activateFirstPage = false;
}
boolean showNavigation = !config.getBooleanSafe(NodeEditController.CONFIG_COMPONENT_MENU);
cpDispC = CPUIFactory.getInstance().createContentOnlyCPDisplayController(ureq, getWindowControl(), new LocalFolderImpl(cpRoot), activateFirstPage, showNavigation, deliveryOptions, nodecmd, courseResource, cpNode.getIdent(), preview);
cpDispC.setContentEncoding(deliveryOptions.getContentEncoding());
cpDispC.setJSEncoding(deliveryOptions.getJavascriptEncoding());
cpDispC.addControllerListener(this);
main.setContent(cpDispC.getInitialComponent());
if (isExternalMenuConfigured()) {
treeModel = cpDispC.getTreeModel();
treeNodeClickListener = this;
if (activateFirstPage) {
selNodeId = cpDispC.getInitialSelectedNodeId();
} else {
String uri = nodecmd;
if (uri.startsWith("/")) {
uri = uri.substring(1, uri.length());
}
selNodeId = cpDispC.getNodeByUri(uri);
}
}
}
use of org.olat.ims.cp.ui.CPPackageConfig in project OpenOLAT by OpenOLAT.
the class CompMenuForm method event.
/**
* @see org.olat.core.gui.control.DefaultController#event(org.olat.core.gui.UserRequest,
* org.olat.core.gui.control.Controller, org.olat.core.gui.control.Event)
*/
public void event(UserRequest urequest, Controller source, Event event) {
if (source == searchController) {
if (event == ReferencableEntriesSearchController.EVENT_REPOSITORY_ENTRY_SELECTED) {
// search controller done
// -> close closeable modal controller
cmc.deactivate();
RepositoryEntry re = searchController.getSelectedEntry();
if (re != null) {
setCPReference(re, config);
cpConfigurationVc.contextPut("showPreviewButton", Boolean.TRUE);
String displayname = StringHelper.escapeHtml(re.getDisplayname());
previewLink = LinkFactory.createCustomLink("command.preview", "command.preview", displayname, Link.NONTRANSLATED, cpConfigurationVc, this);
previewLink.setCustomEnabledLinkCSS("o_preview");
previewLink.setTitle(getTranslator().translate("command.preview"));
// remove existing edit link, add new one if user is allowed to edit this CP
if (editLink != null) {
cpConfigurationVc.remove(editLink);
editLink = null;
}
if (isEditable(urequest.getIdentity(), urequest.getUserSession().getRoles(), re)) {
editLink = LinkFactory.createButtonSmall("edit", cpConfigurationVc, this);
}
// fire event so the updated config is saved by the editormaincontroller
fireEvent(urequest, NodeEditController.NODECONFIG_CHANGED_EVENT);
CPPackageConfig cpConfig = CPManager.getInstance().getCPPackageConfig(re.getOlatResource());
if (cpConfig != null && cpConfig.getDeliveryOptions() != null) {
deliveryOptionsCtrl.setParentDeliveryOptions(cpConfig.getDeliveryOptions());
}
}
}
// else cancelled repo search
} else if (source == accessibilityCondContr) {
if (event == Event.CHANGED_EVENT) {
Condition cond = accessibilityCondContr.getCondition();
cpNode.setPreConditionAccess(cond);
fireEvent(urequest, NodeEditController.NODECONFIG_CHANGED_EVENT);
}
} else if (source == cpMenuForm) {
if (event == Event.DONE_EVENT) {
config.setBooleanEntry(NodeEditController.CONFIG_COMPONENT_MENU, cpMenuForm.isCpMenu());
fireEvent(urequest, NodeEditController.NODECONFIG_CHANGED_EVENT);
}
} else if (source == deliveryOptionsCtrl) {
if (event == Event.DONE_EVENT || event == Event.CHANGED_EVENT) {
config.set(CPEditController.CONFIG_DELIVERYOPTIONS, deliveryOptionsCtrl.getDeliveryOptions());
fireEvent(urequest, NodeEditController.NODECONFIG_CHANGED_EVENT);
}
}
}
Aggregations