diff --git a/src/main/java/org/olat/core/commons/editor/htmleditor/HTMLEditorController.java b/src/main/java/org/olat/core/commons/editor/htmleditor/HTMLEditorController.java index fb823d41242d37589a2ef3fb8f2a3a3bef411e9f..010853e76e6c47ec37cfd0475e250a32c89d4bf1 100644 --- a/src/main/java/org/olat/core/commons/editor/htmleditor/HTMLEditorController.java +++ b/src/main/java/org/olat/core/commons/editor/htmleditor/HTMLEditorController.java @@ -363,6 +363,10 @@ public class HTMLEditorController extends FormBasicController { * @return */ public RichTextConfiguration getRichTextConfiguration() { + if(htmlElement == null) { + //if the file is too big, + return new RichTextConfiguration(getLocale()); + } return htmlElement.getEditorConfiguration(); } diff --git a/src/main/java/org/olat/core/commons/modules/bc/FileUploadController.java b/src/main/java/org/olat/core/commons/modules/bc/FileUploadController.java index d33ed3842ed605ab8d31ddae8ae4192b78616f28..0a361a0dd2c5df13749420b7505f9c33e3eb7e1b 100644 --- a/src/main/java/org/olat/core/commons/modules/bc/FileUploadController.java +++ b/src/main/java/org/olat/core/commons/modules/bc/FileUploadController.java @@ -334,25 +334,18 @@ public class FileUploadController extends FormBasicController { // if so, there is alread a error-msg in log (vfsContainer.createChildLeaf) success = false; } else { - InputStream in = null; - OutputStream out = null; - try { - in = new FileInputStream(uploadedFile); - out = newFile.getOutputStream(false); + try(InputStream in = new FileInputStream(uploadedFile); + OutputStream out = newFile.getOutputStream(false)) { FileUtils.bcopy(in, out, "uploadTmpFileToDestFile"); uploadedFile.delete(); - } catch (IOException e) { success = false; - } finally { - FileUtils.closeSafely(in); - FileUtils.closeSafely(out); } } if (success) { String filePath = (uploadRelPath == null ? "" : uploadRelPath + "/") + newFile.getName(); - finishSuccessfullUpload(filePath, ureq); + finishSuccessfullUpload(filePath, newFile, ureq); fileInfoMBean.logUpload(newFile.getSize()); fireEvent(ureq, Event.DONE_EVENT); } else { @@ -671,16 +664,20 @@ public class FileUploadController extends FormBasicController { private void finishUpload(UserRequest ureq) { // in both cases the upload must be finished and notified with a FolderEvent String filePath = (uploadRelPath == null ? "" : uploadRelPath + "/") + newFile.getName(); - finishSuccessfullUpload(filePath, ureq); - fileInfoMBean.logUpload(newFile.getSize()); + VFSItem item = currentContainer.resolve(filePath); + if(item != null) { + finishSuccessfullUpload(filePath, item, ureq); + fileInfoMBean.logUpload(newFile.getSize()); + } else { + logWarn("Upload with error:" + filePath, null); + } fireEvent(ureq, Event.DONE_EVENT); } /** * Internal helper to finish the upload and add metadata */ - private void finishSuccessfullUpload(String filePath, UserRequest ureq) { - VFSItem item = currentContainer.resolve(filePath); + private void finishSuccessfullUpload(String filePath, VFSItem item, UserRequest ureq) { if (item instanceof OlatRootFileImpl) { OlatRootFileImpl relPathItem = (OlatRootFileImpl) item; // create meta data @@ -692,10 +689,14 @@ public class FileUploadController extends FormBasicController { meta.clearThumbnails();//if overwrite an older file meta.write(); } - ThreadLocalUserActivityLogger.log(FolderLoggingAction.FILE_UPLOADED, getClass(), CoreLoggingResourceable.wrapUploadFile(filePath)); - - // Notify listeners about upload - fireEvent(ureq, new FolderEvent(FolderEvent.UPLOAD_EVENT, item)); + + if(item == null) { + logError("File cannot be uploaded: " + filePath, null); + } else { + ThreadLocalUserActivityLogger.log(FolderLoggingAction.FILE_UPLOADED, getClass(), CoreLoggingResourceable.wrapUploadFile(filePath)); + // Notify listeners about upload + fireEvent(ureq, new FolderEvent(FolderEvent.UPLOAD_EVENT, item)); + } } /** diff --git a/src/main/java/org/olat/core/gui/components/form/flexible/impl/elements/richText/RichTextConfiguration.java b/src/main/java/org/olat/core/gui/components/form/flexible/impl/elements/richText/RichTextConfiguration.java index 58590a328d780cf9354ee87bffa913295a4d1c2f..a84a694d63bbf3014cc6ef96f951195c72bfe998 100644 --- a/src/main/java/org/olat/core/gui/components/form/flexible/impl/elements/richText/RichTextConfiguration.java +++ b/src/main/java/org/olat/core/gui/components/form/flexible/impl/elements/richText/RichTextConfiguration.java @@ -150,6 +150,11 @@ public class RichTextConfiguration implements Disposable { private final Locale locale; private TinyConfig tinyConfig; + + public RichTextConfiguration(Locale locale) { + this.locale = locale; + tinyConfig = TinyConfig.minimalisticConfig; + } /** * Constructor, only used by RichText element itself. Use @@ -158,7 +163,7 @@ public class RichTextConfiguration implements Disposable { * @param domID The ID of the flexi element in the browser DOM * @param rootFormDispatchId The dispatch ID of the root form that deals with the submit button */ - RichTextConfiguration(String domID, String rootFormDispatchId, Locale locale) { + public RichTextConfiguration(String domID, String rootFormDispatchId, Locale locale) { this.domID = domID; this.locale = locale; // use exact mode that only applies to this DOM element diff --git a/src/main/java/org/olat/core/gui/control/DefaultController.java b/src/main/java/org/olat/core/gui/control/DefaultController.java index 18e86b10211863e4461ec2e635c3770d29809504..240182ba331a7a01291403bbc7d34e535e6a95e6 100644 --- a/src/main/java/org/olat/core/gui/control/DefaultController.java +++ b/src/main/java/org/olat/core/gui/control/DefaultController.java @@ -470,10 +470,10 @@ public abstract class DefaultController implements Controller, ControllerEventLi } protected WindowControl addToHistory(UserRequest ureq, Controller controller) { - WindowControl wControl; + WindowControl wControl = null; if(controller instanceof DefaultController) { wControl = ((DefaultController)controller).getWindowControl(); - } else { + } else if(controller != null) { wControl = controller.getWindowControlForDebug(); } BusinessControlFactory.getInstance().addToHistory(ureq, wControl); diff --git a/src/main/java/org/olat/course/nodes/STCourseNode.java b/src/main/java/org/olat/course/nodes/STCourseNode.java index 9f2900d65a0ef61afc4d9cc97619f8ae33faf62a..2e628e348d24f5ce691c32b0e63cdb89f9583eaa 100644 --- a/src/main/java/org/olat/course/nodes/STCourseNode.java +++ b/src/main/java/org/olat/course/nodes/STCourseNode.java @@ -140,6 +140,7 @@ public class STCourseNode extends AbstractAccessableCourseNode implements Calcul * org.olat.course.run.userview.UserCourseEnvironment, * org.olat.course.run.userview.NodeEvaluation) */ + @Override public NodeRunConstructionResult createNodeRunConstructionResult(UserRequest ureq, WindowControl wControl, final UserCourseEnvironment userCourseEnv, NodeEvaluation ne, String nodecmd) { updateModuleConfigDefaults(false); @@ -195,7 +196,7 @@ public class STCourseNode extends AbstractAccessableCourseNode implements Calcul }; Controller wrappedCtrl = TitledWrapperHelper.getWrapper(ureq, wControl, spCtr, this, ICON_CSS_CLASS); if(wrappedCtrl instanceof CloneableController) { - cont = new CloneController(ureq, wControl, (CloneableController)wrappedCtrl, clccc); + cont = new CloneController(ureq, wControl, (CloneableController)wrappedCtrl, clccc); } else { throw new AssertException("Need to be a cloneable"); } diff --git a/src/main/java/org/olat/course/run/RunMainController.java b/src/main/java/org/olat/course/run/RunMainController.java index ac8ee2330a10728d6d26feb1491ff6356113b3d3..fadb97794b767619c5c058f3c8e6169bda10c42a 100644 --- a/src/main/java/org/olat/course/run/RunMainController.java +++ b/src/main/java/org/olat/course/run/RunMainController.java @@ -428,7 +428,14 @@ public class RunMainController extends MainLayoutBasicController implements Gene } else if(currentNodeController instanceof Activateable2) { ((Activateable2)currentNodeController).activate(ureq, entries, state); } - contentP.setContent(currentNodeController.getInitialComponent()); + if(currentNodeController != null) { + contentP.setContent(currentNodeController.getInitialComponent()); + } else { + MessageController msgCtrl = MessageUIFactory + .createWarnMessage(ureq, getWindowControl(), null, translate("msg.nodenotavailableanymore")); + listenTo(msgCtrl); + contentP.setContent(msgCtrl.getInitialComponent()); + } updateNextPrevious(); updateLastUsage(nclr.getCalledCourseNode()); diff --git a/src/test/java/org/olat/test/OlatTestCase.java b/src/test/java/org/olat/test/OlatTestCase.java index df8369cd4b170707a1ffccd86be2b3a3103ea9c1..a7f5e31b8f810968a38eb6aec198b1db67519da2 100644 --- a/src/test/java/org/olat/test/OlatTestCase.java +++ b/src/test/java/org/olat/test/OlatTestCase.java @@ -146,10 +146,9 @@ public abstract class OlatTestCase extends AbstractJUnit4SpringContextTests { final CountDownLatch countDown = new CountDownLatch(1); final AtomicBoolean result = new AtomicBoolean(false); - new Thread(){ + new Thread() { @Override public void run() { - try { int numOfTry = (timeoutInMilliseconds / 100) + 2; for(int i=0; i<numOfTry; i++) { @@ -160,10 +159,14 @@ public abstract class OlatTestCase extends AbstractJUnit4SpringContextTests { } else { result.set(false); } + DBFactory.getInstance().commitAndCloseSession(); + Thread.sleep(100); } } catch (Exception e) { log.error("", e); result.set(false); + } finally { + DBFactory.getInstance().closeSession(); } countDown.countDown(); }