Search in sources :

Example 96 with RepositoryManager

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;
    }
}
Also used : Translator(org.olat.core.gui.translator.Translator) RepositoryEntrySecurity(org.olat.repository.model.RepositoryEntrySecurity) LayoutMain3ColsController(org.olat.core.commons.fullWebApp.LayoutMain3ColsController) RunMainController(org.olat.course.run.RunMainController) RepositoryManager(org.olat.repository.RepositoryManager) RepositoryEntry(org.olat.repository.RepositoryEntry) WindowControl(org.olat.core.gui.control.WindowControl) ContextEntry(org.olat.core.id.context.ContextEntry) RepositoryService(org.olat.repository.RepositoryService)

Example 97 with RepositoryManager

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;
}
Also used : AssertException(org.olat.core.logging.AssertException) RepositoryManager(org.olat.repository.RepositoryManager) RepositoryEntry(org.olat.repository.RepositoryEntry)

Example 98 with RepositoryManager

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;
}
Also used : AssertException(org.olat.core.logging.AssertException) RepositoryManager(org.olat.repository.RepositoryManager) RepositoryEntry(org.olat.repository.RepositoryEntry)

Example 99 with RepositoryManager

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();
        }
    }
}
Also used : EfficiencyStatementEvent(org.olat.course.assessment.EfficiencyStatementEvent) RepositoryManager(org.olat.repository.RepositoryManager) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity)

Example 100 with RepositoryManager

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;
}
Also used : FolderNodeCallback(org.olat.course.nodes.bc.FolderNodeCallback) OlatRootFolderImpl(org.olat.core.commons.modules.bc.vfs.OlatRootFolderImpl) ReadOnlyCallback(org.olat.core.util.vfs.callbacks.ReadOnlyCallback) VFSContainer(org.olat.core.util.vfs.VFSContainer) RepositoryManager(org.olat.repository.RepositoryManager) RepositoryEntry(org.olat.repository.RepositoryEntry) VFSSecurityCallback(org.olat.core.util.vfs.callbacks.VFSSecurityCallback)

Aggregations

RepositoryManager (org.olat.repository.RepositoryManager)136 RepositoryEntry (org.olat.repository.RepositoryEntry)122 Path (javax.ws.rs.Path)42 Identity (org.olat.core.id.Identity)32 Produces (javax.ws.rs.Produces)30 Roles (org.olat.core.id.Roles)30 RestSecurityHelper.getIdentity (org.olat.restapi.security.RestSecurityHelper.getIdentity)26 ArrayList (java.util.ArrayList)20 Consumes (javax.ws.rs.Consumes)20 PUT (javax.ws.rs.PUT)18 MailPackage (org.olat.core.util.mail.MailPackage)16 GET (javax.ws.rs.GET)14 BaseSecurity (org.olat.basesecurity.BaseSecurity)14 AssertException (org.olat.core.logging.AssertException)14 SearchRepositoryEntryParameters (org.olat.repository.model.SearchRepositoryEntryParameters)14 IdentitiesAddEvent (org.olat.admin.securitygroup.gui.IdentitiesAddEvent)12 Controller (org.olat.core.gui.control.Controller)12 OLATResourceable (org.olat.core.id.OLATResourceable)12 UserRequest (org.olat.core.gui.UserRequest)10 WindowControl (org.olat.core.gui.control.WindowControl)10