use of org.olat.repository.RepositoryManager in project OpenOLAT by OpenOLAT.
the class ModifyCourseEvent method createHelpCourseLaunchController.
/**
* Create a user locale dependent help-course run controller
*
* @param ureq The user request
* @param wControl The current window controller
* @return The help-course run controller
*/
public static Controller createHelpCourseLaunchController(UserRequest ureq, WindowControl wControl) {
// Find repository entry for this course
String helpCourseSoftKey = CoreSpringFactory.getImpl(CourseModule.class).getHelpCourseSoftKey();
RepositoryManager rm = RepositoryManager.getInstance();
RepositoryService rs = CoreSpringFactory.getImpl(RepositoryService.class);
RepositoryEntry entry = null;
if (StringHelper.containsNonWhitespace(helpCourseSoftKey)) {
entry = rm.lookupRepositoryEntryBySoftkey(helpCourseSoftKey, false);
}
if (entry == null) {
Translator translator = Util.createPackageTranslator(CourseFactory.class, ureq.getLocale());
wControl.setError(translator.translate("error.helpcourse.not.configured"));
// create empty main controller
LayoutMain3ColsController emptyCtr = new LayoutMain3ColsController(ureq, wControl, null, null, null);
return emptyCtr;
} else {
// Increment launch counter
rs.incrementLaunchCounter(entry);
ICourse course = loadCourse(entry);
ContextEntry ce = BusinessControlFactory.getInstance().createContextEntry(entry);
WindowControl bwControl = BusinessControlFactory.getInstance().createBusinessWindowControl(ce, wControl);
RepositoryEntrySecurity reSecurity = new RepositoryEntrySecurity(false, false, false, false, false, false, false, true, false);
RunMainController launchC = new RunMainController(ureq, bwControl, null, course, entry, reSecurity, null);
return launchC;
}
}
use of org.olat.repository.RepositoryManager in project OpenOLAT by OpenOLAT.
the class CompMenuForm method getCPReference.
/**
* @param config the moduleConfig
* @param strict an assertion exception is thrown if no entry is found when
* strict is set to true, otherwise, null is returned
* @return the repositoryentry or null if not in strict mode and no entry
* found
* @throws AssertException when in strict mode and no entry is found
*/
public static RepositoryEntry getCPReference(ModuleConfiguration config, boolean strict) {
if (config == null) {
if (strict)
throw new AssertException("missing config in CP");
else
return null;
}
String repoSoftkey = (String) config.get(CPEditController.CONFIG_KEY_REPOSITORY_SOFTKEY);
if (repoSoftkey == null) {
if (strict)
throw new AssertException("invalid config when being asked for references");
else
return null;
}
RepositoryManager rm = RepositoryManager.getInstance();
RepositoryEntry entry = rm.lookupRepositoryEntryBySoftkey(repoSoftkey, strict);
// entry can be null only if !strict
return entry;
}
use of org.olat.repository.RepositoryManager in project OpenOLAT by OpenOLAT.
the class VarForm method getScormCPReference.
/**
* @param config the moduleConfig
* @param strict an assertion exception is thrown if no entry is found when
* strict is set to true, otherwise, null is returned
* @return the repositoryentry or null if not in strict mode and no entry
* found
* @throws AssertException when in strict mode and no entry is found
*/
public static RepositoryEntry getScormCPReference(ModuleConfiguration config, boolean strict) {
if (config == null)
throw new AssertException("missing config in CP");
String repoSoftkey = (String) config.get(ScormEditController.CONFIG_KEY_REPOSITORY_SOFTKEY);
if (repoSoftkey == null)
throw new AssertException("invalid config when being asked for references");
RepositoryManager rm = RepositoryManager.getInstance();
RepositoryEntry entry = rm.lookupRepositoryEntryBySoftkey(repoSoftkey, strict);
// entry can be null only if !strict
return entry;
}
use of org.olat.repository.RepositoryManager in project OpenOLAT by OpenOLAT.
the class UpdateEfficiencyStatementsWorker method run.
/**
* @see java.lang.Runnable#run()
*/
public void run() {
boolean success = false;
try {
RepositoryManager rm = CoreSpringFactory.getImpl(RepositoryManager.class);
EfficiencyStatementManager esm = CoreSpringFactory.getImpl(EfficiencyStatementManager.class);
RepositoryEntry re = rm.lookupRepositoryEntry(ores, false);
List<Identity> identities = esm.findIdentitiesWithEfficiencyStatements(re.getKey());
esm.updateEfficiencyStatements(re, identities);
// close db session in this thread
DBFactory.getInstance().commitAndCloseSession();
success = true;
EfficiencyStatementEvent finishedEvent = new EfficiencyStatementEvent(EfficiencyStatementEvent.CMD_FINISHED, ores.getResourceableId());
CoordinatorManager.getInstance().getCoordinator().getEventBus().fireEventToListenersOf(finishedEvent, ores);
} catch (Exception ex) {
log.error("Unexpected exception updating the efficiency statements of " + ores, ex);
} finally {
// close db session in this thread
if (!success) {
DBFactory.getInstance().rollbackAndCloseSession();
}
}
}
use of org.olat.repository.RepositoryManager in project OpenOLAT by OpenOLAT.
the class MergedCourseContainer method getBCContainer.
private VFSContainer getBCContainer(ICourse course, BCCourseNode bcNode, NodeEvaluation nodeEval, boolean isOlatAdmin) {
bcNode.updateModuleConfigDefaults(false);
// add folder not to merge source. Use name and node id to have unique name
VFSContainer rootFolder = null;
String subpath = bcNode.getModuleConfiguration().getStringValue(BCCourseNodeEditController.CONFIG_SUBPATH);
if (StringHelper.containsNonWhitespace(subpath)) {
if (bcNode.isSharedFolder()) {
// grab any shared folder that is configured
OlatRootFolderImpl sharedFolder = null;
String sfSoftkey = course.getCourseConfig().getSharedFolderSoftkey();
if (StringHelper.containsNonWhitespace(sfSoftkey) && !CourseConfig.VALUE_EMPTY_SHAREDFOLDER_SOFTKEY.equals(sfSoftkey)) {
RepositoryManager rm = RepositoryManager.getInstance();
RepositoryEntry re = rm.lookupRepositoryEntryBySoftkey(sfSoftkey, false);
if (re != null) {
sharedFolder = SharedFolderManager.getInstance().getSharedFolder(re.getOlatResource());
VFSContainer courseBase = sharedFolder;
subpath = subpath.replaceFirst("/_sharedfolder", "");
rootFolder = (VFSContainer) courseBase.resolve(subpath);
if (rootFolder != null && (course.getCourseConfig().isSharedFolderReadOnlyMount() || courseReadOnly)) {
rootFolder.setLocalSecurityCallback(new ReadOnlyCallback());
}
}
}
} else {
VFSContainer courseBase = course.getCourseBaseContainer();
rootFolder = (VFSContainer) courseBase.resolve("/coursefolder" + subpath);
}
}
if (bcNode.getModuleConfiguration().getBooleanSafe(BCCourseNodeEditController.CONFIG_AUTO_FOLDER)) {
String path = BCCourseNode.getFoldernodePathRelToFolderBase(course.getCourseEnvironment(), bcNode);
rootFolder = new OlatRootFolderImpl(path, null);
if (nodeEval != null) {
rootFolder.setLocalSecurityCallback(new FolderNodeCallback(path, nodeEval, isOlatAdmin, false, null));
} else {
VFSSecurityCallback secCallback = VFSManager.findInheritedSecurityCallback(this);
if (secCallback != null) {
rootFolder.setLocalSecurityCallback(new OverrideQuotaSecurityCallback(path, secCallback));
}
}
}
return rootFolder;
}
Aggregations