use of org.olat.core.commons.modules.bc.FileUploadController in project OpenOLAT by OpenOLAT.
the class LinkFileCombiCalloutController method doOpenFileChanger.
public void doOpenFileChanger(UserRequest ureq, String tool) {
// close callout and open appropriate file changer controller
calloutCtr.deactivate();
Controller toolCtr = null;
if (tool.equals("chooseLink")) {
VFSItemFilter filter = new SystemItemFilter();
FileChooserController fileChooserCtr = FileChooserUIFactory.createFileChooserController(ureq, getWindowControl(), baseContainer, filter, true);
fileChooserCtr.setShowTitle(true);
fileChooserCtr.selectPath(relFilePath);
toolCtr = fileChooserCtr;
}
if (tool.equals("createLink")) {
String folderPath = null;
if (StringHelper.containsNonWhitespace(relFilePath)) {
// remove file name from relFilePath to represent directory path
folderPath = relFilePath.substring(0, relFilePath.lastIndexOf("/"));
}
toolCtr = new FileCreatorController(ureq, getWindowControl(), baseContainer, folderPath);
}
if (tool.equals("uploadLink")) {
long quotaLeftKB = VFSManager.getQuotaLeftKB(baseContainer);
String folderPath = null;
if (StringHelper.containsNonWhitespace(relFilePath)) {
// remove file name from relFilePath to represent directory path
folderPath = relFilePath.substring(0, relFilePath.lastIndexOf("/"));
}
toolCtr = new FileUploadController(getWindowControl(), baseContainer, ureq, quotaLeftKB, quotaLeftKB, null, false, true, false, false, true, true, folderPath);
}
displayModal(toolCtr);
}
use of org.olat.core.commons.modules.bc.FileUploadController in project OpenOLAT by OpenOLAT.
the class DialogElementsEditController method doUpload.
private void doUpload(UserRequest ureq) {
removeAsListenerAndDispose(fileUplCtr);
VFSContainer tmpContainer = new LocalFolderImpl(new File(WebappHelper.getTmpDir(), "poster_" + UUID.randomUUID()));
fileUplCtr = new FileUploadController(getWindowControl(), tmpContainer, ureq, FolderConfig.getLimitULKB(), Quota.UNLIMITED, null, false, false, false, false, true, false);
listenTo(fileUplCtr);
cmc = new CloseableModalController(getWindowControl(), "close", fileUplCtr.getInitialComponent(), true, translate("dialog.upload.file"));
listenTo(cmc);
cmc.activate();
}
use of org.olat.core.commons.modules.bc.FileUploadController in project OpenOLAT by OpenOLAT.
the class DialogCourseNodeRunController method doUploadFile.
private void doUploadFile(UserRequest ureq) {
removeAsListenerAndDispose(fileUplCtr);
VFSContainer tmpContainer = new LocalFolderImpl(new File(WebappHelper.getTmpDir(), "poster_" + UUID.randomUUID()));
fileUplCtr = new FileUploadController(getWindowControl(), tmpContainer, ureq, FolderConfig.getLimitULKB(), Quota.UNLIMITED, null, false, false, false, false, true, false);
listenTo(fileUplCtr);
cmc = new CloseableModalController(getWindowControl(), "close", fileUplCtr.getInitialComponent(), true, translate("dialog.upload.file"));
listenTo(cmc);
cmc.activate();
}
use of org.olat.core.commons.modules.bc.FileUploadController in project openolat by klemens.
the class DialogCourseNodeRunController method doUploadFile.
private void doUploadFile(UserRequest ureq) {
removeAsListenerAndDispose(fileUplCtr);
VFSContainer tmpContainer = new LocalFolderImpl(new File(WebappHelper.getTmpDir(), "poster_" + UUID.randomUUID()));
fileUplCtr = new FileUploadController(getWindowControl(), tmpContainer, ureq, FolderConfig.getLimitULKB(), Quota.UNLIMITED, null, false, false, false, false, true, false);
listenTo(fileUplCtr);
cmc = new CloseableModalController(getWindowControl(), "close", fileUplCtr.getInitialComponent(), true, translate("dialog.upload.file"));
listenTo(cmc);
cmc.activate();
}
use of org.olat.core.commons.modules.bc.FileUploadController in project OpenOLAT by OpenOLAT.
the class CmdUpload method execute.
public Controller execute(FolderComponent folderComponent, UserRequest ureq, Translator trans, boolean cancelResetsButton) {
this.cancelResetsForm = cancelResetsButton;
setTranslator(trans);
currentContainer = folderComponent.getCurrentContainer();
if (currentContainer.canWrite() != VFSConstants.YES)
throw new AssertException("Cannot write to selected folder.");
// mainVC is the main view
mainVC = createVelocityContainer("upload");
// Add progress bar
ubar = new ProgressBar("ubar");
ubar.setWidth(200);
ubar.setUnitLabel("MB");
ubar.setRenderLabelRights(true);
mainVC.put(ubar.getComponentName(), ubar);
// Calculate quota and limits
long actualUsage = 0;
quotaKB = Quota.UNLIMITED;
uploadLimitKB = Quota.UNLIMITED;
inheritingContainer = VFSManager.findInheritingSecurityCallbackContainer(currentContainer);
if (inheritingContainer != null) {
secCallback = inheritingContainer.getLocalSecurityCallback();
actualUsage = VFSManager.getUsageKB(inheritingContainer);
ubar.setActual(actualUsage / 1024);
if (inheritingContainer.getLocalSecurityCallback().getQuota() != null) {
quotaKB = secCallback.getQuota().getQuotaKB().longValue();
uploadLimitKB = (int) secCallback.getQuota().getUlLimitKB().longValue();
}
}
// set wether we have a quota on this folder
if (quotaKB == Quota.UNLIMITED) {
ubar.setIsNoMax(true);
} else if (quotaKB == 0) {
ubar.setMax(quotaKB);
} else {
ubar.setMax(quotaKB / 1024f);
}
// set default ulLimit if none is defined...
if (uploadLimitKB == Quota.UNLIMITED) {
uploadLimitKB = QuotaManager.getInstance().getDefaultQuotaDependingOnRole(ureq.getIdentity()).getUlLimitKB().longValue();
}
// Add file upload form
long remainingQuotaKB;
if (quotaKB == Quota.UNLIMITED)
remainingQuotaKB = quotaKB;
else if (quotaKB - actualUsage < 0)
remainingQuotaKB = 0;
else
remainingQuotaKB = quotaKB - actualUsage;
removeAsListenerAndDispose(fileUploadCtr);
fileUploadCtr = new FileUploadController(getWindowControl(), currentContainer, ureq, uploadLimitKB, remainingQuotaKB, null, false, true, showMetadata, true, showCancel, false);
listenTo(fileUploadCtr);
mainVC.put("fileUploadCtr", fileUploadCtr.getInitialComponent());
mainVC.contextPut("showFieldset", Boolean.TRUE);
// if folder full show error msg
if (remainingQuotaKB == 0) {
String supportAddr = WebappHelper.getMailConfig("mailQuota");
String msg = translate("QuotaExceededSupport", new String[] { supportAddr });
getWindowControl().setError(msg);
return null;
}
putInitialPanel(mainVC);
return this;
}
Aggregations