diff --git a/pom.xml b/pom.xml index 7ee25a80fa6a5599d056447ab9ff70eaeb17e71a..fa2bfe3f8ad2bb9e27e702ead84667f4b441e3c2 100644 --- a/pom.xml +++ b/pom.xml @@ -1628,7 +1628,12 @@ <dependency> <groupId>org.jcodec</groupId> <artifactId>jcodec</artifactId> - <version>0.1.6-3</version> + <version>0.2.3</version> + </dependency> + <dependency> + <groupId>org.jcodec</groupId> + <artifactId>jcodec-javase</artifactId> + <version>0.2.3</version> </dependency> <dependency> <groupId>org.mnode.ical4j</groupId> diff --git a/src/main/java/org/olat/core/commons/services/video/MovieServiceImpl.java b/src/main/java/org/olat/core/commons/services/video/MovieServiceImpl.java index 08dff59d4300c6f89952e64ff8caa999a842e38b..36d51ec0fc8ac142f606a2bc09ba977bfad230c2 100644 --- a/src/main/java/org/olat/core/commons/services/video/MovieServiceImpl.java +++ b/src/main/java/org/olat/core/commons/services/video/MovieServiceImpl.java @@ -28,17 +28,19 @@ import java.nio.channels.FileChannel; import java.util.ArrayList; import java.util.List; +import org.apache.logging.log4j.Logger; import org.jcodec.api.FrameGrab; -import org.jcodec.common.FileChannelWrapper; +import org.jcodec.common.Codec; +import org.jcodec.common.io.FileChannelWrapper; import org.jcodec.containers.mp4.boxes.MovieBox; import org.jcodec.containers.mp4.demuxer.MP4Demuxer; +import org.jcodec.scale.AWTUtil; import org.olat.core.commons.services.image.Size; import org.olat.core.commons.services.image.spi.ImageHelperImpl; import org.olat.core.commons.services.thumbnail.CannotGenerateThumbnailException; import org.olat.core.commons.services.thumbnail.FinalSize; import org.olat.core.commons.services.thumbnail.ThumbnailSPI; import org.olat.core.commons.services.video.spi.FLVParser; -import org.apache.logging.log4j.Logger; import org.olat.core.logging.Tracing; import org.olat.core.util.FileUtils; import org.olat.core.util.WorkThreadInformations; @@ -59,18 +61,18 @@ public class MovieServiceImpl implements MovieService, ThumbnailSPI { private static final Logger log = Tracing.createLoggerFor(MovieServiceImpl.class); private static final List<String> extensions = new ArrayList<>(); - private static final List<String> fourCCs = new ArrayList<>(); + private static final List<Codec> supportedCodecs = new ArrayList<>(); static { // supported file extensions extensions.add("mp4"); extensions.add("m4v"); extensions.add("mov"); // supported fourCC for H264 codec - fourCCs.add("avc1"); - fourCCs.add("davc"); - fourCCs.add("h264"); - fourCCs.add("x264"); - fourCCs.add("vssh"); + supportedCodecs.add(Codec.codecByFourcc("avc1")); + supportedCodecs.add(Codec.codecByFourcc("davc")); + supportedCodecs.add(Codec.codecByFourcc("h264")); + supportedCodecs.add(Codec.codecByFourcc("x264")); + supportedCodecs.add(Codec.codecByFourcc("vssh")); } @@ -96,9 +98,10 @@ public class MovieServiceImpl implements MovieService, ThumbnailSPI { if(extensions.contains(suffix)) { try(RandomAccessFile accessFile = new RandomAccessFile(file, "r"); FileChannel ch = accessFile.getChannel(); - FileChannelWrapper in = new FileChannelWrapper(ch)) { + FileChannelWrapper in = new FileChannelWrapper(ch); + MP4Demuxer demuxer1 = MP4Demuxer.createMP4Demuxer(in)) { + - MP4Demuxer demuxer1 = new MP4Demuxer(in); org.jcodec.common.model.Size size = demuxer1.getMovie().getDisplaySize(); // Case 1: standard case, get dimension from movie int w = size.getWidth(); @@ -117,7 +120,7 @@ public class MovieServiceImpl implements MovieService, ThumbnailSPI { // flag of the movie. Those mp4 guys are really // secretive folks, did not find any documentation about // this. Best guess. - org.jcodec.common.model.Size size2 = demuxer1.getVideoTrack().getBox().getCodedSize(); + org.jcodec.common.model.Size size2 = demuxer1.getVideoTrack().getMeta().getVideoCodecMeta().getSize(); w = size2.getHeight(); h = size2.getWidth(); } catch(Exception e) { @@ -161,9 +164,9 @@ public class MovieServiceImpl implements MovieService, ThumbnailSPI { if(extensions.contains(suffix)) { try(RandomAccessFile accessFile = new RandomAccessFile(file, "r"); FileChannel ch = accessFile.getChannel(); - FileChannelWrapper in = new FileChannelWrapper(ch)) { - - MP4Demuxer demuxer1 = new MP4Demuxer(in); + FileChannelWrapper in = new FileChannelWrapper(ch); + MP4Demuxer demuxer1 = MP4Demuxer.createMP4Demuxer(in)) { + MovieBox movie = demuxer1.getMovie(); long duration = movie.getDuration(); int timescale = movie.getTimescale(); @@ -196,10 +199,9 @@ public class MovieServiceImpl implements MovieService, ThumbnailSPI { if(extensions.contains(suffix)) { try(RandomAccessFile accessFile = new RandomAccessFile(file, "r"); FileChannel ch = accessFile.getChannel(); - FileChannelWrapper in = new FileChannelWrapper(ch)) { - - MP4Demuxer demuxer1 = new MP4Demuxer(in); - return demuxer1.getVideoTrack().getFrameCount(); + FileChannelWrapper in = new FileChannelWrapper(ch); + MP4Demuxer demuxer1 = MP4Demuxer.createMP4Demuxer(in)) { + return demuxer1.getVideoTrack().getMeta().getTotalFrames(); } catch (Exception | AssertionError e) { log.error("Cannot extract num. of frames of: " + media, e); } @@ -226,12 +228,12 @@ public class MovieServiceImpl implements MovieService, ThumbnailSPI { FileChannel ch = accessFile.getChannel(); FileChannelWrapper in = new FileChannelWrapper(ch)) { - MP4Demuxer demuxer1 = new MP4Demuxer(in); - String fourCC = demuxer1.getVideoTrack().getFourcc(); - if (fourCCs.contains(fourCC.toLowerCase())) { + MP4Demuxer demuxer1 = MP4Demuxer.createMP4Demuxer(in); + Codec codec = demuxer1.getVideoTrack().getMeta().getCodec(); + if (supportedCodecs.contains(codec)) { return true; } - log.info("Movie file::" + fileName + " has correct suffix::" + suffix + " but fourCC::" + fourCC + " not in our list of supported codecs."); + log.info("Movie file::" + fileName + " has correct suffix::" + suffix + " but fourCC::" + codec + " not in our list of supported codecs."); } catch (Exception | Error e) { // anticipated exception, is not an mp4 file } @@ -251,7 +253,7 @@ public class MovieServiceImpl implements MovieService, ThumbnailSPI { File baseFile = ((LocalFileImpl)file).getBasefile(); File scaledImage = ((LocalFileImpl)thumbnailFile).getBasefile(); - BufferedImage frame = FrameGrab.getFrame(baseFile, 20); + BufferedImage frame = AWTUtil.toBufferedImage(FrameGrab.getFrameFromFile(baseFile, 20)); Size scaledSize = ImageHelperImpl.calcScaledSize(frame, maxWidth, maxHeight); if(ImageHelperImpl.writeTo(frame, scaledImage, scaledSize, "jpeg")) { size = new FinalSize(scaledSize.getWidth(), scaledSize.getHeight()); diff --git a/src/main/java/org/olat/course/nodes/livestream/manager/LIveStreamServiceImpl.java b/src/main/java/org/olat/course/nodes/livestream/manager/LIveStreamServiceImpl.java index ff9ec5380504bc9e1a6068f010a1a415be349a0a..e209cc1bb3f39a9d9ef98769053c328ae60e1a90 100644 --- a/src/main/java/org/olat/course/nodes/livestream/manager/LIveStreamServiceImpl.java +++ b/src/main/java/org/olat/course/nodes/livestream/manager/LIveStreamServiceImpl.java @@ -19,6 +19,9 @@ */ package org.olat.course.nodes.livestream.manager; +import java.time.LocalDateTime; +import java.time.LocalTime; +import java.time.ZoneId; import java.util.ArrayList; import java.util.Calendar; import java.util.Date; @@ -52,15 +55,29 @@ public class LIveStreamServiceImpl implements LiveStreamService { public List<? extends LiveStreamEvent> getRunningEvents(CourseCalendars calendars, int bufferBeforeMin, int bufferAfterMin) { Date now = new Date(); + + Calendar cFromStartOfDay = Calendar.getInstance(); + cFromStartOfDay.setTime(now); + int year = cFromStartOfDay.get(Calendar.YEAR); + int month = cFromStartOfDay.get(Calendar.MONTH); + int day = cFromStartOfDay.get(Calendar.DATE); + cFromStartOfDay.set(year, month, day - 1, 0, 0, 0); + Date fromStartOfDay = cFromStartOfDay.getTime(); + Calendar cFrom = Calendar.getInstance(); cFrom.setTime(now); cFrom.add(Calendar.MINUTE, -bufferAfterMin); Date from = cFrom.getTime(); + Calendar cTo = Calendar.getInstance(); cTo.setTime(now); cTo.add(Calendar.MINUTE, bufferBeforeMin); Date to = cTo.getTime(); - return getLiveStreamEvents(calendars, from, to); + + // Use start of day to get all day events as well. + return getLiveStreamEvents(calendars, fromStartOfDay, to).stream() + .filter(startedFilter(from)) + .collect(Collectors.toList()); } @Override @@ -79,6 +96,12 @@ public class LIveStreamServiceImpl implements LiveStreamService { .filter(notStartedFilter(from)) .collect(Collectors.toList()); } + + private Predicate<LiveStreamEvent> startedFilter(Date from) { + return (LiveStreamEvent e) -> { + return e.getBegin().before(from); + }; + } private Predicate<LiveStreamEvent> notStartedFilter(Date from) { return (LiveStreamEvent e) -> { @@ -105,6 +128,7 @@ public class LIveStreamServiceImpl implements LiveStreamService { } } } + return liveStreamEvents; } @@ -115,9 +139,12 @@ public class LIveStreamServiceImpl implements LiveStreamService { private LiveStreamEventImpl toLiveStreamEvent(KalendarEvent event, boolean timeOnly) { LiveStreamEventImpl liveStreamEvent = new LiveStreamEventImpl(); liveStreamEvent.setId(event.getID()); - liveStreamEvent.setBegin(event.getBegin()); - liveStreamEvent.setEnd(event.getEnd()); liveStreamEvent.setAllDayEvent(event.isAllDayEvent()); + liveStreamEvent.setBegin(event.getBegin()); + Date end = event.isAllDayEvent() + ? getEndOfDay(event.getEnd()) + : event.getEnd(); + liveStreamEvent.setEnd(end); liveStreamEvent.setLiveStreamUrl(event.getLiveStreamUrl()); if (!timeOnly) { liveStreamEvent.setSubject(event.getSubject()); @@ -127,4 +154,18 @@ public class LIveStreamServiceImpl implements LiveStreamService { return liveStreamEvent; } + private Date getEndOfDay(Date date) { + LocalDateTime localDateTime = dateToLocalDateTime(date); + LocalDateTime endOfDay = localDateTime.with(LocalTime.MAX); + return localDateTimeToDate(endOfDay); + } + + private LocalDateTime dateToLocalDateTime(Date date) { + return LocalDateTime.ofInstant(date.toInstant(), ZoneId.systemDefault()); + } + + private Date localDateTimeToDate(LocalDateTime localDateTime) { + return Date.from(localDateTime.atZone(ZoneId.systemDefault()).toInstant()); + } + } diff --git a/src/main/java/org/olat/group/manager/BusinessGroupDAO.java b/src/main/java/org/olat/group/manager/BusinessGroupDAO.java index b63c8d32d7c00a4e2225b1b4faf882283d111ee5..a42f913fa432b01dc14424276a334e53325ca6ce 100644 --- a/src/main/java/org/olat/group/manager/BusinessGroupDAO.java +++ b/src/main/java/org/olat/group/manager/BusinessGroupDAO.java @@ -1266,11 +1266,12 @@ public class BusinessGroupDAO { StringBuilder so = new StringBuilder(); so.append("select access.method, resource.key, offer.price from acofferaccess access ") .append(" inner join access.offer offer") - .append(" inner join offer.resource resource"); + .append(" inner join offer.resource resource") + .append(" where offer.valid=true"); if(resourceKeyToGroup.size() < OFFERS_IN_LIMIT) { - so.append(" where resource.key in (:resourceKeys)"); + so.append(" and resource.key in (:resourceKeys)"); } else { - so.append(" where exists (select bgi.key from businessgroup bgi where bgi.resource=resource)"); + so.append(" and exists (select bgi.key from businessgroup bgi where bgi.resource=resource)"); } TypedQuery<Object[]> offersQuery = dbInstance.getCurrentEntityManager() diff --git a/src/main/java/org/olat/group/ui/main/BusinessGroupListFlexiTableModel.java b/src/main/java/org/olat/group/ui/main/BusinessGroupListFlexiTableModel.java index 5c5747adcb1e3d985f2a7424d188fb3a7a39bc43..5a825ee3bcf5ce22e5adfd5c4a9f462dbd9edb80 100644 --- a/src/main/java/org/olat/group/ui/main/BusinessGroupListFlexiTableModel.java +++ b/src/main/java/org/olat/group/ui/main/BusinessGroupListFlexiTableModel.java @@ -95,7 +95,7 @@ public class BusinessGroupListFlexiTableModel extends DefaultFlexiTableDataModel case resources: return wrapped; case accessControl: - return new Boolean(wrapped.isAccessControl()); + return Boolean.valueOf(wrapped.isAccessControl()); case accessControlLaunch: return wrapped.getAccessLink(); case accessTypes: diff --git a/src/main/java/org/olat/ims/qti/QTI12EditorController.java b/src/main/java/org/olat/ims/qti/QTI12EditorController.java index c8e209b820dd0c050667c29c1603bdaa613de2e4..767b71039b89bdc17455af88eaae56249c4ce300 100644 --- a/src/main/java/org/olat/ims/qti/QTI12EditorController.java +++ b/src/main/java/org/olat/ims/qti/QTI12EditorController.java @@ -91,6 +91,11 @@ public class QTI12EditorController extends BasicController implements QPoolItemE putInitialPanel(mainVC); } + @Override + public boolean isValid() { + return item != null; + } + @Override public QuestionItem getItem() { return qitem; diff --git a/src/main/java/org/olat/ims/qti/qpool/QTIQPoolServiceProvider.java b/src/main/java/org/olat/ims/qti/qpool/QTIQPoolServiceProvider.java index 9370bd32bc30d81f18786a62df017a808ca14707..64a44c4e957c86ff061a2ce281526626df309a05 100644 --- a/src/main/java/org/olat/ims/qti/qpool/QTIQPoolServiceProvider.java +++ b/src/main/java/org/olat/ims/qti/qpool/QTIQPoolServiceProvider.java @@ -30,6 +30,7 @@ import java.util.zip.ZipOutputStream; import javax.xml.XMLConstants; +import org.apache.logging.log4j.Logger; import org.dom4j.Document; import org.dom4j.Element; import org.olat.core.commons.persistence.DB; @@ -41,7 +42,6 @@ import org.olat.core.gui.translator.Translator; import org.olat.core.helpers.Settings; import org.olat.core.id.Identity; import org.olat.core.id.OLATResourceable; -import org.apache.logging.log4j.Logger; import org.olat.core.logging.Tracing; import org.olat.core.util.FileUtils; import org.olat.core.util.Util; @@ -69,6 +69,7 @@ import org.olat.ims.resources.IMSEntityResolver; import org.olat.modules.qpool.ExportFormatOptions; import org.olat.modules.qpool.ExportFormatOptions.Outcome; import org.olat.modules.qpool.QItemFactory; +import org.olat.modules.qpool.QPoolItemEditorController; import org.olat.modules.qpool.QPoolSPI; import org.olat.modules.qpool.QPoolService; import org.olat.modules.qpool.QuestionItem; @@ -381,7 +382,7 @@ public class QTIQPoolServiceProvider implements QPoolSPI { } @Override - public Controller getEditableController(UserRequest ureq, WindowControl wControl, QuestionItem item) { + public QPoolItemEditorController getEditableController(UserRequest ureq, WindowControl wControl, QuestionItem item) { return new QTI12EditorController(ureq, wControl, item); } diff --git a/src/main/java/org/olat/ims/qti21/pool/QTI21EditorController.java b/src/main/java/org/olat/ims/qti21/pool/QTI21EditorController.java index 8a9243b1bd136b4fcce966777b605af1269e6968..830c573a41d6b4eb332a38fb213365a85f18bcf8 100644 --- a/src/main/java/org/olat/ims/qti21/pool/QTI21EditorController.java +++ b/src/main/java/org/olat/ims/qti21/pool/QTI21EditorController.java @@ -88,6 +88,11 @@ public class QTI21EditorController extends BasicController implements QPoolItemE putInitialPanel(mainVC); } + @Override + public boolean isValid() { + return true; + } + @Override public QuestionItem getItem() { return questionItem; diff --git a/src/main/java/org/olat/ims/qti21/pool/QTI21QPoolServiceProvider.java b/src/main/java/org/olat/ims/qti21/pool/QTI21QPoolServiceProvider.java index f6d6ddbcd2fe5d7f1f39eeaffb7e65974606bb33..d7e05d8982b046c01547f513f972a776c4a1a0bb 100644 --- a/src/main/java/org/olat/ims/qti21/pool/QTI21QPoolServiceProvider.java +++ b/src/main/java/org/olat/ims/qti21/pool/QTI21QPoolServiceProvider.java @@ -39,13 +39,13 @@ import java.util.zip.ZipOutputStream; import javax.xml.XMLConstants; +import org.apache.logging.log4j.Logger; import org.olat.core.gui.UserRequest; import org.olat.core.gui.control.Controller; import org.olat.core.gui.control.WindowControl; import org.olat.core.gui.media.MediaResource; import org.olat.core.helpers.Settings; import org.olat.core.id.Identity; -import org.apache.logging.log4j.Logger; import org.olat.core.logging.Tracing; import org.olat.core.util.FileUtils; import org.olat.core.util.StringHelper; @@ -76,6 +76,7 @@ import org.olat.imscp.xml.manifest.ResourceType; import org.olat.modules.qpool.ExportFormatOptions; import org.olat.modules.qpool.ExportFormatOptions.Outcome; import org.olat.modules.qpool.QItemFactory; +import org.olat.modules.qpool.QPoolItemEditorController; import org.olat.modules.qpool.QPoolSPI; import org.olat.modules.qpool.QPoolService; import org.olat.modules.qpool.QuestionItem; @@ -321,7 +322,7 @@ public class QTI21QPoolServiceProvider implements QPoolSPI { } @Override - public Controller getEditableController(UserRequest ureq, WindowControl wControl, QuestionItem qitem) { + public QPoolItemEditorController getEditableController(UserRequest ureq, WindowControl wControl, QuestionItem qitem) { return new QTI21EditorController(ureq, wControl, qitem, false); } @@ -329,7 +330,6 @@ public class QTI21QPoolServiceProvider implements QPoolSPI { public Controller getReadOnlyController(UserRequest ureq, WindowControl wControl, QuestionItem item) { return new QTI21EditorController(ureq, wControl, item, true); } - public QuestionItem createItem(Identity identity, QTI21QuestionType type, String title, Locale locale) { AssessmentItemBuilder itemBuilder = AssessmentItemBuilderFactory.get(type, locale); diff --git a/src/main/java/org/olat/ims/qti21/ui/_i18n/LocalStrings_fr.properties b/src/main/java/org/olat/ims/qti21/ui/_i18n/LocalStrings_fr.properties index 46a32b1831f3e3590cfdba501474a5e5713a0486..b516580424dc9be968c06abf825f4c0c5a9d3ae2 100644 --- a/src/main/java/org/olat/ims/qti21/ui/_i18n/LocalStrings_fr.properties +++ b/src/main/java/org/olat/ims/qti21/ui/_i18n/LocalStrings_fr.properties @@ -103,7 +103,7 @@ drawing.opacity=Opacit\u00E9 error.as.directed=Veuillez r\u00E9pondre \u00E0 la question comme indiqu\u00E9. error.as.directed.kprim=Veuillez r\u00E9pondre \u00E0 la question comme indiqu\u00E9. error.assessment.item=Le fichier n'a pas pu \u00EAtre lu. Il semble soit corrompu soit au mauvais format. -error.assessment.item.missing=Le fichier de la question n'a pas \u00EAtre d\u00E9chiffr\u00E9. +error.assessment.item.missing=Le fichier de la question n'a pas \u00EAtre lu. error.choice=Vous devez choisir une des options suivantes. error.digital.certificate.cannotread=Le certificat n'a pas pu \u00EAtre lu. error.digital.certificate.noPrivateKey=La "cl\u00E9 priv\u00E9e" n'a pas \u00E9t\u00E9 trouv\u00E9e. Elle est obligatoire. diff --git a/src/main/java/org/olat/ims/qti21/ui/components/AssessmentRenderFunctions.java b/src/main/java/org/olat/ims/qti21/ui/components/AssessmentRenderFunctions.java index d54ef1081e39e8df7f3ee834401fd4a95686805e..3e6f70d96c254b12267cb45628c9be2be9899bcf 100644 --- a/src/main/java/org/olat/ims/qti21/ui/components/AssessmentRenderFunctions.java +++ b/src/main/java/org/olat/ims/qti21/ui/components/AssessmentRenderFunctions.java @@ -31,8 +31,8 @@ import java.util.List; import java.util.Map; import org.apache.commons.codec.binary.Base64; +import org.apache.commons.io.IOUtils; import org.apache.logging.log4j.Logger; -import org.jcodec.common.IOUtils; import org.olat.core.CoreSpringFactory; import org.olat.core.gui.render.StringOutput; import org.olat.core.logging.Tracing; diff --git a/src/main/java/org/olat/modules/qpool/QPoolItemEditorController.java b/src/main/java/org/olat/modules/qpool/QPoolItemEditorController.java index a2ed5cfa1d3bcee89ee25a25dc2e9bd0907bed2e..e0b128b22570bd63062144ed2363cfc62cf320e6 100644 --- a/src/main/java/org/olat/modules/qpool/QPoolItemEditorController.java +++ b/src/main/java/org/olat/modules/qpool/QPoolItemEditorController.java @@ -30,5 +30,7 @@ import org.olat.core.gui.control.Controller; public interface QPoolItemEditorController extends Controller { public QuestionItem getItem(); + + public boolean isValid(); } diff --git a/src/main/java/org/olat/modules/qpool/QPoolSPI.java b/src/main/java/org/olat/modules/qpool/QPoolSPI.java index 2b741bc40e01391e9b611b5753aad8d5fd3106ae..0dba226e108de6551ffa00227780f79304cbee6c 100644 --- a/src/main/java/org/olat/modules/qpool/QPoolSPI.java +++ b/src/main/java/org/olat/modules/qpool/QPoolSPI.java @@ -124,7 +124,7 @@ public interface QPoolSPI { * @param item * @return */ - public Controller getEditableController(UserRequest ureq, WindowControl wControl, QuestionItem item); + public QPoolItemEditorController getEditableController(UserRequest ureq, WindowControl wControl, QuestionItem item); /** * Return the editable controller in a read only modus. This controller is e.g. diff --git a/src/main/java/org/olat/modules/qpool/impl/FileQPoolServiceProvider.java b/src/main/java/org/olat/modules/qpool/impl/FileQPoolServiceProvider.java index 61ed07a21cb5bfad49767b57d50c3a9be58c6d4c..ad98d68a3beb9a5eec952d89ac05dcfff12ffd2c 100644 --- a/src/main/java/org/olat/modules/qpool/impl/FileQPoolServiceProvider.java +++ b/src/main/java/org/olat/modules/qpool/impl/FileQPoolServiceProvider.java @@ -27,6 +27,7 @@ import org.olat.core.gui.UserRequest; import org.olat.core.gui.control.Controller; import org.olat.core.gui.control.WindowControl; import org.olat.modules.qpool.QItemFactory; +import org.olat.modules.qpool.QPoolItemEditorController; import org.olat.modules.qpool.QPoolService; import org.olat.modules.qpool.QuestionItem; import org.olat.modules.qpool.QuestionType; @@ -86,8 +87,7 @@ public class FileQPoolServiceProvider extends AbstractQPoolServiceProvider { @Override public Controller getPreviewController(UserRequest ureq, WindowControl wControl, QuestionItem item, boolean summary) { - FilePreviewController fileController = new FilePreviewController(ureq, wControl, item); - return fileController; + return new FilePreviewController(ureq, wControl, item); } @Override @@ -96,9 +96,8 @@ public class FileQPoolServiceProvider extends AbstractQPoolServiceProvider { } @Override - public Controller getEditableController(UserRequest ureq, WindowControl wControl, QuestionItem item) { - FilePreviewController fileController = new FilePreviewController(ureq, wControl, item); - return fileController; + public QPoolItemEditorController getEditableController(UserRequest ureq, WindowControl wControl, QuestionItem item) { + return new FilePreviewController(ureq, wControl, item); } @Override diff --git a/src/main/java/org/olat/modules/qpool/impl/TextQPoolServiceProvider.java b/src/main/java/org/olat/modules/qpool/impl/TextQPoolServiceProvider.java index de5c43b21c6188f8518481bd0143b11e6481a694..cb63334ccd465b69a3998864ecff8e4c0081564b 100644 --- a/src/main/java/org/olat/modules/qpool/impl/TextQPoolServiceProvider.java +++ b/src/main/java/org/olat/modules/qpool/impl/TextQPoolServiceProvider.java @@ -27,6 +27,7 @@ import org.olat.core.gui.UserRequest; import org.olat.core.gui.control.Controller; import org.olat.core.gui.control.WindowControl; import org.olat.modules.qpool.QItemFactory; +import org.olat.modules.qpool.QPoolItemEditorController; import org.olat.modules.qpool.QPoolService; import org.olat.modules.qpool.QuestionItem; import org.olat.modules.qpool.QuestionType; @@ -84,8 +85,7 @@ public class TextQPoolServiceProvider extends AbstractQPoolServiceProvider { @Override public Controller getPreviewController(UserRequest ureq, WindowControl wControl, QuestionItem item, boolean summary) { - TextPreviewController txtController = new TextPreviewController(ureq, wControl, item, summary); - return txtController; + return new TextPreviewController(ureq, wControl, item, summary); } @Override @@ -94,9 +94,8 @@ public class TextQPoolServiceProvider extends AbstractQPoolServiceProvider { } @Override - public Controller getEditableController(UserRequest ureq, WindowControl wControl, QuestionItem item) { - TextPreviewController txtController = new TextPreviewController(ureq, wControl, item, false); - return txtController; + public QPoolItemEditorController getEditableController(UserRequest ureq, WindowControl wControl, QuestionItem item) { + return new TextPreviewController(ureq, wControl, item, false); } @Override diff --git a/src/main/java/org/olat/modules/qpool/ui/FilePreviewController.java b/src/main/java/org/olat/modules/qpool/ui/FilePreviewController.java index 9803027ab9466b94d3302b4304efff773b0f63be..8b6cb9fdceea6eadfbb4de767a834e40f46de9bc 100644 --- a/src/main/java/org/olat/modules/qpool/ui/FilePreviewController.java +++ b/src/main/java/org/olat/modules/qpool/ui/FilePreviewController.java @@ -27,8 +27,9 @@ import org.olat.core.gui.control.Event; import org.olat.core.gui.control.WindowControl; import org.olat.core.gui.control.controller.BasicController; import org.olat.core.util.vfs.VFSLeaf; -import org.olat.modules.qpool.QuestionItem; +import org.olat.modules.qpool.QPoolItemEditorController; import org.olat.modules.qpool.QPoolService; +import org.olat.modules.qpool.QuestionItem; /** * @@ -36,12 +37,15 @@ import org.olat.modules.qpool.QPoolService; * @author srosse, stephane.rosse@frentix.com, http://www.frentix.com * */ -public class FilePreviewController extends BasicController { +public class FilePreviewController extends BasicController implements QPoolItemEditorController { private final VelocityContainer mainVC; + + private final QuestionItem qitem; public FilePreviewController(UserRequest ureq, WindowControl wControl, QuestionItem qitem) { super(ureq, wControl); + this.qitem = qitem; QPoolService qpoolService = CoreSpringFactory.getImpl(QPoolService.class); mainVC = createVelocityContainer("file_preview"); @@ -53,6 +57,16 @@ public class FilePreviewController extends BasicController { putInitialPanel(mainVC); } + @Override + public QuestionItem getItem() { + return qitem; + } + + @Override + public boolean isValid() { + return true; + } + @Override protected void doDispose() { // diff --git a/src/main/java/org/olat/modules/qpool/ui/QuestionItemDetailsController.java b/src/main/java/org/olat/modules/qpool/ui/QuestionItemDetailsController.java index 58229966c926252f546933d6f4b0fff2bdee9bb8..2616db26074d89dbea30f1ed349107df7470b7e1 100644 --- a/src/main/java/org/olat/modules/qpool/ui/QuestionItemDetailsController.java +++ b/src/main/java/org/olat/modules/qpool/ui/QuestionItemDetailsController.java @@ -54,6 +54,7 @@ import org.olat.group.model.BusinessGroupSelectionEvent; import org.olat.group.ui.main.SelectBusinessGroupController; import org.olat.ims.qti.QTIConstants; import org.olat.modules.qpool.Pool; +import org.olat.modules.qpool.QPoolItemEditorController; import org.olat.modules.qpool.QPoolSPI; import org.olat.modules.qpool.QPoolSecurityCallback; import org.olat.modules.qpool.QPoolService; @@ -132,6 +133,7 @@ public class QuestionItemDetailsController extends BasicController implements To private final int numberOfItems; private Boolean showMetadatas; private LockResult lock; + private boolean valid = true; private boolean questionEdited = false; @Autowired @@ -195,9 +197,12 @@ public class QuestionItemDetailsController extends BasicController implements To showWarning("locked.readonly", new String[] {displayName}); } + if (spi != null) { if (canEditContent) { - questionCtrl = spi.getEditableController(ureq, getWindowControl(), item); + QPoolItemEditorController editQuestionCtrl = spi.getEditableController(ureq, getWindowControl(), item); + valid = editQuestionCtrl.isValid(); + questionCtrl = editQuestionCtrl; } else { questionCtrl = spi.getReadOnlyController(ureq, getWindowControl(), item); } @@ -211,7 +216,11 @@ public class QuestionItemDetailsController extends BasicController implements To listenTo(questionCtrl); if(mainVC != null) { - mainVC.put("type_specifics", questionCtrl.getInitialComponent()); + if(valid) { + mainVC.put("type_specifics", questionCtrl.getInitialComponent()); + } else { + mainVC.contextPut("corrupted", Boolean.TRUE); + } } } @@ -247,7 +256,7 @@ public class QuestionItemDetailsController extends BasicController implements To copyItemLink.setIconLeftCSS("o_icon o_icon-fw o_icon_qitem_copy"); commandDropdown.addComponent(copyItemLink); - if (QTIConstants.QTI_12_FORMAT.equals(metadatasCtrl.getItem().getFormat())) { + if (QTIConstants.QTI_12_FORMAT.equals(metadatasCtrl.getItem().getFormat()) && valid) { convertItemLink = LinkFactory.createToolLink("convert", translate("convert.item"), this); convertItemLink.setIconLeftCSS("o_icon o_icon-fw o_icon_qitem_convert"); commandDropdown.addComponent(convertItemLink); diff --git a/src/main/java/org/olat/modules/qpool/ui/TextPreviewController.java b/src/main/java/org/olat/modules/qpool/ui/TextPreviewController.java index c49e34f8e084e4ba72a4754fa5b0e9372884999d..75e58515b5692f0b54ab404f5db28ee588282f9e 100644 --- a/src/main/java/org/olat/modules/qpool/ui/TextPreviewController.java +++ b/src/main/java/org/olat/modules/qpool/ui/TextPreviewController.java @@ -23,8 +23,6 @@ import java.io.InputStream; import java.io.InputStreamReader; import java.io.StringWriter; -import org.apache.commons.io.IOUtils; -import org.olat.core.CoreSpringFactory; import org.olat.core.gui.UserRequest; import org.olat.core.gui.components.Component; import org.olat.core.gui.components.velocity.VelocityContainer; @@ -32,8 +30,10 @@ import org.olat.core.gui.control.Event; import org.olat.core.gui.control.WindowControl; import org.olat.core.gui.control.controller.BasicController; import org.olat.core.util.vfs.VFSLeaf; -import org.olat.modules.qpool.QuestionItem; +import org.olat.modules.qpool.QPoolItemEditorController; import org.olat.modules.qpool.QPoolService; +import org.olat.modules.qpool.QuestionItem; +import org.springframework.beans.factory.annotation.Autowired; /** * @@ -41,14 +41,15 @@ import org.olat.modules.qpool.QPoolService; * @author srosse, stephane.rosse@frentix.com, http://www.frentix.com * */ -public class TextPreviewController extends BasicController { +public class TextPreviewController extends BasicController implements QPoolItemEditorController { private final VelocityContainer mainVC; - private final QPoolService qpoolService; + + @Autowired + private QPoolService qpoolService; public TextPreviewController(UserRequest ureq, WindowControl wControl, QuestionItem qitem, boolean summary) { super(ureq, wControl); - qpoolService = CoreSpringFactory.getImpl(QPoolService.class); mainVC = createVelocityContainer("text_preview"); VFSLeaf leaf = qpoolService.getRootLeaf(qitem); @@ -64,34 +65,41 @@ public class TextPreviewController extends BasicController { putInitialPanel(mainVC); } + @Override + public QuestionItem getItem() { + return null; + } + + @Override + public boolean isValid() { + return true; + } + @Override protected void doDispose() { // } protected String readSummary(VFSLeaf leaf) { - StringWriter out = new StringWriter(); - InputStream in = leaf.getInputStream(); - InputStreamReader inr = new InputStreamReader(in); - try { + StringWriter out = new StringWriter(); + + try( InputStream in = leaf.getInputStream(); + InputStreamReader inr = new InputStreamReader(in)) { char[] buffer = new char[4096]; int count = 0; - int n = 0; - while (-1 != (n = inr.read(buffer))) { - out.write(buffer, 0, n); - count += n; - if(count >= 10000) { - break; - } - } + int n = 0; + while (-1 != (n = inr.read(buffer))) { + out.write(buffer, 0, n); + count += n; + if(count >= 10000) { + break; + } + } } catch (Exception e) { logError("", e); - } finally { - IOUtils.closeQuietly(inr); - IOUtils.closeQuietly(in); } - return out.toString(); + return out.toString(); } @Override diff --git a/src/main/java/org/olat/modules/qpool/ui/_content/item_details.html b/src/main/java/org/olat/modules/qpool/ui/_content/item_details.html index 91228600d8fe2e45ab2bb745f6e38d31326dad3a..a6edb9efbccd5edf4aa5256e2aec0380c0a030af 100644 --- a/src/main/java/org/olat/modules/qpool/ui/_content/item_details.html +++ b/src/main/java/org/olat/modules/qpool/ui/_content/item_details.html @@ -13,7 +13,11 @@ <div class="row"> #if($metadataSwitch) <div class="col-md-8"> - $r.render("type_specifics") + #if($r.isTrue($corrupted)) + <div class="o_error">$r.translate("error.corrupted.question")</div> + #elseif($r.available("type_specifics")) + $r.render("type_specifics") + #end $r.render("comments") </div> <div class="col-md-4"> @@ -21,7 +25,11 @@ </div> #else <div class="col-md-12"> - $r.render("type_specifics") + #if($r.isTrue($corrupted)) + <div class="o_error">$r.translate("error.corrupted.question")</div> + #elseif($r.available("type_specifics")) + $r.render("type_specifics") + #end $r.render("comments") </div> #end diff --git a/src/main/java/org/olat/modules/qpool/ui/_i18n/LocalStrings_de.properties b/src/main/java/org/olat/modules/qpool/ui/_i18n/LocalStrings_de.properties index 810a9eb0e7e710e75feb0b49044ed1235c988655..93a2c38898d8eb1db0d59127296f837df4939c68 100644 --- a/src/main/java/org/olat/modules/qpool/ui/_i18n/LocalStrings_de.properties +++ b/src/main/java/org/olat/modules/qpool/ui/_i18n/LocalStrings_de.properties @@ -60,6 +60,7 @@ educational.learningTime.day=d educational.learningTime.hour=h educational.learningTime.minute=m educational.learningTime.second=s +error.corrupted.question=Die Datei der Frage konnte nicht gelesen werden. error.input.toolong=Leider ist Ihr gerade eingegebener Text mit {1} Zeichen zu lang. Bitte beschr\u00E4nken Sie sich auf maximal {0} Zeichen. error.qti.deprecated=Diese Version von QTI wird nicht mehr unterst\u00FCtzt. Bitte auf das neue QTI 2.1 konvertieren. error.select.one=Sie m\u00FCssen mindestens eine Frage w\u00E4hlen. diff --git a/src/main/java/org/olat/modules/qpool/ui/_i18n/LocalStrings_en.properties b/src/main/java/org/olat/modules/qpool/ui/_i18n/LocalStrings_en.properties index 26396d809ec00e6f96637eee5625471c47752e9a..1045cc6a1e70ef815adc4ca46a46244f840710e3 100644 --- a/src/main/java/org/olat/modules/qpool/ui/_i18n/LocalStrings_en.properties +++ b/src/main/java/org/olat/modules/qpool/ui/_i18n/LocalStrings_en.properties @@ -60,6 +60,7 @@ educational.learningTime.day=d educational.learningTime.hour=h educational.learningTime.minute=m educational.learningTime.second=s +error.corrupted.question=The file of the question cannot be read. error.input.toolong=The text you entered is to long ({1} characters). Only {1} characters are allowed. error.qti.deprecated=This version of QTI is deprecated. Please consider to convert your test to QTI 2.1. error.select.one=You need to select at least one question. diff --git a/src/main/java/org/olat/modules/qpool/ui/_i18n/LocalStrings_fr.properties b/src/main/java/org/olat/modules/qpool/ui/_i18n/LocalStrings_fr.properties index 3cebff480b2bdb9b29174c38caed67d97b2c94ec..c9bc01c6dd12ed312c7a1f30d94b6020e54c70b9 100644 --- a/src/main/java/org/olat/modules/qpool/ui/_i18n/LocalStrings_fr.properties +++ b/src/main/java/org/olat/modules/qpool/ui/_i18n/LocalStrings_fr.properties @@ -60,6 +60,7 @@ educational.learningTime.day=j educational.learningTime.hour=h educational.learningTime.minute=m educational.learningTime.second=s +error.corrupted.question=Le fichier de la question n'a pas \u00EAtre lu. error.input.toolong=Le texte que vous avez entr\u00E9 est trop long ({1} caract\u00E8res). Limitez-vous s'il vous pla\u00EEt \u00E0 {1} caract\u00E8res. error.qti.deprecated=Cette version de QTI est obsol\u00E8te. Pensez s'il vous pla\u00EEt \u00E0 convertir votre test au format QTI 2.1. error.select.one=Vous devez s\u00E9lectionner au moins une question. diff --git a/src/main/java/org/olat/modules/qpool/ui/_i18n/LocalStrings_pt_BR.properties b/src/main/java/org/olat/modules/qpool/ui/_i18n/LocalStrings_pt_BR.properties index ee89e22fc044a548c48dc5398db92ac9d8cebf3e..6338518c8e83cea06d1256891ce397b4322e85e6 100644 --- a/src/main/java/org/olat/modules/qpool/ui/_i18n/LocalStrings_pt_BR.properties +++ b/src/main/java/org/olat/modules/qpool/ui/_i18n/LocalStrings_pt_BR.properties @@ -61,6 +61,7 @@ educational.learningTime.day=d educational.learningTime.hour=h educational.learningTime.minute=m educational.learningTime.second=s +error.corrupted.question=O arquivo da pergunta n\u00E3o pode ser lido. error.input.toolong=O texto que voc\u00EA digitou \u00E9 muito grande ({1} caracteres). Apenas {1} caracteres s\u00E3o permitidos. error.qti.deprecated=Esta vers\u00E3o do QTI est\u00E1 obsoleta. Por favor, considere converter seu teste para o QTI 2.1. error.select.one=Voc\u00EA precisa selecionar pelo menos uma quest\u00E3o. diff --git a/src/main/java/org/olat/modules/video/manager/VideoManagerImpl.java b/src/main/java/org/olat/modules/video/manager/VideoManagerImpl.java index f63b6987aff74cc44fe34b768ee2ee619e56e6fc..7ccc6c0d3f3de2e404d237a3fcef6d9075c5207b 100644 --- a/src/main/java/org/olat/modules/video/manager/VideoManagerImpl.java +++ b/src/main/java/org/olat/modules/video/manager/VideoManagerImpl.java @@ -28,9 +28,7 @@ import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; -import java.io.RandomAccessFile; import java.math.RoundingMode; -import java.nio.channels.FileChannel; import java.text.DecimalFormat; import java.text.SimpleDateFormat; import java.util.ArrayList; @@ -51,7 +49,9 @@ import org.apache.http.client.methods.HttpGet; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.logging.log4j.Logger; import org.jcodec.api.FrameGrab; -import org.jcodec.common.FileChannelWrapper; +import org.jcodec.common.io.FileChannelWrapper; +import org.jcodec.common.io.NIOUtils; +import org.jcodec.scale.AWTUtil; import org.olat.core.commons.services.image.Crop; import org.olat.core.commons.services.image.ImageService; import org.olat.core.commons.services.image.Size; @@ -280,19 +280,16 @@ public class VideoManagerImpl implements VideoManager { public boolean getFrame(VFSLeaf video, int frameNumber, VFSLeaf frame) { File videoFile = ((LocalFileImpl)video).getBasefile(); - try (RandomAccessFile randomAccessFile = new RandomAccessFile(videoFile, "r")) { - FileChannel ch = randomAccessFile.getChannel(); - FileChannelWrapper in = new FileChannelWrapper(ch); - FrameGrab frameGrab = new FrameGrab(in).seekToFrameSloppy(frameNumber); + try (FileChannelWrapper in = NIOUtils.readableChannel(videoFile)) { + FrameGrab frameGrab = FrameGrab.createFrameGrab(in).seekToFrameSloppy(frameNumber); OutputStream frameOutputStream = frame.getOutputStream(false); - BufferedImage bufImg = frameGrab.getFrame(); + BufferedImage bufImg = AWTUtil.toBufferedImage(frameGrab.getNativeFrame()); ImageIO.write(bufImg, "JPG", frameOutputStream); // close everything to prevent resource leaks frameOutputStream.close(); in.close(); - ch.close(); return true; } catch (Exception | AssertionError e) { @@ -307,14 +304,11 @@ public class VideoManagerImpl implements VideoManager { BufferedImage bufImg = null; boolean imgBlack = true; int countBlack = 0; - try (RandomAccessFile randomAccessFile = new RandomAccessFile(videoFile, "r")) { + try (FileChannelWrapper in = NIOUtils.readableChannel(videoFile)) { OutputStream frameOutputStream = frame.getOutputStream(false); - - FileChannel ch = randomAccessFile.getChannel(); - FileChannelWrapper in = new FileChannelWrapper(ch); - FrameGrab frameGrab = new FrameGrab(in).seekToFrameSloppy(frameNumber); + FrameGrab frameGrab = FrameGrab.createFrameGrab(in).seekToFrameSloppy(frameNumber); - bufImg = frameGrab.getFrame(); + bufImg = AWTUtil.toBufferedImage(frameGrab.getNativeFrame()); int xmin = bufImg.getMinX(); int ymin = bufImg.getMinY(); @@ -347,7 +341,6 @@ public class VideoManagerImpl implements VideoManager { // close everything to prevent resource leaks frameOutputStream.close(); in.close(); - ch.close(); return imgBlack; } catch (Exception | AssertionError e) { diff --git a/src/main/java/org/olat/repository/_i18n/LocalStrings_de.properties b/src/main/java/org/olat/repository/_i18n/LocalStrings_de.properties index 740e00cd2ddba9c71a494241e22f4d3bce9b1199..c8ce2bdf2abea5d808e607211135c9dc2446ed70 100644 --- a/src/main/java/org/olat/repository/_i18n/LocalStrings_de.properties +++ b/src/main/java/org/olat/repository/_i18n/LocalStrings_de.properties @@ -102,6 +102,7 @@ cif.access.users_guests.warning=G\u00E4ste k\u00F6nnen in dieser Konfiguration o cif.allusers=Alle Benutzer cif.author=Autor cif.author.can=Autoren k\u00F6nnen +cif.author.search=Autor / Besitzer cif.authors=Autoren cif.canCopy=kopieren cif.canDownload=exportieren diff --git a/src/main/java/org/olat/repository/_i18n/LocalStrings_en.properties b/src/main/java/org/olat/repository/_i18n/LocalStrings_en.properties index 34b947b625b96fdad84a8c164825b0c87e3ec79e..f4cbdbd992a4b83632836a3d37667b2c4b25111b 100644 --- a/src/main/java/org/olat/repository/_i18n/LocalStrings_en.properties +++ b/src/main/java/org/olat/repository/_i18n/LocalStrings_en.properties @@ -102,6 +102,7 @@ cif.access.users_guests.warning=This configuration allows anonymous guests to ac cif.allusers=All users cif.author=Author cif.author.can=Authors can +cif.author.search=Author / owner cif.authors=Authors cif.canCopy=copy cif.canDownload=download diff --git a/src/main/java/org/olat/repository/_i18n/LocalStrings_fr.properties b/src/main/java/org/olat/repository/_i18n/LocalStrings_fr.properties index 12cd316973b4282dcb7c50b039c2a031d4fde6d6..3ed1eebf80bc34c715d1328a8f758f91c7aec5e3 100644 --- a/src/main/java/org/olat/repository/_i18n/LocalStrings_fr.properties +++ b/src/main/java/org/olat/repository/_i18n/LocalStrings_fr.properties @@ -102,6 +102,7 @@ cif.access.users_guests.warning=Dans cette configuration, les invit\u00E9s peuve cif.allusers=Tous les utilisateurs cif.author=Auteur cif.author.can=Les auteurs peuvent +cif.author.search=Auteur / propri\u00E9taire cif.authors=Auteurs cif.canCopy=copier cif.canDownload=t\u00E9l\u00E9charger diff --git a/src/main/java/org/olat/repository/manager/RepositoryEntryAuthorQueries.java b/src/main/java/org/olat/repository/manager/RepositoryEntryAuthorQueries.java index ab366ec04369d9cb6d0d2b6841c8050ecafde091..01caba5fb16c7ca9eeed435e957f9d40b464ee17 100644 --- a/src/main/java/org/olat/repository/manager/RepositoryEntryAuthorQueries.java +++ b/src/main/java/org/olat/repository/manager/RepositoryEntryAuthorQueries.java @@ -226,7 +226,7 @@ public class RepositoryEntryAuthorQueries { if (StringHelper.containsNonWhitespace(params.getAuthor())) { // fuzzy author search author = PersistenceHelper.makeFuzzyQueryString(params.getAuthor()); - sb.append(" and v.key in (select rel.entry.key from repoentrytogroup as rel, bgroupmember as membership, ") + sb.append(" and (v.key in (select rel.entry.key from repoentrytogroup as rel, bgroupmember as membership, ") .append(IdentityImpl.class.getName()).append(" as identity, ").append(UserImpl.class.getName()).append(" as user") .append(" where rel.group.key=membership.group.key and membership.identity.key=identity.key and user.identity.key=identity.key") .append(" and membership.role='").append(GroupRoles.owner.name()).append("'") @@ -236,7 +236,11 @@ public class RepositoryEntryAuthorQueries { PersistenceHelper.appendFuzzyLike(sb, "user.lastName", "author", dbInstance.getDbVendor()); sb.append(" or "); PersistenceHelper.appendFuzzyLike(sb, "identity.name", "author", dbInstance.getDbVendor()); - sb.append(" ))"); + sb.append(" or "); + PersistenceHelper.appendFuzzyLike(sb, "identity.name", "author", dbInstance.getDbVendor()); + sb.append(" )) or "); + PersistenceHelper.appendFuzzyLike(sb, "v.authors", "author", dbInstance.getDbVendor()); + sb.append(" )"); } String displayname = params.getDisplayname(); diff --git a/src/main/java/org/olat/repository/manager/RepositoryEntryMyCourseQueries.java b/src/main/java/org/olat/repository/manager/RepositoryEntryMyCourseQueries.java index a24352b01fed06d0cb6d5fee8fd60eb9da3c0d8c..82fe4c23c4a6d2651ebd6619bf5dcd4f107b5dea 100644 --- a/src/main/java/org/olat/repository/manager/RepositoryEntryMyCourseQueries.java +++ b/src/main/java/org/olat/repository/manager/RepositoryEntryMyCourseQueries.java @@ -251,7 +251,7 @@ public class RepositoryEntryMyCourseQueries { if (StringHelper.containsNonWhitespace(author)) { // fuzzy author search author = PersistenceHelper.makeFuzzyQueryString(author); - sb.append(" and v.key in (select rel.entry.key from repoentrytogroup as rel, bgroupmember as membership, ") + sb.append(" and (v.key in (select rel.entry.key from repoentrytogroup as rel, bgroupmember as membership, ") .append(IdentityImpl.class.getName()).append(" as identity, ").append(UserImpl.class.getName()).append(" as user") .append(" where rel.group.key=membership.group.key and membership.identity.key=identity.key and user.identity.key=identity.key") .append(" and membership.role='").append(GroupRoles.owner.name()).append("'") @@ -261,7 +261,9 @@ public class RepositoryEntryMyCourseQueries { PersistenceHelper.appendFuzzyLike(sb, "user.lastName", "author", dbInstance.getDbVendor()); sb.append(" or "); PersistenceHelper.appendFuzzyLike(sb, "identity.name", "author", dbInstance.getDbVendor()); - sb.append(" ))"); + sb.append(" )) or"); + PersistenceHelper.appendFuzzyLike(sb, "v.authors", "author", dbInstance.getDbVendor()); + sb.append(" )"); } String text = params.getText(); diff --git a/src/main/java/org/olat/repository/ui/author/AuthorSearchController.java b/src/main/java/org/olat/repository/ui/author/AuthorSearchController.java index c2978e370d005225f345db450ff24744d1c08d05..2bea008dcb8a72a8c5ce2cef299c4d5c9c554945 100644 --- a/src/main/java/org/olat/repository/ui/author/AuthorSearchController.java +++ b/src/main/java/org/olat/repository/ui/author/AuthorSearchController.java @@ -139,7 +139,7 @@ public class AuthorSearchController extends FormBasicController implements Exten id = uifactory.addTextElement("cif_id", "cif.id", 128, "", leftContainer); id.setElementCssClass("o_sel_repo_search_id"); - author = uifactory.addTextElement("cif_author", "cif.author", 255, "", leftContainer); + author = uifactory.addTextElement("cif_author", "cif.author.search", 255, "", leftContainer); author.setElementCssClass("o_sel_repo_search_author"); description = uifactory.addTextElement("cif_description", "cif.description", 255, "", leftContainer); diff --git a/src/main/java/org/olat/repository/ui/list/RepositoryEntrySearchController.java b/src/main/java/org/olat/repository/ui/list/RepositoryEntrySearchController.java index 48ca125369a451f9c1eaece30291adeac092fa2e..d7743f1a6521804db0135069d361632a865a68ec 100644 --- a/src/main/java/org/olat/repository/ui/list/RepositoryEntrySearchController.java +++ b/src/main/java/org/olat/repository/ui/list/RepositoryEntrySearchController.java @@ -85,7 +85,7 @@ public class RepositoryEntrySearchController extends FormBasicController impleme text.setElementCssClass("o_sel_repo_search_displayname"); text.setFocus(true); - author = uifactory.addTextElement("cif_author", "cif.author", 255, "", leftContainer); + author = uifactory.addTextElement("cif_author", "cif.author.search", 255, "", leftContainer); author.setElementCssClass("o_sel_repo_search_author"); FormLayoutContainer rightContainer = FormLayoutContainer.createDefaultFormLayout("right_1", getTranslator()); diff --git a/src/test/java/org/olat/commons/calendar/CalendarImportTest.java b/src/test/java/org/olat/commons/calendar/CalendarImportTest.java index 4503e60483dcf7bf43936791d27911cdfa2610fd..7c88badde4269aba4920e3f34d4371cc7c661ddc 100644 --- a/src/test/java/org/olat/commons/calendar/CalendarImportTest.java +++ b/src/test/java/org/olat/commons/calendar/CalendarImportTest.java @@ -28,7 +28,6 @@ import java.util.Date; import java.util.Iterator; import org.apache.logging.log4j.Logger; -import org.junit.Ignore; import org.junit.Test; import org.olat.core.logging.Tracing; @@ -40,7 +39,6 @@ import net.fortuna.ical4j.model.Period; import net.fortuna.ical4j.model.PeriodList; import net.fortuna.ical4j.model.component.VEvent; import net.fortuna.ical4j.model.property.RecurrenceId; -import net.fortuna.ical4j.util.CompatibilityHints; /** * @@ -104,9 +102,8 @@ public class CalendarImportTest { Calendar calendar = builder.build(in); assertNotNull(calendar); } - */ - - @Test @Ignore + + @Test public void testImportFromFGiCal() throws IOException, ParserException { //default settings in olat System.setProperty(CompatibilityHints.KEY_RELAXED_UNFOLDING, "true"); @@ -117,6 +114,7 @@ public class CalendarImportTest { Calendar calendar = builder.build(in); assertNotNull(calendar); } + */ @Test public void testImportRecurringCal() throws IOException, ParserException { diff --git a/src/test/java/org/olat/core/util/i18n/I18nTest.java b/src/test/java/org/olat/core/util/i18n/I18nTest.java index 347e40817ffc120a976a3b066a6bf0fc7bb883cc..a1971d19e6c949c41a8e3938be3e13b93d27edb5 100644 --- a/src/test/java/org/olat/core/util/i18n/I18nTest.java +++ b/src/test/java/org/olat/core/util/i18n/I18nTest.java @@ -43,7 +43,6 @@ import java.util.regex.Pattern; import org.apache.logging.log4j.Logger; import org.junit.After; import org.junit.Before; -import org.junit.Ignore; import org.junit.Test; import org.olat.core.gui.render.StringOutput; import org.olat.core.gui.render.URLBuilder; @@ -469,73 +468,11 @@ public class I18nTest extends OlatTestCase { } } - /** - * Test methods i18nManager.getProperties(), i18nManager.saveOrUpdateProperties() and i18nManager.deleteProperties() - */ - @Ignore - @Test public void testGetSaveOrUpdateAndDeleteProperties() { - // test with existing files - Properties props = i18nMgr.getResolvedProperties(i18nMgr.getLocaleOrDefault("de"), "org.olat.core"); - assertNotNull(props); - assertTrue(props.size() > 0); - // test with non existing files - String testNewBundle = "org.olat.core.util.i18n.junittestdata.new"; - Locale testLocale = i18nMgr.getLocaleOrDefault("de"); - File baseDir = i18nModule.getPropertyFilesBaseDir(testLocale, testNewBundle); - File testFile = i18nMgr.getPropertiesFile(testLocale, testNewBundle, baseDir); - // clean first existing files from previous broken testcase - if (testFile.exists()) { - i18nMgr.deleteProperties(testLocale, testNewBundle); - } - props = i18nMgr.getResolvedProperties(testLocale, testNewBundle); - assertNotNull(props); - assertEquals(0, props.size()); - // test deleting of non existing - assertFalse(testFile.exists()); - i18nMgr.deleteProperties(testLocale, testNewBundle); - assertFalse(testFile.exists()); - // test saving of non existing - props.setProperty("test.key", "Hello wörld !"); - i18nMgr.saveOrUpdateProperties(props, testLocale, testNewBundle); - assertTrue(testFile.exists()); - assertEquals("Hello wörld !", i18nMgr.getLocalizedString(testNewBundle, "test.key", null, testLocale, false, false)); - // test saving of existing - props = new Properties(); - props.setProperty("hello.world", "&%çest françias, ê alors"); - i18nMgr.saveOrUpdateProperties(props, testLocale, testNewBundle); - assertTrue(testFile.exists()); - assertEquals("&%çest françias, ê alors", i18nMgr.getLocalizedString(testNewBundle, "hello.world", null, testLocale, false, false)); - assertFalse("Hello wörld !".equals(i18nMgr.getLocalizedString(testNewBundle, "test.key", null, testLocale, false, false))); - // test various special cases - props.setProperty("chinesetest", "è¯·é€‰æ‹©ä½ çš„å¤§å¦"); - props.setProperty("specialtest", "that's like \"really\" bad"); - props.setProperty("multiline", "bla\tbla\nsecond line"); - props.setProperty("html", "<h1>Hello World</h1>"); - props.setProperty("empty.property", ""); - i18nMgr.saveOrUpdateProperties(props, testLocale, testNewBundle); - i18nMgr.clearCaches(); - assertEquals("è¯·é€‰æ‹©ä½ çš„å¤§å¦", i18nMgr.getLocalizedString(testNewBundle, "chinesetest", null, testLocale, false, false)); - assertEquals("that's like \"really\" bad", i18nMgr.getLocalizedString(testNewBundle, "specialtest", null, testLocale, false, false)); - assertEquals("bla\tbla\nsecond line", i18nMgr.getLocalizedString(testNewBundle, "multiline", null, testLocale, false, false)); - assertEquals("<h1>Hello World</h1>", i18nMgr.getLocalizedString(testNewBundle, "html", null, testLocale, false, false)); - assertEquals("", i18nMgr.getLocalizedString(testNewBundle, "empty.property", null, testLocale, false, false)); - assertEquals(null, i18nMgr.getLocalizedString(testNewBundle, "not.existing.property", null, testLocale, false, false)); - // test deleting of existing - i18nMgr.deleteProperties(testLocale, testNewBundle); - assertFalse(testFile.exists()); - assertFalse("Hello wörld !".equals(i18nMgr.getLocalizedString(testNewBundle, "test.key", null, testLocale, false, false))); - assertFalse("&%çest françias, ê alors".equals(i18nMgr.getLocalizedString(testNewBundle, "hello.world", null, testLocale, false, false))); - // clean up - if (testFile.exists()) { - i18nMgr.deleteProperties(testLocale, testNewBundle); - } - if (testFile.getParentFile().exists()) testFile.getParentFile().delete(); - } - /** * Test methods i18nManager.getBundlePriority(), i18nManager.getKeyPriority() */ - @Test public void testGetBundleAndKeyPriority() { + @Test + public void testGetBundleAndKeyPriority() { // existing bundle prios String bundleName = "org.olat.core.util.i18n.junittestdata"; Properties metadataProperties = i18nMgr.getPropertiesWithoutResolvingRecursively(null, bundleName); @@ -555,7 +492,8 @@ public class I18nTest extends OlatTestCase { /** * Test methods i18nManager.getAnnotation() */ - @Test public void testGetAnnotation() { + @Test + public void testGetAnnotation() { // existing bundle prios String bundleName = "org.olat.core.util.i18n.junittestdata"; Locale testLocale = i18nMgr.getLocaleOrDefault("de"); @@ -569,61 +507,12 @@ public class I18nTest extends OlatTestCase { } } } - - /** - * Test methods i18nManager.countI18nItems() and i18nManager.countBundles() - */ - @Ignore - @Test public void testCountI18nItemsAndBundles() { - i18nModule.initBundleNames(); // remove dirty stuff from previous tests - int bundleCounter = i18nModule.getBundleNamesContainingI18nFiles().size(); - String testNewBundle = "org.olat.core.util.i18n.junittestdata.new"; - Locale testLocale = i18nMgr.getLocaleOrDefault("de"); - File baseDir = i18nModule.getPropertyFilesBaseDir(testLocale, testNewBundle); - File testFile = i18nMgr.getPropertiesFile(testLocale, testNewBundle, baseDir); - // clean first existing files from previous broken testcase - if (testFile.exists()) { - i18nMgr.deleteProperties(testLocale, testNewBundle); - } - Properties props = i18nMgr.getResolvedProperties(testLocale, testNewBundle); - assertEquals(0, i18nMgr.countI18nItems(testLocale, testNewBundle, true)); - assertEquals(0, i18nMgr.countI18nItems(testLocale, testNewBundle, false)); - props.setProperty("key.1", "1"); - props.setProperty("key.2", "2"); - i18nMgr.saveOrUpdateProperties(props, testLocale, testNewBundle); - assertEquals(2, i18nMgr.countI18nItems(testLocale, testNewBundle, false)); - assertEquals(0, i18nMgr.countI18nItems(i18nMgr.getLocaleOrDefault("en"), testNewBundle, false)); - assertEquals(bundleCounter + 1, i18nModule.getBundleNamesContainingI18nFiles().size()); - // test all bundles - int allCount = i18nMgr.countI18nItems(testLocale, null, true); - assertEquals(allCount, i18nMgr.countI18nItems(testLocale, null, false)); - props.remove("key.1"); - i18nMgr.saveOrUpdateProperties(props, testLocale, testNewBundle); - assertEquals(allCount-1, i18nMgr.countI18nItems(testLocale, null, false)); - i18nMgr.deleteProperties(testLocale, testNewBundle); - assertEquals(allCount-2, i18nMgr.countI18nItems(testLocale, null, false)); - assertEquals(bundleCounter, i18nModule.getBundleNamesContainingI18nFiles().size()); - // count bundles tests - assertEquals(0, i18nMgr.countBundles("org.olat.core.util.i18n.nonexisting", true)); - assertEquals(1, i18nMgr.countBundles("org.olat.core.util.i18n.ui", true)); - // finds 4: regular: i18n.devtools, i18n.ui; - assertEquals(2, i18nMgr.countBundles("org.olat.core.util.i18n", true)); - assertEquals(0, i18nMgr.countBundles("org.olat.core.util.i18n", false)); - assertEquals(1, i18nMgr.countBundles("org.olat.core.util.i18n.ui", false)); - assertTrue(0 < i18nMgr.countBundles(null, false)); - // clean up - if (testFile.exists()) { - i18nMgr.deleteProperties(testLocale, testNewBundle); - } - if (testFile.getParentFile().exists()) { - testFile.getParentFile().delete(); - } - } /** * Test methods i18nManager.findInKeys() i18nManager.findInValues() */ - @Test public void testFindInKeysAndFindInValues() { + @Test + public void testFindInKeysAndFindInValues() { Locale testLocale = i18nMgr.getLocaleOrDefault("de"); // in keys speedtest long start = System.currentTimeMillis(); diff --git a/src/test/java/org/olat/core/util/mail/manager/MailManagerTest.java b/src/test/java/org/olat/core/util/mail/manager/MailManagerTest.java index 78a95a83d04aeba38191b74e9b302625ba34da6d..afb32ba144da6549c5ad75f439083bf63d0e8c0f 100644 --- a/src/test/java/org/olat/core/util/mail/manager/MailManagerTest.java +++ b/src/test/java/org/olat/core/util/mail/manager/MailManagerTest.java @@ -19,15 +19,8 @@ */ package org.olat.core.util.mail.manager; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import java.util.ArrayList; -import java.util.Collections; import java.util.List; import java.util.UUID; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; import javax.mail.Address; import javax.mail.MessagingException; @@ -37,12 +30,9 @@ import javax.mail.internet.MimeMessage; import org.junit.After; import org.junit.Assert; import org.junit.Before; -import org.junit.Ignore; import org.junit.Test; import org.olat.core.commons.persistence.DB; import org.olat.core.id.Identity; -import org.apache.logging.log4j.Logger; -import org.olat.core.logging.Tracing; import org.olat.core.util.WebappHelper; import org.olat.core.util.mail.ContactList; import org.olat.core.util.mail.MailBundle; @@ -63,8 +53,7 @@ import com.dumbster.smtp.SmtpMessage; * */ public class MailManagerTest extends OlatTestCase { - private static final Logger log = Tracing.createLoggerFor(MailManagerTest.class); - + @Autowired private MailManager mailManager; @Autowired @@ -237,48 +226,6 @@ public class MailManagerTest extends OlatTestCase { Assert.assertEquals(incomingMail, incomingsMails_3.get(0)); } - - @Test @Ignore // not really needed anymore, the subscribe process is asynchrone and serial - public void testParalellSubscribers() { - final int NUM_OF_THREADS = 10; - final int NUM_OF_USERS = 10; - final int NUM_OF_REDONDANCY = 50; - - List<Identity> identities = new ArrayList<>(); - for(int i=0; i<NUM_OF_USERS; i++) { - Identity id = JunitTestHelper.createAndPersistIdentityAsUser("fci-" + i + "-" + UUID.randomUUID()); - for(int j=0; j<NUM_OF_REDONDANCY; j++) { - identities.add(id); - } - } - - final CountDownLatch finishCount = new CountDownLatch(NUM_OF_THREADS); - List<Exception> exceptionHolder = Collections.synchronizedList(new ArrayList<Exception>(1)); - List<Boolean> statusList = Collections.synchronizedList(new ArrayList<Boolean>(1)); - List<SubscribeThread> threads = new ArrayList<>(); - for(int i=0; i<NUM_OF_THREADS; i++) { - List<Identity> ids = new ArrayList<>(identities); - SubscribeThread thread = new SubscribeThread(ids, exceptionHolder, statusList, finishCount); - threads.add(thread); - } - - for(SubscribeThread thread:threads) { - thread.start(); - } - - // sleep until threads should have terminated/excepted - try { - sleep(30000);// eat all JMS events - finishCount.await(120, TimeUnit.SECONDS); - } catch (InterruptedException e) { - log.error("", e); - Assert.fail(); - } - - assertTrue("It throws an exception in test", exceptionHolder.isEmpty()); - assertEquals("Thread(s) did not finish", NUM_OF_THREADS, statusList.size()); - } - @Test public void sendExternMessage() { Identity id = JunitTestHelper.createAndPersistIdentityAsRndUser("mailman-1"); @@ -336,39 +283,4 @@ public class MailManagerTest extends OlatTestCase { msg3.getFrom()[0].equals(fromx)); Assert.assertNotNull(result3); } - - private class SubscribeThread extends Thread { - - private final List<Identity> ids; - private final List<Exception> exceptionHolder; - private final List<Boolean> statusList; - private final CountDownLatch countDown; - - public SubscribeThread(List<Identity> ids, List<Exception> exceptionHolder, List<Boolean> statusList, CountDownLatch countDown) { - this.ids = ids; - this.exceptionHolder = exceptionHolder; - this.statusList = statusList; - this.countDown = countDown; - } - - @Override - public void run() { - try { - Thread.sleep(10); - for(int i=5; i-->0; ) { - for(Identity id:ids) { - mailManager.subscribe(id); - } - } - statusList.add(Boolean.TRUE); - } catch (Exception ex) { - ex.printStackTrace(); - log.error("", ex); - exceptionHolder.add(ex);// no exception should happen - } finally { - countDown.countDown(); - dbInstance.closeSession(); - } - } - } } diff --git a/src/test/java/org/olat/course/nodes/en/EnrollmentManagerConcurrentTest.java b/src/test/java/org/olat/course/nodes/en/EnrollmentManagerConcurrentTest.java index d56bad298670c1729e184cd3c36e8ec920a7057b..5319aee0885e05428d385e66080db9d329f0148a 100644 --- a/src/test/java/org/olat/course/nodes/en/EnrollmentManagerConcurrentTest.java +++ b/src/test/java/org/olat/course/nodes/en/EnrollmentManagerConcurrentTest.java @@ -41,7 +41,6 @@ import java.util.concurrent.TimeUnit; import org.apache.logging.log4j.Logger; import org.junit.Assert; import org.junit.Before; -import org.junit.Ignore; import org.junit.Test; import org.olat.basesecurity.BaseSecurity; import org.olat.basesecurity.GroupRoles; @@ -311,76 +310,7 @@ public class EnrollmentManagerConcurrentTest extends OlatTestCase implements Win } - @Test @Ignore - public void testConcurrentEnrollmentWithWaitingList_big() { - List<Identity> ids = new ArrayList<>(100); - for(int i=0; i<100; i++) { - Identity id = JunitTestHelper.createAndPersistIdentityAsUser("enroll-a-" + i + "-" + UUID.randomUUID().toString()); - ids.add(id); - } - - Identity author = JunitTestHelper.createAndPersistIdentityAsAuthor("enroller"); - RepositoryEntry addedEntry = JunitTestHelper.deployBasicCourse(author); - - ENCourseNode enNode1 = new ENCourseNode(); - ENCourseNode enNode2 = new ENCourseNode(); - ENCourseNode enNode3 = new ENCourseNode(); - ENCourseNode enNode4 = new ENCourseNode(); - ENCourseNode enNode5 = new ENCourseNode(); - - CourseEnvironment cenv = CourseFactory.loadCourse(addedEntry).getCourseEnvironment(); - BusinessGroup group1 = businessGroupService.createBusinessGroup(author, "Enrollment 1", "Enroll 1", new Integer(1), new Integer(8), true, true, addedEntry); - BusinessGroup group2 = businessGroupService.createBusinessGroup(author, "Enrollment 2", "Enroll 2", new Integer(1), new Integer(10), true, true, addedEntry); - BusinessGroup group3 = businessGroupService.createBusinessGroup(author, "Enrollment 3", "Enroll 3", new Integer(1), new Integer(4), true, true, addedEntry); - BusinessGroup group4 = businessGroupService.createBusinessGroup(author, "Enrollment 4", "Enroll 4", new Integer(1), new Integer(10), true, true, addedEntry); - BusinessGroup group5 = businessGroupService.createBusinessGroup(author, "Enrollment 5", "Enroll 5", new Integer(1), new Integer(9), true, true, addedEntry); - dbInstance.commitAndCloseSession(); - - EnrollThread[] threads = new EnrollThread[100]; - - final CountDownLatch doneSignal = new CountDownLatch(ids.size()); - int t = 0; - for(int i=0; i<30; i++) { - threads[t++] = new EnrollThread(ids.get(i), addedEntry, group1, enNode1, cenv, doneSignal); - } - for(int i=30; i<50; i++) { - threads[t++] = new EnrollThread(ids.get(i), addedEntry, group2, enNode2, cenv, doneSignal); - } - for(int i=50; i<70; i++) { - threads[t++] = new EnrollThread(ids.get(i), addedEntry, group3, enNode3, cenv, doneSignal); - } - for(int i=70; i<90; i++) { - threads[t++] = new EnrollThread(ids.get(i), addedEntry, group4, enNode4, cenv, doneSignal); - } - for(int i=90; i<100; i++) { - threads[t++] = new EnrollThread(ids.get(i), addedEntry, group5, enNode5, cenv, doneSignal); - } - - for(EnrollThread thread:threads) { - thread.start(); - } - - try { - boolean interrupt = doneSignal.await(360, TimeUnit.SECONDS); - assertTrue("Test takes too long (more than 10s)", interrupt); - } catch (InterruptedException e) { - fail("" + e.getMessage()); - } - - dbInstance.commitAndCloseSession(); - - List<Identity> enrolled_1_Ids = businessGroupService.getMembers(group1, GroupRoles.participant.name()); - Assert.assertEquals(8, enrolled_1_Ids.size()); - List<Identity> enrolled_2_Ids = businessGroupService.getMembers(group2, GroupRoles.participant.name()); - Assert.assertEquals(10, enrolled_2_Ids.size()); - List<Identity> enrolled_3_Ids = businessGroupService.getMembers(group3, GroupRoles.participant.name()); - Assert.assertEquals(4, enrolled_3_Ids.size()); - List<Identity> enrolled_4_Ids = businessGroupService.getMembers(group4, GroupRoles.participant.name()); - Assert.assertEquals(10, enrolled_4_Ids.size()); - List<Identity> enrolled_5_Ids = businessGroupService.getMembers(group5, GroupRoles.participant.name()); - Assert.assertEquals(9, enrolled_5_Ids.size()); - } - + private class EnrollThread extends Thread { private final ENCourseNode enNode; private final Identity identity; diff --git a/src/test/java/org/olat/course/statistic/WeeklyStatisticUpdateManagerTest.java b/src/test/java/org/olat/course/statistic/WeeklyStatisticUpdateManagerTest.java index 5686fce92954e92f9db3224a0af560eea004d09e..7f0a4f2fe595df882f374f703e8964d025c613e7 100644 --- a/src/test/java/org/olat/course/statistic/WeeklyStatisticUpdateManagerTest.java +++ b/src/test/java/org/olat/course/statistic/WeeklyStatisticUpdateManagerTest.java @@ -25,7 +25,6 @@ import java.util.Locale; import java.util.Map; import org.junit.Assert; -import org.junit.Ignore; import org.junit.Test; import org.olat.core.gui.util.SyntheticUserRequest; import org.olat.core.id.Identity; @@ -49,7 +48,7 @@ public class WeeklyStatisticUpdateManagerTest extends AbstractStatisticUpdateMan private final WeeklyStatisticManager weeklyStatisticManager = new WeeklyStatisticManager(); - @Test @Ignore + @Test public void statistics_weekly() { statisticUpdateManager.setEnabled(true); diff --git a/src/test/java/org/olat/group/test/BGAreaManagerTest.java b/src/test/java/org/olat/group/test/BGAreaManagerTest.java index ccebfd85b751177dcb6eb0c7cd17757d7ad1e336..4aefb6377aec6c823eadb48fdc935eeee5bbbee5 100644 --- a/src/test/java/org/olat/group/test/BGAreaManagerTest.java +++ b/src/test/java/org/olat/group/test/BGAreaManagerTest.java @@ -825,7 +825,7 @@ public class BGAreaManagerTest extends OlatTestCase { @Test public void testSynchronisationUpdateBGArea() { - final int maxLoop = 75; // => 400 x 100ms => 40sec => finished in 50sec + final int maxLoop = 30; final String areaName = "BGArea_2"; final List<Exception> exceptionHolder = Collections.synchronizedList(new ArrayList<Exception>(1)); diff --git a/src/test/java/org/olat/group/test/BusinessGroupServiceTest.java b/src/test/java/org/olat/group/test/BusinessGroupServiceTest.java index 913201c09da942ae5766054deada837be985fbdc..cf2a0208d7100fc914660d08d95f8258764ac583 100644 --- a/src/test/java/org/olat/group/test/BusinessGroupServiceTest.java +++ b/src/test/java/org/olat/group/test/BusinessGroupServiceTest.java @@ -36,7 +36,6 @@ import org.junit.After; import org.junit.Assert; import org.junit.Before; import org.junit.FixMethodOrder; -import org.junit.Ignore; import org.junit.Test; import org.junit.runners.MethodSorters; import org.olat.basesecurity.BaseSecurity; @@ -1286,15 +1285,15 @@ public class BusinessGroupServiceTest extends OlatTestCase { Assert.assertFalse(contactList.contains(adminIdentity3)); } - @Ignore @Test + @Test public void parallelRemoveParticipants() { mailModule.setInterSystem(true); businessGroupModule.setMandatoryEnrolmentEmailFor(OrganisationRoles.user, "true"); Identity admin = JunitTestHelper.createAndPersistIdentityAsRndUser("remove-p1-1"); - int NUM_OF_THREADS = 20; - int NUM_OF_GROUPS = 50; + int NUM_OF_THREADS = 5; + int NUM_OF_GROUPS = 5; int NUM_OF_PARTICIPANTS = 10; //create the members diff --git a/src/test/java/org/olat/resource/lock/pessimistic/PLockTest.java b/src/test/java/org/olat/resource/lock/pessimistic/PLockTest.java index b10d1fd37c7fc1d9e2af72f4a2cb16e33e004176..de5b51ec43fe0425a6df62d49c0246ba6999ea7c 100644 --- a/src/test/java/org/olat/resource/lock/pessimistic/PLockTest.java +++ b/src/test/java/org/olat/resource/lock/pessimistic/PLockTest.java @@ -29,7 +29,6 @@ package org.olat.resource.lock.pessimistic; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; -import static org.junit.Assume.assumeTrue; import java.util.ArrayList; import java.util.Collections; @@ -38,6 +37,7 @@ import java.util.UUID; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; +import org.apache.logging.log4j.Logger; import org.junit.Assert; import org.junit.Test; import org.olat.basesecurity.SecurityGroup; @@ -46,7 +46,6 @@ import org.olat.core.commons.persistence.DB; import org.olat.core.commons.services.lock.pessimistic.PLock; import org.olat.core.commons.services.lock.pessimistic.PessimisticLockManager; import org.olat.core.id.Identity; -import org.apache.logging.log4j.Logger; import org.olat.core.logging.Tracing; import org.olat.test.JunitTestHelper; import org.olat.test.OlatTestCase; @@ -177,89 +176,6 @@ public class PLockTest extends OlatTestCase { } assertTrue("exception in test => see sysout", exceptionHolder.size() == 0); } - - @Test public void testLockWaitTimout() { - //Ignore Test if DB is PostgreSQL. PostgreSQL has not lock timeout - assumeTrue(!isPostgresqlConfigured() && !isOracleConfigured()); - - final String asset = "testLockWaitTimout"; - - log.info("testing if holding a lock timeouts"); - // make sure all three row entries for the locks are created, otherwise the system-wide locking - // applied on lock-row-creation cannot support row-level-locking by definition. - - PLock pc3 = pessimisticLockManager.findOrPersistPLock("blibli"); - assertNotNull(pc3); - dbInstance.closeSession(); - - /** - * t1 t2 - * .. bli - * .. .. - * .. .. - * .. .. - * bli .. - * .. - * .. - * .... hold for longer than 30 secs - * - */ - - - final List<Exception> exceptionHolder = Collections.synchronizedList(new ArrayList<Exception>(1)); - final CountDownLatch finishCount = new CountDownLatch(2); - - // t1 - new Thread(new Runnable() { - public void run() { - try { - sleep(500); - PLock p3 = pessimisticLockManager.findOrPersistPLock(asset); - assertNotNull(p3); - } catch (Exception e) { - exceptionHolder.add(e); - } finally { - finishCount.countDown(); - try { - dbInstance.closeSession(); - } catch (Exception e) { - // ignore - } - } - }}).start(); - - // t2 - new Thread(new Runnable() { - public void run() { - try { - PLock p2 = pessimisticLockManager.findOrPersistPLock(asset); - assertNotNull(p2); - sleep(55000); - // holding the lock for more than the transaction timeout - // (normally 30secs, configured where? hib) should cause a lock timeout - // if the db is configured so (innodb_lock_wait_timeout). - } catch (Exception e) { - exceptionHolder.add(e); - } finally { - finishCount.countDown(); - try { - dbInstance.closeSession(); - } catch (Exception e) { - // ignore - } - } - }}).start(); - - // sleep until t1 and t2 should have terminated/excepted - try { - log.info("Sleep 55s"); - finishCount.await(60, TimeUnit.SECONDS); - } catch (InterruptedException e) { - Assert.fail(""); - } - - Assert.assertEquals("expected a lock wait timeout exceeded exception", 1, exceptionHolder.size()); - } @Test public void testSingleRowLockingSupported() { diff --git a/src/test/java/org/olat/restapi/CurriculumElementsWebServiceTest.java b/src/test/java/org/olat/restapi/CurriculumElementsWebServiceTest.java index 28e1e685fd3f8fa05bae2873dd898978b68da09c..4dbd9b3d39232f13c0478f5f2a5d5e4f7430bcd7 100644 --- a/src/test/java/org/olat/restapi/CurriculumElementsWebServiceTest.java +++ b/src/test/java/org/olat/restapi/CurriculumElementsWebServiceTest.java @@ -42,8 +42,8 @@ import org.apache.http.client.methods.HttpPut; import org.apache.http.util.EntityUtils; import org.hamcrest.Matchers; import org.junit.Assert; -import org.junit.Ignore; import org.junit.Test; +import org.olat.basesecurity.OrganisationRoles; import org.olat.basesecurity.OrganisationService; import org.olat.core.commons.persistence.DB; import org.olat.core.id.Identity; @@ -522,7 +522,7 @@ public class CurriculumElementsWebServiceTest extends OlatRestTestCase { Assert.assertEquals(curriculum, savedElement.getCurriculum()); } - @Test @Ignore + @Test public void updateCurriculumElement_notAuthorized() throws IOException, URISyntaxException { Organisation defOrganisation = organisationService.getDefaultOrganisation(); @@ -532,9 +532,15 @@ public class CurriculumElementsWebServiceTest extends OlatRestTestCase { null, null, null, null, CurriculumCalendars.disabled, CurriculumLectures.disabled, curriculum); Curriculum otherCurriculum = curriculumService.createCurriculum("REST-Curriculum-elements", "REST Curriculum", "A curriculum accessible by REST API for elemets", organisation); dbInstance.commitAndCloseSession(); - + + // other administration organisation + Organisation adminOrganisation = organisationService.createOrganisation("REST Admin Organisation", "REST-p-4admin-organisation", "", defOrganisation, null); + Identity admin = JunitTestHelper.createAndPersistIdentityAsRndUser("p-4admin"); + organisationService.addMember(adminOrganisation, admin, OrganisationRoles.administrator); + dbInstance.commitAndCloseSession(); + RestConnection conn = new RestConnection(); - assertTrue(conn.login("administrator", "openolat")); + assertTrue(conn.login(admin.getName(), JunitTestHelper.PWD)); CurriculumElementVO vo = CurriculumElementVO.valueOf(element); vo.setExternalId("REST-CEL-10"); @@ -546,7 +552,7 @@ public class CurriculumElementsWebServiceTest extends OlatRestTestCase { conn.addJsonEntity(method, vo); HttpResponse response = conn.execute(method); - Assert.assertEquals(409, response.getStatusLine().getStatusCode()); + Assert.assertEquals(401, response.getStatusLine().getStatusCode()); EntityUtils.consume(response.getEntity()); } diff --git a/src/test/java/org/olat/test/AllTestsJunit4.java b/src/test/java/org/olat/test/AllTestsJunit4.java index 996dfac9a88c8e83b3827950fb5f682f42c7f3cc..e018056a9c0f1f805ab0bc3d4465ae3654fdac61 100644 --- a/src/test/java/org/olat/test/AllTestsJunit4.java +++ b/src/test/java/org/olat/test/AllTestsJunit4.java @@ -185,7 +185,7 @@ import org.junit.runners.Suite; org.olat.course.statistic.DailyStatisticUpdateManagerTest.class, org.olat.course.statistic.DayOfWeekStatisticUpdateManagerTest.class, org.olat.course.statistic.HourOfDayStatisticUpdateManagerTest.class, - org.olat.course.statistic.WeeklyStatisticUpdateManagerTest.class, + // org.olat.course.statistic.WeeklyStatisticUpdateManagerTest.class, org.olat.modules.assessment.manager.AssessmentEntryDAOTest.class, org.olat.course.certificate.manager.CertificatesManagerTest.class, org.olat.course.config.CourseConfigManagerImplTest.class, diff --git a/src/test/java/org/olat/test/OlatTestCase.java b/src/test/java/org/olat/test/OlatTestCase.java index bf272297b793ccb1e131c3e4bb55fb3e423b32c8..f23525943140127958da86a5e5e1e86dfede47af 100644 --- a/src/test/java/org/olat/test/OlatTestCase.java +++ b/src/test/java/org/olat/test/OlatTestCase.java @@ -42,6 +42,7 @@ import org.olat.core.commons.persistence.DBFactory; import org.olat.core.helpers.Settings; import org.apache.logging.log4j.Logger; import org.olat.core.logging.Tracing; +import org.olat.core.util.CodeHelper; import org.olat.core.util.WebappHelper; import org.olat.core.util.event.FrameworkStartupEventChannel; import org.springframework.core.io.ClassPathResource; @@ -69,6 +70,7 @@ public abstract class OlatTestCase extends AbstractJUnit4SpringContextTests { private static boolean oracleConfigured = false; private static boolean started = false; private static SimpleSmtpServer dumbster; + private static long timestamp; @Rule public TestName currentTestName = new TestName(); @@ -89,6 +91,7 @@ public abstract class OlatTestCase extends AbstractJUnit4SpringContextTests { @Before public void printBanner() { + timestamp = System.nanoTime(); log.info("Method run: " + currentTestName.getMethodName() + "(" + this.getClass().getCanonicalName() + ")"); if(started) { @@ -121,7 +124,8 @@ public abstract class OlatTestCase extends AbstractJUnit4SpringContextTests { @After public void closeConnectionAfter() { - log.info("Method test finished: " + currentTestName.getMethodName() + "(" + this.getClass().getCanonicalName() + ")"); + long time = CodeHelper.nanoToMilliTime(timestamp); + log.info("Method test finished: {} ({}) takes (ms): {}", currentTestName.getMethodName(), this.getClass().getCanonicalName(), time); try { DBFactory.getInstance().commitAndCloseSession(); } catch (Exception e) {