Search in sources :

Example 1 with CourseNodeIndexer

use of org.olat.search.service.indexer.repository.course.CourseNodeIndexer in project OpenOLAT by OpenOLAT.

the class CourseIndexer method doIndexCourse.

/**
 * @param repositoryResourceContext
 * @param course
 * @param courseNode
 * @param indexWriter
 * @throws IOException
 * @throws InterruptedException
 */
private void doIndexCourse(SearchResourceContext repositoryResourceContext, ICourse course, INode node, OlatFullIndexer indexWriter) throws IOException, InterruptedException {
    // try to index the course node
    if (node instanceof CourseNode) {
        if (isLogDebugEnabled())
            logDebug("Analyse CourseNode child ... childCourseNode=" + node);
        // go further with resource
        CourseNode childCourseNode = (CourseNode) node;
        CourseNodeIndexer courseNodeIndexer = getCourseNodeIndexer(childCourseNode);
        if (courseNodeIndexer != null) {
            if (isLogDebugEnabled())
                logDebug("courseNodeIndexer=" + courseNodeIndexer);
            try {
                courseNodeIndexer.doIndex(repositoryResourceContext, course, childCourseNode, indexWriter);
            } catch (Exception e) {
                logWarn("Can not index course node=" + childCourseNode.getIdent(), e);
            }
        }
    }
    // loop over all child nodes
    int childCount = node.getChildCount();
    for (int i = 0; i < childCount; i++) {
        INode childNode = node.getChildAt(i);
        doIndexCourse(repositoryResourceContext, course, childNode, indexWriter);
    }
}
Also used : INode(org.olat.core.util.nodes.INode) CourseNodeIndexer(org.olat.search.service.indexer.repository.course.CourseNodeIndexer) CourseNode(org.olat.course.nodes.CourseNode) AssertException(org.olat.core.logging.AssertException) CorruptedCourseException(org.olat.course.CorruptedCourseException) StartupException(org.olat.core.logging.StartupException) IOException(java.io.IOException)

Example 2 with CourseNodeIndexer

use of org.olat.search.service.indexer.repository.course.CourseNodeIndexer in project openolat by klemens.

the class CourseIndexer method checkAccess.

@Override
public boolean checkAccess(ContextEntry contextEntry, BusinessControl businessControl, Identity identity, Roles roles) {
    ContextEntry bcContextEntry = businessControl.popLauncherContextEntry();
    if (bcContextEntry == null) {
        // not a course node of course we have access to the course metadata
        return true;
    }
    if (isLogDebugEnabled())
        logDebug("Start identity=" + identity + "  roles=" + roles);
    Long repositoryKey = contextEntry.getOLATResourceable().getResourceableId();
    RepositoryEntry repositoryEntry = repositoryManager.lookupRepositoryEntry(repositoryKey);
    if (isLogDebugEnabled())
        logDebug("repositoryEntry=" + repositoryEntry);
    if (roles.isGuestOnly()) {
        if (repositoryEntry.getAccess() != RepositoryEntry.ACC_USERS_GUESTS) {
            return false;
        }
    }
    Long nodeId = bcContextEntry.getOLATResourceable().getResourceableId();
    if (isLogDebugEnabled())
        logDebug("nodeId=" + nodeId);
    ICourse course = CourseFactory.loadCourse(repositoryEntry);
    IdentityEnvironment ienv = new IdentityEnvironment();
    ienv.setIdentity(identity);
    ienv.setRoles(roles);
    UserCourseEnvironment userCourseEnv = new UserCourseEnvironmentImpl(ienv, course.getCourseEnvironment());
    if (isLogDebugEnabled())
        logDebug("userCourseEnv=" + userCourseEnv + "ienv=" + ienv);
    CourseNode rootCn = userCourseEnv.getCourseEnvironment().getRunStructure().getRootNode();
    String nodeIdS = nodeId.toString();
    CourseNode courseNode = course.getRunStructure().getNode(nodeIdS);
    if (isLogDebugEnabled())
        logDebug("courseNode=" + courseNode);
    TreeEvaluation treeEval = new TreeEvaluation();
    NodeEvaluation rootNodeEval = rootCn.eval(userCourseEnv.getConditionInterpreter(), treeEval, new VisibleTreeFilter());
    if (isLogDebugEnabled())
        logDebug("rootNodeEval=" + rootNodeEval);
    TreeNode newCalledTreeNode = treeEval.getCorrespondingTreeNode(courseNode);
    if (newCalledTreeNode == null) {
        // TreeNode no longer visible
        return false;
    }
    // go further
    NodeEvaluation nodeEval = (NodeEvaluation) newCalledTreeNode.getUserObject();
    if (isLogDebugEnabled())
        logDebug("nodeEval=" + nodeEval);
    if (nodeEval.getCourseNode() != courseNode)
        throw new AssertException("error in structure");
    if (!nodeEval.isVisible())
        throw new AssertException("node eval not visible!!");
    if (isLogDebugEnabled())
        logDebug("call mayAccessWholeTreeUp...");
    boolean mayAccessWholeTreeUp = NavigationHandler.mayAccessWholeTreeUp(nodeEval);
    if (isLogDebugEnabled())
        logDebug("call mayAccessWholeTreeUp=" + mayAccessWholeTreeUp);
    if (mayAccessWholeTreeUp) {
        CourseNodeIndexer courseNodeIndexer = getCourseNodeIndexer(courseNode);
        bcContextEntry.setTransientState(new CourseNodeEntry(courseNode));
        return courseNodeIndexer.checkAccess(bcContextEntry, businessControl, identity, roles) && super.checkAccess(bcContextEntry, businessControl, identity, roles);
    } else {
        return false;
    }
}
Also used : AssertException(org.olat.core.logging.AssertException) UserCourseEnvironment(org.olat.course.run.userview.UserCourseEnvironment) VisibleTreeFilter(org.olat.course.run.userview.VisibleTreeFilter) ICourse(org.olat.course.ICourse) RepositoryEntry(org.olat.repository.RepositoryEntry) ContextEntry(org.olat.core.id.context.ContextEntry) UserCourseEnvironmentImpl(org.olat.course.run.userview.UserCourseEnvironmentImpl) CourseNodeIndexer(org.olat.search.service.indexer.repository.course.CourseNodeIndexer) TreeNode(org.olat.core.gui.components.tree.TreeNode) TreeEvaluation(org.olat.course.run.userview.TreeEvaluation) CourseNodeEntry(org.olat.search.service.indexer.repository.course.CourseNodeEntry) CourseNode(org.olat.course.nodes.CourseNode) IdentityEnvironment(org.olat.core.id.IdentityEnvironment) NodeEvaluation(org.olat.course.run.userview.NodeEvaluation)

Example 3 with CourseNodeIndexer

use of org.olat.search.service.indexer.repository.course.CourseNodeIndexer in project OpenOLAT by OpenOLAT.

the class CourseIndexer method checkAccess.

@Override
public boolean checkAccess(ContextEntry contextEntry, BusinessControl businessControl, Identity identity, Roles roles) {
    ContextEntry bcContextEntry = businessControl.popLauncherContextEntry();
    if (bcContextEntry == null) {
        // not a course node of course we have access to the course metadata
        return true;
    }
    if (isLogDebugEnabled())
        logDebug("Start identity=" + identity + "  roles=" + roles);
    Long repositoryKey = contextEntry.getOLATResourceable().getResourceableId();
    RepositoryEntry repositoryEntry = repositoryManager.lookupRepositoryEntry(repositoryKey);
    if (isLogDebugEnabled())
        logDebug("repositoryEntry=" + repositoryEntry);
    if (roles.isGuestOnly()) {
        if (repositoryEntry.getAccess() != RepositoryEntry.ACC_USERS_GUESTS) {
            return false;
        }
    }
    Long nodeId = bcContextEntry.getOLATResourceable().getResourceableId();
    if (isLogDebugEnabled())
        logDebug("nodeId=" + nodeId);
    ICourse course = CourseFactory.loadCourse(repositoryEntry);
    IdentityEnvironment ienv = new IdentityEnvironment();
    ienv.setIdentity(identity);
    ienv.setRoles(roles);
    UserCourseEnvironment userCourseEnv = new UserCourseEnvironmentImpl(ienv, course.getCourseEnvironment());
    if (isLogDebugEnabled())
        logDebug("userCourseEnv=" + userCourseEnv + "ienv=" + ienv);
    CourseNode rootCn = userCourseEnv.getCourseEnvironment().getRunStructure().getRootNode();
    String nodeIdS = nodeId.toString();
    CourseNode courseNode = course.getRunStructure().getNode(nodeIdS);
    if (isLogDebugEnabled())
        logDebug("courseNode=" + courseNode);
    TreeEvaluation treeEval = new TreeEvaluation();
    NodeEvaluation rootNodeEval = rootCn.eval(userCourseEnv.getConditionInterpreter(), treeEval, new VisibleTreeFilter());
    if (isLogDebugEnabled())
        logDebug("rootNodeEval=" + rootNodeEval);
    TreeNode newCalledTreeNode = treeEval.getCorrespondingTreeNode(courseNode);
    if (newCalledTreeNode == null) {
        // TreeNode no longer visible
        return false;
    }
    // go further
    NodeEvaluation nodeEval = (NodeEvaluation) newCalledTreeNode.getUserObject();
    if (isLogDebugEnabled())
        logDebug("nodeEval=" + nodeEval);
    if (nodeEval.getCourseNode() != courseNode)
        throw new AssertException("error in structure");
    if (!nodeEval.isVisible())
        throw new AssertException("node eval not visible!!");
    if (isLogDebugEnabled())
        logDebug("call mayAccessWholeTreeUp...");
    boolean mayAccessWholeTreeUp = NavigationHandler.mayAccessWholeTreeUp(nodeEval);
    if (isLogDebugEnabled())
        logDebug("call mayAccessWholeTreeUp=" + mayAccessWholeTreeUp);
    if (mayAccessWholeTreeUp) {
        CourseNodeIndexer courseNodeIndexer = getCourseNodeIndexer(courseNode);
        bcContextEntry.setTransientState(new CourseNodeEntry(courseNode));
        return courseNodeIndexer.checkAccess(bcContextEntry, businessControl, identity, roles) && super.checkAccess(bcContextEntry, businessControl, identity, roles);
    } else {
        return false;
    }
}
Also used : AssertException(org.olat.core.logging.AssertException) UserCourseEnvironment(org.olat.course.run.userview.UserCourseEnvironment) VisibleTreeFilter(org.olat.course.run.userview.VisibleTreeFilter) ICourse(org.olat.course.ICourse) RepositoryEntry(org.olat.repository.RepositoryEntry) ContextEntry(org.olat.core.id.context.ContextEntry) UserCourseEnvironmentImpl(org.olat.course.run.userview.UserCourseEnvironmentImpl) CourseNodeIndexer(org.olat.search.service.indexer.repository.course.CourseNodeIndexer) TreeNode(org.olat.core.gui.components.tree.TreeNode) TreeEvaluation(org.olat.course.run.userview.TreeEvaluation) CourseNodeEntry(org.olat.search.service.indexer.repository.course.CourseNodeEntry) CourseNode(org.olat.course.nodes.CourseNode) IdentityEnvironment(org.olat.core.id.IdentityEnvironment) NodeEvaluation(org.olat.course.run.userview.NodeEvaluation)

Example 4 with CourseNodeIndexer

use of org.olat.search.service.indexer.repository.course.CourseNodeIndexer in project openolat by klemens.

the class CourseIndexer method doIndexCourse.

/**
 * @param repositoryResourceContext
 * @param course
 * @param courseNode
 * @param indexWriter
 * @throws IOException
 * @throws InterruptedException
 */
private void doIndexCourse(SearchResourceContext repositoryResourceContext, ICourse course, INode node, OlatFullIndexer indexWriter) throws IOException, InterruptedException {
    // try to index the course node
    if (node instanceof CourseNode) {
        if (isLogDebugEnabled())
            logDebug("Analyse CourseNode child ... childCourseNode=" + node);
        // go further with resource
        CourseNode childCourseNode = (CourseNode) node;
        CourseNodeIndexer courseNodeIndexer = getCourseNodeIndexer(childCourseNode);
        if (courseNodeIndexer != null) {
            if (isLogDebugEnabled())
                logDebug("courseNodeIndexer=" + courseNodeIndexer);
            try {
                courseNodeIndexer.doIndex(repositoryResourceContext, course, childCourseNode, indexWriter);
            } catch (Exception e) {
                logWarn("Can not index course node=" + childCourseNode.getIdent(), e);
            }
        }
    }
    // loop over all child nodes
    int childCount = node.getChildCount();
    for (int i = 0; i < childCount; i++) {
        INode childNode = node.getChildAt(i);
        doIndexCourse(repositoryResourceContext, course, childNode, indexWriter);
    }
}
Also used : INode(org.olat.core.util.nodes.INode) CourseNodeIndexer(org.olat.search.service.indexer.repository.course.CourseNodeIndexer) CourseNode(org.olat.course.nodes.CourseNode) AssertException(org.olat.core.logging.AssertException) CorruptedCourseException(org.olat.course.CorruptedCourseException) StartupException(org.olat.core.logging.StartupException) IOException(java.io.IOException)

Aggregations

AssertException (org.olat.core.logging.AssertException)4 CourseNode (org.olat.course.nodes.CourseNode)4 CourseNodeIndexer (org.olat.search.service.indexer.repository.course.CourseNodeIndexer)4 IOException (java.io.IOException)2 TreeNode (org.olat.core.gui.components.tree.TreeNode)2 IdentityEnvironment (org.olat.core.id.IdentityEnvironment)2 ContextEntry (org.olat.core.id.context.ContextEntry)2 StartupException (org.olat.core.logging.StartupException)2 INode (org.olat.core.util.nodes.INode)2 CorruptedCourseException (org.olat.course.CorruptedCourseException)2 ICourse (org.olat.course.ICourse)2 NodeEvaluation (org.olat.course.run.userview.NodeEvaluation)2 TreeEvaluation (org.olat.course.run.userview.TreeEvaluation)2 UserCourseEnvironment (org.olat.course.run.userview.UserCourseEnvironment)2 UserCourseEnvironmentImpl (org.olat.course.run.userview.UserCourseEnvironmentImpl)2 VisibleTreeFilter (org.olat.course.run.userview.VisibleTreeFilter)2 RepositoryEntry (org.olat.repository.RepositoryEntry)2 CourseNodeEntry (org.olat.search.service.indexer.repository.course.CourseNodeEntry)2