Skip to content

Commit b29668a

Browse files
labkey-klumlabkey-nickacnathe
authored
Container scoping improvements for NAb assay (#7747)
#### Rationale Small refactors to help introduce better container scoping checks for NAb actions. #### Related Pull Requests - #7747 - LabKey/commonAssays#1022 - LabKey/testAutomation#3042 --------- Co-authored-by: labkey-nicka <[email protected]> Co-authored-by: cnathe <[email protected]>
1 parent 3c591cd commit b29668a

6 files changed

Lines changed: 44 additions & 4 deletions

File tree

api/src/org/labkey/api/exp/api/ExperimentService.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,9 @@ enum DataTypeForExclusion
163163
@Nullable
164164
ExpRun getExpRun(int rowId);
165165

166+
@Nullable
167+
ExpRun getExpRun(int rowId, @Nullable Container container);
168+
166169
List<? extends ExpRun> getExpRuns(Collection<Integer> rowIds);
167170

168171
@Nullable

api/src/org/labkey/api/view/ViewServlet.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -506,6 +506,12 @@ public void setActionURL(ActionURL actionURL)
506506
return _actionURL.getParameterMap();
507507
}
508508

509+
@Override
510+
public String getParameter(@NotNull String name)
511+
{
512+
return _actionURL.getParameter(name);
513+
}
514+
509515
@Override
510516
public @NotNull String @NotNull [] getParameterValues(@NotNull String name)
511517
{

assay/api-src/org/labkey/api/assay/nab/view/DilutionGraphAction.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ public ModelAndView getView(GraphForm form, BindException errors) throws Excepti
4444
{
4545
if (form.getRowId() == -1)
4646
throw new NotFoundException("Run ID not specified.");
47-
ExpRun run = ExperimentService.get().getExpRun(form.getRowId());
47+
// GitHub Issue #1892: Resolve the run scoped to the current container
48+
ExpRun run = ExperimentService.get().getExpRun(form.getRowId(), getContainer());
4849
if (run == null)
4950
throw new NotFoundException("Run " + form.getRowId() + " does not exist.");
5051

assay/api-src/org/labkey/api/assay/nab/view/GraphSelectedAction.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ public ModelAndView getView(FormType form, BindException errors) throws Exceptio
7171
objectIds[idx++] = Integer.parseInt(objectIdString);
7272
}
7373

74+
// GitHub Issue #1892: (NAB-9) The object ids come straight from the request and getDilutionSummaries() resolves them to runs
75+
verifyObjectIdsReadable(objectIds);
7476
Set<Integer> cutoffSet = new HashSet<>();
7577
DilutionAssayProvider provider = (DilutionAssayProvider) AssayService.get().getProvider(_protocol);
7678
Map<DilutionSummary, DilutionAssayRun> summaries = provider.getDataHandler().getDilutionSummaries(getUser(), form.getFitTypeEnum(), objectIds);
@@ -92,6 +94,13 @@ public ModelAndView getView(FormType form, BindException errors) throws Exceptio
9294
return new VBox(new AssayHeaderView(_protocol, provider, false, true, null), multiGraphView);
9395
}
9496

97+
/**
98+
* Verify that the current user may view each of the requested object ids before any run data is loaded.
99+
*/
100+
protected void verifyObjectIdsReadable(int[] ids) throws Exception
101+
{
102+
}
103+
95104
protected abstract GraphSelectedBean createSelectionBean(ViewContext context, ExpProtocol protocol, int[] cutoffs,
96105
int[] dataObjectIds, String caption, String title);
97106

assay/api-src/org/labkey/api/assay/nab/view/MultiGraphAction.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@
1616
package org.labkey.api.assay.nab.view;
1717

1818
import org.labkey.api.action.SimpleViewAction;
19+
import org.labkey.api.assay.AssayService;
1920
import org.labkey.api.assay.dilution.DilutionAssayProvider;
2021
import org.labkey.api.assay.dilution.DilutionAssayRun;
2122
import org.labkey.api.assay.dilution.DilutionSummary;
2223
import org.labkey.api.assay.nab.NabGraph;
2324
import org.labkey.api.exp.api.ExpProtocol;
2425
import org.labkey.api.exp.api.ExperimentService;
25-
import org.labkey.api.assay.AssayService;
2626
import org.labkey.api.view.NavTree;
2727
import org.springframework.validation.BindException;
2828
import org.springframework.web.servlet.ModelAndView;
@@ -35,12 +35,13 @@
3535
* User: klum
3636
* Date: 6/11/13
3737
*/
38-
public class MultiGraphAction<FormType extends GraphSelectedForm> extends SimpleViewAction<FormType>
38+
public abstract class MultiGraphAction<FormType extends GraphSelectedForm> extends SimpleViewAction<FormType>
3939
{
4040
@Override
4141
public ModelAndView getView(FormType form, BindException errors) throws Exception
4242
{
4343
int[] ids = form.getId();
44+
verifyObjectIdsReadable(ids);
4445
ExpProtocol protocol = ExperimentService.get().getExpProtocol(form.getProtocolId());
4546
DilutionAssayProvider provider = (DilutionAssayProvider)AssayService.get().getProvider(protocol);
4647
Map<DilutionSummary, DilutionAssayRun> summaries = provider.getDataHandler().getDilutionSummaries(getUser(), form.getFitTypeEnum(), ids);
@@ -63,6 +64,13 @@ public ModelAndView getView(FormType form, BindException errors) throws Exceptio
6364
return null;
6465
}
6566

67+
/**
68+
* Verify that the current user may view each of the requested object ids before any run data is loaded.
69+
*/
70+
protected void verifyObjectIdsReadable(int[] ids) throws Exception
71+
{
72+
}
73+
6674
protected NabGraph.Config getGraphConfig(FormType form)
6775
{
6876
NabGraph.Config config = new NabGraph.Config();

experiment/src/org/labkey/experiment/api/ExperimentServiceImpl.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -374,10 +374,23 @@ public void clearDataClassCache(@Nullable Container c)
374374

375375
@Override
376376
public @Nullable ExpRunImpl getExpRun(int rowId)
377+
{
378+
return getExpRun(rowId, null);
379+
}
380+
381+
@Override
382+
public @Nullable ExpRunImpl getExpRun(int rowId, @Nullable Container container)
377383
{
378384
SimpleFilter filter = new SimpleFilter(FieldKey.fromParts(ExpRunTable.Column.RowId.name()), rowId);
379385
ExperimentRun run = new TableSelector(getTinfoExperimentRun(), filter, null).getObject(ExperimentRun.class);
380-
return run == null ? null : new ExpRunImpl(run);
386+
if (run == null)
387+
return null;
388+
389+
// GitHub Issue #1892: if container provided, ensure the run belongs to the container
390+
if (container != null && !run.getContainer().equals(container))
391+
return null;
392+
393+
return new ExpRunImpl(run);
381394
}
382395

383396
private List<ExpRunImpl> getExpRuns(SimpleFilter filter)

0 commit comments

Comments
 (0)