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
7447d2ad
"README.md" did not exist on "2f0d5c2ec445e45a2851e6d674d37377fb48c80d"
Commit
7447d2ad
authored
6 years ago
by
srosse
Browse files
Options
Downloads
Patches
Plain Diff
OO-3881: delete drop participant folders and tasks of deleted users
parent
dc577714
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/org/olat/admin/user/delete/service/DeleteUserDataTask.java
+48
-3
48 additions, 3 deletions
...rg/olat/admin/user/delete/service/DeleteUserDataTask.java
with
48 additions
and
3 deletions
src/main/java/org/olat/admin/user/delete/service/DeleteUserDataTask.java
+
48
−
3
View file @
7447d2ad
...
...
@@ -35,12 +35,14 @@ import org.olat.core.logging.OLog;
import
org.olat.core.logging.Tracing
;
import
org.olat.core.util.FileUtils
;
import
org.olat.core.util.StringHelper
;
import
org.olat.core.util.io.SystemFileFilter
;
import
org.olat.course.CourseFactory
;
import
org.olat.course.ICourse
;
import
org.olat.course.PersistingCourseImpl
;
import
org.olat.course.assessment.manager.CourseAssessmentManagerImpl
;
import
org.olat.course.nodes.ProjectBrokerCourseNode
;
import
org.olat.course.nodes.TACourseNode
;
import
org.olat.course.nodes.pf.manager.PFManager
;
import
org.olat.course.nodes.ta.DropboxController
;
import
org.olat.course.nodes.ta.ReturnboxController
;
import
org.olat.resource.OLATResource
;
...
...
@@ -91,6 +93,49 @@ public class DeleteUserDataTask implements LowPriorityRunnable {
if
(
courseDir
.
isDirectory
())
{
deleteAssessmentDocuments
(
identity
,
courseDir
);
deleteDropboxReturnbox
(
identity
,
courseDir
);
deleteParticipantFolder
(
identity
,
courseDir
);
deleteGTasks
(
identity
,
courseDir
);
}
}
}
/**
* /coursedir/participantfolder/{node}/{identityKey}
* @param identity
* @param courseDir
*/
private
void
deleteParticipantFolder
(
Identity
identity
,
File
courseDir
)
{
File
participantFoldersDir
=
new
File
(
courseDir
,
PFManager
.
FILENAME_PARTICIPANTFOLDER
);
if
(
participantFoldersDir
.
exists
())
{
File
[]
nodeDirs
=
participantFoldersDir
.
listFiles
(
new
SystemFileFilter
(
false
,
true
));
for
(
File
nodeDir:
nodeDirs
)
{
File
userDir
=
new
File
(
nodeDir
,
identity
.
getKey
().
toString
());
if
(
userDir
.
exists
())
{
FileUtils
.
deleteDirsAndFiles
(
userDir
,
true
,
true
);
log
.
audit
(
"User-Deletion: identity="
+
identity
.
getKey
()
+
" : User file data deleted under dir="
+
userDir
.
getAbsolutePath
());
}
}
}
}
/**
* /coursedir/gtasks/{nodeId}/revisions/person_{identityKey}
* @param identity
* @param courseDir
*/
private
void
deleteGTasks
(
Identity
identity
,
File
courseDir
)
{
File
gtasksDir
=
new
File
(
courseDir
,
"gtasks"
);
if
(
gtasksDir
.
exists
())
{
File
[]
nodeDirs
=
gtasksDir
.
listFiles
(
new
SystemFileFilter
(
false
,
true
));
for
(
File
nodeDir:
nodeDirs
)
{
File
[]
boxes
=
nodeDir
.
listFiles
(
new
SystemFileFilter
(
false
,
true
));
for
(
File
box:
boxes
)
{
File
userDir
=
new
File
(
box
,
"person_"
+
identity
.
getKey
());
if
(
userDir
.
exists
())
{
FileUtils
.
deleteDirsAndFiles
(
userDir
,
true
,
true
);
log
.
audit
(
"User-Deletion: identity="
+
identity
.
getKey
()
+
" : User file data deleted under dir="
+
userDir
.
getAbsolutePath
());
}
}
}
}
}
...
...
@@ -98,7 +143,7 @@ public class DeleteUserDataTask implements LowPriorityRunnable {
private
void
deleteAssessmentDocuments
(
Identity
identity
,
File
courseDir
)
{
File
assessmentDocsDir
=
new
File
(
courseDir
,
CourseAssessmentManagerImpl
.
ASSESSMENT_DOCS_DIR
);
if
(
assessmentDocsDir
.
exists
())
{
File
[]
nodeDirs
=
assessmentDocsDir
.
listFiles
();
File
[]
nodeDirs
=
assessmentDocsDir
.
listFiles
(
new
SystemFileFilter
(
false
,
true
)
);
for
(
File
nodeDir:
nodeDirs
)
{
File
userDir
=
new
File
(
nodeDir
,
"person_"
+
identity
.
getKey
());
if
(
userDir
.
exists
())
{
...
...
@@ -118,7 +163,7 @@ public class DeleteUserDataTask implements LowPriorityRunnable {
for
(
File
dropboxReturnboxDir:
dropboxReturnboxDirs
)
{
if
(!
dropboxReturnboxDir
.
exists
())
continue
;
File
[]
nodeDirs
=
dropboxReturnboxDir
.
listFiles
();
File
[]
nodeDirs
=
dropboxReturnboxDir
.
listFiles
(
new
SystemFileFilter
(
false
,
true
)
);
// 3. loop over all node-id e.g. 78933379704296
for
(
File
nodeDir:
nodeDirs
)
{
String
currentNodeId
=
nodeDir
.
getName
();
...
...
@@ -132,7 +177,7 @@ public class DeleteUserDataTask implements LowPriorityRunnable {
deleteUserDirectory
(
identity
,
nodeDir
);
}
else
if
(
isProjectBrokerNode
(
currentCourse
,
currentNodeId
))
{
// additional loop over project-id
File
[]
projectDirs
=
nodeDir
.
listFiles
();
File
[]
projectDirs
=
nodeDir
.
listFiles
(
new
SystemFileFilter
(
false
,
true
)
);
for
(
File
projectDir:
projectDirs
)
{
deleteUserDirectory
(
identity
,
projectDir
);
}
...
...
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