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);
}
}
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;
}
}
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;
}
}
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);
}
}
Aggregations