From 4d83a389d71dda29235a2cf67919ec56b6df58ac Mon Sep 17 00:00:00 2001 From: srosse <none@none> Date: Fri, 24 May 2013 15:36:10 +0200 Subject: [PATCH] no-jira: in repository details, open the editor of course the same way it will opened from the course (with breadcrumbs) --- .../java/org/olat/course/CourseFactory.java | 30 +++++++++--------- .../olat/course/run/RunMainController.java | 31 +++++++++++-------- .../RepositoryDetailsController.java | 3 -- .../repository/handlers/CourseHandler.java | 6 ++-- 4 files changed, 36 insertions(+), 34 deletions(-) diff --git a/src/main/java/org/olat/course/CourseFactory.java b/src/main/java/org/olat/course/CourseFactory.java index 43048880cae..2aebb83a5ca 100644 --- a/src/main/java/org/olat/course/CourseFactory.java +++ b/src/main/java/org/olat/course/CourseFactory.java @@ -144,7 +144,7 @@ import org.olat.util.logging.activity.LoggingResourceable; */ public class CourseFactory extends BasicManager { - private static CacheWrapper loadedCourses; + private static CacheWrapper<Long,PersistingCourseImpl> loadedCourses; private static ConcurrentHashMap<Long, ModifyCourseEvent> modifyCourseEvents = new ConcurrentHashMap<Long, ModifyCourseEvent>(); public static final String COURSE_EDITOR_LOCK = "courseEditLock"; @@ -184,14 +184,14 @@ public class CourseFactory extends BasicManager { */ public static MainLayoutController createLaunchController(UserRequest ureq, WindowControl wControl, final OLATResourceable olatResource) { ICourse course = loadCourse(olatResource); - boolean isDebug = Tracing.isDebugEnabled(CourseFactory.class); + boolean isDebug = log.isDebug(); long startT = 0; if(isDebug){ startT = System.currentTimeMillis(); } MainLayoutController launchC = new RunMainController(ureq, wControl, course, true, true); if(isDebug){ - Tracing.logDebug("Runview for [["+course.getCourseTitle()+"]] took [ms]"+(System.currentTimeMillis() - startT), CourseFactory.class); + log.debug("Runview for [["+course.getCourseTitle()+"]] took [ms]"+(System.currentTimeMillis() - startT)); } return launchC; @@ -312,7 +312,7 @@ public class CourseFactory extends BasicManager { * @return the PersistingCourseImpl instance for the input key. */ static PersistingCourseImpl getCourseFromCache(Long resourceableId) { //o_clusterOK by:ld - return (PersistingCourseImpl)loadedCourses.get(String.valueOf(resourceableId.longValue())); + return loadedCourses.get(resourceableId); } /** @@ -321,8 +321,8 @@ public class CourseFactory extends BasicManager { * @param course */ static void putCourseInCache(Long resourceableId, PersistingCourseImpl course) { //o_clusterOK by:ld - loadedCourses.put(String.valueOf(resourceableId.longValue()), course); - Tracing.logDebug("putCourseInCache ", CourseFactory.class); + loadedCourses.put(resourceableId, course); + log.debug("putCourseInCache "); } /** @@ -330,8 +330,8 @@ public class CourseFactory extends BasicManager { * @param resourceableId */ private static void removeFromCache(Long resourceableId) { //o_clusterOK by: ld - loadedCourses.remove(String.valueOf(resourceableId.longValue())); - Tracing.logDebug("removeFromCache ", CourseFactory.class); + loadedCourses.remove(resourceableId); + log.debug("removeFromCache"); } /** @@ -340,8 +340,8 @@ public class CourseFactory extends BasicManager { * @param course */ private static void updateCourseInCache(Long resourceableId, PersistingCourseImpl course) { //o_clusterOK by:ld - loadedCourses.update(String.valueOf(resourceableId.longValue()), course); - Tracing.logDebug("updateCourseInCache ", CourseFactory.class); + loadedCourses.update(resourceableId, course); + log.debug("updateCourseInCache"); } /** @@ -590,7 +590,7 @@ public class CourseFactory extends BasicManager { ICourse course = CourseFactory.importCourseFromZip(newCourseResource, exportedCourseZIPFile); // course is now also in course cache! if (course == null) { - Tracing.logError("Error deploying course from ZIP: " + exportedCourseZIPFile.getAbsolutePath(), CourseFactory.class); + log.error("Error deploying course from ZIP: " + exportedCourseZIPFile.getAbsolutePath()); return null; } File courseExportData = course.getCourseExportDataDir().getBasefile(); @@ -603,7 +603,7 @@ public class CourseFactory extends BasicManager { } RepositoryEntry existingEntry = repositoryManager.lookupRepositoryEntryBySoftkey(softKey, false); if (existingEntry != null) { - Tracing.logInfo("RepositoryEntry with softkey " + softKey + " already exists. Course will not be deployed.", CourseFactory.class); + log.info("RepositoryEntry with softkey " + softKey + " already exists. Course will not be deployed."); //seem to be a problem UserCourseInformationsManager userCourseInformationsManager = CoreSpringFactory.getImpl(UserCourseInformationsManager.class); userCourseInformationsManager.deleteUserCourseInformations(existingEntry); @@ -678,7 +678,7 @@ public class CourseFactory extends BasicManager { closeCourseEditSession(course.getResourceableId(), true); // cleanup export data FileUtils.deleteDirsAndFiles(courseExportData, true, true); - Tracing.logInfo("Successfully deployed course " + re.getDisplayname() + " from ZIP: " + exportedCourseZIPFile.getAbsolutePath(), CourseFactory.class); + log.info("Successfully deployed course " + re.getDisplayname() + " from ZIP: " + exportedCourseZIPFile.getAbsolutePath()); return re; } @@ -1267,7 +1267,7 @@ class NodeDeletionVisitor implements Visitor { * @author Lavinia Dumitrescu */ class ModifyCourseEvent extends MultiUserEvent { - + private static final long serialVersionUID = -2940724437608086461L; private final Long courseId; /** * @param command @@ -1280,6 +1280,4 @@ class ModifyCourseEvent extends MultiUserEvent { public Long getCourseId() { return courseId; } - - } \ No newline at end of file diff --git a/src/main/java/org/olat/course/run/RunMainController.java b/src/main/java/org/olat/course/run/RunMainController.java index e14fd68650c..d882106a6be 100644 --- a/src/main/java/org/olat/course/run/RunMainController.java +++ b/src/main/java/org/olat/course/run/RunMainController.java @@ -123,6 +123,7 @@ import org.olat.repository.RepositoryEntry; import org.olat.repository.RepositoryEntryStatus; import org.olat.repository.RepositoryManager; import org.olat.repository.controllers.EntryChangedEvent; +import org.olat.repository.controllers.RepositoryDetailsController; import org.olat.util.logging.activity.LoggingResourceable; /** @@ -675,21 +676,9 @@ public class RunMainController extends MainLayoutBasicController implements Gene } } else if (cmd.equals(COMMAND_EDIT)) { - if (hasCourseRight(CourseRights.RIGHT_COURSEEDITOR) || isCourseAdmin) { - Controller ec = CourseFactory.createEditorController(ureq, getWindowControl(), all, course); - //user activity logger which was initialized with course run - if(ec != null){ - //we are in editing mode - currentToolCtr = ec; - listenTo(currentToolCtr); - isInEditor = true; - all.pushController(translate("command.openeditor"), currentToolCtr); - } - } else throw new OLATSecurityException("wanted to activate editor, but no according right"); - + doEdit(ureq) ; } else if (cmd.equals("unifiedusermngt")) { launchMembersManagement(ureq); - } else if (cmd.equals("statistic")) { if (hasCourseRight(CourseRights.RIGHT_STATISTICS) || isCourseAdmin) { currentToolCtr = new StatisticMainController(ureq, getWindowControl(), course); @@ -821,6 +810,20 @@ public class RunMainController extends MainLayoutBasicController implements Gene } } + private void doEdit(UserRequest ureq) { + if (hasCourseRight(CourseRights.RIGHT_COURSEEDITOR) || isCourseAdmin) { + Controller ec = CourseFactory.createEditorController(ureq, getWindowControl(), all, course); + //user activity logger which was initialized with course run + if(ec != null){ + //we are in editing mode + currentToolCtr = ec; + listenTo(currentToolCtr); + isInEditor = true; + all.pushController(translate("command.openeditor"), currentToolCtr); + } + } else throw new OLATSecurityException("wanted to activate editor, but no according right"); + } + private MembersManagementMainController launchMembersManagement(UserRequest ureq) { if (hasCourseRight(CourseRights.RIGHT_GROUPMANAGEMENT) || isCourseAdmin) { if(!(currentToolCtr instanceof MembersManagementMainController)) { @@ -1249,6 +1252,8 @@ public class RunMainController extends MainLayoutBasicController implements Gene } catch (OLATSecurityException e) { //the wrong link to the wrong person } + } else if(RepositoryDetailsController.ACTIVATE_EDITOR.equals(type)) { + doEdit(ureq); } } diff --git a/src/main/java/org/olat/repository/controllers/RepositoryDetailsController.java b/src/main/java/org/olat/repository/controllers/RepositoryDetailsController.java index 209ecf8c491..f48f45c10ef 100644 --- a/src/main/java/org/olat/repository/controllers/RepositoryDetailsController.java +++ b/src/main/java/org/olat/repository/controllers/RepositoryDetailsController.java @@ -572,11 +572,8 @@ public class RepositoryDetailsController extends BasicController implements Gene if (cmd.equals(ACTION_DETAILSEDIT)) { // detailsForm.setDisplayOnly(false); main.contextPut("enableEdit", Boolean.valueOf(false)); // disable edit - // button - return; } else if (cmd.equals(ACTION_CLOSE)) { // close details doCloseDetailView(ureq); - return; } else if (cmd.equals(ACTION_LAUNCH)) { // launch resource } diff --git a/src/main/java/org/olat/repository/handlers/CourseHandler.java b/src/main/java/org/olat/repository/handlers/CourseHandler.java index 86abe124c72..c2f8ea6b615 100644 --- a/src/main/java/org/olat/repository/handlers/CourseHandler.java +++ b/src/main/java/org/olat/repository/handlers/CourseHandler.java @@ -164,8 +164,10 @@ public class CourseHandler implements RepositoryHandler { * @see org.olat.repository.handlers.RepositoryHandler#getEditorController(org.olat.core.id.OLATResourceable org.olat.core.gui.UserRequest, org.olat.core.gui.control.WindowControl) */ public Controller createEditorController(OLATResourceable res, UserRequest ureq, WindowControl wControl) { - //throw new AssertException("a course is not directly editable!!! (reason: lock is never released), res-id:"+res.getResourceableId()); - return CourseFactory.createEditorController(ureq, wControl, null, res); + //run + activate + MainLayoutController courseCtrl = CourseFactory.createLaunchController(ureq, wControl, res); + RepositoryMainAccessControllerWrapper wrapper = new RepositoryMainAccessControllerWrapper(ureq, wControl, res, courseCtrl); + return wrapper; } /** -- GitLab