Skip to content

Commit 447e425

Browse files
PLUGINS-314 Adding disable functionality to configuration dashboard.
1 parent aaea4fe commit 447e425

29 files changed

Lines changed: 516 additions & 621 deletions
Lines changed: 13 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,25 @@
11
package org.nrg.xnat.xsync.anonymize;
22

33
import java.util.List;
4+
5+
import lombok.Getter;
6+
import lombok.Setter;
47
import org.nrg.dicom.mizer.objects.AnonymizationResult;
58

9+
@Getter
610
public class AnonScanResult {
711

8-
private final String id;
9-
private boolean removed = false;
10-
private List<AnonymizationResult> results;
12+
private final String id;
13+
@Setter
14+
private boolean removed = false;
15+
@Setter
16+
private List<AnonymizationResult> results;
1117

12-
public AnonScanResult(final String id) {
18+
public AnonScanResult(final String id) {
1319
this.id = id;
1420
}
1521

16-
public void setRemoved(final boolean removed) {
17-
this.removed = removed;
18-
}
19-
20-
public boolean isRemoved() {
21-
return this.removed;
22-
}
23-
24-
public String getId() {
25-
return this.id;
26-
}
27-
28-
public List<AnonymizationResult> getResults() {
29-
return this.results;
30-
}
31-
32-
public void setResults(final List<AnonymizationResult> results) {
33-
this.results = results;
34-
}
35-
36-
public boolean containsResult(final String entryName) {
37-
return getResults().stream().anyMatch(anonymizationResult -> anonymizationResult.getAbsolutePath().endsWith(entryName));
38-
}
22+
public boolean containsResult(final String entryName) {
23+
return getResults().stream().anyMatch(anonymizationResult -> anonymizationResult.getAbsolutePath().endsWith(entryName));
24+
}
3925
}

src/main/java/org/nrg/xsync/components/XsyncSitePreferencesBean.java

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,19 @@ public void setXsyncWhitelistEnabled(boolean xsyncWhitelistEnabled) {
104104
}
105105
}
106106

107+
@NrgPreference(defaultValue = "[]")
108+
public List<String> getSitesBlacklist() {
109+
return getListValue("sitesBlacklist");
110+
}
111+
112+
public void setSitesBlacklist(final List<String> sitesBlacklist) {
113+
try {
114+
setListValue("sitesBlacklist", sitesBlacklist);
115+
} catch (InvalidPreferenceName e) {
116+
_log.error("Invalid preference name: 'sitesBlacklist'");
117+
}
118+
}
119+
107120
@NrgPreference(defaultValue = "true")
108121
public boolean getHttpsEnabled() {
109122
return getBooleanValue("httpsEnabled");
@@ -187,7 +200,7 @@ public long getTokenRefreshIntervalInMillis() {
187200
try {
188201
return calculateIntervalInMillis(getValue("tokenRefreshInterval"));
189202
} catch (InvalidValueException e) {
190-
_log.info("XSync - Invalid token refresh interval specified - " + getValue("tokenRefreshInterval") + ". Using default.");
203+
_log.info("XSync - Invalid token refresh interval specified - {}. Using default.", getValue("tokenRefreshInterval"));
191204
try {
192205
return calculateIntervalInMillis(DEFAULT_TOKEN_REFRESH_INTERVAL);
193206
} catch (InvalidValueException e1) {
@@ -220,7 +233,7 @@ public long getSyncRetryIntervalInMillis() {
220233
try {
221234
return calculateIntervalInMillis(getValue("syncRetryInterval"));
222235
} catch (InvalidValueException e) {
223-
_log.info("XSync - Invalid sync refresh interval specified - " + getValue("syncRetryInterval") + ". Using default.");
236+
_log.info("XSync - Invalid sync refresh interval specified - {}. Using default.", getValue("syncRetryInterval"));
224237
try {
225238
return calculateIntervalInMillis(DEFAULT_SYNC_RETRY_INTERVAL);
226239
} catch (InvalidValueException e1) {
@@ -252,7 +265,7 @@ public int getSyncRetryCountInt() {
252265
try {
253266
return Integer.parseInt(getValue("syncRetryCount"));
254267
} catch (Exception e) {
255-
_log.info("XSync - Invalid sync refresh count specified - " + getValue("syncRetryCount") + ". Using default.");
268+
_log.info("XSync - Invalid sync refresh count specified - {}. Using default.", getValue("syncRetryCount"));
256269
try {
257270
return Integer.parseInt(DEFAULT_SYNC_RETRY_COUNT);
258271
} catch (Exception e1) {
@@ -273,7 +286,7 @@ private static long calculateIntervalInMillis(final String intervalStr) throws I
273286
final long minIntervalMilis = 300000;
274287

275288
if (intervalArr.length==2) {
276-
final long intervalNum = Long.valueOf(intervalArr[0]);
289+
final long intervalNum = Long.parseLong(intervalArr[0]);
277290
Long interval = null;
278291
if (intervalArr[1].toLowerCase().contains("hour")) {
279292
interval = intervalNum*1000*60*60;
@@ -341,6 +354,4 @@ public XsyncSitePreferencesPojo toPojo() {
341354
getAsperaEnabled()
342355
);
343356
}
344-
345-
346357
}

src/main/java/org/nrg/xsync/configuration/ProjectSyncConfiguration.java

Lines changed: 37 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import java.util.GregorianCalendar;
77

88
import lombok.extern.slf4j.Slf4j;
9+
import lombok.Getter;
910
import org.nrg.config.entities.Configuration;
1011
import org.nrg.config.services.ConfigService;
1112
import org.nrg.framework.constants.Scope;
@@ -35,59 +36,51 @@ public class ProjectSyncConfiguration {
3536
public ProjectSyncConfiguration(final ConfigService configService, final SerializerService serializer, final JdbcTemplate jdbcTemplate,
3637
final String projectId, final UserI user) throws XsyncNotConfiguredException {
3738
_user = user;
38-
_project = XnatProjectdata.getProjectByIDorAlias(projectId, user, false);
39+
project = XnatProjectdata.getProjectByIDorAlias(projectId, user, false);
3940
_configService = configService;
4041
_serializer = serializer;
4142
_jdbcTemplate = new NamedParameterJdbcTemplate(jdbcTemplate);
42-
_syncConfiguration = setSyncConfigurationFromService(projectId);
43-
_syncProjectConfiguration = setProjectSyncConfiguration();
44-
}
45-
46-
public XnatProjectdata getProject() {
47-
return _project;
43+
synchronizationConfiguration = setSyncConfigurationFromService(projectId);
44+
syncProjectConfiguration = setProjectSyncConfiguration();
4845
}
4946

5047
public XsyncXsyncprojectdata getProjectSyncConfigurationFromDB() {
51-
return _syncProjectConfiguration;
52-
}
53-
54-
public SyncConfiguration getSynchronizationConfiguration() {
55-
return _syncConfiguration;
48+
return syncProjectConfiguration;
5649
}
5750

5851
public boolean isResourceToBeSynced(String resourceLabel) {
59-
return _syncConfiguration != null && _syncConfiguration.isProjectResourceAllowedToSync(resourceLabel);
52+
return synchronizationConfiguration != null && synchronizationConfiguration.isProjectResourceAllowedToSync(resourceLabel);
6053
}
6154

6255
public boolean isSubjectResourceToBeSynced(String resourceLabel) {
63-
return _syncConfiguration != null && _syncConfiguration.isSubjectResourceAllowedToSync(resourceLabel);
56+
return synchronizationConfiguration != null && synchronizationConfiguration.isSubjectResourceAllowedToSync(resourceLabel);
6457
}
6558

6659
public boolean isSubjectAssessorToBeSynced(String assessorXsiType) {
67-
return _syncConfiguration != null && _syncConfiguration.isSubjectAssessorAllowedToSync(assessorXsiType);
60+
return synchronizationConfiguration != null && synchronizationConfiguration.isSubjectAssessorAllowedToSync(assessorXsiType);
6861
}
6962

7063
public boolean isSubjectAssessorResourceToBeSynced(String assessorXsiType, String resourceLabel) {
7164
boolean allowedToSync = true;
72-
if (_syncConfiguration.hasSubjectAssessorConfigurationDefinition()) {
73-
SyncConfigurationXsiType advOption = _syncConfiguration.getSubjectAssessor(assessorXsiType);
65+
if (synchronizationConfiguration.hasSubjectAssessorConfigurationDefinition()) {
66+
SyncConfigurationXsiType advOption = synchronizationConfiguration.getSubjectAssessor(assessorXsiType);
7467
allowedToSync = advOption.isResourceAllowedToSync(resourceLabel);
7568
}
7669
return allowedToSync;
7770
}
7871

7972
public boolean subjectAssessorNeedsOkToSync(String assessorXsiType) {
80-
if (_syncConfiguration.hasSubjectAssessorConfigurationDefinition()) {
81-
SyncConfigurationXsiType advOption = _syncConfiguration.getSubjectAssessor(assessorXsiType);
73+
if (synchronizationConfiguration.hasSubjectAssessorConfigurationDefinition()) {
74+
SyncConfigurationXsiType advOption = synchronizationConfiguration.getSubjectAssessor(assessorXsiType);
8275
return advOption.getNeeds_ok_to_sync();
8376
} else {
8477
return false;
8578
}
8679
}
8780

8881
public boolean imagingSessionNeedsOkToSync(String xsiType) {
89-
if (_syncConfiguration.hasImagingSessionConfigurationDefinition()) {
90-
SyncConfigurationImagingSessionXsiType advOption = _syncConfiguration.getImagingSession(xsiType);
82+
if (synchronizationConfiguration.hasImagingSessionConfigurationDefinition()) {
83+
SyncConfigurationImagingSessionXsiType advOption = synchronizationConfiguration.getImagingSession(xsiType);
9184
try {
9285
return advOption.getNeeds_ok_to_sync();
9386
}catch(Exception e) {
@@ -99,8 +92,8 @@ public boolean imagingSessionNeedsOkToSync(String xsiType) {
9992
}
10093

10194
public boolean imagingAssessorNeedsOkToSync(String xsiType, String assessorXsiType) {
102-
if (_syncConfiguration.hasImagingSessionConfigurationDefinition()) {
103-
SyncConfigurationImagingSessionXsiType advOption = _syncConfiguration.getImagingSession(xsiType);
95+
if (synchronizationConfiguration.hasImagingSessionConfigurationDefinition()) {
96+
SyncConfigurationImagingSessionXsiType advOption = synchronizationConfiguration.getImagingSession(xsiType);
10497
try {
10598
SyncConfigurationXsiType advSessionAssessorOption = advOption.getSession_assessors().getXsiType(assessorXsiType);
10699
return advSessionAssessorOption.getNeeds_ok_to_sync();
@@ -117,24 +110,23 @@ public boolean isOnlyASubjectAssessor(XnatSubjectassessordataI experiment) {
117110
}
118111

119112
public boolean isImagingSessionToBeSynced(String imagingSessionXsiType) {
120-
return _syncConfiguration != null && _syncConfiguration.isImagingSessionAllowedToSync(imagingSessionXsiType);
113+
return synchronizationConfiguration != null && synchronizationConfiguration.isImagingSessionAllowedToSync(imagingSessionXsiType);
121114
}
122115

123116
public boolean isImagingSessionScanToBeSynced(String imagingSessionXsiType, String imagingScanType) {
124-
if (_syncConfiguration == null) {
117+
if (synchronizationConfiguration == null) {
125118
return false;
126119
} else {
127-
SyncConfigurationImagingSessionXsiType imgSessionAdvOption = _syncConfiguration.getImagingSession(imagingSessionXsiType);
120+
SyncConfigurationImagingSessionXsiType imgSessionAdvOption = synchronizationConfiguration.getImagingSession(imagingSessionXsiType);
128121
return imgSessionAdvOption.isAllowedToSyncScan(imagingScanType);
129122
}
130-
131123
}
132124

133125
public boolean isImagingSessionScanResourceToBeSynced(String imagingSessionXsiType, String imagingScanType, String imagingScanResourceName) {
134-
if (_syncConfiguration == null) {
126+
if (synchronizationConfiguration == null) {
135127
return false;
136128
}
137-
SyncConfigurationImagingSessionXsiType imgSessionAdvOption = _syncConfiguration.getImagingSession(imagingSessionXsiType);
129+
SyncConfigurationImagingSessionXsiType imgSessionAdvOption = synchronizationConfiguration.getImagingSession(imagingSessionXsiType);
138130
return imgSessionAdvOption.isAllowedToSyncScan(imagingScanType) && imgSessionAdvOption.isAllowedToSyncScanResource(imagingScanResourceName);
139131
}
140132

@@ -162,12 +154,12 @@ public boolean isThisProjectBeingSyncedForTheFirstTime() {
162154
@Override
163155
public String toString() {
164156
String self = "";
165-
self += " Project : " + _project + "\n";
166-
self += "SyncConfiguration: " + _syncConfiguration + "\n";
157+
self += " Project : " + project + "\n";
158+
self += "SyncConfiguration: " + synchronizationConfiguration + "\n";
167159
self += " DB SyncInfo: " + "\n";
168-
self += "Remote Project: " + _syncProjectConfiguration.getSyncinfo().getRemoteProjectId() + "\n";
169-
self += "Remote URL: " + _syncProjectConfiguration.getSyncinfo().getRemoteUrl();
170-
self += "Sync_Blocked: " + _syncProjectConfiguration.getSyncBlocked();
160+
self += "Remote Project: " + syncProjectConfiguration.getSyncinfo().getRemoteProjectId() + "\n";
161+
self += "Remote URL: " + syncProjectConfiguration.getSyncinfo().getRemoteUrl();
162+
self += "Sync_Blocked: " + syncProjectConfiguration.getSyncBlocked();
171163
return self;
172164
}
173165

@@ -177,11 +169,11 @@ private static String getAnonymizationFilePath(final String projectArchiveRootPa
177169

178170
private XsyncXsyncprojectdata setProjectSyncConfiguration() throws XsyncNotConfiguredException {
179171
final XsyncUtils xsyncUtils = new XsyncUtils(_jdbcTemplate, _user);
180-
final XsyncXsyncprojectdata syncProjectConfiguration = xsyncUtils.getSyncDetailsForProject(_project.getId());
172+
final XsyncXsyncprojectdata syncProjectConfiguration = xsyncUtils.getSyncDetailsForProject(project.getId());
181173

182174
if (syncProjectConfiguration == null) {
183-
log.error("Could not find sync data for _project {}", _project.getId());
184-
throw new XsyncNotConfiguredException("Could not find sync data for _project " + _project.getId());
175+
log.error("Could not find sync data for project {}", project.getId());
176+
throw new XsyncNotConfiguredException("Could not find sync data for project " + project.getId());
185177
}
186178
boolean save = false;
187179
//No sync has been done so far. Set a dummy date and then start
@@ -201,7 +193,7 @@ private XsyncXsyncprojectdata setProjectSyncConfiguration() throws XsyncNotConfi
201193
syncProjectConfiguration.save(_user, false, true, c);
202194
} catch (Exception e) {
203195
log.debug("Unable to save synchronization start time: Cause:{}", e.getMessage());
204-
throw new XsyncNotConfiguredException("Unable to save synchronization start time: " + " Cause:" + e.getMessage());
196+
throw new XsyncNotConfiguredException("Unable to save synchronization start time: Cause:" + e.getMessage());
205197
}
206198
}
207199
return syncProjectConfiguration;
@@ -214,10 +206,10 @@ private SyncConfiguration setSyncConfigurationFromService(final String projectId
214206
try {
215207
return _serializer.deserializeJson(config, SyncConfiguration.class);
216208
} catch (Exception e) {
217-
throw new XsyncNotConfiguredException("Synchronization Configuration does not exist for " + _project.getId());
209+
throw new XsyncNotConfiguredException("Synchronization Configuration does not exist for " + project.getId());
218210
}
219211
} else {
220-
throw new XsyncNotConfiguredException("Synchronization Configuration does not exist for " + _project.getId());
212+
throw new XsyncNotConfiguredException("Synchronization Configuration does not exist for " + project.getId());
221213
}
222214
}
223215

@@ -227,7 +219,9 @@ private SyncConfiguration setSyncConfigurationFromService(final String projectId
227219
private final SerializerService _serializer;
228220
private final NamedParameterJdbcTemplate _jdbcTemplate;
229221
private final UserI _user;
230-
private final XsyncXsyncprojectdata _syncProjectConfiguration;
231-
private final XnatProjectdata _project;
232-
private final SyncConfiguration _syncConfiguration;
222+
private final XsyncXsyncprojectdata syncProjectConfiguration;
223+
@Getter
224+
private final XnatProjectdata project;
225+
@Getter
226+
private final SyncConfiguration synchronizationConfiguration;
233227
}

src/main/java/org/nrg/xsync/configuration/json/SyncConfiguration.java

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,7 @@ public boolean isSubjectAssessorAllowedToSync(String xsiType) {
5555
}else {
5656
return true; //Anything not configured defaults to sync
5757
}
58-
} catch(NullPointerException ignored) {
59-
60-
}
58+
} catch(NullPointerException ignored) {}
6159
return false;
6260
}
6361

@@ -69,7 +67,6 @@ public boolean hasSubjectResourceConfigurationDefinition() {
6967
return subject_resources != null;
7068
}
7169

72-
7370
public boolean hasSubjectAssessorConfigurationDefinition() {
7471
return subject_assessors != null;
7572
}
@@ -92,16 +89,16 @@ public boolean isImagingSessionAllowedToSync(String xsiType) {
9289
public SyncConfigurationXsiType getSubjectAssessor(String xsiType) {
9390
SyncConfigurationXsiType advOption = SyncConfigurationXsiType.GetDefaultSyncConfiguration(xsiType);
9491
if (hasSubjectAssessorConfigurationDefinition()) {
95-
List<SyncConfigurationXsiType> advOptions = subject_assessors.getXsi_types();
96-
if (advOptions == null || advOptions.isEmpty()) {
97-
return advOption;
98-
}
99-
for (SyncConfigurationXsiType aOption : advOptions) {
100-
if (xsiType.equals(aOption.getXsi_type())) {
101-
advOption = aOption;
102-
break;
103-
}
92+
List<SyncConfigurationXsiType> advOptions = subject_assessors.getXsi_types();
93+
if (advOptions == null || advOptions.isEmpty()) {
94+
return advOption;
95+
}
96+
for (SyncConfigurationXsiType aOption : advOptions) {
97+
if (xsiType.equals(aOption.getXsi_type())) {
98+
advOption = aOption;
99+
break;
104100
}
101+
}
105102
}
106103
return advOption;
107104
}

0 commit comments

Comments
 (0)