diff --git a/src/main/java/org/olat/admin/UserAdminMainController.java b/src/main/java/org/olat/admin/UserAdminMainController.java index b700c2fb531e1f0a1295853a5e30971495a71cbd..e95b3af9ab76540c70a0dd4f9772fac692af09d5 100644 --- a/src/main/java/org/olat/admin/UserAdminMainController.java +++ b/src/main/java/org/olat/admin/UserAdminMainController.java @@ -71,10 +71,11 @@ import org.olat.core.id.context.StateEntry; import org.olat.core.logging.AssertException; import org.olat.core.logging.OLog; import org.olat.core.logging.Tracing; +import org.olat.core.logging.activity.ThreadLocalUserActivityLogger; import org.olat.core.util.coordinate.CoordinatorManager; import org.olat.core.util.coordinate.LockResult; -import org.olat.core.util.nodes.INode; import org.olat.core.util.resource.OresHelper; +import org.olat.util.logging.activity.LoggingResourceable; /** * <pre> @@ -123,6 +124,7 @@ public class UserAdminMainController extends MainLayoutBasicController implement // we always start with a search controller //fxdiff BAKS-7 Resume function OLATResourceable ores = OresHelper.createOLATResourceableInstance(firstNode.getUserObject().toString(), 0l); + ThreadLocalUserActivityLogger.addLoggingResourceInfo(LoggingResourceable.wrapBusinessPath(ores)); WindowControl bwControl = addToHistory(ureq, ores, null); contentCtr = new UsermanagerUserSearchController(ureq, bwControl); listenTo(contentCtr); // auto dispose later @@ -168,6 +170,8 @@ public class UserAdminMainController extends MainLayoutBasicController implement //fxdiff BAKS-7 Resume function OLATResourceable ores = OresHelper.createOLATResourceableInstance(Identity.class, identity.getKey()); + ThreadLocalUserActivityLogger.addLoggingResourceInfo(LoggingResourceable.wrapBusinessPath(ores)); + WindowControl bwControl; if(contentCtr instanceof UsermanagerUserSearchController) { UsermanagerUserSearchController ctrl = (UsermanagerUserSearchController)contentCtr; diff --git a/src/main/java/org/olat/admin/site/UserAdminSite.java b/src/main/java/org/olat/admin/site/UserAdminSite.java index 778541b0060b614656a82cfc405a899d48e7106c..93cf931f70f8b5bdab449127f6df9738c8d2a9e2 100644 --- a/src/main/java/org/olat/admin/site/UserAdminSite.java +++ b/src/main/java/org/olat/admin/site/UserAdminSite.java @@ -41,8 +41,10 @@ import org.olat.core.gui.translator.Translator; import org.olat.core.id.OLATResourceable; import org.olat.core.id.context.BusinessControlFactory; import org.olat.core.id.context.StateSite; +import org.olat.core.logging.activity.ThreadLocalUserActivityLogger; import org.olat.core.util.Util; import org.olat.core.util.resource.OresHelper; +import org.olat.util.logging.activity.LoggingResourceable; /** * Initial Date: Jan 16, 2006 * @author Florian Gnaegi @@ -78,6 +80,7 @@ public class UserAdminSite implements SiteInstance { public MainLayoutController createController(UserRequest ureq, WindowControl wControl) { //fxdiff BAKS-7 Resume function OLATResourceable ores = OresHelper.createOLATResourceableInstance(UserAdminSite.class, 0l); + ThreadLocalUserActivityLogger.addLoggingResourceInfo(LoggingResourceable.wrapBusinessPath(ores)); WindowControl bwControl = BusinessControlFactory.getInstance().createBusinessWindowControl(ureq, ores, new StateSite(this), wControl, true); MainLayoutController c = ControllerFactory.createLaunchController(ORES_OLATUSERADMINS, null, ureq, bwControl, true); return c; diff --git a/src/main/java/org/olat/admin/user/UsermanagerUserSearchController.java b/src/main/java/org/olat/admin/user/UsermanagerUserSearchController.java index d90b3a13e59224fbb7af73e6f845a9eacad61120..cb44c18d58111968a6b1eb781f406b1e13ca26d5 100644 --- a/src/main/java/org/olat/admin/user/UsermanagerUserSearchController.java +++ b/src/main/java/org/olat/admin/user/UsermanagerUserSearchController.java @@ -82,6 +82,7 @@ import org.olat.core.id.context.ContextEntry; import org.olat.core.id.context.StateEntry; import org.olat.core.id.context.StateMapped; import org.olat.core.logging.AssertException; +import org.olat.core.logging.activity.ThreadLocalUserActivityLogger; import org.olat.core.servlets.WebDAVManager; import org.olat.core.util.StringHelper; import org.olat.core.util.Util; @@ -95,6 +96,7 @@ import org.olat.modules.co.ContactFormController; import org.olat.user.UserInfoMainController; import org.olat.user.UserManager; import org.olat.user.propertyhandlers.UserPropertyHandler; +import org.olat.util.logging.activity.LoggingResourceable; /** * Initial Date: Jan 31, 2006 @@ -310,6 +312,7 @@ public class UsermanagerUserSearchController extends BasicController implements removeAsListenerAndDispose(tableCtr); //fxdiff BAKS-7 Resume function OLATResourceable ores = OresHelper.createOLATResourceableInstance("table", 0l); + ThreadLocalUserActivityLogger.addLoggingResourceInfo(LoggingResourceable.wrapBusinessPath(ores)); WindowControl bwControl = addToHistory(ureq, ores, null); tableCtr = ExtendedIdentitiesTableControllerFactory.createController(tdm, ureq, bwControl, actionEnabled); listenTo(tableCtr); diff --git a/src/main/java/org/olat/core/gui/control/generic/layout/GenericMainController.java b/src/main/java/org/olat/core/gui/control/generic/layout/GenericMainController.java index c14e2d7c9cde02ec771ee67ff4876190d1d746d4..98fdfbd6ac30975af315f1a79642f0103e68123f 100644 --- a/src/main/java/org/olat/core/gui/control/generic/layout/GenericMainController.java +++ b/src/main/java/org/olat/core/gui/control/generic/layout/GenericMainController.java @@ -49,9 +49,11 @@ import org.olat.core.id.OLATResourceable; import org.olat.core.id.context.ContextEntry; import org.olat.core.id.context.StateEntry; import org.olat.core.logging.AssertException; +import org.olat.core.logging.activity.ThreadLocalUserActivityLogger; import org.olat.core.util.CodeHelper; import org.olat.core.util.StringHelper; import org.olat.core.util.resource.OresHelper; +import org.olat.util.logging.activity.LoggingResourceable; /** * Description:<br> @@ -351,6 +353,7 @@ public abstract class GenericMainController extends MainLayoutBasicController { } else { ores = OresHelper.createOLATResourceableInstance(GMCMT, CodeHelper.getUniqueIDFromString(nE.getUniqueExtensionID())); } + ThreadLocalUserActivityLogger.addLoggingResourceInfo(LoggingResourceable.wrapBusinessPath(ores)); bwControl = addToHistory(ureq, ores, null); } } diff --git a/src/main/java/org/olat/core/logging/activity/CoreLoggingResourceable.java b/src/main/java/org/olat/core/logging/activity/CoreLoggingResourceable.java index a2e506c7cca9ac3566b58d272edf8ec4b91ddaf6..e1b1917aaf06e325fba3c8c971490b020b6738c0 100644 --- a/src/main/java/org/olat/core/logging/activity/CoreLoggingResourceable.java +++ b/src/main/java/org/olat/core/logging/activity/CoreLoggingResourceable.java @@ -26,7 +26,6 @@ package org.olat.core.logging.activity; -import org.olat.core.commons.persistence.PersistentObject; import org.olat.core.id.Identity; import org.olat.core.id.OLATResourceable; import org.olat.core.id.context.ContextEntry; @@ -97,6 +96,8 @@ public class CoreLoggingResourceable implements ILoggingResourceable { /** the OlatResourceable if we have one - null otherwise. Used for equals() and the businessPath check mainly **/ private final OLATResourceable resourceable_; + private final boolean ignorable_; + /** * Internal constructor to create a LoggingResourceable object with the given mandatory * parameters initialized. @@ -110,7 +111,7 @@ public class CoreLoggingResourceable implements ILoggingResourceable { * @param id the id to be stored to the database * @param name the name to be stored to the database */ - private CoreLoggingResourceable(OLATResourceable resourceable, ILoggingResourceableType resourceableType, String type, String id, String name) { + private CoreLoggingResourceable(OLATResourceable resourceable, ILoggingResourceableType resourceableType, String type, String id, String name, boolean ignorable) { if (type!=null && type.length()>32) { log_.error("<init> type too long. Allowed 32, actual: "+type.length()+", type="+type); type = type.substring(0, 32); @@ -128,6 +129,7 @@ public class CoreLoggingResourceable implements ILoggingResourceable { type_ = type; id_ = id; name_ = name; + ignorable_ = ignorable; } // @@ -153,7 +155,7 @@ public class CoreLoggingResourceable implements ILoggingResourceable { */ public static CoreLoggingResourceable wrapNonOlatResource(StringResourceableType type, String idForDB, String nameForDB) { return new CoreLoggingResourceable(null, type, - type.name(), idForDB, nameForDB); + type.name(), idForDB, nameForDB, false); } /** @@ -220,7 +222,7 @@ public class CoreLoggingResourceable implements ILoggingResourceable { */ public static CoreLoggingResourceable wrap(OLATResourceable olatResourceable, ILoggingResourceableType type) { return new CoreLoggingResourceable(olatResourceable, type, olatResourceable.getResourceableTypeName(), - String.valueOf(olatResourceable.getResourceableId()), ""); + String.valueOf(olatResourceable.getResourceableId()), "", false); } /** @@ -275,6 +277,11 @@ public class CoreLoggingResourceable implements ILoggingResourceable { return resourceableType_; } + @Override + public boolean isIgnorable() { + return ignorable_; + } + @Override public int hashCode() { return type_.hashCode()+id_.hashCode()+(resourceable_!=null ? resourceable_.getResourceableTypeName().hashCode()+(int)resourceable_.getResourceableId().longValue() : 0) + (resourceableType_!=null ? resourceableType_.hashCode() : 0); diff --git a/src/main/java/org/olat/core/logging/activity/CourseLoggingAction.java b/src/main/java/org/olat/core/logging/activity/CourseLoggingAction.java index d9054d48aeedc44b41d3954b6f2bf559f980cf45..b7d5ea81e066188ffa42cc9bfaa83dba82caf5d6 100644 --- a/src/main/java/org/olat/core/logging/activity/CourseLoggingAction.java +++ b/src/main/java/org/olat/core/logging/activity/CourseLoggingAction.java @@ -93,6 +93,7 @@ public class CourseLoggingAction extends BaseLoggingAction { public static final ILoggingAction COURSE_LEAVING = new CourseLoggingAction(ActionType.statistic, CrudAction.exit, ActionVerb.exit, ActionObject.course).setTypeList( new ResourceableTypeList().addMandatory(OlatResourceableType.course). + or().addMandatory(OlatResourceableType.course).addOptional(OlatResourceableType.node). or().addMandatory(OlatResourceableType.course, OlatResourceableType.genRepoEntry).addOptional(OlatResourceableType.businessGroup). or().addMandatory(OlatResourceableType.genRepoEntry, StringResourceableType.targetIdentity).addOptional(OlatResourceableType.businessGroup).addOptional(OlatResourceableType.sharedFolder).addOptional(OlatResourceableType.course). or().addMandatory(OlatResourceableType.course, StringResourceableType.targetIdentity)); diff --git a/src/main/java/org/olat/core/logging/activity/ILoggingResourceable.java b/src/main/java/org/olat/core/logging/activity/ILoggingResourceable.java index 6aee445ab415ec98c7893ebb526a989df9eefdda..8c48563d6f0acacfe54fa019f9bddede343b7f94 100644 --- a/src/main/java/org/olat/core/logging/activity/ILoggingResourceable.java +++ b/src/main/java/org/olat/core/logging/activity/ILoggingResourceable.java @@ -66,4 +66,11 @@ public interface ILoggingResourceable { * @return the ILoggingResourceableType of this LoggingResourceable */ public ILoggingResourceableType getResourceableType(); + + /** + * Some components of a list of context entries are used to recreate the + * controllers hierarchy by back button and haven't any meaning for logging. + * @return + */ + public boolean isIgnorable(); } diff --git a/src/main/java/org/olat/core/logging/activity/LearningResourceLoggingAction.java b/src/main/java/org/olat/core/logging/activity/LearningResourceLoggingAction.java index 97a66391a5498442a18fc28a5332cadc8f5256f0..4b36b6bf63bffbafc72f0930cbac7d0dc5fc7cc4 100644 --- a/src/main/java/org/olat/core/logging/activity/LearningResourceLoggingAction.java +++ b/src/main/java/org/olat/core/logging/activity/LearningResourceLoggingAction.java @@ -59,6 +59,8 @@ public class LearningResourceLoggingAction extends BaseLoggingAction { or().addMandatory(OlatResourceableType.course, OlatResourceableType.node, OlatResourceableType.wiki). // this is the case when you open a scorm resource as a course node or().addMandatory(OlatResourceableType.course, OlatResourceableType.node, StringResourceableType.scormResource). + // this is the case when you open a QTI resource as a course node + or().addMandatory(OlatResourceableType.course, OlatResourceableType.node, OlatResourceableType.iq). // this is another case of closing a resource or().addMandatory(OlatResourceableType.course, OlatResourceableType.node); public static final ILoggingAction LEARNING_RESOURCE_OPEN = diff --git a/src/main/java/org/olat/core/logging/activity/OlatResourceableType.java b/src/main/java/org/olat/core/logging/activity/OlatResourceableType.java index 646c0bde658af839433458919b3f69f8827f8ecb..db4333d1f2fcae8d6c92ef55785cbb70099d9a61 100644 --- a/src/main/java/org/olat/core/logging/activity/OlatResourceableType.java +++ b/src/main/java/org/olat/core/logging/activity/OlatResourceableType.java @@ -78,5 +78,8 @@ public enum OlatResourceableType implements ILoggingResourceableType { calendar, /** reprensents a portfolio map **/ - portfolio; + portfolio, + + /** business path component **/ + businessPath } \ No newline at end of file diff --git a/src/main/java/org/olat/core/logging/activity/ResourceableTypeList.java b/src/main/java/org/olat/core/logging/activity/ResourceableTypeList.java index 4877e618801b159f0c2bb8abc894c3266ad0f7b6..a7cb0d60b9df3d7820f8cfc88130d67b21b2ee63 100644 --- a/src/main/java/org/olat/core/logging/activity/ResourceableTypeList.java +++ b/src/main/java/org/olat/core/logging/activity/ResourceableTypeList.java @@ -267,6 +267,14 @@ public class ResourceableTypeList { } List<ILoggingResourceable> resourceInfosCopy = new LinkedList<ILoggingResourceable>(resourceInfos); + + for (Iterator<ILoggingResourceable> it = resourceInfosCopy.iterator(); it.hasNext();) { + if(it.next().isIgnorable()) { + it.remove(); + } + } + + List<ILoggingResourceableType> mandatory = getMandatory(); for (Iterator<ILoggingResourceableType> it = mandatory.iterator(); it.hasNext();) { ILoggingResourceableType type = it.next(); diff --git a/src/main/java/org/olat/core/logging/activity/ThreadLocalUserActivityLogger.java b/src/main/java/org/olat/core/logging/activity/ThreadLocalUserActivityLogger.java index f71be6af75b198d2be7578364bc5f3458fca1d5b..99af9e48ce9b9f18607273b683283db19e0f39a5 100644 --- a/src/main/java/org/olat/core/logging/activity/ThreadLocalUserActivityLogger.java +++ b/src/main/java/org/olat/core/logging/activity/ThreadLocalUserActivityLogger.java @@ -92,7 +92,9 @@ public class ThreadLocalUserActivityLogger { static IUserActivityLogger getUserActivityLogger() { IUserActivityLogger logger = userActivityLogger_.get(); if (logger==null) { - log_.warn("No UserActivityLogger set! Reinitializing now.", new Exception("stacktrace")); + if(log_.isDebug()) {//only generate this exception in debug + log_.warn("No UserActivityLogger set! Reinitializing now.", new Exception("stacktrace")); + } return new UserActivityLoggerImpl(); } return logger; diff --git a/src/main/java/org/olat/core/logging/activity/UserActivityLoggerImpl.java b/src/main/java/org/olat/core/logging/activity/UserActivityLoggerImpl.java index 2e20420a85490aa0d2ed85d9a0a6e3d72f494ce4..c04ffa3269ce0287f7a4d9494cafe0afe2f3bb20 100644 --- a/src/main/java/org/olat/core/logging/activity/UserActivityLoggerImpl.java +++ b/src/main/java/org/olat/core/logging/activity/UserActivityLoggerImpl.java @@ -32,7 +32,6 @@ import java.io.UnsupportedEncodingException; import java.io.Writer; import java.lang.reflect.InvocationTargetException; import java.util.ArrayList; -import java.util.Date; import java.util.Iterator; import java.util.LinkedList; import java.util.List; @@ -41,10 +40,8 @@ import java.util.Set; import javax.servlet.http.HttpServletRequest; -import org.hibernate.FlushMode; import org.olat.core.commons.persistence.DB; import org.olat.core.commons.persistence.DBFactory; -import org.olat.core.commons.persistence.DBQuery; import org.olat.core.gui.control.Controller; import org.olat.core.gui.control.WindowControl; import org.olat.core.id.Identity; @@ -509,7 +506,8 @@ public class UserActivityLoggerImpl implements IUserActivityLogger { } if (!foundIt) { String oresourceableOres = "n/a (null)"; - if (ce !=null && ce.getOLATResourceable() !=null) { + // SR: why generate exception for unuseable information??? + if (log_.isDebug() && ce !=null && ce.getOLATResourceable() !=null) { try { java.lang.reflect.Method getOlatResource = ce.getOLATResourceable().getClass().getDeclaredMethod("getOlatResource"); if (getOlatResource!=null) { @@ -532,8 +530,12 @@ public class UserActivityLoggerImpl implements IUserActivityLogger { ILoggingResourceable resourceInfo = it2.next(); log_.info("id: "+resourceInfo.getId()+", name="+resourceInfo.getName()+", type="+resourceInfo.getType()+", toString: "+resourceInfo.toString()); } - log_.warn("Could not find any LoggingResourceable corresponding to this ContextEntry: "+ce.toString(), - new Exception("UserActivityLoggerImpl.getCombinedOrderedLoggingResourceables()")); + if(log_.isDebug()) {//only generate the stacktrace in debug mode + log_.warn("Could not find any LoggingResourceable corresponding to this ContextEntry: "+ce.toString(), + new Exception("UserActivityLoggerImpl.getCombinedOrderedLoggingResourceables()")); + } else { + log_.warn("Could not find any LoggingResourceable corresponding to this ContextEntry: "+ce.toString(), null); + } } } } @@ -727,6 +729,12 @@ public class UserActivityLoggerImpl implements IUserActivityLogger { // alongside the log message // check if we have more than 4 - if we do, issue a log and remove the middle ones + for(Iterator<ILoggingResourceable> riIterator=resourceInfos.iterator(); riIterator.hasNext(); ) { + if(riIterator.next().isIgnorable()) { + riIterator.remove(); + } + } + if (resourceInfos.size()>4) { log_.warn("More than 4 resource infos set on a user activity log. Can only have 4. Having: "+resourceInfos.size()); int diff = resourceInfos.size()-4; diff --git a/src/main/java/org/olat/course/assessment/AssessmentLoggingAction.java b/src/main/java/org/olat/course/assessment/AssessmentLoggingAction.java index e9c42a98efaf5404522a80a4e1f8ecd46eab4d35..35915d08515d95e55c77f7e224211e9f2dc16436 100644 --- a/src/main/java/org/olat/course/assessment/AssessmentLoggingAction.java +++ b/src/main/java/org/olat/course/assessment/AssessmentLoggingAction.java @@ -61,21 +61,21 @@ import org.olat.core.logging.activity.StringResourceableType; // the stickyactiontype to admin public static final ILoggingAction ASSESSMENT_ATTEMPTS_UPDATED = new AssessmentLoggingAction(ActionType.statistic, CrudAction.update, ActionVerb.edit, ActionObject.testattempts).setTypeList( - new ResourceableTypeList().addMandatory(OlatResourceableType.course, OlatResourceableType.node, StringResourceableType.qtiAttempts, StringResourceableType.targetIdentity)); + new ResourceableTypeList().addMandatory(OlatResourceableType.course, OlatResourceableType.node, StringResourceableType.qtiAttempts).addOptional(StringResourceableType.targetIdentity)); public static final ILoggingAction ASSESSMENT_SCORE_UPDATED = new AssessmentLoggingAction(ActionType.statistic, CrudAction.update, ActionVerb.edit, ActionObject.testscore).setTypeList( - new ResourceableTypeList().addMandatory(OlatResourceableType.course, OlatResourceableType.node, StringResourceableType.qtiScore, StringResourceableType.targetIdentity)); + new ResourceableTypeList().addMandatory(OlatResourceableType.course, OlatResourceableType.node, StringResourceableType.qtiScore).addOptional(StringResourceableType.targetIdentity)); public static final ILoggingAction ASSESSMENT_PASSED_UPDATED = new AssessmentLoggingAction(ActionType.statistic, CrudAction.update, ActionVerb.edit, ActionObject.testsuccess).setTypeList( - new ResourceableTypeList().addMandatory(OlatResourceableType.course, OlatResourceableType.node, StringResourceableType.qtiPassed, StringResourceableType.targetIdentity)); + new ResourceableTypeList().addMandatory(OlatResourceableType.course, OlatResourceableType.node, StringResourceableType.qtiPassed).addOptional(StringResourceableType.targetIdentity)); // note that comments can only be set via a tutor, hence the following two are strict admin actions public static final ILoggingAction ASSESSMENT_USERCOMMENT_UPDATED = new AssessmentLoggingAction(ActionType.admin, CrudAction.update, ActionVerb.edit, ActionObject.testcomment).setTypeList( - new ResourceableTypeList().addMandatory(OlatResourceableType.course, OlatResourceableType.node, StringResourceableType.qtiUserComment, StringResourceableType.targetIdentity)); + new ResourceableTypeList().addMandatory(OlatResourceableType.course, OlatResourceableType.node, StringResourceableType.qtiUserComment).addOptional(StringResourceableType.targetIdentity)); public static final ILoggingAction ASSESSMENT_COACHCOMMENT_UPDATED = new AssessmentLoggingAction(ActionType.admin, CrudAction.update, ActionVerb.edit, ActionObject.testcomment).setTypeList( - new ResourceableTypeList().addMandatory(OlatResourceableType.course, OlatResourceableType.node, StringResourceableType.qtiCoachComment, StringResourceableType.targetIdentity)); + new ResourceableTypeList().addMandatory(OlatResourceableType.course, OlatResourceableType.node, StringResourceableType.qtiCoachComment).addOptional(StringResourceableType.targetIdentity)); /** diff --git a/src/main/java/org/olat/course/nodes/iq/IQRunController.java b/src/main/java/org/olat/course/nodes/iq/IQRunController.java index 235a5220a781815eea089db57c009393b00ab965..4ca8dd71395c0ae7b61f0889fcfc36cf3d312d3e 100644 --- a/src/main/java/org/olat/course/nodes/iq/IQRunController.java +++ b/src/main/java/org/olat/course/nodes/iq/IQRunController.java @@ -52,6 +52,7 @@ import org.olat.core.id.context.ContextEntry; import org.olat.core.id.context.StateEntry; import org.olat.core.logging.AssertException; import org.olat.core.logging.OLATRuntimeException; +import org.olat.core.logging.activity.ThreadLocalUserActivityLogger; import org.olat.core.util.Formatter; import org.olat.core.util.UserSession; import org.olat.core.util.event.EventBus; @@ -381,6 +382,7 @@ public class IQRunController extends BasicController implements GenericEventList //fxdiff BAKS-7 Resume function OLATResourceable ores = OresHelper.createOLATResourceableTypeWithoutCheck("test"); + ThreadLocalUserActivityLogger.addLoggingResourceInfo(LoggingResourceable.wrapBusinessPath(ores)); WindowControl bwControl = addToHistory(ureq, ores, null); Controller returnController = IQManager.getInstance().createIQDisplayController(modConfig, secCallback, ureq, bwControl, callingResId, callingResDetail); /* @@ -457,7 +459,6 @@ public class IQRunController extends BasicController implements GenericEventList IQSubmittedEvent se = (IQSubmittedEvent) event; AssessmentManager am = userCourseEnv.getCourseEnvironment().getAssessmentManager(); - // Save results in case of test if (type.equals(AssessmentInstance.QMD_ENTRY_TYPE_ASSESS)) { // update scoring overview for the user in the current course diff --git a/src/main/java/org/olat/group/site/GroupsManagementSite.java b/src/main/java/org/olat/group/site/GroupsManagementSite.java index fa50be2a580498002914f507222696adb34249ad..bc61e0370c92fd4a12fee92e7874782897a7bc7a 100644 --- a/src/main/java/org/olat/group/site/GroupsManagementSite.java +++ b/src/main/java/org/olat/group/site/GroupsManagementSite.java @@ -40,9 +40,11 @@ import org.olat.core.gui.translator.Translator; import org.olat.core.id.OLATResourceable; import org.olat.core.id.context.BusinessControlFactory; import org.olat.core.id.context.StateSite; +import org.olat.core.logging.activity.ThreadLocalUserActivityLogger; import org.olat.core.util.Util; import org.olat.core.util.resource.OresHelper; import org.olat.group.ui.context.BGContextManagementController; +import org.olat.util.logging.activity.LoggingResourceable; /** * Description:<br> @@ -83,6 +85,7 @@ public class GroupsManagementSite implements SiteInstance { public MainLayoutController createController(UserRequest ureq, WindowControl wControl) { //fxdiff BAKS-7 Resume function OLATResourceable ores = OresHelper.createOLATResourceableInstance(GroupsManagementSite.class, 0l); + ThreadLocalUserActivityLogger.addLoggingResourceInfo(LoggingResourceable.wrapBusinessPath(ores)); WindowControl bwControl = BusinessControlFactory.getInstance().createBusinessWindowControl(ureq, ores, new StateSite(this), wControl, true); MainLayoutController c = ControllerFactory.createLaunchController(ORES_GROUPSMANAGEMENT, null, ureq, bwControl, true); return c; diff --git a/src/main/java/org/olat/group/ui/run/BusinessGroupMainRunController.java b/src/main/java/org/olat/group/ui/run/BusinessGroupMainRunController.java index 44cd753186b3408f3765fd890d27a466844b6c3b..3ec6de5492f9cb679d2da480b4b7e11ddf298b91 100644 --- a/src/main/java/org/olat/group/ui/run/BusinessGroupMainRunController.java +++ b/src/main/java/org/olat/group/ui/run/BusinessGroupMainRunController.java @@ -713,6 +713,7 @@ public class BusinessGroupMainRunController extends MainLayoutBasicController im WindowControl bwControl = getWindowControl(); // calculate the new businesscontext for the forum clicked ContextEntry ce = BusinessControlFactory.getInstance().createContextEntry(ORES_TOOLCAL); + ThreadLocalUserActivityLogger.addLoggingResourceInfo(LoggingResourceable.wrapBusinessPath(ce.getOLATResourceable())); bwControl = BusinessControlFactory.getInstance().createBusinessWindowControl(ce, bwControl); collabToolCtr = collabTools.createCalendarController(ureq, bwControl, this.businessGroup, isAdmin); @@ -721,6 +722,7 @@ public class BusinessGroupMainRunController extends MainLayoutBasicController im } else if (ACTIVITY_MENUSELECT_INFORMATION.equals(cmd)) { //fxdiff BAKS-7 Resume function ContextEntry ce = BusinessControlFactory.getInstance().createContextEntry(ORES_TOOLMSG); + ThreadLocalUserActivityLogger.addLoggingResourceInfo(LoggingResourceable.wrapBusinessPath(ce.getOLATResourceable())); WindowControl bwControl = BusinessControlFactory.getInstance().createBusinessWindowControl(ce, getWindowControl()); collabToolCtr = collabTools.createNewsController(ureq, bwControl); listenTo(collabToolCtr); @@ -733,6 +735,7 @@ public class BusinessGroupMainRunController extends MainLayoutBasicController im WindowControl bwControl = getWindowControl(); // calculate the new businesscontext for the forum clicked ContextEntry ce = BusinessControlFactory.getInstance().createContextEntry(ORES_TOOLFOLDER); + ThreadLocalUserActivityLogger.addLoggingResourceInfo(LoggingResourceable.wrapBusinessPath(ce.getOLATResourceable())); bwControl = BusinessControlFactory.getInstance().createBusinessWindowControl(ce, bwControl); //fxdiff VCRP-8: collaboration tools folder access control collabToolCtr = collabTools.createFolderController(ureq, bwControl, businessGroup, isAdmin, sc); @@ -777,6 +780,7 @@ public class BusinessGroupMainRunController extends MainLayoutBasicController im private void doAdministration(UserRequest ureq) { removeAsListenerAndDispose(bgEditCntrllr); //fxdiff BAKS-7 Resume function + ThreadLocalUserActivityLogger.addLoggingResourceInfo(LoggingResourceable.wrapBusinessPath(ORES_TOOLADMIN)); WindowControl bwControl = BusinessControlFactory.getInstance().createBusinessWindowControl(ORES_TOOLADMIN, null, getWindowControl()); collabToolCtr = bgEditCntrllr = BGControllerFactory.getInstance().createEditControllerFor(ureq, bwControl, businessGroup); listenTo(bgEditCntrllr); diff --git a/src/main/java/org/olat/home/HomeSite.java b/src/main/java/org/olat/home/HomeSite.java index a57a88d94e12dc39eea49bc13c641b0833a95659..997b0e026fbfb35b4c22999e8d92f5c90cdc49a4 100644 --- a/src/main/java/org/olat/home/HomeSite.java +++ b/src/main/java/org/olat/home/HomeSite.java @@ -30,8 +30,10 @@ import org.olat.core.gui.translator.Translator; import org.olat.core.id.OLATResourceable; import org.olat.core.id.context.BusinessControlFactory; import org.olat.core.id.context.StateSite; +import org.olat.core.logging.activity.ThreadLocalUserActivityLogger; import org.olat.core.util.Util; import org.olat.core.util.resource.OresHelper; +import org.olat.util.logging.activity.LoggingResourceable; /** * <h3>Description:</h3> Instantiates the genericmainctrl for a minimal home @@ -62,6 +64,7 @@ public class HomeSite implements SiteInstance { @Override public MainLayoutController createController(UserRequest ureq, WindowControl wControl) { OLATResourceable ores = OresHelper.createOLATResourceableInstance(HomeSite.class, ureq.getIdentity().getKey()); + ThreadLocalUserActivityLogger.addLoggingResourceInfo(LoggingResourceable.wrapBusinessPath(ores)); WindowControl bwControl = BusinessControlFactory.getInstance().createBusinessWindowControl(ureq, ores, new StateSite(this), wControl, true); MainLayoutController c = new HomeMainController(ureq, bwControl); return c; diff --git a/src/main/java/org/olat/repository/site/RepositorySite.java b/src/main/java/org/olat/repository/site/RepositorySite.java index 21ee689d83c98c8169a6019736103a5db3f8a6d5..30d763f1cccaa0cadbaabffe579df5d87a5268da 100644 --- a/src/main/java/org/olat/repository/site/RepositorySite.java +++ b/src/main/java/org/olat/repository/site/RepositorySite.java @@ -40,9 +40,11 @@ import org.olat.core.gui.translator.Translator; import org.olat.core.id.OLATResourceable; import org.olat.core.id.context.BusinessControlFactory; import org.olat.core.id.context.StateSite; +import org.olat.core.logging.activity.ThreadLocalUserActivityLogger; import org.olat.core.util.Util; import org.olat.core.util.resource.OresHelper; import org.olat.repository.controllers.RepositoryMainController; +import org.olat.util.logging.activity.LoggingResourceable; /** * Description:<br> * TODO: Felix Jost Class Description for HomeSite @@ -85,6 +87,7 @@ public class RepositorySite implements SiteInstance { // for existing controller which are part of the main olat -> use the controllerfactory //fxdiff BAKS-7 Resume function OLATResourceable ores = OresHelper.createOLATResourceableInstance(RepositorySite.class, 0l); + ThreadLocalUserActivityLogger.addLoggingResourceInfo(LoggingResourceable.wrapBusinessPath(ores)); WindowControl bwControl = BusinessControlFactory.getInstance().createBusinessWindowControl(ureq, ores, new StateSite(this), wControl, true); MainLayoutController c = ControllerFactory.createLaunchController(ORES_REPO, null, ureq, bwControl, true); return c; diff --git a/src/main/java/org/olat/util/logging/activity/LoggingResourceable.java b/src/main/java/org/olat/util/logging/activity/LoggingResourceable.java index 3f9d6fb7fbf05c9963db7690facf9b3bb8d579fb..443fc21a36f0780b5439eb8c535cfac4c34f955b 100644 --- a/src/main/java/org/olat/util/logging/activity/LoggingResourceable.java +++ b/src/main/java/org/olat/util/logging/activity/LoggingResourceable.java @@ -127,6 +127,9 @@ public class LoggingResourceable implements ILoggingResourceable { /** the OlatResourceable if we have one - null otherwise. Used for equals() and the businessPath check mainly **/ private final OLATResourceable resourceable_; + + private final boolean ignorable; + /** * Restrict the given argument to the given number of bytes using UTF-8 encoding. * <p> @@ -193,12 +196,22 @@ public class LoggingResourceable implements ILoggingResourceable { * @param id the id to be stored to the database * @param name the name to be stored to the database */ - private LoggingResourceable(OLATResourceable resourceable, ILoggingResourceableType resourceableType, String type, String id, String name) { + private LoggingResourceable(OLATResourceable resourceable, ILoggingResourceableType resourceableType, String type, String id, String name, boolean ignorable) { type_ = restrictStringLength(type, MAX_TYPE_LEN, "type", true); id_ = restrictStringLength(id, MAX_ID_LEN, "id", true); name_ = restrictStringLength(name, MAX_NAME_LEN, "name", true); resourceable_ = resourceable; resourceableType_ = resourceableType; + this.ignorable = ignorable; + } + + /** + * These are ignored from the logging. + * @param olatResourceable + * @return + */ + public static LoggingResourceable wrapBusinessPath(OLATResourceable olatResourceable) { + return new LoggingResourceable(olatResourceable, OlatResourceableType.businessPath, "businessPath", "0", "", true); } // @@ -223,7 +236,7 @@ public class LoggingResourceable implements ILoggingResourceable { throw new IllegalArgumentException("olatResourceable must not be null"); } if (olatResourceable.equals(BusinessGroupMainRunController.ORES_TOOLWIKI)) { - return new LoggingResourceable(olatResourceable, OlatResourceableType.wiki, "wiki", "0", ""); + return new LoggingResourceable(olatResourceable, OlatResourceableType.wiki, "wiki", "0", "", false); } else { return wrap(olatResourceable, OlatResourceableType.wiki); } @@ -239,7 +252,7 @@ public class LoggingResourceable implements ILoggingResourceable { throw new IllegalArgumentException("olatResourceable must not be null"); } if (olatResourceable.equals(BusinessGroupMainRunController.ORES_TOOLPORTFOLIO)) { - return new LoggingResourceable(olatResourceable, OlatResourceableType.portfolio, "portfolio", "0", ""); + return new LoggingResourceable(olatResourceable, OlatResourceableType.portfolio, "portfolio", "0", "", false); } else { return wrap(olatResourceable, OlatResourceableType.portfolio); } @@ -262,14 +275,14 @@ public class LoggingResourceable implements ILoggingResourceable { } if (repoEntry!=null) { return new LoggingResourceable(repoEntry, type, repoEntry.getOlatResource().getResourceableTypeName(), - String.valueOf(repoEntry.getOlatResource().getResourceableId()), repoEntry.getDisplayname()); + String.valueOf(repoEntry.getOlatResource().getResourceableId()), repoEntry.getDisplayname(), false); } else if (olatResourceable instanceof OLATResource) { OLATResource olatResource = (OLATResource) olatResourceable; return new LoggingResourceable(olatResource, type, olatResource.getResourceableTypeName(), - String.valueOf(olatResource.getResourceableId()), String.valueOf(olatResource.getKey())); + String.valueOf(olatResource.getResourceableId()), String.valueOf(olatResource.getKey()), false); } else { return new LoggingResourceable(olatResourceable, type, olatResourceable.getResourceableTypeName(), - String.valueOf(olatResourceable.getResourceableId()), ""); + String.valueOf(olatResourceable.getResourceableId()), "", false); } } @@ -291,7 +304,7 @@ public class LoggingResourceable implements ILoggingResourceable { */ public static LoggingResourceable wrapNonOlatResource(StringResourceableType type, String idForDB, String nameForDB) { return new LoggingResourceable(null, type, - type.name(), idForDB, nameForDB); + type.name(), idForDB, nameForDB, false); } /** @@ -371,7 +384,7 @@ public class LoggingResourceable implements ILoggingResourceable { name = forumMessages.get(0).getTitle(); } return new LoggingResourceable(forum, OlatResourceableType.forum, forum.getResourceableTypeName(), - String.valueOf(forum.getResourceableId()), name); + String.valueOf(forum.getResourceableId()), name, false); } /** @@ -381,7 +394,7 @@ public class LoggingResourceable implements ILoggingResourceable { */ public static LoggingResourceable wrap(Message forumMessage) { return new LoggingResourceable(OresHelper.createOLATResourceableInstance(Message.class, forumMessage.getKey()), OlatResourceableType.forumMessage, OlatResourceableType.forumMessage.name(), - String.valueOf(forumMessage.getKey()), forumMessage.getTitle()); + String.valueOf(forumMessage.getKey()), forumMessage.getTitle(), false); } /** @@ -394,7 +407,7 @@ public class LoggingResourceable implements ILoggingResourceable { // truncate title after 230 chars if (title.length() > 230) title = title.substring(0, 229); return new LoggingResourceable(feed, OlatResourceableType.feed, feed.getResourceableTypeName(), - String.valueOf(feed.getResourceableId()), title); + String.valueOf(feed.getResourceableId()), title, false); } /** @@ -428,7 +441,7 @@ public class LoggingResourceable implements ILoggingResourceable { name = DEFAULT_COURSE_GROUP_CONTEXT_NAME; } return new LoggingResourceable(bgContext, OlatResourceableType.bgContext, bgContext.getGroupType(), - String.valueOf(bgContext.getResourceableId()), name); + String.valueOf(bgContext.getResourceableId()), name, false); } /** @@ -438,7 +451,7 @@ public class LoggingResourceable implements ILoggingResourceable { */ public static LoggingResourceable wrap(BusinessGroup group) { return new LoggingResourceable(group, OlatResourceableType.businessGroup, group.getResourceableTypeName(), - String.valueOf(group.getKey()), group.getName()); + String.valueOf(group.getKey()), group.getName(), false); } /** @@ -448,7 +461,7 @@ public class LoggingResourceable implements ILoggingResourceable { */ public static LoggingResourceable wrap(ICourse course) { return new LoggingResourceable(course, OlatResourceableType.course, course.getResourceableTypeName(), - String.valueOf(course.getResourceableId()), course.getCourseTitle()); + String.valueOf(course.getResourceableId()), course.getCourseTitle(), false); } /** @@ -465,10 +478,10 @@ public class LoggingResourceable implements ILoggingResourceable { Long id = Long.parseLong(ident); return new LoggingResourceable(OresHelper.createOLATResourceableInstance("CourseNode", id), OlatResourceableType.node, typeForLogging, - node.getIdent(), name); + node.getIdent(), name, false); } catch(NumberFormatException nfe) { return new LoggingResourceable(null, OlatResourceableType.node, typeForLogging, - node.getIdent(), name); + node.getIdent(), name, false); } } @@ -533,6 +546,11 @@ public class LoggingResourceable implements ILoggingResourceable { return resourceableType_; } + @Override + public boolean isIgnorable() { + return ignorable; + } + @Override public int hashCode() { return type_.hashCode()+(id_!=null ? id_.hashCode() : 1)+(resourceable_!=null ? resourceable_.getResourceableTypeName().hashCode()+(int)resourceable_.getResourceableId().longValue() : 0) + (resourceableType_!=null ? resourceableType_.hashCode() : 0);