diff --git a/experiment/src/org/labkey/experiment/api/ExperimentServiceImpl.java b/experiment/src/org/labkey/experiment/api/ExperimentServiceImpl.java index e64a820f563..4026b3ea3ee 100644 --- a/experiment/src/org/labkey/experiment/api/ExperimentServiceImpl.java +++ b/experiment/src/org/labkey/experiment/api/ExperimentServiceImpl.java @@ -8564,7 +8564,7 @@ private void removeDataTypeExclusion(Collection rowIds, DataTypeForExcl new SqlExecutor(getExpSchema()).execute(sql); } - @NotNull private Map[] _getContainerDataTypeExclusions(@Nullable DataTypeForExclusion dataType, @Nullable String excludedContainerIdOrPath, @Nullable Integer dataTypeRowId) + @NotNull private List> _getContainerDataTypeExclusions(@Nullable DataTypeForExclusion dataType, @Nullable String excludedContainerIdOrPath, @Nullable Integer dataTypeRowId) { SQLFragment sql = new SQLFragment("SELECT DataTypeRowId, DataType, ExcludedContainer FROM ") .append(getTinfoDataTypeExclusion()) @@ -8583,8 +8583,13 @@ private void removeDataTypeExclusion(Collection rowIds, DataTypeForExcl if (!GUID.isGUID(excludedContainerIdOrPath)) { Container container = ContainerManager.getForPath(excludedContainerIdOrPath); - if (container != null) - excludedContainerId = container.getId(); + if (container == null) + { + // container not found, it may have been deleted, return empty array instead of making the DB query + return Collections.emptyList(); + } + + excludedContainerId = container.getId(); } sql.append(and); @@ -8600,13 +8605,13 @@ private void removeDataTypeExclusion(Collection rowIds, DataTypeForExcl sql.add(dataTypeRowId); } - return new SqlSelector(getTinfoDataTypeExclusion().getSchema(), sql).getMapArray(); + return Arrays.stream(new SqlSelector(getTinfoDataTypeExclusion().getSchema(), sql).getMapArray()).toList(); } @Override public @NotNull Map> getContainerDataTypeExclusions(@NotNull String excludedContainerId) { - Map[] exclusions = _getContainerDataTypeExclusions(null, excludedContainerId, null); + List> exclusions = _getContainerDataTypeExclusions(null, excludedContainerId, null); Map> typeExclusions = new HashMap<>(); for (Map exclusion : exclusions) @@ -8624,7 +8629,7 @@ private void removeDataTypeExclusion(Collection rowIds, DataTypeForExcl @Override public Set getDataTypeContainerExclusions(@NotNull DataTypeForExclusion dataType, @NotNull Integer dataTypeRowId) { - Map[] exclusions = _getContainerDataTypeExclusions(dataType, null, dataTypeRowId); + List> exclusions = _getContainerDataTypeExclusions(dataType, null, dataTypeRowId); Set excludedProjects = new HashSet<>(); for (Map exclusion : exclusions) excludedProjects.add((String) exclusion.get("ExcludedContainer")); @@ -8635,7 +8640,7 @@ public Set getDataTypeContainerExclusions(@NotNull DataTypeForExclusion private Set _getContainerDataTypeExclusions(DataTypeForExclusion dataType, String excludedContainerId) { Set excludedRowIds = new HashSet<>(); - Map[] exclusions = _getContainerDataTypeExclusions(dataType, excludedContainerId, null); + List> exclusions = _getContainerDataTypeExclusions(dataType, excludedContainerId, null); for (Map exclusion : exclusions) excludedRowIds.add((Integer) exclusion.get("DataTypeRowId"));