Skip to content

Commit 781f01c

Browse files
Ticket 45210: Fall back quietly when adding demographics sources via linked schema doesn't allow referencing configured source container
1 parent e926756 commit 781f01c

File tree

3 files changed

+29
-11
lines changed

3 files changed

+29
-11
lines changed

laboratory/src/org/labkey/laboratory/AdditionalDataSource.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package org.labkey.laboratory;
22

33
import org.apache.commons.lang3.StringUtils;
4-
import org.apache.logging.log4j.Logger;
54
import org.apache.logging.log4j.LogManager;
5+
import org.apache.logging.log4j.Logger;
66
import org.jetbrains.annotations.Nullable;
77
import org.json.JSONException;
88
import org.json.JSONObject;
@@ -46,7 +46,7 @@ public static AdditionalDataSource getFromParts(Container c, User u, String item
4646
return new AdditionalDataSource(cat, label, containerId, schemaName, queryName, reportCategory, importIntoWorkbooks, subjectFieldKey, sampleDateFieldKey);
4747
}
4848

49-
public static AdditionalDataSource getFromPropertyManager(Container c, User u, String key, String value) throws IllegalArgumentException
49+
public static @Nullable AdditionalDataSource getFromPropertyManager(Container c, User u, String key, String value) throws IllegalArgumentException
5050
{
5151
if (value == null)
5252
return null;

laboratory/src/org/labkey/laboratory/DemographicsSource.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,12 @@ public static DemographicsSource getFromParts(Container c, User u, String label,
4444
return new DemographicsSource(label, containerId, schemaName, queryName, targetColumn);
4545
}
4646

47-
public static DemographicsSource getFromPropertyManager(Container c, User u, String key, String value) throws IllegalArgumentException
47+
public static @Nullable DemographicsSource getFromPropertyManager(Container c, User u, String key, String value) throws IllegalArgumentException
4848
{
4949
if (value == null)
50+
{
5051
return null;
52+
}
5153

5254
try
5355
{

laboratory/src/org/labkey/laboratory/LaboratoryServiceImpl.java

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -431,11 +431,19 @@ public Map<Container, Set<AdditionalDataSource>> getAllAdditionalDataSources(Use
431431
set = new HashSet<>();
432432

433433
AdditionalDataSource source = AdditionalDataSource.getFromPropertyManager(c, u, entry.getKey(), entry.getValue());
434-
if (source != null)
435-
set.add(source);
434+
if (source == null)
435+
{
436+
continue;
437+
}
438+
439+
Container targetContainer = source.getTargetContainer(c);
440+
if (targetContainer == null || !targetContainer.hasPermission(u, ReadPermission.class))
441+
{
442+
continue;
443+
}
436444

437-
if (set.size() > 0)
438-
map.put(c, set);
445+
set.add(source);
446+
map.put(c, set);
439447
}
440448

441449
return Collections.unmodifiableMap(map);
@@ -457,11 +465,19 @@ public Map<Container, Set<DemographicsSource>> getAllDemographicsSources(User u)
457465
set = new HashSet<>();
458466

459467
DemographicsSource source = DemographicsSource.getFromPropertyManager(c, u, entry.getKey(), entry.getValue());
460-
if (source != null)
461-
set.add(source);
468+
if (source == null)
469+
{
470+
continue;
471+
}
472+
473+
Container targetContainer = source.getTargetContainer(c);
474+
if (targetContainer == null || !targetContainer.hasPermission(u, ReadPermission.class))
475+
{
476+
continue;
477+
}
462478

463-
if (set.size() > 0)
464-
map.put(c, set);
479+
set.add(source);
480+
map.put(c, set);
465481
}
466482

467483
return Collections.unmodifiableMap(map);

0 commit comments

Comments
 (0)