/**
* OLAT - Online Learning and Training<br>
* http://www.olat.org
* <p>
* Licensed under the Apache License, Version 2.0 (the "License"); <br>
* you may not use this file except in compliance with the License.<br>
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing,<br>
* software distributed under the License is distributed on an "AS IS" BASIS, <br>
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. <br>
* See the License for the specific language governing permissions and <br>
* limitations under the License.
* <p>
* Copyright (c) since 2004 at Multimedia- & E-Learning Services (MELS),<br>
* University of Zurich, Switzerland.
* <p>
*/
package org.olat.course.nodes.ta;
import java.util.ArrayList;
import java.util.List;
import org.olat.admin.quota.QuotaConstants;
import org.olat.core.commons.modules.bc.FolderRunController;
import org.olat.core.commons.modules.bc.vfs.OlatNamedContainerImpl;
import org.olat.core.commons.modules.bc.vfs.OlatRootFolderImpl;
import org.olat.core.gui.UserRequest;
import org.olat.core.gui.components.Component;
import org.olat.core.gui.components.form.Form;
import org.olat.core.gui.components.link.Link;
import org.olat.core.gui.components.link.LinkFactory;
import org.olat.core.gui.components.tabbedpane.TabbedPane;
import org.olat.core.gui.components.velocity.VelocityContainer;
import org.olat.core.gui.control.Controller;
import org.olat.core.gui.control.ControllerEventListener;
import org.olat.core.gui.control.Event;
import org.olat.core.gui.control.WindowControl;
import org.olat.core.gui.control.generic.closablewrapper.CloseableModalController;
import org.olat.core.gui.control.generic.layouter.LayoutController;
import org.olat.core.gui.control.generic.layouter.Layouts;
import org.olat.core.gui.control.generic.modal.DialogBoxController;
import org.olat.core.gui.control.generic.modal.DialogBoxUIFactory;
import org.olat.core.gui.control.generic.tabbable.ActivateableTabbableDefaultController;
import org.olat.core.gui.translator.PackageTranslator;
import org.olat.core.gui.translator.Translator;
import org.olat.core.logging.OLog;
import org.olat.core.logging.Tracing;
import org.olat.core.util.Util;
import org.olat.core.util.notifications.SubscriptionContext;
import org.olat.core.util.vfs.Quota;
import org.olat.core.util.vfs.QuotaManager;
import org.olat.core.util.vfs.callbacks.FullAccessWithQuotaCallback;
import org.olat.core.util.vfs.callbacks.VFSSecurityCallback;
import org.olat.course.ICourse;
import org.olat.course.assessment.AssessmentHelper;
import org.olat.course.auditing.UserNodeAuditManager;
import org.olat.course.condition.Condition;
import org.olat.course.condition.ConditionEditController;
import org.olat.course.editor.NodeEditController;
import org.olat.course.groupsandrights.CourseGroupManager;
import org.olat.course.nodes.TACourseNode;
import org.olat.course.nodes.ms.MSCourseNodeEditController;
import org.olat.course.nodes.ms.MSEditFormController;
import org.olat.course.properties.CoursePropertyManager;
import org.olat.course.properties.PersistingCoursePropertyManager;
import org.olat.course.run.userview.UserCourseEnvironment;
import org.olat.group.ui.context.BGContextEvent;
import org.olat.modules.ModuleConfiguration;
/**
*
* Initial Date: 30.08.2004
*
* @author Mike Stock
*
* Comment:
*
* </pre>
*/
public class TACourseNodeEditController extends ActivateableTabbableDefaultController implements ControllerEventListener {
private OLog log = Tracing.createLoggerFor(this.getClass());
public static final String PANE_TAB_CONF_SCORING = "pane.tab.conf.scoring";
public static final String PANE_TAB_CONF_DROPBOX = "pane.tab.conf.dropbox";
public static final String PANE_TAB_CONF_TASK = "pane.tab.conf.task";
public static final String PANE_TAB_CONF_MODULES = "pane.tab.conf.modules";
public static final String PANE_TAB_ACCESSIBILITY = "pane.tab.accessibility";
public static final String PANE_TAB_SOLUTION = "pane.tab.solution";
private static final String[] paneKeys = { PANE_TAB_SOLUTION, PANE_TAB_CONF_SCORING, PANE_TAB_CONF_DROPBOX, PANE_TAB_CONF_TASK, PANE_TAB_CONF_MODULES,
PANE_TAB_ACCESSIBILITY };
private ICourse course;
private TACourseNode node;
private ModuleConfiguration config;
private VelocityContainer accessabilityVC, solutionVC;
private VelocityContainer editModules, editTask, editDropbox, editScoring;
private TabbedPane myTabbedPane;
private int taskTabPosition, dropboxTabPosition, scoringTabPosition, solutionTabPosition;
private ModulesForm modulesForm;
private TaskFormController taskController;
private DropboxForm dropboxForm;
private MSEditFormController scoringController;
private FolderRunController frc;
private ConditionEditController taskConditionC, dropConditionC, returnboxConditionC, scoringConditionC, solutionConditionC;
private boolean hasLogEntries;
private DialogBoxController dialogBoxController;
private Link btfButton;
private Link editScoringConfigButton;
private Link vfButton;
/**
* @param ureq
* @param wControl
* @param course
* @param node
* @param groupMgr
*/
public TACourseNodeEditController(UserRequest ureq, WindowControl wControl, ICourse course, TACourseNode node,
CourseGroupManager groupMgr, UserCourseEnvironment euce) {
super(ureq, wControl);
this.node = node;
//o_clusterOk by guido: save to hold reference to course inside editor
this.course = course;
this.config = node.getModuleConfiguration();
Translator newTranslator = new PackageTranslator(Util.getPackageName(TACourseNodeEditController.class), ureq.getLocale(), new PackageTranslator(Util
.getPackageName(MSCourseNodeEditController.class), ureq.getLocale()));
setTranslator(newTranslator);
accessabilityVC = this.createVelocityContainer("edit");
// Task precondition
taskConditionC = new ConditionEditController(ureq, getWindowControl(), groupMgr, node.getConditionTask(), "taskConditionForm",
AssessmentHelper.getAssessableNodes(course.getEditorTreeModel(), node), euce);
this.listenTo(taskConditionC);
if (((Boolean) config.get(TACourseNode.CONF_TASK_ENABLED)).booleanValue()) accessabilityVC.put("taskCondition", taskConditionC
.getInitialComponent());
// DropBox precondition
dropConditionC = new ConditionEditController(ureq, getWindowControl(), groupMgr, node.getConditionDrop(), "dropConditionForm",
AssessmentHelper.getAssessableNodes(course.getEditorTreeModel(), node), euce);
this.listenTo(dropConditionC);
Boolean hasDropboxValue = ((Boolean) config.get(TACourseNode.CONF_DROPBOX_ENABLED)!=null) ? (Boolean) config.get(TACourseNode.CONF_DROPBOX_ENABLED) : false;
if (hasDropboxValue) accessabilityVC.put("dropCondition", dropConditionC.getInitialComponent());
//returnbox precondition - use dropbox condition if none defined for returnbox
Condition dropboxCondition = node.getConditionDrop();
Condition returnboxCondition = node.getConditionReturnbox();
if(dropboxCondition!=null && returnboxCondition!= null && returnboxCondition.getConditionExpression()==null) {
//old courses: use ConditionExpression from dropbox if none defined for returnbox
returnboxCondition = dropboxCondition;
returnboxCondition.setConditionId(TACourseNode.ACCESS_RETURNBOX);
node.setConditionReturnbox(returnboxCondition);
}
returnboxConditionC = new ConditionEditController(ureq, getWindowControl(), groupMgr, returnboxCondition, "returnboxConditionForm",
AssessmentHelper.getAssessableNodes(course.getEditorTreeModel(), node), euce);
this.listenTo(returnboxConditionC);
Object returnBoxConf = config.get(TACourseNode.CONF_RETURNBOX_ENABLED);
//use the dropbox config if none specified for the return box
boolean returnBoxEnabled = (returnBoxConf !=null) ? ((Boolean) returnBoxConf).booleanValue() : hasDropboxValue;
if (returnBoxEnabled) accessabilityVC.put("returnboxCondition", returnboxConditionC.getInitialComponent());
// Scoring precondition
scoringConditionC = new ConditionEditController(ureq, getWindowControl(), groupMgr, node.getConditionScoring(), "scoringConditionForm",
AssessmentHelper.getAssessableNodes(course.getEditorTreeModel(), node), euce);
this.listenTo(scoringConditionC);
if (((Boolean) config.get(TACourseNode.CONF_SCORING_ENABLED)).booleanValue()) accessabilityVC.put("scoringCondition", scoringConditionC
.getInitialComponent());
// SolutionFolder precondition
solutionConditionC = new ConditionEditController(ureq, getWindowControl(), groupMgr, node.getConditionSolution(),
"solutionConditionForm", AssessmentHelper.getAssessableNodes(course.getEditorTreeModel(), node), euce);
this.listenTo(solutionConditionC);
if (((Boolean) config.get(TACourseNode.CONF_SOLUTION_ENABLED)).booleanValue()) accessabilityVC.put("solutionCondition", solutionConditionC
.getInitialComponent());
// Modules config
editModules = this.createVelocityContainer("editModules");
modulesForm = new ModulesForm("modulesform", getTranslator(), config);
modulesForm.addListener(this);
editModules.put(modulesForm);
// Task config
editTask = this.createVelocityContainer("editTask");
btfButton = LinkFactory.createButton("taskfolder", editTask, this);
taskController = new TaskFormController(ureq, wControl, config);
listenTo(taskController);
String taskFolderPath = (String) node.getModuleConfiguration().get(TACourseNode.CONF_TASK_FOLDER_REL_PATH);
if (taskFolderPath == null) editTask.contextPut("taskfolder", translate("taskfolder.empty"));
else editTask.contextPut("taskfolder", taskFolderPath);
editTask.put("taskform", taskController.getInitialComponent());
// DropBox config
editDropbox = this.createVelocityContainer("editDropbox");
dropboxForm = new DropboxForm("dropboxform", getTranslator(), config);
dropboxForm.addListener(this);
editDropbox.put(dropboxForm);
// Scoring config
editScoring = this.createVelocityContainer("editScoring");
editScoringConfigButton = LinkFactory.createButtonSmall("scoring.config.enable.button", editScoring, this);
scoringController = new MSEditFormController(ureq, wControl, config);
listenTo(scoringController);
editScoring.put("scoringController", scoringController.getInitialComponent());
// if there is already user data available, make for read only
UserNodeAuditManager am = course.getCourseEnvironment().getAuditManager();
hasLogEntries = am.hasUserNodeLogs(node);
editScoring.contextPut("hasLogEntries", new Boolean(hasLogEntries));
if (hasLogEntries) {
scoringController.setDisplayOnly(true);
}
//Initialstate
editScoring.contextPut("isOverwriting", new Boolean(false));
// Solution-Tab
solutionVC = this.createVelocityContainer("editSolutionFolder");
vfButton = LinkFactory.createButton("link.solutionFolder", solutionVC, this);
}
private VFSSecurityCallback getTaskFolderSecCallback(String relPath) {
// check if any tasks assigned yet
CoursePropertyManager cpm = PersistingCoursePropertyManager.getInstance(course);
List assignedProps = cpm.listCourseNodeProperties(node, null, null, TaskController.PROP_ASSIGNED);
// return new TaskFolderCallback(relPath, (assignedProps.size() > 0));
return new TaskFolderCallback(relPath, false); // do not look task folder
}
/**
* @see org.olat.core.gui.control.DefaultController#event(org.olat.core.gui.UserRequest,
* org.olat.core.gui.components.Component, org.olat.core.gui.control.Event)
*/
@Override
public void event(UserRequest ureq, Component source, Event event) {
if (log.isDebug()) log.debug("event source=" + source + " " + event.toString());
if (source == btfButton){
// check if there are already assigned tasks
CoursePropertyManager cpm = PersistingCoursePropertyManager.getInstance(course);
List assignedProps = cpm.listCourseNodeProperties(node, null, null, TaskController.PROP_ASSIGNED);
if (assignedProps.size() == 0) {
// no task assigned
String relPath = TACourseNode.getTaskFolderPathRelToFolderRoot(course, node);
OlatRootFolderImpl rootFolder = new OlatRootFolderImpl(relPath, null);
OlatNamedContainerImpl namedFolder = new OlatNamedContainerImpl(translate("taskfolder"), rootFolder);
namedFolder.setLocalSecurityCallback(getTaskFolderSecCallback(relPath));
frc = new FolderRunController(namedFolder, false, ureq, getWindowControl());
CloseableModalController cmc = new CloseableModalController(getWindowControl(), translate("folder.close"), frc
.getInitialComponent());
cmc.activate();
} else {
// already assigned task => open dialog with warn
String[] args = new String[] { new Integer(assignedProps.size()).toString() };
dialogBoxController = this.activateOkCancelDialog(ureq, "", getTranslator().translate("taskfolder.overwriting.confirm", args), dialogBoxController);
List cs = new ArrayList();
cs.add(dialogBoxController);
LayoutController vcc = new LayoutController(Layouts.VERTICAL, cs);
}
} else if (source == modulesForm) {
if (event == Form.EVNT_FORM_CANCELLED) {
return;
} else if (event == Form.EVNT_VALIDATION_OK) {
config.set(TACourseNode.CONF_TASK_ENABLED, new Boolean(modulesForm.hasTask()));
config.set(TACourseNode.CONF_DROPBOX_ENABLED, new Boolean(modulesForm.hasDropbox()));
config.set(TACourseNode.CONF_RETURNBOX_ENABLED, new Boolean(modulesForm.hasReturnbox()));
config.set(TACourseNode.CONF_SCORING_ENABLED, new Boolean(modulesForm.hasScoring()));
config.set(TACourseNode.CONF_SOLUTION_ENABLED, new Boolean(modulesForm.hasSolution()));
myTabbedPane.setEnabled(taskTabPosition, modulesForm.hasTask());
if (modulesForm.hasTask()) {
accessabilityVC.put("taskCondition", taskConditionC.getInitialComponent());
} else {
accessabilityVC.remove(taskConditionC.getInitialComponent());
}
myTabbedPane.setEnabled(dropboxTabPosition, modulesForm.hasDropbox());
if (modulesForm.hasDropbox()) {
accessabilityVC.put("dropCondition", dropConditionC.getInitialComponent());
} else {
accessabilityVC.remove(dropConditionC.getInitialComponent());
}
//add/remove returnboxConditionC
if (modulesForm.hasReturnbox()) {
accessabilityVC.put("returnboxCondition", returnboxConditionC.getInitialComponent());
} else {
accessabilityVC.remove(returnboxConditionC.getInitialComponent());
}
myTabbedPane.setEnabled(scoringTabPosition, modulesForm.hasScoring());
if (modulesForm.hasScoring()) {
accessabilityVC.put("scoringCondition", scoringConditionC.getInitialComponent());
} else {
accessabilityVC.remove(scoringConditionC.getInitialComponent());
}
myTabbedPane.setEnabled(solutionTabPosition, modulesForm.hasSolution());
if (modulesForm.hasSolution()) {
accessabilityVC.put("solutionCondition", solutionConditionC.getInitialComponent());
} else {
accessabilityVC.remove(solutionConditionC.getInitialComponent());
}
fireEvent(ureq, NodeEditController.NODECONFIG_CHANGED_EVENT);
return;
}
} else if (source == dropboxForm) {
if (event == Form.EVNT_FORM_CANCELLED) {
return;
} else if (event == Form.EVNT_VALIDATION_OK) {
config.set(TACourseNode.CONF_DROPBOX_ENABLEMAIL, new Boolean(dropboxForm.mailEnabled()));
config.set(TACourseNode.CONF_DROPBOX_CONFIRMATION, dropboxForm.getConfirmation());
fireEvent(ureq, NodeEditController.NODECONFIG_CHANGED_EVENT);
return;
}
} else if (source == vfButton) {
if (log.isDebug()) log.debug("Event for sampleVC");
// switch to new dialog
OlatNamedContainerImpl namedContainer = TACourseNode.getNodeFolderContainer(node, course.getCourseEnvironment());
Quota quota = QuotaManager.getInstance().getCustomQuota(namedContainer.getRelPath());
if (quota == null) {
Quota defQuota = QuotaManager.getInstance().getDefaultQuota(QuotaConstants.IDENTIFIER_DEFAULT_NODES);
quota = QuotaManager.getInstance().createQuota(namedContainer.getRelPath(), defQuota.getQuotaKB(), defQuota.getUlLimitKB());
}
VFSSecurityCallback secCallback = new FullAccessWithQuotaCallback(quota);
namedContainer.setLocalSecurityCallback(secCallback);
CloseableModalController cmc = new CloseableModalController(getWindowControl(), translate("close"),
new FolderRunController(namedContainer, false, ureq, getWindowControl()).getInitialComponent());
cmc.activate();
if (log.isDebug()) log.debug("Switch to sample folder dialog : DONE");
return;
} else if (source == editScoringConfigButton){
scoringController.setDisplayOnly(false);
editScoring.contextPut("isOverwriting", new Boolean(true));
}
}
/**
* @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)
*/
@Override
public void event(UserRequest urequest, Controller source, Event event) {
if (source == taskConditionC) {
if (event == Event.CHANGED_EVENT) {
node.setConditionTask(taskConditionC.getCondition());
fireEvent(urequest, NodeEditController.NODECONFIG_CHANGED_EVENT);
}else if(event instanceof BGContextEvent) {
//fired by condition edit controllers if areas / groups created
//updated other condition controllers -> e.g. change create link to choose
dropConditionC.updateGroupsAndAreasCheck();
returnboxConditionC.updateGroupsAndAreasCheck();
scoringConditionC.updateGroupsAndAreasCheck();
solutionConditionC.updateGroupsAndAreasCheck();
}
} else if (source == dropConditionC) {
if (event == Event.CHANGED_EVENT) {
node.setConditionDrop(dropConditionC.getCondition());
fireEvent(urequest, NodeEditController.NODECONFIG_CHANGED_EVENT);
}else if(event instanceof BGContextEvent) {
//fired by condition edit controllers if areas / groups created
//updated other condition controllers -> e.g. change create link to choose
taskConditionC.updateGroupsAndAreasCheck();
scoringConditionC.updateGroupsAndAreasCheck();
solutionConditionC.updateGroupsAndAreasCheck();
returnboxConditionC.updateGroupsAndAreasCheck();
}
} else if (source == returnboxConditionC) {
if (event == Event.CHANGED_EVENT) {
node.setConditionReturnbox(returnboxConditionC.getCondition());
fireEvent(urequest, NodeEditController.NODECONFIG_CHANGED_EVENT);
}else if(event instanceof BGContextEvent) {
//fired by condition edit controllers if areas / groups created
//updated other condition controllers -> e.g. change create link to choose
taskConditionC.updateGroupsAndAreasCheck();
scoringConditionC.updateGroupsAndAreasCheck();
solutionConditionC.updateGroupsAndAreasCheck();
dropConditionC.updateGroupsAndAreasCheck();
}
} else if (source == scoringConditionC) {
if (event == Event.CHANGED_EVENT) {
node.setConditionScoring(scoringConditionC.getCondition());
fireEvent(urequest, NodeEditController.NODECONFIG_CHANGED_EVENT);
}else if(event instanceof BGContextEvent) {
//fired by condition edit controllers if areas / groups created
//updated other condition controllers -> e.g. change create link to choose
dropConditionC.updateGroupsAndAreasCheck();
returnboxConditionC.updateGroupsAndAreasCheck();
taskConditionC.updateGroupsAndAreasCheck();
solutionConditionC.updateGroupsAndAreasCheck();
}
} else if (source == solutionConditionC) {
if (event == Event.CHANGED_EVENT) {
node.setConditionSolution(solutionConditionC.getCondition());
fireEvent(urequest, NodeEditController.NODECONFIG_CHANGED_EVENT);
}else if(event instanceof BGContextEvent) {
//fired by condition edit controllers if areas / groups created
//updated other condition controllers -> e.g. change create link to choose
dropConditionC.updateGroupsAndAreasCheck();
returnboxConditionC.updateGroupsAndAreasCheck();
scoringConditionC.updateGroupsAndAreasCheck();
taskConditionC.updateGroupsAndAreasCheck();
}
} else if (source == dialogBoxController) {
if (DialogBoxUIFactory.isOkEvent(event)) {
// ok: open task folder
String relPath = TACourseNode.getTaskFolderPathRelToFolderRoot(course, node);
OlatRootFolderImpl rootFolder = new OlatRootFolderImpl(relPath, null);
OlatNamedContainerImpl namedFolder = new OlatNamedContainerImpl(translate("taskfolder"), rootFolder);
namedFolder.setLocalSecurityCallback(getTaskFolderSecCallback(relPath));
frc = new FolderRunController(namedFolder, false, urequest, getWindowControl());
CloseableModalController cmc = new CloseableModalController(getWindowControl(), translate("folder.close"), frc
.getInitialComponent());
cmc.activate();
fireEvent(urequest, Event.CHANGED_EVENT);
}
} else if (source == taskController) {
if (event == Event.CANCELLED_EVENT) {
return;
} else if (event == Event.DONE_EVENT) {
config.set(TACourseNode.CONF_TASK_TYPE, taskController.getTaskType());
config.set(TACourseNode.CONF_TASK_TEXT, taskController.getOptionalText());
config.set(TACourseNode.CONF_TASK_SAMPLING_WITH_REPLACEMENT, new Boolean(taskController.getIsSamplingWithReplacement()));
config.setBooleanEntry(TACourseNode.CONF_TASK_PREVIEW, taskController.isTaskPreviewMode());
fireEvent(urequest, NodeEditController.NODECONFIG_CHANGED_EVENT);
return;
}
} else if (source == scoringController) {
if (event == Event.CANCELLED_EVENT) {
if (hasLogEntries) {
scoringController.setDisplayOnly(true);}
editScoring.contextPut("isOverwriting", new Boolean(false));
return;
} else if (event == Event.DONE_EVENT){
scoringController.updateModuleConfiguration(config);
fireEvent(urequest, NodeEditController.NODECONFIG_CHANGED_EVENT);
}
}
else {
log.warn("Can not handle event in TACourseNodeEditController source=" + source + " " + event.toString());
}
}
/**
* @see org.olat.core.gui.control.generic.tabbable.TabbableController#addTabs(org.olat.core.gui.components.TabbedPane)
*/
public void addTabs(TabbedPane theTabbedPane) {
this.myTabbedPane = theTabbedPane;
myTabbedPane.addTab(translate(PANE_TAB_ACCESSIBILITY), accessabilityVC);
myTabbedPane.addTab(translate(PANE_TAB_CONF_MODULES), editModules);
taskTabPosition = myTabbedPane.addTab(translate(PANE_TAB_CONF_TASK), editTask);
dropboxTabPosition = myTabbedPane.addTab(translate(PANE_TAB_CONF_DROPBOX), editDropbox);
scoringTabPosition = myTabbedPane.addTab(translate(PANE_TAB_CONF_SCORING), editScoring);
solutionTabPosition = myTabbedPane.addTab(translate(PANE_TAB_SOLUTION), solutionVC);
Boolean bool = (Boolean) config.get(TACourseNode.CONF_TASK_ENABLED);
myTabbedPane.setEnabled(taskTabPosition, (bool != null) ? bool.booleanValue() : true);
bool = (Boolean) config.get(TACourseNode.CONF_DROPBOX_ENABLED);
myTabbedPane.setEnabled(dropboxTabPosition, (bool != null) ? bool.booleanValue() : true);
bool = (Boolean) config.get(TACourseNode.CONF_SCORING_ENABLED);
myTabbedPane.setEnabled(scoringTabPosition, (bool != null) ? bool.booleanValue() : true);
bool = (Boolean) config.get(TACourseNode.CONF_SOLUTION_ENABLED);
myTabbedPane.setEnabled(solutionTabPosition, (bool != null) ? bool.booleanValue() : true);
}
/**
* @see org.olat.core.gui.control.DefaultController#doDispose(boolean)
*/
@Override
protected void doDispose() {
//child controllers registered with listenTo() get disposed in BasicController
}
@Override
public String[] getPaneKeys() {
return paneKeys;
}
@Override
public TabbedPane getTabbedPane() {
return myTabbedPane;
}
}
class TaskFolderCallback implements VFSSecurityCallback {
private boolean folderLocked;
private Quota folderQuota = null;
/**
* @param folderLocked
*/
public TaskFolderCallback(String relPath, boolean folderLocked) {
this.folderLocked = folderLocked;
initTaskFolderQuota(relPath);
}
private void initTaskFolderQuota(String relPath) {
QuotaManager qm = QuotaManager.getInstance();
folderQuota = qm.getCustomQuota(relPath);
if (folderQuota == null) {
Quota defQuota = qm.getDefaultQuota(QuotaConstants.IDENTIFIER_DEFAULT_POWER);
folderQuota = QuotaManager.getInstance().createQuota(relPath, defQuota.getQuotaKB(), defQuota.getUlLimitKB());
}
}
/**
* @see org.olat.modules.bc.callbacks.SecurityCallback#canRead(org.olat.modules.bc.Path)
*/
public boolean canRead() {
return true;
}
/**
* @see org.olat.modules.bc.callbacks.SecurityCallback#canWrite(org.olat.modules.bc.Path)
*/
public boolean canWrite() {
return !folderLocked;
}
/**
* @see org.olat.modules.bc.callbacks.SecurityCallback#canDelete(org.olat.modules.bc.Path)
*/
public boolean canDelete() {
return !folderLocked;
}
/**
* @see org.olat.modules.bc.callbacks.SecurityCallback#canList(org.olat.modules.bc.Path)
*/
public boolean canList() {
return true;
}
/**
* @see org.olat.core.util.vfs.callbacks.VFSSecurityCallback#canCopy()
*/
public boolean canCopy() {
return true;
}
/**
* @see org.olat.core.util.vfs.callbacks.VFSSecurityCallback#canDeleteRevisionsPermanently()
*/
public boolean canDeleteRevisionsPermanently() {
return false;
}
/**
* @see org.olat.modules.bc.callbacks.SecurityCallback#getQuotaKB(org.olat.modules.bc.Path)
*/
public Quota getQuota() {
return folderQuota;
}
/**
* @see org.olat.core.util.vfs.callbacks.VFSSecurityCallback#setQuota(org.olat.admin.quota.Quota)
*/
public void setQuota(Quota quota) {
folderQuota = quota;
}
/**
* @see org.olat.modules.bc.callbacks.SecurityCallback#getSubscriptionContext()
*/
public SubscriptionContext getSubscriptionContext() {
return null;
}
}