Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
X
xnat-web
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository 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
dhcp
xnat-web
Commits
21e28946
Commit
21e28946
authored
8 years ago
by
Mike McKay
Browse files
Options
Downloads
Patches
Plain Diff
Made changes to the Site-wide Anonymization Script take effect.
parent
73306f36
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/nrg/xnat/event/listeners/methods/AnonymizationHandlerMethod.java
+77
-0
77 additions, 0 deletions
...t/event/listeners/methods/AnonymizationHandlerMethod.java
with
77 additions
and
0 deletions
src/main/java/org/nrg/xnat/event/listeners/methods/AnonymizationHandlerMethod.java
0 → 100644
+
77
−
0
View file @
21e28946
package
org.nrg.xnat.event.listeners.methods
;
import
com.google.common.collect.ImmutableList
;
import
org.nrg.xdat.XDAT
;
import
org.nrg.xdat.security.helpers.Roles
;
import
org.nrg.xdat.security.helpers.Users
;
import
org.nrg.xft.security.UserI
;
import
org.nrg.xnat.helpers.editscript.DicomEdit
;
import
org.nrg.xnat.helpers.merge.AnonUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.context.annotation.Lazy
;
import
org.springframework.jdbc.core.JdbcTemplate
;
import
org.springframework.stereotype.Component
;
import
java.util.Arrays
;
import
java.util.Collections
;
import
java.util.List
;
import
java.util.Map
;
@Component
public
class
AnonymizationHandlerMethod
extends
AbstractSiteConfigPreferenceHandlerMethod
{
@Override
public
List
<
String
>
getHandledPreferences
()
{
return
PREFERENCES
;
}
@Override
public
void
handlePreferences
(
final
Map
<
String
,
String
>
values
)
{
if
(!
Collections
.
disjoint
(
PREFERENCES
,
values
.
keySet
()))
{
updateInactivityBeforeLockout
();
}
}
@Override
public
void
handlePreference
(
final
String
preference
,
final
String
value
)
{
if
(
PREFERENCES
.
contains
(
preference
)){
updateInactivityBeforeLockout
();
}
}
private
void
updateInactivityBeforeLockout
(){
try
{
if
(
XDAT
.
getSiteConfigPreferences
().
getEnableSitewideAnonymizationScript
())
{
AnonUtils
.
getService
().
enableSiteWide
(
getAdminUser
().
getLogin
(),
DicomEdit
.
buildScriptPath
(
DicomEdit
.
ResourceScope
.
SITE_WIDE
,
null
));
}
else
{
AnonUtils
.
getService
().
disableSiteWide
(
getAdminUser
().
getLogin
(),
DicomEdit
.
buildScriptPath
(
DicomEdit
.
ResourceScope
.
SITE_WIDE
,
null
));
}
}
catch
(
Exception
e
){
_log
.
error
(
"Failed to enable/disable sitewide anon script."
,
e
);
}
try
{
AnonUtils
.
getService
().
setSiteWideScript
(
getAdminUser
().
getLogin
(),
DicomEdit
.
buildScriptPath
(
DicomEdit
.
ResourceScope
.
SITE_WIDE
,
null
),
XDAT
.
getSiteConfigPreferences
().
getSitewideAnonymizationScript
());
}
catch
(
Exception
e
){
_log
.
error
(
"Failed to set sitewide anon script."
,
e
);
}
}
private
static
final
Logger
_log
=
LoggerFactory
.
getLogger
(
AnonymizationHandlerMethod
.
class
);
private
static
final
List
<
String
>
PREFERENCES
=
ImmutableList
.
copyOf
(
Arrays
.
asList
(
"enableSitewideAnonymizationScript"
,
"sitewideAnonymizationScript"
));
private
UserI
getAdminUser
()
throws
Exception
{
for
(
String
login
:
Users
.
getAllLogins
())
{
final
UserI
user
=
Users
.
getUser
(
login
);
if
(
Roles
.
isSiteAdmin
(
user
))
{
return
user
;
}
}
return
null
;
}
@Autowired
@Lazy
private
JdbcTemplate
_template
;
}
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