Search in sources :

Example 1 with RepositoryManager

use of org.olat.repository.RepositoryManager in project OpenOLAT by OpenOLAT.

the class VCCourseNode method createNodeRunConstructionResult.

@Override
public NodeRunConstructionResult createNodeRunConstructionResult(UserRequest ureq, WindowControl wControl, UserCourseEnvironment userCourseEnv, NodeEvaluation ne, String nodecmd) {
    updateModuleConfigDefaults(false);
    // check if user is moderator of the virtual classroom
    Roles roles = ureq.getUserSession().getRoles();
    boolean moderator = roles.isOLATAdmin();
    Long key = userCourseEnv.getCourseEnvironment().getCourseResourceableId();
    if (!moderator) {
        if (roles.isInstitutionalResourceManager() | roles.isAuthor()) {
            RepositoryManager rm = RepositoryManager.getInstance();
            ICourse course = CourseFactory.loadCourse(key);
            RepositoryEntry re = course.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
            if (re != null) {
                moderator = rm.isOwnerOfRepositoryEntry(ureq.getIdentity(), re);
                if (!moderator) {
                    moderator = rm.isInstitutionalRessourceManagerFor(ureq.getIdentity(), ureq.getUserSession().getRoles(), re);
                }
            }
        }
    }
    // load configuration
    final String providerId = getModuleConfiguration().getStringValue(CONF_PROVIDER_ID);
    VCProvider provider = providerId == null ? VCProviderFactory.createDefaultProvider() : VCProviderFactory.createProvider(providerId);
    VCConfiguration config = handleConfig(provider);
    // create run controller
    Controller runCtr = new VCRunController(ureq, wControl, key + "_" + getIdent(), getShortName(), getLongTitle(), config, provider, moderator, userCourseEnv.isCourseReadOnly());
    Controller controller = TitledWrapperHelper.getWrapper(ureq, wControl, runCtr, this, "o_vc_icon");
    return new NodeRunConstructionResult(controller);
}
Also used : VCRunController(de.bps.course.nodes.vc.VCRunController) Roles(org.olat.core.id.Roles) RepositoryManager(org.olat.repository.RepositoryManager) ICourse(org.olat.course.ICourse) RepositoryEntry(org.olat.repository.RepositoryEntry) TabbableController(org.olat.core.gui.control.generic.tabbable.TabbableController) TabbableDefaultController(org.olat.core.gui.control.generic.tabbable.TabbableDefaultController) NoProviderController(de.bps.course.nodes.vc.NoProviderController) VCEditController(de.bps.course.nodes.vc.VCEditController) VCRunController(de.bps.course.nodes.vc.VCRunController) Controller(org.olat.core.gui.control.Controller) NodeEditController(org.olat.course.editor.NodeEditController) ConditionEditController(org.olat.course.condition.ConditionEditController) NodeRunConstructionResult(org.olat.course.run.navigation.NodeRunConstructionResult) VCProvider(de.bps.course.nodes.vc.provider.VCProvider) VCConfiguration(de.bps.course.nodes.vc.VCConfiguration)

Example 2 with RepositoryManager

use of org.olat.repository.RepositoryManager in project OpenOLAT by OpenOLAT.

the class CatalogHelper method addCourseToCatalogEntry.

/**
 * Add a persisted course to the given catalog entry.
 *
 * @param course course object
 * @param catEntry catalog entry
 */
public static final void addCourseToCatalogEntry(final ICourse course, final CatalogEntry catEntry) {
    OLATResource ores = OLATResourceManager.getInstance().findResourceable(course.getResourceableId(), course.getResourceableTypeName());
    RepositoryManager rm = RepositoryManager.getInstance();
    RepositoryEntry re = rm.lookupRepositoryEntry(ores, true);
    CatalogManager cm = CoreSpringFactory.getImpl(CatalogManager.class);
    CatalogEntry newLinkNotPersistedYet = cm.createCatalogEntry();
    newLinkNotPersistedYet.setName(re.getDisplayname());
    newLinkNotPersistedYet.setDescription(re.getDescription());
    newLinkNotPersistedYet.setRepositoryEntry(re);
    newLinkNotPersistedYet.setType(CatalogEntry.TYPE_LEAF);
    newLinkNotPersistedYet.setOwnerGroup(BaseSecurityManager.getInstance().createAndPersistSecurityGroup());
    cm.addCatalogEntry(catEntry, newLinkNotPersistedYet);
}
Also used : CatalogEntry(org.olat.repository.CatalogEntry) OLATResource(org.olat.resource.OLATResource) RepositoryManager(org.olat.repository.RepositoryManager) RepositoryEntry(org.olat.repository.RepositoryEntry) CatalogManager(org.olat.repository.manager.CatalogManager)

Example 3 with RepositoryManager

use of org.olat.repository.RepositoryManager in project OpenOLAT by OpenOLAT.

the class CourseSite method createController.

@Override
protected MainLayoutController createController(UserRequest ureq, WindowControl wControl, SiteConfiguration config) {
    RepositoryManager rm = RepositoryManager.getInstance();
    RepositoryService rs = CoreSpringFactory.getImpl(RepositoryService.class);
    RepositoryEntry entry = rm.lookupRepositoryEntryBySoftkey(repositorySoftKey, false);
    if (entry == null) {
        return getAlternativeController(ureq, wControl, config);
    }
    MainLayoutController c;
    ICourse course = CourseFactory.loadCourse(entry);
    UserSession usess = ureq.getUserSession();
    // course-launch-state depending course-settings
    RepositoryEntrySecurity reSecurity = rm.isAllowed(ureq, entry);
    boolean isAllowedToLaunch = reSecurity.canLaunch();
    boolean hasAccess = false;
    if (isAllowedToLaunch) {
        // either check with securityCallback or use access-settings from course-nodes
        if (siteSecCallback != null) {
            hasAccess = siteSecCallback.isAllowedToLaunchSite(ureq);
        } else if (usess.isInAssessmentModeProcess() && !usess.matchLockResource(course)) {
            hasAccess = false;
        } else {
            // check within course: accessibility of course root node
            CourseNode rootNode = course.getRunStructure().getRootNode();
            UserCourseEnvironmentImpl uce = new UserCourseEnvironmentImpl(ureq.getUserSession().getIdentityEnvironment(), course.getCourseEnvironment());
            NodeEvaluation nodeEval = rootNode.eval(uce.getConditionInterpreter(), new TreeEvaluation(), new VisibleTreeFilter());
            boolean mayAccessWholeTreeUp = NavigationHandler.mayAccessWholeTreeUp(nodeEval);
            hasAccess = mayAccessWholeTreeUp && nodeEval.isVisible();
        }
    }
    // load course (admins always see content) or alternative controller if course is not launchable
    if (hasAccess || usess.getRoles().isOLATAdmin()) {
        rs.incrementLaunchCounter(entry);
        // build up the context path for linked course
        WindowControl bwControl = BusinessControlFactory.getInstance().createBusinessWindowControl(ureq, entry, new StateSite(this), wControl, true);
        CourseRuntimeController runCtr = new CourseRuntimeController(ureq, bwControl, entry, reSecurity, new RuntimeControllerCreator() {

            @Override
            public Controller create(UserRequest uureq, WindowControl wwControl, TooledStackedPanel toolbarPanel, RepositoryEntry re, RepositoryEntrySecurity security, AssessmentMode assessmentMode) {
                return new RunMainController(uureq, wwControl, toolbarPanel, CourseFactory.loadCourse(re), re, security, assessmentMode);
            }
        }, false, true);
        // Configure run controller
        // a: don't show close link, is opened as site not tab
        runCtr.setCourseCloseEnabled(false);
        // b: don't show toolbar
        if (!showToolController) {
            runCtr.setToolControllerEnabled(false);
        }
        c = runCtr;
    } else {
        // access restricted (not in group / author) -> show controller
        // defined in olat_extensions (type autoCreator)
        c = getAlternativeController(ureq, wControl, config);
    }
    return c;
}
Also used : TooledStackedPanel(org.olat.core.gui.components.stack.TooledStackedPanel) AssessmentMode(org.olat.course.assessment.AssessmentMode) StateSite(org.olat.core.id.context.StateSite) VisibleTreeFilter(org.olat.course.run.userview.VisibleTreeFilter) RunMainController(org.olat.course.run.RunMainController) ICourse(org.olat.course.ICourse) RepositoryEntry(org.olat.repository.RepositoryEntry) WindowControl(org.olat.core.gui.control.WindowControl) MainLayoutController(org.olat.core.gui.control.generic.layout.MainLayoutController) RunMainController(org.olat.course.run.RunMainController) CourseRuntimeController(org.olat.course.run.CourseRuntimeController) Controller(org.olat.core.gui.control.Controller) RuntimeControllerCreator(org.olat.repository.ui.RepositoryEntryRuntimeController.RuntimeControllerCreator) UserCourseEnvironmentImpl(org.olat.course.run.userview.UserCourseEnvironmentImpl) RepositoryEntrySecurity(org.olat.repository.model.RepositoryEntrySecurity) CourseRuntimeController(org.olat.course.run.CourseRuntimeController) UserSession(org.olat.core.util.UserSession) TreeEvaluation(org.olat.course.run.userview.TreeEvaluation) MainLayoutController(org.olat.core.gui.control.generic.layout.MainLayoutController) RepositoryManager(org.olat.repository.RepositoryManager) CourseNode(org.olat.course.nodes.CourseNode) NodeEvaluation(org.olat.course.run.userview.NodeEvaluation) UserRequest(org.olat.core.gui.UserRequest) RepositoryService(org.olat.repository.RepositoryService)

Example 4 with RepositoryManager

use of org.olat.repository.RepositoryManager in project OpenOLAT by OpenOLAT.

the class CourseSiteContextEntryControllerCreator method createLaunchController.

/**
 * Create a launch controller used to launch the given repo entry.
 * @param re
 * @param initialViewIdentifier if null the default view will be started, otherwise a controllerfactory type dependant view will be activated (subscription subtype)
 * @param ureq
 * @param wControl
 * @return null if no entry was found, a no access message controller if not allowed to launch or the launch
 * controller if successful.
 */
private Controller createLaunchController(RepositoryEntry re, UserRequest ureq, WindowControl wControl) {
    if (re == null) {
        return messageController(ureq, wControl, "repositoryentry.not.existing");
    }
    UserSession usess = ureq.getUserSession();
    if (re.getAccess() == RepositoryEntry.DELETED) {
        Roles roles = usess.getRoles();
        if (!roles.isInstitutionalResourceManager() && !roles.isOLATAdmin()) {
            return messageController(ureq, wControl, "repositoryentry.deleted");
        }
    }
    if (usess.isInAssessmentModeProcess() && !usess.matchLockResource(re.getOlatResource())) {
        return null;
    }
    RepositoryManager rm = RepositoryManager.getInstance();
    RepositoryEntrySecurity reSecurity = rm.isAllowed(ureq, re);
    if (!reSecurity.canLaunch()) {
        return messageController(ureq, wControl, "launch.noaccess");
    }
    RepositoryService rs = CoreSpringFactory.getImpl(RepositoryService.class);
    rs.incrementLaunchCounter(re);
    RepositoryHandler handler = RepositoryHandlerFactory.getInstance().getRepositoryHandler(re);
    WindowControl bwControl;
    OLATResourceable businessOres = re;
    ContextEntry ce = BusinessControlFactory.getInstance().createContextEntry(businessOres);
    if (ce.equals(wControl.getBusinessControl().getCurrentContextEntry())) {
        bwControl = wControl;
    } else {
        bwControl = BusinessControlFactory.getInstance().createBusinessWindowControl(ce, wControl);
    }
    MainLayoutController ctrl = handler.createLaunchController(re, reSecurity, ureq, bwControl);
    if (ctrl == null) {
        throw new AssertException("could not create controller for repositoryEntry " + re);
    }
    return ctrl;
}
Also used : AssertException(org.olat.core.logging.AssertException) OLATResourceable(org.olat.core.id.OLATResourceable) RepositoryEntrySecurity(org.olat.repository.model.RepositoryEntrySecurity) UserSession(org.olat.core.util.UserSession) MainLayoutController(org.olat.core.gui.control.generic.layout.MainLayoutController) Roles(org.olat.core.id.Roles) RepositoryManager(org.olat.repository.RepositoryManager) RepositoryHandler(org.olat.repository.handlers.RepositoryHandler) WindowControl(org.olat.core.gui.control.WindowControl) ContextEntry(org.olat.core.id.context.ContextEntry) RepositoryService(org.olat.repository.RepositoryService)

Example 5 with RepositoryManager

use of org.olat.repository.RepositoryManager in project OpenOLAT by OpenOLAT.

the class WikisWebService method getAccessibleWikiRepositoryEntries.

/**
 * returns all accessiblewikiRepositoryEntries of type wiki
 *
 * @param httpRequest
 * @return
 */
private static List<RepositoryEntry> getAccessibleWikiRepositoryEntries(HttpServletRequest httpRequest) {
    Roles roles = getRoles(httpRequest);
    Identity identity = getIdentity(httpRequest);
    RepositoryManager rm = RepositoryManager.getInstance();
    SearchRepositoryEntryParameters params = new SearchRepositoryEntryParameters(identity, roles, new String[] { WikiResource.TYPE_NAME });
    List<RepositoryEntry> res = rm.genericANDQueryWithRolesRestriction(params, 0, -1, true);
    return res;
}
Also used : SearchRepositoryEntryParameters(org.olat.repository.model.SearchRepositoryEntryParameters) RestSecurityHelper.getRoles(org.olat.restapi.security.RestSecurityHelper.getRoles) Roles(org.olat.core.id.Roles) RepositoryManager(org.olat.repository.RepositoryManager) RepositoryEntry(org.olat.repository.RepositoryEntry) RestSecurityHelper.getIdentity(org.olat.restapi.security.RestSecurityHelper.getIdentity) Identity(org.olat.core.id.Identity)

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