Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
OLAT CI-CD Testing Project
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Requirements
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Service Desk
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Lars Oliver Dam
OLAT CI-CD Testing Project
Commits
7c1f98fa
Commit
7c1f98fa
authored
6 years ago
by
srosse
Browse files
Options
Downloads
Patches
Plain Diff
OO-3909: hardened the tree visitor to handle possible "null" nodes
parent
94316f2a
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/main/java/org/olat/core/util/tree/TreeVisitor.java
+6
-4
6 additions, 4 deletions
src/main/java/org/olat/core/util/tree/TreeVisitor.java
src/main/java/org/olat/course/folder/MergedCourseElementDataContainer.java
+9
-20
9 additions, 20 deletions
.../olat/course/folder/MergedCourseElementDataContainer.java
with
15 additions
and
24 deletions
src/main/java/org/olat/core/util/tree/TreeVisitor.java
+
6
−
4
View file @
7c1f98fa
...
...
@@ -61,10 +61,12 @@ public class TreeVisitor {
if
(!
visitChildrenFirst
)
{
v
.
visit
(
node
);
}
int
chdCnt
=
node
.
getChildCount
();
for
(
int
i
=
0
;
i
<
chdCnt
;
i
++)
{
INode
chd
=
node
.
getChildAt
(
i
);
doVisit
(
chd
);
if
(
node
!=
null
)
{
int
chdCnt
=
node
.
getChildCount
();
for
(
int
i
=
0
;
i
<
chdCnt
;
i
++)
{
INode
chd
=
node
.
getChildAt
(
i
);
doVisit
(
chd
);
}
}
if
(
visitChildrenFirst
)
{
v
.
visit
(
node
);
...
...
This diff is collapsed.
Click to expand it.
src/main/java/org/olat/course/folder/MergedCourseElementDataContainer.java
+
9
−
20
View file @
7c1f98fa
...
...
@@ -31,9 +31,7 @@ import org.olat.core.id.IdentityEnvironment;
import
org.olat.core.logging.OLog
;
import
org.olat.core.logging.Tracing
;
import
org.olat.core.util.StringHelper
;
import
org.olat.core.util.nodes.INode
;
import
org.olat.core.util.tree.TreeVisitor
;
import
org.olat.core.util.tree.Visitor
;
import
org.olat.core.util.vfs.MergeSource
;
import
org.olat.core.util.vfs.NamedContainerImpl
;
import
org.olat.core.util.vfs.Quota
;
...
...
@@ -92,12 +90,9 @@ public class MergedCourseElementDataContainer extends MergeSource {
ICourse
course
=
CourseFactory
.
loadCourse
(
courseId
);
AtomicInteger
count
=
new
AtomicInteger
(
0
);
if
(
identityEnv
==
null
)
{
new
TreeVisitor
(
new
Visitor
()
{
@Override
public
void
visit
(
INode
node
)
{
if
(
node
instanceof
PFCourseNode
||
node
instanceof
BCCourseNode
)
{
count
.
incrementAndGet
();
}
new
TreeVisitor
(
node
->
{
if
(
node
instanceof
PFCourseNode
||
node
instanceof
BCCourseNode
)
{
count
.
incrementAndGet
();
}
},
course
.
getRunStructure
().
getRootNode
(),
true
).
visitAll
();
}
else
if
(
course
instanceof
PersistingCourseImpl
)
{
...
...
@@ -107,18 +102,12 @@ public class MergedCourseElementDataContainer extends MergeSource {
CourseNode
rootCn
=
userCourseEnv
.
getCourseEnvironment
().
getRunStructure
().
getRootNode
();
NodeEvaluation
rootNodeEval
=
rootCn
.
eval
(
userCourseEnv
.
getConditionInterpreter
(),
treeEval
,
new
VisibleTreeFilter
());
new
TreeVisitor
(
new
Visitor
()
{
@Override
public
void
visit
(
INode
node
)
{
if
(
node
instanceof
TreeNode
)
{
if
(((
TreeNode
)
node
).
getUserObject
()
instanceof
NodeEvaluation
)
{
NodeEvaluation
nodeEval
=
(
NodeEvaluation
)((
TreeNode
)
node
).
getUserObject
();
if
(
nodeEval
!=
null
&&
(
nodeEval
.
getCourseNode
()
instanceof
PFCourseNode
||
nodeEval
.
getCourseNode
()
instanceof
BCCourseNode
))
{
count
.
incrementAndGet
();
}
}
new
TreeVisitor
(
node
->
{
if
(
node
instanceof
TreeNode
&&
((
TreeNode
)
node
).
getUserObject
()
instanceof
NodeEvaluation
)
{
NodeEvaluation
nodeEval
=
(
NodeEvaluation
)((
TreeNode
)
node
).
getUserObject
();
if
(
nodeEval
!=
null
&&
(
nodeEval
.
getCourseNode
()
instanceof
PFCourseNode
||
nodeEval
.
getCourseNode
()
instanceof
BCCourseNode
))
{
count
.
incrementAndGet
();
}
}
},
rootNodeEval
.
getTreeNode
(),
true
).
visitAll
();
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment