Skip to content
Snippets Groups Projects
Commit 4d83a389 authored by srosse's avatar srosse
Browse files

no-jira: in repository details, open the editor of course the same way it will...

no-jira: in repository details, open the editor of course the same way it will opened from the course (with breadcrumbs)
parent 88e8c346
No related branches found
No related tags found
No related merge requests found
...@@ -144,7 +144,7 @@ import org.olat.util.logging.activity.LoggingResourceable; ...@@ -144,7 +144,7 @@ import org.olat.util.logging.activity.LoggingResourceable;
*/ */
public class CourseFactory extends BasicManager { 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>(); private static ConcurrentHashMap<Long, ModifyCourseEvent> modifyCourseEvents = new ConcurrentHashMap<Long, ModifyCourseEvent>();
public static final String COURSE_EDITOR_LOCK = "courseEditLock"; public static final String COURSE_EDITOR_LOCK = "courseEditLock";
...@@ -184,14 +184,14 @@ public class CourseFactory extends BasicManager { ...@@ -184,14 +184,14 @@ public class CourseFactory extends BasicManager {
*/ */
public static MainLayoutController createLaunchController(UserRequest ureq, WindowControl wControl, final OLATResourceable olatResource) { public static MainLayoutController createLaunchController(UserRequest ureq, WindowControl wControl, final OLATResourceable olatResource) {
ICourse course = loadCourse(olatResource); ICourse course = loadCourse(olatResource);
boolean isDebug = Tracing.isDebugEnabled(CourseFactory.class); boolean isDebug = log.isDebug();
long startT = 0; long startT = 0;
if(isDebug){ if(isDebug){
startT = System.currentTimeMillis(); startT = System.currentTimeMillis();
} }
MainLayoutController launchC = new RunMainController(ureq, wControl, course, true, true); MainLayoutController launchC = new RunMainController(ureq, wControl, course, true, true);
if(isDebug){ 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; return launchC;
...@@ -312,7 +312,7 @@ public class CourseFactory extends BasicManager { ...@@ -312,7 +312,7 @@ public class CourseFactory extends BasicManager {
* @return the PersistingCourseImpl instance for the input key. * @return the PersistingCourseImpl instance for the input key.
*/ */
static PersistingCourseImpl getCourseFromCache(Long resourceableId) { //o_clusterOK by:ld 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 { ...@@ -321,8 +321,8 @@ public class CourseFactory extends BasicManager {
* @param course * @param course
*/ */
static void putCourseInCache(Long resourceableId, PersistingCourseImpl course) { //o_clusterOK by:ld static void putCourseInCache(Long resourceableId, PersistingCourseImpl course) { //o_clusterOK by:ld
loadedCourses.put(String.valueOf(resourceableId.longValue()), course); loadedCourses.put(resourceableId, course);
Tracing.logDebug("putCourseInCache ", CourseFactory.class); log.debug("putCourseInCache ");
} }
/** /**
...@@ -330,8 +330,8 @@ public class CourseFactory extends BasicManager { ...@@ -330,8 +330,8 @@ public class CourseFactory extends BasicManager {
* @param resourceableId * @param resourceableId
*/ */
private static void removeFromCache(Long resourceableId) { //o_clusterOK by: ld private static void removeFromCache(Long resourceableId) { //o_clusterOK by: ld
loadedCourses.remove(String.valueOf(resourceableId.longValue())); loadedCourses.remove(resourceableId);
Tracing.logDebug("removeFromCache ", CourseFactory.class); log.debug("removeFromCache");
} }
/** /**
...@@ -340,8 +340,8 @@ public class CourseFactory extends BasicManager { ...@@ -340,8 +340,8 @@ public class CourseFactory extends BasicManager {
* @param course * @param course
*/ */
private static void updateCourseInCache(Long resourceableId, PersistingCourseImpl course) { //o_clusterOK by:ld private static void updateCourseInCache(Long resourceableId, PersistingCourseImpl course) { //o_clusterOK by:ld
loadedCourses.update(String.valueOf(resourceableId.longValue()), course); loadedCourses.update(resourceableId, course);
Tracing.logDebug("updateCourseInCache ", CourseFactory.class); log.debug("updateCourseInCache");
} }
/** /**
...@@ -590,7 +590,7 @@ public class CourseFactory extends BasicManager { ...@@ -590,7 +590,7 @@ public class CourseFactory extends BasicManager {
ICourse course = CourseFactory.importCourseFromZip(newCourseResource, exportedCourseZIPFile); ICourse course = CourseFactory.importCourseFromZip(newCourseResource, exportedCourseZIPFile);
// course is now also in course cache! // course is now also in course cache!
if (course == null) { 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; return null;
} }
File courseExportData = course.getCourseExportDataDir().getBasefile(); File courseExportData = course.getCourseExportDataDir().getBasefile();
...@@ -603,7 +603,7 @@ public class CourseFactory extends BasicManager { ...@@ -603,7 +603,7 @@ public class CourseFactory extends BasicManager {
} }
RepositoryEntry existingEntry = repositoryManager.lookupRepositoryEntryBySoftkey(softKey, false); RepositoryEntry existingEntry = repositoryManager.lookupRepositoryEntryBySoftkey(softKey, false);
if (existingEntry != null) { 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 //seem to be a problem
UserCourseInformationsManager userCourseInformationsManager = CoreSpringFactory.getImpl(UserCourseInformationsManager.class); UserCourseInformationsManager userCourseInformationsManager = CoreSpringFactory.getImpl(UserCourseInformationsManager.class);
userCourseInformationsManager.deleteUserCourseInformations(existingEntry); userCourseInformationsManager.deleteUserCourseInformations(existingEntry);
...@@ -678,7 +678,7 @@ public class CourseFactory extends BasicManager { ...@@ -678,7 +678,7 @@ public class CourseFactory extends BasicManager {
closeCourseEditSession(course.getResourceableId(), true); closeCourseEditSession(course.getResourceableId(), true);
// cleanup export data // cleanup export data
FileUtils.deleteDirsAndFiles(courseExportData, true, true); 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; return re;
} }
...@@ -1267,7 +1267,7 @@ class NodeDeletionVisitor implements Visitor { ...@@ -1267,7 +1267,7 @@ class NodeDeletionVisitor implements Visitor {
* @author Lavinia Dumitrescu * @author Lavinia Dumitrescu
*/ */
class ModifyCourseEvent extends MultiUserEvent { class ModifyCourseEvent extends MultiUserEvent {
private static final long serialVersionUID = -2940724437608086461L;
private final Long courseId; private final Long courseId;
/** /**
* @param command * @param command
...@@ -1280,6 +1280,4 @@ class ModifyCourseEvent extends MultiUserEvent { ...@@ -1280,6 +1280,4 @@ class ModifyCourseEvent extends MultiUserEvent {
public Long getCourseId() { public Long getCourseId() {
return courseId; return courseId;
} }
} }
\ No newline at end of file
...@@ -123,6 +123,7 @@ import org.olat.repository.RepositoryEntry; ...@@ -123,6 +123,7 @@ import org.olat.repository.RepositoryEntry;
import org.olat.repository.RepositoryEntryStatus; import org.olat.repository.RepositoryEntryStatus;
import org.olat.repository.RepositoryManager; import org.olat.repository.RepositoryManager;
import org.olat.repository.controllers.EntryChangedEvent; import org.olat.repository.controllers.EntryChangedEvent;
import org.olat.repository.controllers.RepositoryDetailsController;
import org.olat.util.logging.activity.LoggingResourceable; import org.olat.util.logging.activity.LoggingResourceable;
/** /**
...@@ -675,21 +676,9 @@ public class RunMainController extends MainLayoutBasicController implements Gene ...@@ -675,21 +676,9 @@ public class RunMainController extends MainLayoutBasicController implements Gene
} }
} else if (cmd.equals(COMMAND_EDIT)) { } else if (cmd.equals(COMMAND_EDIT)) {
if (hasCourseRight(CourseRights.RIGHT_COURSEEDITOR) || isCourseAdmin) { doEdit(ureq) ;
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");
} else if (cmd.equals("unifiedusermngt")) { } else if (cmd.equals("unifiedusermngt")) {
launchMembersManagement(ureq); launchMembersManagement(ureq);
} else if (cmd.equals("statistic")) { } else if (cmd.equals("statistic")) {
if (hasCourseRight(CourseRights.RIGHT_STATISTICS) || isCourseAdmin) { if (hasCourseRight(CourseRights.RIGHT_STATISTICS) || isCourseAdmin) {
currentToolCtr = new StatisticMainController(ureq, getWindowControl(), course); currentToolCtr = new StatisticMainController(ureq, getWindowControl(), course);
...@@ -821,6 +810,20 @@ public class RunMainController extends MainLayoutBasicController implements Gene ...@@ -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) { private MembersManagementMainController launchMembersManagement(UserRequest ureq) {
if (hasCourseRight(CourseRights.RIGHT_GROUPMANAGEMENT) || isCourseAdmin) { if (hasCourseRight(CourseRights.RIGHT_GROUPMANAGEMENT) || isCourseAdmin) {
if(!(currentToolCtr instanceof MembersManagementMainController)) { if(!(currentToolCtr instanceof MembersManagementMainController)) {
...@@ -1249,6 +1252,8 @@ public class RunMainController extends MainLayoutBasicController implements Gene ...@@ -1249,6 +1252,8 @@ public class RunMainController extends MainLayoutBasicController implements Gene
} catch (OLATSecurityException e) { } catch (OLATSecurityException e) {
//the wrong link to the wrong person //the wrong link to the wrong person
} }
} else if(RepositoryDetailsController.ACTIVATE_EDITOR.equals(type)) {
doEdit(ureq);
} }
} }
......
...@@ -572,11 +572,8 @@ public class RepositoryDetailsController extends BasicController implements Gene ...@@ -572,11 +572,8 @@ public class RepositoryDetailsController extends BasicController implements Gene
if (cmd.equals(ACTION_DETAILSEDIT)) { if (cmd.equals(ACTION_DETAILSEDIT)) {
// detailsForm.setDisplayOnly(false); // detailsForm.setDisplayOnly(false);
main.contextPut("enableEdit", Boolean.valueOf(false)); // disable edit main.contextPut("enableEdit", Boolean.valueOf(false)); // disable edit
// button
return;
} else if (cmd.equals(ACTION_CLOSE)) { // close details } else if (cmd.equals(ACTION_CLOSE)) { // close details
doCloseDetailView(ureq); doCloseDetailView(ureq);
return;
} else if (cmd.equals(ACTION_LAUNCH)) { // launch resource } else if (cmd.equals(ACTION_LAUNCH)) { // launch resource
} }
......
...@@ -164,8 +164,10 @@ public class CourseHandler implements RepositoryHandler { ...@@ -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) * @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) { 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()); //run + activate
return CourseFactory.createEditorController(ureq, wControl, null, res); MainLayoutController courseCtrl = CourseFactory.createLaunchController(ureq, wControl, res);
RepositoryMainAccessControllerWrapper wrapper = new RepositoryMainAccessControllerWrapper(ureq, wControl, res, courseCtrl);
return wrapper;
} }
/** /**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment