diff --git a/src/main/java/de/tuchemnitz/wizard/workflows/coursecreation/CourseCreationHelper.java b/src/main/java/de/tuchemnitz/wizard/workflows/coursecreation/CourseCreationHelper.java index e39abc195b6c9dbef434e995d99966b7800e2864..fa845ab75191207302e28b39cdf6a485554bee86 100644 --- a/src/main/java/de/tuchemnitz/wizard/workflows/coursecreation/CourseCreationHelper.java +++ b/src/main/java/de/tuchemnitz/wizard/workflows/coursecreation/CourseCreationHelper.java @@ -45,6 +45,7 @@ import org.olat.core.CoreSpringFactory; import org.olat.core.gui.UserRequest; import org.olat.core.gui.translator.Translator; import org.olat.core.id.UserConstants; +import org.olat.core.logging.OLog; import org.olat.core.logging.Tracing; import org.olat.core.util.Util; import org.olat.core.util.vfs.VFSLeaf; @@ -85,6 +86,8 @@ import de.tuchemnitz.wizard.workflows.coursecreation.model.CourseCreationConfigu * @author Sebastian Fritzsche (seb.fritzsche@googlemail.com) */ public class CourseCreationHelper { + + private static final OLog log = Tracing.createLoggerFor(CourseCreationHelper.class); private CourseCreationConfiguration courseConfig; private final Translator translator; @@ -270,16 +273,18 @@ public class CourseCreationHelper { // 3.1. setup rights // -------------------------- if (courseConfig.getPublish()) { + + int access = RepositoryEntry.ACC_OWNERS; if (courseConfig.getAclType().equals(CourseCreationConfiguration.ACL_GUEST)) { // set "BARG" as rule - addedEntry.setAccess(RepositoryEntry.ACC_USERS_GUESTS); + access = RepositoryEntry.ACC_USERS_GUESTS; } else if (courseConfig.getAclType().equals(CourseCreationConfiguration.ACL_OLAT)) { // set "BAR" as rule - addedEntry.setAccess(RepositoryEntry.ACC_USERS); + access = RepositoryEntry.ACC_USERS; } else if (courseConfig.getAclType().equals(CourseCreationConfiguration.ACL_UNI)) { // set "BAR" rule + expert rule on university // hasAttribute("institution","[Hochschule]") - addedEntry.setAccess(RepositoryEntry.ACC_USERS); + access = RepositoryEntry.ACC_USERS; final CourseNode cnRoot = course.getEditorTreeModel().getCourseEditorNodeById(course.getEditorTreeModel().getRootNode().getIdent()) .getCourseNode(); String shibInstitution = ureq.getIdentity().getUser().getProperty(UserConstants.INSTITUTIONALNAME, ureq.getLocale()); @@ -292,9 +297,9 @@ public class CourseCreationHelper { + "\")")); } } else { - Tracing.createLoggerFor(this.getClass()).error("No valid ACL Rule: " + courseConfig.getAclType()); + log.error("No valid ACL Rule: " + courseConfig.getAclType()); } - RepositoryManager.getInstance().updateRepositoryEntry(addedEntry); + addedEntry = RepositoryManager.getInstance().setAccess(addedEntry, access, false); } CourseFactory.openCourseEditSession(course.getResourceableId()); @@ -325,7 +330,7 @@ public class CourseCreationHelper { boolean isValid = sds.length == 0; if (!isValid) { // no error and no warnings -> return immediate - Tracing.createLoggerFor(this.getClass()).error("Course Publishing failed", new AssertionError()); + log.error("Course Publishing failed", new AssertionError()); } pp.applyPublishSet(ureq.getIdentity(), ureq.getLocale()); CourseFactory.closeCourseEditSession(course.getResourceableId(), true); diff --git a/src/main/java/org/olat/catalog/CatalogManager.java b/src/main/java/org/olat/catalog/CatalogManager.java index 2da6378d9cee72d0a9038226bef4abad90ac53f2..df5589ef049359fd95715fdda2ade7f691f0e0af 100644 --- a/src/main/java/org/olat/catalog/CatalogManager.java +++ b/src/main/java/org/olat/catalog/CatalogManager.java @@ -584,13 +584,10 @@ public class CatalogManager extends BasicManager implements UserDataDeletable, I /** * - * @param repositoryEntry + * @param re */ - public void updateReferencedRepositoryEntry(RepositoryEntry repositoryEntry) { - RepositoryEntry reloaded = RepositoryManager.getInstance().lookupRepositoryEntry(repositoryEntry.getKey()); - reloaded.setDisplayname(repositoryEntry.getDisplayname()); - reloaded.setDescription(repositoryEntry.getDescription()); - RepositoryManager.getInstance().updateRepositoryEntry(reloaded); + public void updateReferencedRepositoryEntry(RepositoryEntry re) { + RepositoryEntry reloaded = RepositoryManager.getInstance().setDescriptionAndName(re, re.getDisplayname(), re.getDescription()); // inform anybody interested about this change MultiUserEvent modifiedEvent = new EntryChangedEvent(reloaded, EntryChangedEvent.MODIFIED_DESCRIPTION); CoordinatorManager.getInstance().getCoordinator().getEventBus().fireEventToListenersOf(modifiedEvent, reloaded); diff --git a/src/main/java/org/olat/core/id/context/HistoryPointImpl.java b/src/main/java/org/olat/core/id/context/HistoryPointImpl.java index 2f44a8b44b4e6f365114a4cdff1bf9b9c34f5945..02c39f9459d6251e72f2c47ec3f21c69bb562a8d 100644 --- a/src/main/java/org/olat/core/id/context/HistoryPointImpl.java +++ b/src/main/java/org/olat/core/id/context/HistoryPointImpl.java @@ -21,6 +21,7 @@ package org.olat.core.id.context; import java.util.ArrayList; +import java.util.Collections; import java.util.List; /** @@ -35,12 +36,15 @@ public class HistoryPointImpl implements HistoryPoint { private final String uuid; private final String businessPath; - private final List<ContextEntry> entries = new ArrayList<ContextEntry>(); + private final List<ContextEntry> entries; public HistoryPointImpl(String uuid, String businessPath, List<ContextEntry> entries) { this.uuid = uuid; this.businessPath = businessPath; - if(entries != null) { + if(entries == null) { + this.entries = Collections.emptyList(); + } else { + this.entries = new ArrayList<ContextEntry>(entries.size()); for(ContextEntry entry:entries) { this.entries.add(entry.clone()); } diff --git a/src/main/java/org/olat/course/run/navigation/NodeClickedRef.java b/src/main/java/org/olat/course/run/navigation/NodeClickedRef.java index 5d87c46542e5602dd906f6e924b381b71b0f0061..455fc380393fdb3c852e3c3d008d7e0078b7dfa2 100644 --- a/src/main/java/org/olat/course/run/navigation/NodeClickedRef.java +++ b/src/main/java/org/olat/course/run/navigation/NodeClickedRef.java @@ -146,7 +146,9 @@ public class NodeClickedRef { */ public Controller getRunController() { if(calledCourseNode == null || nodeConstructionResult == null) return null; - RepositoryManager.setLastUsageNowFor(calledCourseNode.getReferencedRepositoryEntry()); + if(calledCourseNode.needsReferenceToARepositoryEntry()) { + RepositoryManager.getInstance().setLastUsageNowFor(calledCourseNode.getReferencedRepositoryEntry()); + } return nodeConstructionResult.getRunController(); } diff --git a/src/main/java/org/olat/repository/RepositoryEntry.java b/src/main/java/org/olat/repository/RepositoryEntry.java index a3a24f5afb46779d08fe47160bc37e0c5fb74495..e06f793f4405bb841b236444514a54e75799a86e 100644 --- a/src/main/java/org/olat/repository/RepositoryEntry.java +++ b/src/main/java/org/olat/repository/RepositoryEntry.java @@ -376,12 +376,16 @@ public class RepositoryEntry extends PersistentObject implements ModifiedInfo, O /** * Increment launch counter. */ - public void incrementLaunchCounter() { launchCounter++; } + public void incrementLaunchCounter() { + launchCounter++; + } /** * Increment download counter. */ - public void incrementDownloadCounter() { downloadCounter++; } + public void incrementDownloadCounter() { + downloadCounter++; + } /** * @return Returns the displayname. diff --git a/src/main/java/org/olat/repository/RepositoryManager.java b/src/main/java/org/olat/repository/RepositoryManager.java index 48471aaed9548f847bbdbdd581b0749a8f87a8eb..027cb7f1c6caabac5d7536d550e8cb0e15b4e7ec 100644 --- a/src/main/java/org/olat/repository/RepositoryManager.java +++ b/src/main/java/org/olat/repository/RepositoryManager.java @@ -32,6 +32,8 @@ import java.util.Collections; import java.util.Date; import java.util.List; +import javax.persistence.CacheRetrieveMode; +import javax.persistence.LockModeType; import javax.persistence.TypedQuery; import org.hibernate.type.StandardBasicTypes; @@ -44,6 +46,8 @@ import org.olat.basesecurity.SecurityGroup; import org.olat.basesecurity.SecurityGroupMembershipImpl; import org.olat.bookmark.BookmarkManager; import org.olat.catalog.CatalogManager; +import org.olat.commons.lifecycle.LifeCycleManager; +import org.olat.core.CoreSpringFactory; import org.olat.core.commons.modules.bc.FolderConfig; import org.olat.core.commons.persistence.DB; import org.olat.core.commons.persistence.DBFactory; @@ -55,6 +59,7 @@ import org.olat.core.id.Identity; import org.olat.core.id.OLATResourceable; import org.olat.core.id.Roles; import org.olat.core.logging.AssertException; +import org.olat.core.logging.OLog; import org.olat.core.logging.Tracing; import org.olat.core.logging.activity.ActionType; import org.olat.core.logging.activity.OlatResourceableType; @@ -72,13 +77,7 @@ import org.olat.core.util.vfs.VFSManager; import org.olat.course.assessment.manager.UserCourseInformationsManager; import org.olat.group.GroupLoggingAction; import org.olat.group.model.BGResourceRelation; -import org.olat.repository.async.BackgroundTaskQueueManager; -import org.olat.repository.async.IncrementDownloadCounterBackgroundTask; -import org.olat.repository.async.IncrementLaunchCounterBackgroundTask; -import org.olat.repository.async.SetAccessBackgroundTask; -import org.olat.repository.async.SetDescriptionNameBackgroundTask; -import org.olat.repository.async.SetLastUsageBackgroundTask; -import org.olat.repository.async.SetPropertiesBackgroundTask; +import org.olat.repository.delete.service.RepositoryDeletionManager; import org.olat.repository.handlers.RepositoryHandler; import org.olat.repository.handlers.RepositoryHandlerFactory; import org.olat.repository.model.RepositoryEntryMember; @@ -91,6 +90,7 @@ import org.olat.resource.OLATResource; import org.olat.resource.OLATResourceImpl; import org.olat.resource.OLATResourceManager; import org.olat.util.logging.activity.LoggingResourceable; +import org.springframework.transaction.annotation.Transactional; /** * Initial Date: Mar 31, 2004 @@ -102,24 +102,24 @@ import org.olat.util.logging.activity.LoggingResourceable; */ public class RepositoryManager extends BasicManager { + private static final OLog log = Tracing.createLoggerFor(RepositoryManager.class); + private final int PICTUREWIDTH = 570; - private static RepositoryManager INSTANCE; private BaseSecurity securityManager; private ImageHelper imageHelper; - private static BackgroundTaskQueueManager taskQueueManager; private UserCourseInformationsManager userCourseInformationsManager; private DB dbInstance; + /** - * [used by spring] + * [used by Spring] + * @param securityManager */ - private RepositoryManager(BaseSecurity securityManager, BackgroundTaskQueueManager taskQueueManager) { + public void setSecurityManager(BaseSecurity securityManager) { this.securityManager = securityManager; - RepositoryManager.taskQueueManager = taskQueueManager; - INSTANCE = this; } - + /** * [used by Spring] * @param userCourseInformationsManager @@ -147,7 +147,9 @@ public class RepositoryManager extends BasicManager { /** * @return Singleton. */ - public static RepositoryManager getInstance() { return INSTANCE; } + public static RepositoryManager getInstance() { + return CoreSpringFactory.getImpl(RepositoryManager.class); + } /** * @param initialAuthor @@ -195,10 +197,10 @@ public class RepositoryManager extends BasicManager { * Update repo entry. * @param re */ - public void updateRepositoryEntry(RepositoryEntry re) { + /*public void updateRepositoryEntry(RepositoryEntry re) { re.setLastModified(new Date()); DBFactory.getInstance().updateObject(re); - } + }*/ /** * Delete repo entry. @@ -212,8 +214,16 @@ public class RepositoryManager extends BasicManager { deleteImage(re); } - public void createTutorSecurityGroup(RepositoryEntry re) { - if(re.getTutorGroup() != null) return; + /** + * + * @param re + * @param update If true, update the repository immediately + * @return + */ + public RepositoryEntry createTutorSecurityGroup(RepositoryEntry re, boolean update) { + if(re.getTutorGroup() != null) { + return re; + } SecurityGroup tutorGroup = securityManager.createAndPersistSecurityGroup(); // member of this group may modify member's membership @@ -222,10 +232,21 @@ public class RepositoryManager extends BasicManager { // members of this group are always tutors also securityManager.createAndPersistPolicy(tutorGroup, Constants.PERMISSION_HASROLE, Constants.ORESOURCE_TUTOR); re.setTutorGroup(tutorGroup); + if(update) { + re = DBFactory.getInstance().getCurrentEntityManager().merge(re); + } + return re; } - public void createParticipantSecurityGroup(RepositoryEntry re) { - if(re.getParticipantGroup() != null) return; + /** + * + * @param re + * @param update If true, update the repository immediately + */ + public RepositoryEntry createParticipantSecurityGroup(RepositoryEntry re, boolean update) { + if(re.getParticipantGroup() != null) { + return re; + } SecurityGroup participantGroup = securityManager.createAndPersistSecurityGroup(); // member of this group may modify member's membership @@ -234,6 +255,10 @@ public class RepositoryManager extends BasicManager { // members of this group are always participants also securityManager.createAndPersistPolicy(participantGroup, Constants.PERMISSION_HASROLE, Constants.ORESOURCE_PARTICIPANT); re.setParticipantGroup(participantGroup); + if(update) { + re = DBFactory.getInstance().getCurrentEntityManager().merge(re); + } + return re; } public void createOwnerSecurityGroup(RepositoryEntry re) { @@ -393,6 +418,7 @@ public class RepositoryManager extends BasicManager { * @param the repository entry key (not the olatresourceable key) * @return Repo entry represented by key or null if no such entry or key is null. */ + @Transactional(readOnly=true) public RepositoryEntry lookupRepositoryEntry(Long key) { if (key == null) return null; return lookupRepositoryEntry(key, false) ; @@ -403,6 +429,7 @@ public class RepositoryManager extends BasicManager { * @param the repository entry key (not the olatresourceable key) * @return Repo entry represented by key or null if no such entry or key is null. */ + @Transactional(readOnly=true) public RepositoryEntry lookupRepositoryEntry(Long key, boolean strict) { if (key == null) return null; if(strict) { @@ -423,7 +450,8 @@ public class RepositoryManager extends BasicManager { } return entries.get(0); } - + + @Transactional(readOnly=true) public List<RepositoryEntry> lookupRepositoryEntries(Collection<Long> keys) { if (keys == null || keys.isEmpty()) { return Collections.emptyList(); @@ -451,6 +479,7 @@ public class RepositoryManager extends BasicManager { * @return the RepositorEntry or null if strict=false * @throws AssertException if the softkey could not be found (strict=true) */ + @Transactional(readOnly=true) public RepositoryEntry lookupRepositoryEntry(OLATResourceable resourceable, boolean strict) { OLATResource ores = (resourceable instanceof OLATResource) ? (OLATResource)resourceable : OLATResourceManager.getInstance().findResourceable(resourceable); @@ -619,48 +648,124 @@ public class RepositoryManager extends BasicManager { return false; } + private RepositoryEntry loadForUpdate(RepositoryEntry re) { + //first remove it from caches + DBFactory.getInstance().getCurrentEntityManager().detach(re); + + StringBuilder query = new StringBuilder(); + query.append("select v from ").append(RepositoryEntry.class.getName()).append(" as v ") + .append(" left join fetch v.olatResource as ores") + .append(" left join fetch v.ownerGroup as ownerGroup") + .append(" left join fetch v.participantGroup as participantGroup") + .append(" left join fetch v.tutorGroup as tutorGroup") + .append(" where v.key=:repoKey"); + + RepositoryEntry entry = DBFactory.getInstance().getCurrentEntityManager().createQuery(query.toString(), RepositoryEntry.class) + .setParameter("repoKey", re.getKey()) + .setLockMode(LockModeType.PESSIMISTIC_WRITE) + .getSingleResult(); + return entry; + } + + private void updateLifeCycle(RepositoryEntry reloadedRe) { + LifeCycleManager lcManager = LifeCycleManager.createInstanceFor(reloadedRe); + if (lcManager.lookupLifeCycleEntry(RepositoryDeletionManager.SEND_DELETE_EMAIL_ACTION) != null) { + log.audit("Repository-Deletion: Remove from delete-list repositoryEntry=" + reloadedRe); + lcManager.deleteTimestampFor(RepositoryDeletionManager.SEND_DELETE_EMAIL_ACTION); + } + } + /** * Increment the launch counter. * @param re */ - public void incrementLaunchCounter(RepositoryEntry re) { - taskQueueManager.addTask(new IncrementLaunchCounterBackgroundTask(re)); + @Transactional + public RepositoryEntry incrementLaunchCounter(RepositoryEntry re) { + RepositoryEntry reloadedRe = loadForUpdate(re); + if(reloadedRe == null) return null;//deleted + + reloadedRe.setLaunchCounter(reloadedRe.getLaunchCounter() + 1); + reloadedRe.setLastUsage(new Date()); + updateLifeCycle(reloadedRe); + + RepositoryEntry updatedRe = DBFactory.getInstance().getCurrentEntityManager().merge(reloadedRe); + DBFactory.getInstance().commitAndCloseSession(); + return updatedRe; } - + /** * Increment the download counter. * @param re */ - public void incrementDownloadCounter(final RepositoryEntry re) { - taskQueueManager.addTask(new IncrementDownloadCounterBackgroundTask(re)); + @Transactional + public RepositoryEntry incrementDownloadCounter( final RepositoryEntry re) { + RepositoryEntry reloadedRe = loadForUpdate(re); + if(reloadedRe == null) return null;//deleted + + reloadedRe.incrementDownloadCounter(); + reloadedRe.setLastUsage(new Date()); + updateLifeCycle(reloadedRe); + RepositoryEntry updatedRe = DBFactory.getInstance().getCurrentEntityManager().merge(reloadedRe); + DBFactory.getInstance().commitAndCloseSession(); + return updatedRe; } /** * Set last-usage date to to now for certain repository-entry. * @param */ - public static void setLastUsageNowFor(final RepositoryEntry re) { - if (re != null) { - taskQueueManager.addTask(new SetLastUsageBackgroundTask(re)); - } + @Transactional + public RepositoryEntry setLastUsageNowFor(final RepositoryEntry re) { + if (re == null) return null; + RepositoryEntry reloadedRe = loadForUpdate(re); + reloadedRe.setLastUsage(new Date()); + RepositoryEntry updatedRe = DBFactory.getInstance().getCurrentEntityManager().merge(reloadedRe); + DBFactory.getInstance().commitAndCloseSession(); + return updatedRe; } - public void setAccess(final RepositoryEntry re, int access, boolean membersOnly ) { - SetAccessBackgroundTask task = new SetAccessBackgroundTask(re, access, membersOnly); - taskQueueManager.addTask(task); - task.waitForDone(); + @Transactional + public RepositoryEntry setAccess(final RepositoryEntry re, int access, boolean membersOnly ) { + RepositoryEntry reloadedRe = loadForUpdate(re); + reloadedRe.setAccess(access); + reloadedRe.setMembersOnly(membersOnly);//fxdiff VCRP-1,2: access control of resources + + RepositoryEntry updatedRe = DBFactory.getInstance().getCurrentEntityManager().merge(reloadedRe); + DBFactory.getInstance().commitAndCloseSession(); + return updatedRe; } - public void setDescriptionAndName(final RepositoryEntry re, String displayName, String description ) { - SetDescriptionNameBackgroundTask task = new SetDescriptionNameBackgroundTask(re, displayName, description); - taskQueueManager.addTask(task); - task.waitForDone(); + /** + * + * @param re + * @param displayName If null, nothing happen + * @param description If null, nothing happen + * @return + */ + @Transactional + public RepositoryEntry setDescriptionAndName(final RepositoryEntry re, String displayName, String description ) { + RepositoryEntry reloadedRe = loadForUpdate(re); + if(StringHelper.containsNonWhitespace(displayName)) { + reloadedRe.setDisplayname(displayName); + } + if(StringHelper.containsNonWhitespace(description)) { + reloadedRe.setDescription(description); + } + RepositoryEntry updatedRe = DBFactory.getInstance().getCurrentEntityManager().merge(reloadedRe); + DBFactory.getInstance().commitAndCloseSession(); + return updatedRe; } - public void setProperties(final RepositoryEntry re, boolean canCopy, boolean canReference, boolean canLaunch, boolean canDownload ) { - SetPropertiesBackgroundTask task = new SetPropertiesBackgroundTask(re, canCopy, canReference, canLaunch, canDownload); - taskQueueManager.addTask(task); - task.waitForDone(); + @Transactional + public RepositoryEntry setProperties(final RepositoryEntry re, boolean canCopy, boolean canReference, boolean canLaunch, boolean canDownload ) { + RepositoryEntry reloadedRe = loadForUpdate(re); + reloadedRe.setCanCopy(canCopy); + reloadedRe.setCanReference(canReference); + reloadedRe.setCanLaunch(canLaunch); + reloadedRe.setCanDownload(canDownload); + RepositoryEntry updatedRe = DBFactory.getInstance().getCurrentEntityManager().merge(reloadedRe); + DBFactory.getInstance().commitAndCloseSession(); + return updatedRe; } diff --git a/src/main/java/org/olat/repository/_spring/repositoryContext.xml b/src/main/java/org/olat/repository/_spring/repositoryContext.xml index 360ec651ddd70ae14550d69a7c54f04cee30c9fe..0d3c773f0100950cd592ebdcc886a330cfbf4edd 100644 --- a/src/main/java/org/olat/repository/_spring/repositoryContext.xml +++ b/src/main/java/org/olat/repository/_spring/repositoryContext.xml @@ -22,17 +22,10 @@ <bean id="repositoryManager" class="org.olat.repository.RepositoryManager"> - <constructor-arg index="0" ref="baseSecurityManager" /> - <constructor-arg index="1" ref="org.olat.core.commons.persistence.async.BackgroundTaskQueueManager" /> <property name="userCourseInformationsManager" ref="userCourseInformationsManager"/> <property name="imageHelper" ref="imageHelper"/> <property name="dbInstance" ref="database"/> + <property name="securityManager" ref="baseSecurityManager" /> </bean> -<!-- BackgroundTaskQueueManager for increment launch-,download-counter and set LastUsage in background thread --> -<bean id="org.olat.core.commons.persistence.async.BackgroundTaskQueueManager" class="org.olat.repository.async.BackgroundTaskQueueManager" destroy-method="destroy"> - <!-- Number of retries when a task failed e.g. incrementLaunchCounter try 20 times to increment when a exception occurs --> - <property name="maxRetry" value="20"/> -</bean> - </beans> \ No newline at end of file diff --git a/src/main/java/org/olat/repository/async/AbstractBackgroundTask.java b/src/main/java/org/olat/repository/async/AbstractBackgroundTask.java deleted file mode 100644 index a115eaae7eae960668ea3d9c934bd5e154075602..0000000000000000000000000000000000000000 --- a/src/main/java/org/olat/repository/async/AbstractBackgroundTask.java +++ /dev/null @@ -1,143 +0,0 @@ -/** -* OLAT - Online Learning and Training<br> -* http://www.olat.org -* <p> -* Licensed under the Apache License, Version 2.0 (the "License"); <br> -* you may not use this file except in compliance with the License.<br> -* You may obtain a copy of the License at -* <p> -* http://www.apache.org/licenses/LICENSE-2.0 -* <p> -* Unless required by applicable law or agreed to in writing,<br> -* software distributed under the License is distributed on an "AS IS" BASIS, <br> -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. <br> -* See the License for the specific language governing permissions and <br> -* limitations under the License. -* <p> -* Copyright (c) since 2004 at Multimedia- & E-Learning Services (MELS),<br> -* University of Zurich, Switzerland. -* <hr> -* <a href="http://www.openolat.org"> -* OpenOLAT - Online Learning and Training</a><br> -* This file has been modified by the OpenOLAT community. Changes are licensed -* under the Apache 2.0 license as the original file. -*/ -package org.olat.repository.async; - -import org.hibernate.HibernateException; -import org.olat.core.commons.persistence.DBFactory; -import org.olat.core.logging.DBRuntimeException; -import org.olat.core.logging.OLog; -import org.olat.core.logging.Tracing; - - -/** - * @author Christian Guretzki - */ -public abstract class AbstractBackgroundTask implements BackgroundTask { - private static OLog log = Tracing.createLoggerFor(AbstractBackgroundTask.class); - - private int maxRetry = 1000;// 0 = endless retry - - private boolean taskDone = false; - - public AbstractBackgroundTask() { - } - - public void execute() { - boolean finished = false; - int retry = 0; - while(!finished ) { - try { - executeTask(); - DBFactory.getInstance().commitAndCloseSession(); - finished = true; - // catch all exception because other cluster nodes can write data concurrently - } catch (DBRuntimeException re) { - log.debug("DBRuntimeException in executeTask retry=" + retry + " Ex=" + re); - retry++; - finished = handleError( retry); - } catch (HibernateException re) { - log.debug("RuntimeException in executeTask retry=" + retry); - retry++; - finished = handleError( retry); - } catch (Error re) { - log.debug("Error in executeTask retry=" + retry); - retry++; - finished = handleError( retry); - } catch(Throwable th) { - log.debug("Error in executeTask retry=" + retry); - retry++; - finished = handleError( retry); - } - if (!finished) { - try { - Thread.sleep(5); - } catch (InterruptedException e) { - // empty is ok - } - } - } - if (retry > 0) { - if (retry >= maxRetry) { - log.error("Too many retries, check background-task , retry=" + retry ); - } else { - log.debug("retry=" + retry ); - } - } - log.debug("set taskDone=true this=" + this); - taskDone = true; - } - - - private boolean handleError( int retry) { - boolean finished = false; - if ( (maxRetry != 0 ) && (retry >= maxRetry) ){ - // finished because to many retries - finished = true; - } - try { - DBFactory.getInstance().rollbackAndCloseSession(); - log.debug("handleError DB-Session rolled back and closed"); - } catch (DBRuntimeException re) { - log.debug("###DBRuntimeException2, Could not rollbackAndCloseSession properly after Exception in BackgroundTask.execute"); - } catch (HibernateException re2) { - log.debug("###HibernateException2, Could not rollbackAndCloseSession properly after Exception in BackgroundTask.execute"); - } catch (Error re) { - log.debug("###Error2, Could not rollbackAndCloseSession properly after Exception in BackgroundTask.execute"); - } catch (Throwable th2) { - log.debug("###Could not rollbackAndCloseSession properly after Exception in BackgroundTask.execute" ); - } - return finished; - } - - public void setMaxRetry(int maxRetry) { - this.maxRetry = maxRetry; - } - - public abstract void executeTask(); - - public boolean isTaskDone() { - return taskDone; - } - - public void waitForDone() { - log.debug("waitForDone start"); - // Wait until background task is done or reach timeout - int counter = 0; - int COUNTER_LIMIT = 10; - while (!this.isTaskDone() && counter < COUNTER_LIMIT) { - try { - log.debug("waitForDone: this.isTaskDone()=" + this.isTaskDone() + " counter=" + counter + " this=" + this); - Thread.sleep(200); - counter++; - } catch (InterruptedException e) { - // no log - } - } - if (counter >= COUNTER_LIMIT) { - log.error("waitForDone: Could not finish BackgroundTask this=" + this); - } - } - -} diff --git a/src/main/java/org/olat/repository/async/BackgroundTask.java b/src/main/java/org/olat/repository/async/BackgroundTask.java deleted file mode 100644 index ff01ad6fec4e1c930dccef0e928c04c2d1a9e6a2..0000000000000000000000000000000000000000 --- a/src/main/java/org/olat/repository/async/BackgroundTask.java +++ /dev/null @@ -1,37 +0,0 @@ -/** -* OLAT - Online Learning and Training<br> -* http://www.olat.org -* <p> -* Licensed under the Apache License, Version 2.0 (the "License"); <br> -* you may not use this file except in compliance with the License.<br> -* You may obtain a copy of the License at -* <p> -* http://www.apache.org/licenses/LICENSE-2.0 -* <p> -* Unless required by applicable law or agreed to in writing,<br> -* software distributed under the License is distributed on an "AS IS" BASIS, <br> -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. <br> -* See the License for the specific language governing permissions and <br> -* limitations under the License. -* <p> -* Copyright (c) since 2004 at Multimedia- & E-Learning Services (MELS),<br> -* University of Zurich, Switzerland. -* <hr> -* <a href="http://www.openolat.org"> -* OpenOLAT - Online Learning and Training</a><br> -* This file has been modified by the OpenOLAT community. Changes are licensed -* under the Apache 2.0 license as the original file. -*/ -package org.olat.repository.async; - - -/** - * @author Christian Guretzki - */ -public interface BackgroundTask { - - public void execute(); - - public void setMaxRetry(int maxRetry); - -} diff --git a/src/main/java/org/olat/repository/async/BackgroundTaskQueueManager.java b/src/main/java/org/olat/repository/async/BackgroundTaskQueueManager.java deleted file mode 100644 index a50c83e9cd5ec80cd44ab3313ebe3de733c7b685..0000000000000000000000000000000000000000 --- a/src/main/java/org/olat/repository/async/BackgroundTaskQueueManager.java +++ /dev/null @@ -1,90 +0,0 @@ -/** -* OLAT - Online Learning and Training<br> -* http://www.olat.org -* <p> -* Licensed under the Apache License, Version 2.0 (the "License"); <br> -* you may not use this file except in compliance with the License.<br> -* You may obtain a copy of the License at -* <p> -* http://www.apache.org/licenses/LICENSE-2.0 -* <p> -* Unless required by applicable law or agreed to in writing,<br> -* software distributed under the License is distributed on an "AS IS" BASIS, <br> -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. <br> -* See the License for the specific language governing permissions and <br> -* limitations under the License. -* <p> -* Copyright (c) since 2004 at Multimedia- & E-Learning Services (MELS),<br> -* University of Zurich, Switzerland. -* <hr> -* <a href="http://www.openolat.org"> -* OpenOLAT - Online Learning and Training</a><br> -* This file has been modified by the OpenOLAT community. Changes are licensed -* under the Apache 2.0 license as the original file. -*/ -package org.olat.repository.async; - -import java.util.Queue; -import java.util.concurrent.ConcurrentLinkedQueue; - -import org.apache.log4j.Logger; -import org.olat.core.manager.BasicManager; - -/** - * !!!This is only for the Repository Manager. It's absolutely forbidden to use for something else!!! - * - * FIFO-queue for background job. Application can put-in 'background-task', the background-job check in a fix interval - * this queue and can execute task. If you look for scheduled tasks check TaskExecutorManager - * - * @author Christian Guretzki - */ -public class BackgroundTaskQueueManager extends BasicManager { - private static Logger log = Logger.getLogger(BackgroundTaskQueueManager.class.getName()); - - private Queue<BackgroundTask> backgroundTaskQueue; - - private int maxRetry; - - private TaskExecutorThread taskExecutor; - - /** - * [used by spring] - */ - private BackgroundTaskQueueManager() { - backgroundTaskQueue = new ConcurrentLinkedQueue<BackgroundTask>(); - taskExecutor = new TaskExecutorThread(backgroundTaskQueue); - taskExecutor.setDaemon(true); - taskExecutor.start(); - } - - /** - * [used by spring] - */ - public void destroy() { - taskExecutor.stopExecutor(); - addTask(new BackgroundTask() { - @Override - public void execute() { /* */ } - @Override - public void setMaxRetry(int maxRetry) { /* */ } - }); - } - - public Queue<BackgroundTask> getQueue() { - return backgroundTaskQueue; - } - - public void addTask(BackgroundTask task) { - log.debug("Add task=" + task); - task.setMaxRetry(maxRetry); - synchronized(backgroundTaskQueue) { - backgroundTaskQueue.offer(task); - backgroundTaskQueue.notifyAll(); - } - } - - public void setMaxRetry(int maxRetry) { - this.maxRetry = maxRetry; - } - -} diff --git a/src/main/java/org/olat/repository/async/IncrementDownloadCounterBackgroundTask.java b/src/main/java/org/olat/repository/async/IncrementDownloadCounterBackgroundTask.java deleted file mode 100644 index 23d1ef37c9251c449b8a8afc59dcb4ed23e06f48..0000000000000000000000000000000000000000 --- a/src/main/java/org/olat/repository/async/IncrementDownloadCounterBackgroundTask.java +++ /dev/null @@ -1,70 +0,0 @@ -/** -* OLAT - Online Learning and Training<br> -* http://www.olat.org -* <p> -* Licensed under the Apache License, Version 2.0 (the "License"); <br> -* you may not use this file except in compliance with the License.<br> -* You may obtain a copy of the License at -* <p> -* http://www.apache.org/licenses/LICENSE-2.0 -* <p> -* Unless required by applicable law or agreed to in writing,<br> -* software distributed under the License is distributed on an "AS IS" BASIS, <br> -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. <br> -* See the License for the specific language governing permissions and <br> -* limitations under the License. -* <p> -* Copyright (c) since 2004 at Multimedia- & E-Learning Services (MELS),<br> -* University of Zurich, Switzerland. -* <hr> -* <a href="http://www.openolat.org"> -* OpenOLAT - Online Learning and Training</a><br> -* This file has been modified by the OpenOLAT community. Changes are licensed -* under the Apache 2.0 license as the original file. -*/ -package org.olat.repository.async; - -import java.util.Date; - -import org.olat.commons.lifecycle.LifeCycleManager; -import org.olat.core.commons.persistence.DBFactory; -import org.olat.core.logging.OLog; -import org.olat.core.logging.Tracing; -import org.olat.repository.RepositoryEntry; -import org.olat.repository.RepositoryManager; -import org.olat.repository.delete.service.RepositoryDeletionManager; -import org.olat.testutils.codepoints.server.Codepoint; - - -/** - * @author Christian Guretzki - */ -public class IncrementDownloadCounterBackgroundTask extends AbstractBackgroundTask { - private static OLog log = Tracing.createLoggerFor(IncrementDownloadCounterBackgroundTask.class); - - private RepositoryEntry repositoryEntry; - - public IncrementDownloadCounterBackgroundTask(RepositoryEntry repositoryEntry) { - this.repositoryEntry = repositoryEntry; - } - public void executeTask() { - log.debug("IncrementDownloadCounterBackgroundTask executing with repositoryEntry=" + repositoryEntry); - // this code must not be synchronized because in case of exception we try it again - // this code must not have any error handling or retry, this will be done in super class - if ( RepositoryManager.getInstance().lookupRepositoryEntry(repositoryEntry.getKey()) != null ) { - RepositoryEntry reloadedRe = (RepositoryEntry) DBFactory.getInstance().loadObject(repositoryEntry, true); - reloadedRe.incrementDownloadCounter(); - reloadedRe.setLastUsage(new Date()); - LifeCycleManager lcManager = LifeCycleManager.createInstanceFor(reloadedRe); - if (lcManager.lookupLifeCycleEntry(RepositoryDeletionManager.SEND_DELETE_EMAIL_ACTION) != null) { - log.audit("Repository-Deletion: Remove from delete-list repositoryEntry=" + reloadedRe); - LifeCycleManager.createInstanceFor(reloadedRe).deleteTimestampFor(RepositoryDeletionManager.SEND_DELETE_EMAIL_ACTION); - } - Codepoint.hierarchicalCodepoint(IncrementDownloadCounterBackgroundTask.class, "executeTask-before-update", 1); - RepositoryManager.getInstance().updateRepositoryEntry(reloadedRe); - } else { - log.info("Could not executeTask, because repositoryEntry does no longer exist"); - } - } - -} diff --git a/src/main/java/org/olat/repository/async/IncrementLaunchCounterBackgroundTask.java b/src/main/java/org/olat/repository/async/IncrementLaunchCounterBackgroundTask.java deleted file mode 100644 index 5e2e68ef5313603978857f51c40d513304d64c95..0000000000000000000000000000000000000000 --- a/src/main/java/org/olat/repository/async/IncrementLaunchCounterBackgroundTask.java +++ /dev/null @@ -1,68 +0,0 @@ -/** -* OLAT - Online Learning and Training<br> -* http://www.olat.org -* <p> -* Licensed under the Apache License, Version 2.0 (the "License"); <br> -* you may not use this file except in compliance with the License.<br> -* You may obtain a copy of the License at -* <p> -* http://www.apache.org/licenses/LICENSE-2.0 -* <p> -* Unless required by applicable law or agreed to in writing,<br> -* software distributed under the License is distributed on an "AS IS" BASIS, <br> -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. <br> -* See the License for the specific language governing permissions and <br> -* limitations under the License. -* <p> -* Copyright (c) since 2004 at Multimedia- & E-Learning Services (MELS),<br> -* University of Zurich, Switzerland. -* <hr> -* <a href="http://www.openolat.org"> -* OpenOLAT - Online Learning and Training</a><br> -* This file has been modified by the OpenOLAT community. Changes are licensed -* under the Apache 2.0 license as the original file. -*/ -package org.olat.repository.async; - -import java.util.Date; - -import org.olat.commons.lifecycle.LifeCycleManager; -import org.olat.core.commons.persistence.DBFactory; -import org.olat.core.logging.OLog; -import org.olat.core.logging.Tracing; -import org.olat.repository.RepositoryEntry; -import org.olat.repository.RepositoryManager; -import org.olat.repository.delete.service.RepositoryDeletionManager; - - -/** - * @author Christian Guretzki - */ -public class IncrementLaunchCounterBackgroundTask extends AbstractBackgroundTask { - private static OLog log = Tracing.createLoggerFor(IncrementLaunchCounterBackgroundTask.class); - - private RepositoryEntry repositoryEntry; - - public IncrementLaunchCounterBackgroundTask(RepositoryEntry repositoryEntry) { - this.repositoryEntry = repositoryEntry; - } - public void executeTask() { - log.debug("IncrementLaunchCounterBackgroundTask executing with repositoryEntry=" + repositoryEntry); - // this code must not be synchronized because in case of exception we try it again - // this code must not have any error handling or retry, this will be done in super class - if ( RepositoryManager.getInstance().lookupRepositoryEntry(repositoryEntry.getKey()) != null ) { - RepositoryEntry reloadedRe = (RepositoryEntry) DBFactory.getInstance().loadObject(repositoryEntry, true); - reloadedRe.incrementLaunchCounter(); - reloadedRe.setLastUsage(new Date()); - LifeCycleManager lcManager = LifeCycleManager.createInstanceFor(reloadedRe); - if (lcManager.lookupLifeCycleEntry(RepositoryDeletionManager.SEND_DELETE_EMAIL_ACTION) != null) { - log.audit("Repository-Deletion: Remove from delete-list repositoryEntry=" + reloadedRe); - LifeCycleManager.createInstanceFor(reloadedRe).deleteTimestampFor(RepositoryDeletionManager.SEND_DELETE_EMAIL_ACTION); - } - RepositoryManager.getInstance().updateRepositoryEntry(reloadedRe); - } else { - log.info("Could not executeTask, because repositoryEntry does no longer exist"); - } - } - -} diff --git a/src/main/java/org/olat/repository/async/SetAccessBackgroundTask.java b/src/main/java/org/olat/repository/async/SetAccessBackgroundTask.java deleted file mode 100644 index 71beb1636e2cc4cf8e263a6250320fd54eb20960..0000000000000000000000000000000000000000 --- a/src/main/java/org/olat/repository/async/SetAccessBackgroundTask.java +++ /dev/null @@ -1,66 +0,0 @@ -/** -* OLAT - Online Learning and Training<br> -* http://www.olat.org -* <p> -* Licensed under the Apache License, Version 2.0 (the "License"); <br> -* you may not use this file except in compliance with the License.<br> -* You may obtain a copy of the License at -* <p> -* http://www.apache.org/licenses/LICENSE-2.0 -* <p> -* Unless required by applicable law or agreed to in writing,<br> -* software distributed under the License is distributed on an "AS IS" BASIS, <br> -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. <br> -* See the License for the specific language governing permissions and <br> -* limitations under the License. -* <p> -* Copyright (c) since 2004 at Multimedia- & E-Learning Services (MELS),<br> -* University of Zurich, Switzerland. -* <hr> -* <a href="http://www.openolat.org"> -* OpenOLAT - Online Learning and Training</a><br> -* This file has been modified by the OpenOLAT community. Changes are licensed -* under the Apache 2.0 license as the original file. -*/ -package org.olat.repository.async; - -import org.olat.core.commons.persistence.DBFactory; -import org.olat.core.logging.OLog; -import org.olat.core.logging.Tracing; -import org.olat.repository.RepositoryEntry; -import org.olat.repository.RepositoryManager; - - -/** - * @author Christian Guretzki - */ -public class SetAccessBackgroundTask extends AbstractBackgroundTask { - private static OLog log = Tracing.createLoggerFor(SetAccessBackgroundTask.class); - - private RepositoryEntry repositoryEntry; - private int access; - private boolean membersOnly;//fxdiff VCRP-1,2: access control of resources - - public SetAccessBackgroundTask(RepositoryEntry repositoryEntry, int access, boolean membersOnly) { - this.repositoryEntry = repositoryEntry; - this.access = access; - this.membersOnly = membersOnly; - } - - public void executeTask() { - log.debug("SetAccessBackgroundTask executing with repositoryEntry=" + repositoryEntry); - // this code must not be synchronized because in case of exception we try it again - // this code must not have any error handling or retry, this will be done in super class - if ( RepositoryManager.getInstance().lookupRepositoryEntry(repositoryEntry.getKey()) != null ) { - RepositoryEntry reloadedRe = (RepositoryEntry) DBFactory.getInstance().loadObject(repositoryEntry, true); - reloadedRe.setAccess(access); - reloadedRe.setMembersOnly(membersOnly);//fxdiff VCRP-1,2: access control of resources - RepositoryManager.getInstance().updateRepositoryEntry(reloadedRe); - log.debug("SetAccessBackgroundTask DONE for repositoryEntry=" + repositoryEntry + " this=" + this); - } else { - log.info("Could not executeTask, because repositoryEntry does no longer exist"); - } - } - - -} diff --git a/src/main/java/org/olat/repository/async/SetDescriptionNameBackgroundTask.java b/src/main/java/org/olat/repository/async/SetDescriptionNameBackgroundTask.java deleted file mode 100644 index ac075733fa5b8cf47478cecb65a7b0439777e62c..0000000000000000000000000000000000000000 --- a/src/main/java/org/olat/repository/async/SetDescriptionNameBackgroundTask.java +++ /dev/null @@ -1,65 +0,0 @@ -/** -* OLAT - Online Learning and Training<br> -* http://www.olat.org -* <p> -* Licensed under the Apache License, Version 2.0 (the "License"); <br> -* you may not use this file except in compliance with the License.<br> -* You may obtain a copy of the License at -* <p> -* http://www.apache.org/licenses/LICENSE-2.0 -* <p> -* Unless required by applicable law or agreed to in writing,<br> -* software distributed under the License is distributed on an "AS IS" BASIS, <br> -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. <br> -* See the License for the specific language governing permissions and <br> -* limitations under the License. -* <p> -* Copyright (c) since 2004 at Multimedia- & E-Learning Services (MELS),<br> -* University of Zurich, Switzerland. -* <hr> -* <a href="http://www.openolat.org"> -* OpenOLAT - Online Learning and Training</a><br> -* This file has been modified by the OpenOLAT community. Changes are licensed -* under the Apache 2.0 license as the original file. -*/ -package org.olat.repository.async; - -import org.olat.core.commons.persistence.DBFactory; -import org.olat.core.logging.OLog; -import org.olat.core.logging.Tracing; -import org.olat.repository.RepositoryEntry; -import org.olat.repository.RepositoryManager; - - -/** - * @author Christian Guretzki - */ -public class SetDescriptionNameBackgroundTask extends AbstractBackgroundTask { - private static OLog log = Tracing.createLoggerFor(SetDescriptionNameBackgroundTask.class); - - private RepositoryEntry repositoryEntry; - - private String displayname; - - private String description; - - public SetDescriptionNameBackgroundTask(RepositoryEntry repositoryEntry, String displayname, String description) { - this.repositoryEntry = repositoryEntry; - this.displayname = displayname; - this.description = description; - } - public void executeTask() { - log.debug("SetDescriptionNameBackgroundTask executing with repositoryEntry=" + repositoryEntry); - // this code must not be synchronized because in case of exception we try it again - // this code must not have any error handling or retry, this will be done in super class - if ( RepositoryManager.getInstance().lookupRepositoryEntry(repositoryEntry.getKey()) != null ) { - RepositoryEntry reloadedRe = (RepositoryEntry) DBFactory.getInstance().loadObject(repositoryEntry, true); - reloadedRe.setDisplayname(displayname); - reloadedRe.setDescription(description); - RepositoryManager.getInstance().updateRepositoryEntry(reloadedRe); - } else { - log.info("Could not executeTask, because repositoryEntry does no longer exist"); - } - } - -} diff --git a/src/main/java/org/olat/repository/async/SetLastUsageBackgroundTask.java b/src/main/java/org/olat/repository/async/SetLastUsageBackgroundTask.java deleted file mode 100644 index a553ff6ce7c4b4716db33ebc96ecbc2f6d030fe0..0000000000000000000000000000000000000000 --- a/src/main/java/org/olat/repository/async/SetLastUsageBackgroundTask.java +++ /dev/null @@ -1,67 +0,0 @@ -/** -* OLAT - Online Learning and Training<br> -* http://www.olat.org -* <p> -* Licensed under the Apache License, Version 2.0 (the "License"); <br> -* you may not use this file except in compliance with the License.<br> -* You may obtain a copy of the License at -* <p> -* http://www.apache.org/licenses/LICENSE-2.0 -* <p> -* Unless required by applicable law or agreed to in writing,<br> -* software distributed under the License is distributed on an "AS IS" BASIS, <br> -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. <br> -* See the License for the specific language governing permissions and <br> -* limitations under the License. -* <p> -* Copyright (c) since 2004 at Multimedia- & E-Learning Services (MELS),<br> -* University of Zurich, Switzerland. -* <hr> -* <a href="http://www.openolat.org"> -* OpenOLAT - Online Learning and Training</a><br> -* This file has been modified by the OpenOLAT community. Changes are licensed -* under the Apache 2.0 license as the original file. -*/ -package org.olat.repository.async; - -import java.util.Date; - -import org.olat.commons.lifecycle.LifeCycleManager; -import org.olat.core.commons.persistence.DBFactory; -import org.olat.core.logging.OLog; -import org.olat.core.logging.Tracing; -import org.olat.repository.RepositoryEntry; -import org.olat.repository.RepositoryManager; -import org.olat.repository.delete.service.RepositoryDeletionManager; - - -/** - * @author Christian Guretzki - */ -public class SetLastUsageBackgroundTask extends AbstractBackgroundTask { - private static OLog log = Tracing.createLoggerFor(SetLastUsageBackgroundTask.class); - - private RepositoryEntry repositoryEntry; - - public SetLastUsageBackgroundTask(RepositoryEntry repositoryEntry) { - this.repositoryEntry = repositoryEntry; - } - public void executeTask() { - log.debug("SetLastUsageBackgroundTask executing with repositoryEntry=" + repositoryEntry); - // this code must not be synchronized because in case of exception we try it again - // this code must not have any error handling or retry, this will be done in super class - if ( RepositoryManager.getInstance().lookupRepositoryEntry(repositoryEntry.getKey()) != null ) { - RepositoryEntry reloadedRe = (RepositoryEntry) DBFactory.getInstance().loadObject(repositoryEntry, true); - reloadedRe.setLastUsage(new Date()); - LifeCycleManager lcManager = LifeCycleManager.createInstanceFor(reloadedRe); - if (lcManager.lookupLifeCycleEntry(RepositoryDeletionManager.SEND_DELETE_EMAIL_ACTION) != null) { - log.audit("Repository-Deletion: Remove from delete-list repositoryEntry=" + reloadedRe); - lcManager.deleteTimestampFor(RepositoryDeletionManager.SEND_DELETE_EMAIL_ACTION); - } - RepositoryManager.getInstance().updateRepositoryEntry(reloadedRe); - } else { - log.info("Could not executeTask, because repositoryEntry does no longer exist"); - } - } - -} diff --git a/src/main/java/org/olat/repository/async/SetPropertiesBackgroundTask.java b/src/main/java/org/olat/repository/async/SetPropertiesBackgroundTask.java deleted file mode 100644 index 6b1a272b30da31f74865ba62900a2bd11c367ca2..0000000000000000000000000000000000000000 --- a/src/main/java/org/olat/repository/async/SetPropertiesBackgroundTask.java +++ /dev/null @@ -1,71 +0,0 @@ -/** -* OLAT - Online Learning and Training<br> -* http://www.olat.org -* <p> -* Licensed under the Apache License, Version 2.0 (the "License"); <br> -* you may not use this file except in compliance with the License.<br> -* You may obtain a copy of the License at -* <p> -* http://www.apache.org/licenses/LICENSE-2.0 -* <p> -* Unless required by applicable law or agreed to in writing,<br> -* software distributed under the License is distributed on an "AS IS" BASIS, <br> -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. <br> -* See the License for the specific language governing permissions and <br> -* limitations under the License. -* <p> -* Copyright (c) since 2004 at Multimedia- & E-Learning Services (MELS),<br> -* University of Zurich, Switzerland. -* <hr> -* <a href="http://www.openolat.org"> -* OpenOLAT - Online Learning and Training</a><br> -* This file has been modified by the OpenOLAT community. Changes are licensed -* under the Apache 2.0 license as the original file. -*/ -package org.olat.repository.async; - -import org.olat.core.commons.persistence.DBFactory; -import org.olat.core.logging.OLog; -import org.olat.core.logging.Tracing; -import org.olat.repository.RepositoryEntry; -import org.olat.repository.RepositoryManager; - - -/** - * @author Christian Guretzki - */ -public class SetPropertiesBackgroundTask extends AbstractBackgroundTask { - private static OLog log = Tracing.createLoggerFor(SetPropertiesBackgroundTask.class); - - private RepositoryEntry repositoryEntry; - - private boolean canCopy; - private boolean canReference; - private boolean canLaunch; - private boolean canDownload; - - - public SetPropertiesBackgroundTask(RepositoryEntry repositoryEntry, boolean canCopy, boolean canReference, boolean canLaunch, boolean canDownload) { - this.repositoryEntry = repositoryEntry; - this.canCopy = canCopy; - this.canReference = canReference; - this.canLaunch = canLaunch; - this.canDownload = canDownload; - } - public void executeTask() { - log.debug("SetPropertiesBackgroundTask executing with repositoryEntry=" + repositoryEntry); - // this code must not be synchronized because in case of exception we try it again - // this code must not have any error handling or retry, this will be done in super class - if ( RepositoryManager.getInstance().lookupRepositoryEntry(repositoryEntry.getKey()) != null ) { - RepositoryEntry reloadedRe = (RepositoryEntry) DBFactory.getInstance().loadObject(repositoryEntry, true); - reloadedRe.setCanCopy(canCopy); - reloadedRe.setCanReference(canReference); - reloadedRe.setCanLaunch(canLaunch); - reloadedRe.setCanDownload(canDownload); - RepositoryManager.getInstance().updateRepositoryEntry(reloadedRe); - } else { - log.info("Could not executeTask, because repositoryEntry does no longer exist"); - } - } - -} diff --git a/src/main/java/org/olat/repository/async/TaskExecutorThread.java b/src/main/java/org/olat/repository/async/TaskExecutorThread.java deleted file mode 100644 index ac052645138d6d87f69ce8bc576d088f5d9248b9..0000000000000000000000000000000000000000 --- a/src/main/java/org/olat/repository/async/TaskExecutorThread.java +++ /dev/null @@ -1,99 +0,0 @@ -/** -* OLAT - Online Learning and Training<br> -* http://www.olat.org -* <p> -* Licensed under the Apache License, Version 2.0 (the "License"); <br> -* you may not use this file except in compliance with the License.<br> -* You may obtain a copy of the License at -* <p> -* http://www.apache.org/licenses/LICENSE-2.0 -* <p> -* Unless required by applicable law or agreed to in writing,<br> -* software distributed under the License is distributed on an "AS IS" BASIS, <br> -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. <br> -* See the License for the specific language governing permissions and <br> -* limitations under the License. -* <p> -* Copyright (c) since 2004 at Multimedia- & E-Learning Services (MELS),<br> -* University of Zurich, Switzerland. -* <hr> -* <a href="http://www.openolat.org"> -* OpenOLAT - Online Learning and Training</a><br> -* This file has been modified by the OpenOLAT community. Changes are licensed -* under the Apache 2.0 license as the original file. -*/ -package org.olat.repository.async; - -import java.util.Queue; - -import org.olat.core.commons.persistence.DBFactory; -import org.olat.core.logging.OLog; -import org.olat.core.logging.Tracing; - -/** - * this is a special task executor system used only for learning resources. If you look for a general task Executor for scheduled tasks - * search for TaskExecutorManager which does Quartz scheduled tasks. - * TODO:gs may convert this to taskexecutor manager - * @author Christian Guretzki - */ -public class TaskExecutorThread extends Thread { - private static OLog log = Tracing.createLoggerFor(TaskExecutorThread.class); - private Queue<BackgroundTask> taskQueue; - private volatile boolean running = true; - - public TaskExecutorThread(Queue<BackgroundTask> taskQueue) { - super("TaskExecutorThread"); - this.taskQueue = taskQueue; - } - - public void stopExecutor() { - running = false; - } - - public void run() { - log.info("TaskExecutorThread started"); - while(running) { - synchronized(taskQueue) { - if (taskQueue.size() == 0) { - try { - log.debug("TaskExecutorThread waiting..."); - taskQueue.wait(); - } catch (InterruptedException e) { - log.error("Execption when waiting", e); - } - } - } - log.debug("TaskExecutorThread in working loop"); - if (taskQueue.size() > 0) { - // Queue is not empty - long startTime = 0; - if (log.isDebug()) { - startTime = System.currentTimeMillis(); - } - if (taskQueue.size() > 10) { - if (taskQueue.size() > 20) { - log.error("Too many item in background-job queue, queue-size=" + taskQueue.size() + ", check execution-time"); - } else { - log.warn("Many item in background-job queue, queue-size=" + taskQueue.size() + ", check execution-time"); - } - } - int executeCount = 0; - while(!taskQueue.isEmpty()) { - log.debug("TaskExecutorThread taskQueue is not empty => execute task"); - taskQueue.poll().execute(); - executeCount++; - } - // running in a seperate thread, we must close db-session after each run. - DBFactory.getInstance().commitAndCloseSession(); - if (log.isDebug()) { - long endTime = System.currentTimeMillis(); - log.debug("TaskExecutorThread executed in " + (endTime - startTime) + "ms, executeCount=" + executeCount ); - } - } else { - log.warn("taskQueue notified but queue was empty"); - } - } - log.info("TaskExecutorThread finished"); - } - -} diff --git a/src/main/java/org/olat/repository/async/doc-files/BackgroundJobDesign.png b/src/main/java/org/olat/repository/async/doc-files/BackgroundJobDesign.png deleted file mode 100644 index 87ac35dee102a4808ddeca07cbada8a0f40c56ce..0000000000000000000000000000000000000000 Binary files a/src/main/java/org/olat/repository/async/doc-files/BackgroundJobDesign.png and /dev/null differ diff --git a/src/main/java/org/olat/repository/async/doc-files/BackgroundJobDesign.vsd b/src/main/java/org/olat/repository/async/doc-files/BackgroundJobDesign.vsd deleted file mode 100644 index 905aed11310c5b0852fe0d51433ce7d5bb0f6446..0000000000000000000000000000000000000000 Binary files a/src/main/java/org/olat/repository/async/doc-files/BackgroundJobDesign.vsd and /dev/null differ diff --git a/src/main/java/org/olat/repository/async/package.html b/src/main/java/org/olat/repository/async/package.html deleted file mode 100644 index 166a16bfeaa6ad159969c5e8daaac78dfc7c8187..0000000000000000000000000000000000000000 --- a/src/main/java/org/olat/repository/async/package.html +++ /dev/null @@ -1,17 +0,0 @@ -<html> -<head> -</head> - -<body> - -Overview description of asynchron background task. -The business-logic can create background-task, which will be executed async by the background-db-updater job (QuarzJob). -This job runs with a configurable interval. The task will be added to FIFO queue. The queue will be checked by the background-db-updater job. - -<h3>Class Diagram</h3> -<p> -<img src="doc-files/BackgroundJobDesign.png"/> - - -</body> -</html> \ No newline at end of file diff --git a/src/main/java/org/olat/repository/controllers/RepositoryAddController.java b/src/main/java/org/olat/repository/controllers/RepositoryAddController.java index d6d6ee8554627dfb0e494da9446f4b84b186d185..8d93ae2f344570a2a7ebec4a2ebc32f85f8547dd 100644 --- a/src/main/java/org/olat/repository/controllers/RepositoryAddController.java +++ b/src/main/java/org/olat/repository/controllers/RepositoryAddController.java @@ -116,7 +116,6 @@ public class RepositoryAddController extends BasicController { private boolean workflowSuccessful = false; private Link cancelButton; private Link forwardButton; - private Panel panel; private String actionAddCommand, actionProcess; /** @@ -284,8 +283,7 @@ public class RepositoryAddController extends BasicController { repositoryadd.contextPut("typeIntro", typeIntro); forwardButton.setEnabled(false); forwardButton.setTextReasonForDisabling(translate("disabledforwardreason")); - panel = putInitialPanel(repositoryadd); - return; + putInitialPanel(repositoryadd); } /** @@ -312,19 +310,14 @@ public class RepositoryAddController extends BasicController { */ public void event(UserRequest ureq, Component source, Event event) { if (source == forwardButton){ - - //FIXME: this code belongs to the repo manager and not here! // finish transaction and add repository entry if (!addController.transactionFinishBeforeCreate()) return; //save current name and description from create from String displayName = addedEntry.getDisplayname(); String description = addedEntry.getDescription(); // Do set access for owner at the end, because unfinished course should be invisible - addedEntry = (RepositoryEntry) DBFactory.getInstance().loadObject(addedEntry); // need a reload from hibernate because create a new cp load a repository-entry (OLAT-5631) TODO: 7.1 Refactor in method getRepositoryEntry() - addedEntry.setAccess(RepositoryEntry.ACC_OWNERS); - addedEntry.setDisplayname(displayName); - addedEntry.setDescription(description); - RepositoryManager.getInstance().updateRepositoryEntry(addedEntry); + addedEntry = RepositoryManager.getInstance().setDescriptionAndName(addedEntry, displayName, description); + addedEntry = RepositoryManager.getInstance().setAccess(addedEntry, RepositoryEntry.ACC_OWNERS, false); addController.repositoryEntryCreated(addedEntry); workflowSuccessful = true; diff --git a/src/main/java/org/olat/repository/controllers/RepositoryCopyController.java b/src/main/java/org/olat/repository/controllers/RepositoryCopyController.java index d87e14a3f1ee213e4b05db6399e8e509be96d0a5..53b0dc4bc87262dac9115a1676eb91585c0a8027 100644 --- a/src/main/java/org/olat/repository/controllers/RepositoryCopyController.java +++ b/src/main/java/org/olat/repository/controllers/RepositoryCopyController.java @@ -42,7 +42,6 @@ import org.olat.core.id.OLATResourceable; import org.olat.core.logging.DBRuntimeException; import org.olat.core.logging.OLog; import org.olat.core.logging.Tracing; -import org.olat.core.util.Util; import org.olat.repository.DetailsReadOnlyForm; import org.olat.repository.RepositoryEntry; import org.olat.repository.RepositoryManager; @@ -59,10 +58,7 @@ import org.olat.resource.OLATResourceManager; */ public class RepositoryCopyController extends BasicController { - OLog log = Tracing.createLoggerFor(this.getClass()); - - private static final String PACKAGE = Util.getPackageName(RepositoryManager.class); - private static final String VELOCITY_ROOT = Util.getPackageVelocityRoot(RepositoryManager.class); + private static final OLog log = Tracing.createLoggerFor(RepositoryCopyController.class); private VelocityContainer mainContainer; private Link cancelButton; @@ -142,9 +138,10 @@ public class RepositoryCopyController extends BasicController { fireEvent(ureq, new EntryChangedEvent(sourceEntry, EntryChangedEvent.DELETED)); return; } - newEntry = descriptionController.getRepositoryEntry(); + String displayname = descriptionController.getRepositoryEntry().getDisplayname(); + String description = descriptionController.getRepositoryEntry().getDescription(); //update needed to save changed name and desc. - RepositoryManager.getInstance().updateRepositoryEntry(newEntry); + newEntry = RepositoryManager.getInstance().setDescriptionAndName(newEntry, displayname, description); RepositoryHandler typeToCopy = RepositoryHandlerFactory.getInstance().getRepositoryHandler(sourceEntry); IAddController addController = typeToCopy.createAddController(null, null, ureq, getWindowControl()); addController.repositoryEntryCreated(newEntry); diff --git a/src/main/java/org/olat/repository/controllers/RepositoryDetailsController.java b/src/main/java/org/olat/repository/controllers/RepositoryDetailsController.java index 639343a17f5acf95702c77df6b7442cc82123cbd..82e01a29b07d2b20214cd04bbcd7f520b7a9bcc5 100644 --- a/src/main/java/org/olat/repository/controllers/RepositoryDetailsController.java +++ b/src/main/java/org/olat/repository/controllers/RepositoryDetailsController.java @@ -958,16 +958,14 @@ public class RepositoryDetailsController extends BasicController implements Gene } else if (cmd.equals(ACTION_GROUPS_TUTOR)) { // edit tutor group if (!isOwner) throw new OLATSecurityException("Trying to access groupmanagement, but not allowed: user = " + ureq.getIdentity()); if(repositoryEntry.getTutorGroup() == null){ - RepositoryManager.getInstance().createTutorSecurityGroup(repositoryEntry); - RepositoryManager.getInstance().updateRepositoryEntry(repositoryEntry); + repositoryEntry = RepositoryManager.getInstance().createTutorSecurityGroup(repositoryEntry, true); } groupTutorEditController = doManageSecurityGroup(ureq, false, repositoryEntry.getTutorGroup(), "groups_tutor"); return; } else if (cmd.equals(ACTION_GROUPS_PARTICIPANT)) { // edit tutor group if (!isOwner) throw new OLATSecurityException("Trying to access groupmanagement, but not allowed: user = " + ureq.getIdentity()); if(repositoryEntry.getParticipantGroup() == null){ - RepositoryManager.getInstance().createParticipantSecurityGroup(repositoryEntry); - RepositoryManager.getInstance().updateRepositoryEntry(repositoryEntry); + repositoryEntry = RepositoryManager.getInstance().createParticipantSecurityGroup(repositoryEntry, true); } groupParticipantEditController = doManageSecurityGroup(ureq, false, repositoryEntry.getParticipantGroup(), "groups_participant"); return; @@ -1021,10 +1019,9 @@ public class RepositoryDetailsController extends BasicController implements Gene if (event == Event.CHANGED_EVENT) { // RepositoryEntry changed // setEntry(repositoryEditDescriptionController.getRepositoryEntry(), ureq); - this.repositoryEntry = (RepositoryEntry) DBFactory.getInstance().loadObject(repositoryEditDescriptionController.getRepositoryEntry()); // need a reload from hibernate because create a new cp load a repository-entry (OLAT-5631) TODO: 7.1 Refactor in method getRepositoryEntry() - this.repositoryEntry.setDisplayname(repositoryEditDescriptionController.getRepositoryEntry().getDisplayname()); - this.repositoryEntry.setDescription(repositoryEditDescriptionController.getRepositoryEntry().getDescription()); - RepositoryManager.getInstance().updateRepositoryEntry(this.repositoryEntry); + String displayname = repositoryEditDescriptionController.getRepositoryEntry().getDisplayname(); + String description = repositoryEditDescriptionController.getRepositoryEntry().getDescription(); + repositoryEntry = RepositoryManager.getInstance().setDescriptionAndName(repositoryEntry, displayname, description); // do not close upon save/upload image closeableModalController.deactivate(); updateView(ureq); } else if (event == Event.CANCELLED_EVENT) { diff --git a/src/main/java/org/olat/repository/delete/ReadyToDeleteController.java b/src/main/java/org/olat/repository/delete/ReadyToDeleteController.java index 5c1d0794579e7e4b2800621e26c99a37c42e269f..0149c89c11d779c3523a6d7c96b18f2251b4db90 100644 --- a/src/main/java/org/olat/repository/delete/ReadyToDeleteController.java +++ b/src/main/java/org/olat/repository/delete/ReadyToDeleteController.java @@ -115,7 +115,7 @@ public class ReadyToDeleteController extends BasicController { TableEvent te = (TableEvent) event; if (te.getActionId().equals(ACTION_SINGLESELECT_CHOOSE)) { int rowid = te.getRowId(); - RepositoryManager.setLastUsageNowFor( (RepositoryEntry) redtm.getObject(rowid) ); + RepositoryManager.getInstance().setLastUsageNowFor( (RepositoryEntry) redtm.getObject(rowid) ); updateRepositoryEntryList(); } } else if (event.getCommand().equals(Table.COMMAND_MULTISELECT)) { diff --git a/src/main/java/org/olat/repository/delete/SelectionController.java b/src/main/java/org/olat/repository/delete/SelectionController.java index a62c2881bd79818cca53ecebba0388f95ddb45b8..384e98cdc2b9653d7d98451b994f79b031abb68a 100644 --- a/src/main/java/org/olat/repository/delete/SelectionController.java +++ b/src/main/java/org/olat/repository/delete/SelectionController.java @@ -153,7 +153,7 @@ public class SelectionController extends BasicController { TableEvent te = (TableEvent) event; if (te.getActionId().equals(ACTION_SINGLESELECT_CHOOSE)) { int rowid = te.getRowId(); - RepositoryManager.setLastUsageNowFor( (RepositoryEntry) redtm.getObject(rowid) ); + RepositoryManager.getInstance().setLastUsageNowFor( (RepositoryEntry) redtm.getObject(rowid) ); updateRepositoryEntryList(); } } else if (event.getCommand().equals(Table.COMMAND_MULTISELECT)) { diff --git a/src/main/java/org/olat/repository/delete/StatusController.java b/src/main/java/org/olat/repository/delete/StatusController.java index d45e9a20053fc170c0c7a97f72992b29b40bc7b7..a106bb8ff0248201055e4aa631883c3b94d376e4 100644 --- a/src/main/java/org/olat/repository/delete/StatusController.java +++ b/src/main/java/org/olat/repository/delete/StatusController.java @@ -106,7 +106,7 @@ public class StatusController extends BasicController { TableEvent te = (TableEvent) event; if (te.getActionId().equals(ACTION_SINGLESELECT_CHOOSE)) { int rowid = te.getRowId(); - RepositoryManager.setLastUsageNowFor( (RepositoryEntry) redtm.getObject(rowid) ); + RepositoryManager.getInstance().setLastUsageNowFor( (RepositoryEntry) redtm.getObject(rowid) ); updateRepositoryEntryList(); } } diff --git a/src/main/java/org/olat/repository/delete/service/RepositoryDeletionManager.java b/src/main/java/org/olat/repository/delete/service/RepositoryDeletionManager.java index 857d176ed35e6ae3062723961d6bdca5e3e39363..9fefa92288cce7b93582164f7b20df78ccab6080 100644 --- a/src/main/java/org/olat/repository/delete/service/RepositoryDeletionManager.java +++ b/src/main/java/org/olat/repository/delete/service/RepositoryDeletionManager.java @@ -261,9 +261,9 @@ public class RepositoryDeletionManager extends BasicManager implements UserDataD } private void markSendEmailEvent(RepositoryEntry repositoryEntry) { - repositoryEntry = (RepositoryEntry)DBFactory.getInstance().loadObject(repositoryEntry); + //repositoryEntry = (RepositoryEntry)DBFactory.getInstance().loadObject(repositoryEntry); LifeCycleManager.createInstanceFor(repositoryEntry).markTimestampFor(SEND_DELETE_EMAIL_ACTION); - DBFactory.getInstance().updateObject(repositoryEntry); + //DBFactory.getInstance().updateObject(repositoryEntry); } diff --git a/src/main/java/org/olat/restapi/repository/RepositoryEntryResource.java b/src/main/java/org/olat/restapi/repository/RepositoryEntryResource.java index 18ea491a48f7bf3de369f8eec0e23841bddd6ade..dfd07a4761791045455f909a2c874c59bde40eea 100644 --- a/src/main/java/org/olat/restapi/repository/RepositoryEntryResource.java +++ b/src/main/java/org/olat/restapi/repository/RepositoryEntryResource.java @@ -223,14 +223,7 @@ public class RepositoryEntryResource { Identity identity = RestSecurityHelper.getUserRequest(request).getIdentity(); RepositoryEntry replacedRe; if(file == null) { - replacedRe = re; - if(StringHelper.containsNonWhitespace(displayname)) { - replacedRe.setDisplayname(displayname); - } - if(StringHelper.containsNonWhitespace(description)) { - replacedRe.setDescription(description); - } - RepositoryManager.getInstance().updateRepositoryEntry(replacedRe); + replacedRe = RepositoryManager.getInstance().setDescriptionAndName(re, displayname, description); } else { String tmpName = StringHelper.containsNonWhitespace(filename) ? filename : "import.zip"; tmpFile = getTmpFile(tmpName); @@ -245,8 +238,7 @@ public class RepositoryEntryResource { if(replacedRe == null) { return Response.serverError().status(Status.NOT_FOUND).build(); } else if (StringHelper.containsNonWhitespace(displayname)) { - replacedRe.setDisplayname(displayname); - RepositoryManager.getInstance().updateRepositoryEntry(replacedRe); + replacedRe = RepositoryManager.getInstance().setDescriptionAndName(replacedRe, displayname, null); } } RepositoryEntryVO vo = ObjectFactory.get(replacedRe); diff --git a/src/main/java/org/olat/restapi/repository/course/CoursesWebService.java b/src/main/java/org/olat/restapi/repository/course/CoursesWebService.java index 75fb8a6a07e09af82f1aa387e7b0a8a9a8307054..b57cbdab685153e6a0deb449a72fed72fd2364cd 100644 --- a/src/main/java/org/olat/restapi/repository/course/CoursesWebService.java +++ b/src/main/java/org/olat/restapi/repository/course/CoursesWebService.java @@ -522,7 +522,7 @@ public class CoursesWebService { courseConfig.setSharedFolderSoftkey(courseConfigVO.getSharedFolderSoftKey()); } } - RepositoryManager.getInstance().updateRepositoryEntry(addedEntry); + //RepositoryManager.getInstance().updateRepositoryEntry(addedEntry); CourseFactory.saveCourse(course.getResourceableId()); CourseFactory.closeCourseEditSession(course.getResourceableId(), true); diff --git a/src/test/java/org/olat/commons/coordinate/CoordinatorTest.java b/src/test/java/org/olat/commons/coordinate/CoordinatorTest.java index 4290ff545c643194ffac709fcf7a5e661f535c09..44f243bd90bca07721fd4281ea1d20315fa78685 100644 --- a/src/test/java/org/olat/commons/coordinate/CoordinatorTest.java +++ b/src/test/java/org/olat/commons/coordinate/CoordinatorTest.java @@ -31,7 +31,6 @@ import static org.junit.Assert.fail; import java.util.ArrayList; import java.util.Collections; -import java.util.Date; import java.util.List; import org.apache.log4j.Logger; @@ -49,8 +48,6 @@ import org.olat.core.util.coordinate.SyncerExecutor; import org.olat.core.util.resource.OresHelper; import org.olat.repository.RepositoryEntry; import org.olat.repository.RepositoryManager; -import org.olat.resource.OLATResource; -import org.olat.resource.OLATResourceManager; import org.olat.test.OlatTestCase; /** @@ -347,7 +344,7 @@ public class CoordinatorTest extends OlatTestCase { SecurityGroup ownerGroup = BaseSecurityManager.getInstance().createAndPersistSecurityGroup(); re.setOwnerGroup(ownerGroup); RepositoryManager.getInstance().saveRepositoryEntry(re); - DBFactory.getInstance().closeSession(); + DBFactory.getInstance().commitAndCloseSession(); // 1. Do job without doInSync System.out.println("testDoInSyncPerformance: start test with doInSync"); @@ -392,12 +389,9 @@ public class CoordinatorTest extends OlatTestCase { } private Boolean doTestPerformanceJob(RepositoryEntry re) { - RepositoryEntry reloadedRe = (RepositoryEntry) DBFactory.getInstance().loadObject(re, true); - reloadedRe.incrementLaunchCounter(); - reloadedRe.setLastUsage(new Date()); - RepositoryManager.getInstance().updateRepositoryEntry(reloadedRe); - return true; - } + RepositoryManager.getInstance().incrementLaunchCounter(re); + return true; + } diff --git a/src/test/java/org/olat/repository/RepositoryManagerConcurrentTest.java b/src/test/java/org/olat/repository/RepositoryManagerConcurrentTest.java index 00c580526560c075701fe5409a927322cab0370f..32073b9aaf68a4ac55ebadd794723620016a0f6d 100644 --- a/src/test/java/org/olat/repository/RepositoryManagerConcurrentTest.java +++ b/src/test/java/org/olat/repository/RepositoryManagerConcurrentTest.java @@ -32,9 +32,7 @@ import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import java.util.ArrayList; -import java.util.Calendar; import java.util.Collections; -import java.util.Date; import java.util.List; import java.util.UUID; import java.util.concurrent.CountDownLatch; @@ -42,13 +40,11 @@ import java.util.concurrent.TimeUnit; import org.junit.After; import org.junit.Before; -import org.junit.Ignore; import org.junit.Test; import org.olat.basesecurity.BaseSecurity; import org.olat.basesecurity.BaseSecurityManager; import org.olat.basesecurity.Constants; import org.olat.basesecurity.SecurityGroup; -import org.olat.commons.coordinate.cluster.ClusterSyncer; import org.olat.core.commons.persistence.DB; import org.olat.core.commons.persistence.DBFactory; import org.olat.core.id.Identity; @@ -56,19 +52,11 @@ import org.olat.core.id.OLATResourceable; import org.olat.core.id.Roles; import org.olat.core.logging.OLog; import org.olat.core.logging.Tracing; -import org.olat.core.util.coordinate.CoordinatorManager; -import org.olat.core.util.coordinate.Syncer; import org.olat.resource.OLATResource; import org.olat.resource.OLATResourceManager; import org.olat.test.JMSCodePointServerJunitHelper; import org.olat.test.JunitTestHelper; import org.olat.test.OlatTestCase; -import org.olat.testutils.codepoints.client.BreakpointStateException; -import org.olat.testutils.codepoints.client.CodepointClient; -import org.olat.testutils.codepoints.client.CodepointClientFactory; -import org.olat.testutils.codepoints.client.CodepointRef; -import org.olat.testutils.codepoints.client.CommunicationException; -import org.olat.testutils.codepoints.client.TemporaryPausedThread; /** * Initial Date: Mar 26, 2004 @@ -191,9 +179,8 @@ public class RepositoryManagerConcurrentTest extends OlatTestCase { /** * */ - @Test public void testIncrementLaunchCounter() { - Syncer syncer = CoordinatorManager.getInstance().getCoordinator().getSyncer(); - assertTrue("syncer is not of type 'ClusterSyncer'", syncer instanceof ClusterSyncer); + @Test + public void testIncrementLaunchCounter() { RepositoryEntry repositoryEntry = createRepositoryCG("T1_perf2"); final Long keyRepo = repositoryEntry.getKey(); final OLATResourceable resourceable = repositoryEntry.getOlatResource(); @@ -212,20 +199,14 @@ public class RepositoryManagerConcurrentTest extends OlatTestCase { } long endTime = System.currentTimeMillis(); System.out.println("testIncrementLaunchCounter time=" + (endTime - startTime) + " for " + loop + " incrementLaunchCounter calls"); - sleep(2000); } - sleep(20000); RepositoryEntry repositoryEntry2 = RepositoryManager.getInstance().lookupRepositoryEntry(keyRepo); assertEquals("Wrong value of incrementLaunch counter",mainLoop * loop,repositoryEntry2.getLaunchCounter()); System.out.println("testIncrementLaunchCounter finished"); } - - /** - * - */ - @Test public void testIncrementDownloadCounter() { - Syncer syncer = CoordinatorManager.getInstance().getCoordinator().getSyncer(); - assertTrue("syncer is not of type 'ClusterSyncer'", syncer instanceof ClusterSyncer); + + @Test + public void testIncrementDownloadCounter() { RepositoryEntry repositoryEntry = createRepositoryCG("T1_perf2"); final Long keyRepo = repositoryEntry.getKey(); final OLATResourceable resourceable = repositoryEntry.getOlatResource(); @@ -244,95 +225,52 @@ public class RepositoryManagerConcurrentTest extends OlatTestCase { } long endTime = System.currentTimeMillis(); System.out.println("testIncrementDownloadCounter time=" + (endTime - startTime) + " for " + loop + " incrementDownloadCounter calls"); - sleep(2000); } - sleep(20000); RepositoryEntry repositoryEntry2 = RepositoryManager.getInstance().lookupRepositoryEntry(keyRepo); assertEquals("Wrong value of incrementLaunch counter",mainLoop * loop,repositoryEntry2.getDownloadCounter()); System.out.println("testIncrementDownloadCounter finished"); } - - - /** - * Test synchronization between same RepositoryEntry and setLastUsageNowFor, incrementLaunchCounter and incrementDownloadCounter. - * This test starts 4 threads : - * 2 to call setLastUsageNowFor, - * 1 to call incrementLaunchCounter - * 1 to call incrementDownloadCounter - * Breakpoint is set for 'setLastUsageNowFor', all other calls must wait. - */ - @Test @Ignore //this test doesn't test anything, and result is fully random - public void testSetLastUsageNowFor() { - Date lastSetLastUsageDate = null; - Syncer syncer = CoordinatorManager.getInstance().getCoordinator().getSyncer(); - assertTrue("syncer is not of type 'ClusterSyncer'", syncer instanceof ClusterSyncer); - - final int loop = 500; - RepositoryEntry repositoryEntry = createRepositoryCG("T1_perf2"); - final Long keyRepo = repositoryEntry.getKey(); - final OLATResourceable resourceable = repositoryEntry.getOlatResource(); - assertNotNull(resourceable); - DBFactory.getInstance().closeSession(); - long startTime = System.currentTimeMillis(); - for (int i = 0; i < loop; i++) { - // 1. load RepositoryEntry - RepositoryEntry repositoryEntryT1 = RepositoryManager.getInstance().lookupRepositoryEntry(keyRepo); - RepositoryManager.setLastUsageNowFor(repositoryEntryT1); - lastSetLastUsageDate = Calendar.getInstance().getTime(); - DBFactory.getInstance().closeSession(); - } - long endTime = System.currentTimeMillis(); - sleep(20000); - - RepositoryEntry repositoryEntry2 = RepositoryManager.getInstance().lookupRepositoryEntry(keyRepo); - assertTrue("Wrong date-value of lastUsage, could not be before ",repositoryEntry2.getLastUsage().after(lastSetLastUsageDate) ); - System.out.println("testSetLastUsageNowFor time=" + (endTime - startTime) + " for " + loop + " testSetLastUsageNowFor calls"); - System.out.println("testSetLastUsageNowFor finished"); - } - @Test public void testConcurrentIncrementLaunchCounter() { + @Test + public void testConcurrentIncrementLaunchCounter() { final List<Exception> exceptionHolder = Collections.synchronizedList(new ArrayList<Exception>(1)); final List<Boolean> statusList = Collections.synchronizedList(new ArrayList<Boolean>(1)); - Syncer syncer = CoordinatorManager.getInstance().getCoordinator().getSyncer(); - assertTrue("syncer is not of type 'ClusterSyncer'", syncer instanceof ClusterSyncer); final int loop = 100; final int numberOfThreads = 3; - RepositoryEntry repositoryEntry = createRepositoryCG("T1_perf2"); + final RepositoryEntry repositoryEntry = createRepositoryCG("T1_perf2"); final Long keyRepo = repositoryEntry.getKey(); - final OLATResourceable resourceable = repositoryEntry.getOlatResource(); - assertNotNull(resourceable); - DBFactory.getInstance().closeSession(); + assertNotNull(repositoryEntry.getOlatResource()); + DBFactory.getInstance().commitAndCloseSession(); assertEquals("Launch counter was not 0", 0, repositoryEntry.getLaunchCounter() ); long startTime = System.currentTimeMillis(); + + final CountDownLatch doneSignal = new CountDownLatch(3); + // start thread 1 : incrementLaunchCounter / setAccess - new Thread(new Runnable() { + Thread thread1 = new Thread(){ public void run() { try { + sleep(10); for (int i = 1; i <= loop; i++) { // 1. load RepositoryEntry - RepositoryEntry repositoryEntryT1 = RepositoryManager.getInstance().lookupRepositoryEntry(keyRepo); - RepositoryManager.getInstance().incrementLaunchCounter(repositoryEntryT1); + RepositoryEntry re = RepositoryManager.getInstance().lookupRepositoryEntry(keyRepo); + re = RepositoryManager.getInstance().incrementLaunchCounter(re); if (i % 20 == 0 ) { int ACCESS_VALUE = 4; - System.out.println("RepositoryManagerTest: call setAccess i=" + i); //fxdiff VCRP-1,2: access control of resources - RepositoryManager.getInstance().setAccess(repositoryEntryT1, ACCESS_VALUE, false); - DBFactory.getInstance().closeSession(); + re = RepositoryManager.getInstance().setAccess(re, ACCESS_VALUE, false); RepositoryEntry repositoryEntryT1Reloaded = RepositoryManager.getInstance().lookupRepositoryEntry(keyRepo); - assertEquals("Wrong access value",ACCESS_VALUE,repositoryEntryT1Reloaded.getAccess()); + assertEquals("Wrong access value", ACCESS_VALUE, repositoryEntryT1Reloaded.getAccess()); } else if (i % 10 == 0 ) { int ACCESS_VALUE = 1; - System.out.println("RepositoryManagerTest: call setAccess i=" + i); //fxdiff VCRP-1,2: access control of resources - RepositoryManager.getInstance().setAccess(repositoryEntryT1, ACCESS_VALUE, false); - DBFactory.getInstance().closeSession(); + re = RepositoryManager.getInstance().setAccess(re, ACCESS_VALUE, false); RepositoryEntry repositoryEntryT1Reloaded = RepositoryManager.getInstance().lookupRepositoryEntry(keyRepo); assertEquals("Wrong access value",ACCESS_VALUE,repositoryEntryT1Reloaded.getAccess()); } - DBFactory.getInstance().closeSession(); + DBFactory.getInstance().commitAndCloseSession(); } - System.out.println("Thread-1: finished"); statusList.add(Boolean.TRUE); } catch (Exception e) { exceptionHolder.add(e); @@ -342,29 +280,30 @@ public class RepositoryManagerConcurrentTest extends OlatTestCase { } catch (Exception e) { // ignore } + doneSignal.countDown(); } - }}).start(); + } + }; + // start thread 2 : incrementLaunchCounter / setDescriptionAndName - new Thread(new Runnable() { + Thread thread2 = new Thread() { public void run() { try { + sleep(10); for (int i = 1; i <= loop; i++) { // 1. load RepositoryEntry - RepositoryEntry repositoryEntryT1 = RepositoryManager.getInstance().lookupRepositoryEntry(keyRepo); - RepositoryManager.getInstance().incrementLaunchCounter(repositoryEntryT1); + RepositoryEntry re = RepositoryManager.getInstance().lookupRepositoryEntry(keyRepo); + re = RepositoryManager.getInstance().incrementLaunchCounter(re); if (i % 25 == 0 ) { String displayName = "DisplayName" + i; String description = "Description" + i; - System.out.println("RepositoryManagerTest: call setDescriptionAndName"); - RepositoryManager.getInstance().setDescriptionAndName(repositoryEntryT1, displayName,description); - DBFactory.getInstance().closeSession(); - RepositoryEntry repositoryEntryT1Reloaded = RepositoryManager.getInstance().lookupRepositoryEntry(keyRepo); - assertEquals("Wrong displayName value",displayName,repositoryEntryT1Reloaded.getDisplayname()); - assertEquals("Wrong description value",description,repositoryEntryT1Reloaded.getDescription()); + re = RepositoryManager.getInstance().setDescriptionAndName(re, displayName,description); + RepositoryEntry reReloaded = RepositoryManager.getInstance().lookupRepositoryEntry(keyRepo); + assertEquals("Wrong displayName value", displayName, reReloaded.getDisplayname()); + assertEquals("Wrong description value", description, reReloaded.getDescription()); } - DBFactory.getInstance().closeSession(); + DBFactory.getInstance().commitAndCloseSession(); } - System.out.println("Thread-1: finished"); statusList.add(Boolean.TRUE); } catch (Exception e) { exceptionHolder.add(e); @@ -374,38 +313,37 @@ public class RepositoryManagerConcurrentTest extends OlatTestCase { } catch (Exception e) { // ignore } + doneSignal.countDown(); } - }}).start(); + } + }; + // start thread 3 - new Thread(new Runnable() { + Thread thread3 = new Thread() { public void run() { try { + sleep(10); for (int i = 1; i <= loop; i++) { // 1. load RepositoryEntry - RepositoryEntry repositoryEntryT1 = RepositoryManager.getInstance().lookupRepositoryEntry(keyRepo); - RepositoryManager.getInstance().incrementLaunchCounter(repositoryEntryT1); + RepositoryEntry re = RepositoryManager.getInstance().lookupRepositoryEntry(keyRepo); + re = RepositoryManager.getInstance().incrementLaunchCounter(re); if (i % 30 == 0 ) { - System.out.println("RepositoryManagerTest: call setProperties i=" + i); - RepositoryManager.getInstance().setProperties(repositoryEntryT1, true, false, true, false); - DBFactory.getInstance().closeSession(); - RepositoryEntry repositoryEntryT1Reloaded = RepositoryManager.getInstance().lookupRepositoryEntry(keyRepo); - assertEquals("Wrong canCopy value",true,repositoryEntryT1Reloaded.getCanCopy()); - assertEquals("Wrong getCanReference value",false,repositoryEntryT1Reloaded.getCanReference()); - assertEquals("Wrong getCanLaunch value",true,repositoryEntryT1Reloaded.getCanLaunch()); - assertEquals("Wrong getCanDownload value",false,repositoryEntryT1Reloaded.getCanDownload()); + re = RepositoryManager.getInstance().setProperties(re, true, false, true, false); + RepositoryEntry reT3Reloaded = RepositoryManager.getInstance().lookupRepositoryEntry(keyRepo); + assertEquals("Wrong canCopy value", true, reT3Reloaded.getCanCopy()); + assertEquals("Wrong getCanReference value",false, reT3Reloaded.getCanReference()); + assertEquals("Wrong getCanLaunch value", true, reT3Reloaded.getCanLaunch()); + assertEquals("Wrong getCanDownload value", false, reT3Reloaded.getCanDownload()); } else if (i % 15 == 0 ) { - System.out.println("RepositoryManagerTest: call setProperties i=" + i); - RepositoryManager.getInstance().setProperties(repositoryEntryT1, false, true, false, true); - DBFactory.getInstance().closeSession(); - RepositoryEntry repositoryEntryT1Reloaded = RepositoryManager.getInstance().lookupRepositoryEntry(keyRepo); - assertEquals("Wrong canCopy value",false,repositoryEntryT1Reloaded.getCanCopy()); - assertEquals("Wrong getCanReference value",true,repositoryEntryT1Reloaded.getCanReference()); - assertEquals("Wrong getCanLaunch value",false,repositoryEntryT1Reloaded.getCanLaunch() ); - assertEquals("Wrong getCanDownload value",true,repositoryEntryT1Reloaded.getCanDownload()); + re = RepositoryManager.getInstance().setProperties(re, false, true, false, true); + RepositoryEntry reT3Reloaded = RepositoryManager.getInstance().lookupRepositoryEntry(keyRepo); + assertEquals("Wrong canCopy value", false, reT3Reloaded.getCanCopy()); + assertEquals("Wrong getCanReference value", true, reT3Reloaded.getCanReference()); + assertEquals("Wrong getCanLaunch value", false, reT3Reloaded.getCanLaunch() ); + assertEquals("Wrong getCanDownload value", true, reT3Reloaded.getCanDownload()); } - DBFactory.getInstance().closeSession(); + DBFactory.getInstance().commitAndCloseSession(); } - System.out.println("Thread-1: finished"); statusList.add(Boolean.TRUE); } catch (Exception e) { exceptionHolder.add(e); @@ -415,21 +353,41 @@ public class RepositoryManagerConcurrentTest extends OlatTestCase { } catch (Exception e) { // ignore } + doneSignal.countDown(); } - }}).start(); + } + }; - long endTime = System.currentTimeMillis(); - sleep(20000); - RepositoryEntry repositoryEntry2 = RepositoryManager.getInstance().lookupRepositoryEntry(keyRepo); - assertEquals("Worng value of incrementLaunch counter",loop * numberOfThreads,repositoryEntry2.getLaunchCounter()); - System.out.println("testConcurrentIncrementLaunchCounter time=" + (endTime - startTime) + " for " + loop + " incrementLaunchCounter calls"); + //go! go! go! + thread1.start(); + thread2.start(); + thread3.start(); + + try { + boolean interrupt = doneSignal.await(30, TimeUnit.SECONDS); + assertTrue("Test takes too long (more than 10s)", interrupt); + } catch (InterruptedException e) { + fail("" + e.getMessage()); + } + + for(Exception e:exceptionHolder) { + e.printStackTrace(); + } + assertEquals("Exceptions", 0, exceptionHolder.size()); + + RepositoryEntry re = RepositoryManager.getInstance().lookupRepositoryEntry(keyRepo); + assertEquals("Worng value of incrementLaunch counter", loop * numberOfThreads, re.getLaunchCounter()); + assertEquals("DisplayName" + loop, re.getDisplayname());//check if the displayname is correct + assertEquals("Description" + loop, re.getDescription()); + System.out.println("testConcurrentIncrementLaunchCounter time=" + (System.currentTimeMillis() - startTime) + " for " + loop + " incrementLaunchCounter calls"); System.out.println("testConcurrentIncrementLaunchCounter finished"); } /** * Compare async increment-call with sync 'setDscription' call. */ - @Test public void testIncrementLaunchCounterSetDescription() { + @Test + public void testIncrementLaunchCounterSetDescription() { System.out.println("testIncrementLaunchCounterSetDescription: START..."); RepositoryEntry repositoryEntry = createRepositoryCG("testIncrementLaunchCounterSetDescription"); DBFactory.getInstance().closeSession(); @@ -462,8 +420,8 @@ public class RepositoryManagerConcurrentTest extends OlatTestCase { * Thread 3 : update access-value on repository-entry directly after 200ms * Codepoint-breakpoint at IncrementDownloadCounterBackgroundTask in executeTask before update */ - @Ignore //the test works random - @Test public void testConcurrentIncrementLaunchCounterWithCodePoints() { + @Test + public void testConcurrentIncrementLaunchCounter_v2() { final List<Exception> exceptionHolder = Collections.synchronizedList(new ArrayList<Exception>(1)); RepositoryEntry repositoryEntry = createRepositoryCG("IncCodePoint"); @@ -474,19 +432,6 @@ public class RepositoryManagerConcurrentTest extends OlatTestCase { DBFactory.getInstance().closeSession(); assertEquals("Launch counter was not 0", 0, repositoryEntry.getLaunchCounter() ); - // enable breakpoint - CodepointClient codepointClient = null; - CodepointRef codepointRef = null; - try { - codepointClient = CodepointClientFactory.createCodepointClient("vm://localhost?broker.persistent=false", CODEPOINT_SERVER_ID); - codepointRef = codepointClient.getCodepoint("org.olat.repository.async.IncrementDownloadCounterBackgroundTask.executeTask-before-update"); - codepointRef.enableBreakpoint(); - } catch (Exception e) { - e.printStackTrace(); - fail("Could not initialzed CodepointClient"); - } - - final CountDownLatch doneSignal = new CountDownLatch(3); // thread 1 @@ -495,13 +440,13 @@ public class RepositoryManagerConcurrentTest extends OlatTestCase { try { Thread.sleep(100); RepositoryEntry repositoryEntryT1 = RepositoryManager.getInstance().lookupRepositoryEntry(keyRepo); - RepositoryManager.getInstance().incrementDownloadCounter(repositoryEntryT1); + repositoryEntryT1 = RepositoryManager.getInstance().incrementDownloadCounter(repositoryEntryT1); System.out.println("testConcurrentIncrementLaunchCounterWithCodePoints: Thread1 incremented download-counter"); } catch (Exception ex) { exceptionHolder.add(ex);// no exception should happen } finally { - doneSignal.countDown(); DBFactory.getInstance().commitAndCloseSession(); + doneSignal.countDown(); } }}; @@ -511,13 +456,13 @@ public class RepositoryManagerConcurrentTest extends OlatTestCase { try { Thread.sleep(300); RepositoryEntry repositoryEntryT2 = RepositoryManager.getInstance().lookupRepositoryEntry(keyRepo); - RepositoryManager.getInstance().incrementDownloadCounter(repositoryEntryT2); + repositoryEntryT2 = RepositoryManager.getInstance().incrementDownloadCounter(repositoryEntryT2); System.out.println("testConcurrentIncrementLaunchCounterWithCodePoints: Thread2 incremented download-counter"); } catch (Exception ex) { exceptionHolder.add(ex);// no exception should happen } finally { - doneSignal.countDown(); DBFactory.getInstance().commitAndCloseSession(); + doneSignal.countDown(); } }}; @@ -527,16 +472,14 @@ public class RepositoryManagerConcurrentTest extends OlatTestCase { try { Thread.sleep(200); RepositoryEntry repositoryEntryT3 = RepositoryManager.getInstance().lookupRepositoryEntry(keyRepo); - // change repository directly and not via RepositoryManager.setAccess(...) for testing - repositoryEntryT3.setAccess(access); - RepositoryManager.getInstance().updateRepositoryEntry(repositoryEntryT3); + repositoryEntryT3 = RepositoryManager.getInstance().setAccess(repositoryEntryT3, access, false); DBFactory.getInstance().closeSession(); System.out.println("testConcurrentIncrementLaunchCounterWithCodePoints: Thread3 setAccess DONE"); } catch (Exception ex) { exceptionHolder.add(ex);// no exception should happen } finally { - doneSignal.countDown(); DBFactory.getInstance().commitAndCloseSession(); + doneSignal.countDown(); } }}; @@ -551,29 +494,9 @@ public class RepositoryManagerConcurrentTest extends OlatTestCase { fail("" + e.getMessage()); } - try { - // to see all registered code-points: comment-in next 2 lines - // List<CodepointRef> codepointList = codepointClient.listAllCodepoints(); - // System.out.println("codepointList=" + codepointList); - System.out.println("testConcurrentIncrementLaunchCounterWithCodePoints start waiting for breakpoint reached"); - TemporaryPausedThread[] threads = codepointRef.waitForBreakpointReached(1000); - assertTrue("Did not reach breakpoint", threads.length > 0); - System.out.println("threads[0].getCodepointRef()=" + threads[0].getCodepointRef()); - codepointRef.disableBreakpoint(true); - System.out.println("testConcurrentIncrementLaunchCounterWithCodePoints breakpoint reached => continue"); - } catch (BreakpointStateException e) { - e.printStackTrace(); - fail("Codepoints: BreakpointStateException=" + e.getMessage()); - } catch (CommunicationException e) { - e.printStackTrace(); - fail("Codepoints: CommunicationException=" + e.getMessage()); - } - sleep(100); RepositoryEntry repositoryEntry2 = RepositoryManager.getInstance().lookupRepositoryEntry(keyRepo); assertEquals("Wrong value of incrementLaunch counter",2,repositoryEntry2.getDownloadCounter()); assertEquals("Wrong access value",access,repositoryEntry2.getAccess()); - - codepointClient.close(); System.out.println("testConcurrentIncrementLaunchCounterWithCodePoints finish successful"); } @@ -592,17 +515,4 @@ public class RepositoryManagerConcurrentTest extends OlatTestCase { DBFactory.getInstance().saveObject(d); return d; } - - /** - * - * @param milis the duration in miliseconds to sleep - */ - private void sleep(int milis) { - try { - Thread.sleep(milis); - } catch (InterruptedException e) { - e.printStackTrace(); - } - } - } diff --git a/src/test/java/org/olat/resource/accesscontrol/ACFrontendManagerTest.java b/src/test/java/org/olat/resource/accesscontrol/ACFrontendManagerTest.java index 2d71d54d4618e0a2aa0da77d8e4a1f79673d9f1e..c7d17b9aa95efe8ac6bdf2b531b0de406a3014f3 100644 --- a/src/test/java/org/olat/resource/accesscontrol/ACFrontendManagerTest.java +++ b/src/test/java/org/olat/resource/accesscontrol/ACFrontendManagerTest.java @@ -336,8 +336,8 @@ public class ACFrontendManagerTest extends OlatTestCase { re.setOlatResource(r); re.setAccess(RepositoryEntry.ACC_OWNERS_AUTHORS); - repositoryManager.createParticipantSecurityGroup(re); - repositoryManager.createTutorSecurityGroup(re); + repositoryManager.createParticipantSecurityGroup(re, false); + repositoryManager.createTutorSecurityGroup(re, false); repositoryManager.createOwnerSecurityGroup(re); repositoryManager.saveRepositoryEntry(re); dbInstance.commitAndCloseSession(); diff --git a/src/test/java/org/olat/test/JunitTestHelper.java b/src/test/java/org/olat/test/JunitTestHelper.java index abfe7a89d29ccde219dc9064e05aa2d9441d9b92..14c16292f48de71acb3a623dcbec9304853b08d3 100644 --- a/src/test/java/org/olat/test/JunitTestHelper.java +++ b/src/test/java/org/olat/test/JunitTestHelper.java @@ -163,8 +163,8 @@ public class JunitTestHelper { re.setResourcename("Lernen mit OLAT"); re.setDisplayname(r.getResourceableTypeName()); repositoryManager.createOwnerSecurityGroup(re); - repositoryManager.createTutorSecurityGroup(re); - repositoryManager.createParticipantSecurityGroup(re); + repositoryManager.createTutorSecurityGroup(re, false); + repositoryManager.createParticipantSecurityGroup(re, false); repositoryManager.saveRepositoryEntry(re); return re; }