From 284d2f382022fa10f8e24ef0b0ce004217dd5f15 Mon Sep 17 00:00:00 2001 From: labkey-tchad Date: Thu, 22 May 2025 11:57:04 -0700 Subject: [PATCH 1/2] Make assay/sample publish confirmation actions POST-only They require more context than can be expected from a GET and trip up the crawler --- .../api/study/publish/AbstractPublishConfirmAction.java | 4 ++++ .../org/labkey/study/assay/AssayPublishConfirmAction.java | 6 +----- .../controllers/publish/SampleTypePublishConfirmAction.java | 4 ---- 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/api/src/org/labkey/api/study/publish/AbstractPublishConfirmAction.java b/api/src/org/labkey/api/study/publish/AbstractPublishConfirmAction.java index 8ac8a9ff954..1e620b36d18 100644 --- a/api/src/org/labkey/api/study/publish/AbstractPublishConfirmAction.java +++ b/api/src/org/labkey/api/study/publish/AbstractPublishConfirmAction.java @@ -28,6 +28,7 @@ import org.labkey.api.query.FieldKey; import org.labkey.api.query.QuerySettings; import org.labkey.api.query.UserSchema; +import org.labkey.api.security.MethodsAllowed; import org.labkey.api.security.RequiresPermission; import org.labkey.api.security.permissions.InsertPermission; import org.labkey.api.study.Dataset; @@ -57,6 +58,9 @@ import java.util.Map; import java.util.Set; +import static org.labkey.api.util.HttpUtil.Method.POST; + +@MethodsAllowed(POST) @RequiresPermission(InsertPermission.class) public abstract class AbstractPublishConfirmAction
extends FormViewAction { diff --git a/study/src/org/labkey/study/assay/AssayPublishConfirmAction.java b/study/src/org/labkey/study/assay/AssayPublishConfirmAction.java index d3b6ad05350..4620e332975 100644 --- a/study/src/org/labkey/study/assay/AssayPublishConfirmAction.java +++ b/study/src/org/labkey/study/assay/AssayPublishConfirmAction.java @@ -32,7 +32,6 @@ import org.labkey.api.util.Pair; import org.labkey.api.view.ActionURL; import org.labkey.api.view.DataView; -import org.labkey.api.view.HtmlView; import org.labkey.api.view.NavTree; import org.labkey.api.view.NotFoundException; import org.labkey.api.view.UnauthorizedException; @@ -58,7 +57,7 @@ public static class AssayPublishConfirmForm extends PublishConfirmForm private ExpProtocol _protocol; private AssayProvider _provider; - ExpProtocol getProtocol() + @NotNull ExpProtocol getProtocol() { if (_protocol == null) { @@ -289,9 +288,6 @@ protected ActionURL linkToStudy(AssayPublishConfirmForm form, Container targetSt @Override public ModelAndView getView(AssayPublishConfirmForm form, boolean reshow, BindException errors) throws Exception { - if (form.getProtocol() == null) - return HtmlView.err("Could not resolve the source protocol."); - return super.getView(form, reshow, errors); } diff --git a/study/src/org/labkey/study/controllers/publish/SampleTypePublishConfirmAction.java b/study/src/org/labkey/study/controllers/publish/SampleTypePublishConfirmAction.java index d096fd45bb3..0f40a8a7ed9 100644 --- a/study/src/org/labkey/study/controllers/publish/SampleTypePublishConfirmAction.java +++ b/study/src/org/labkey/study/controllers/publish/SampleTypePublishConfirmAction.java @@ -23,7 +23,6 @@ import org.labkey.api.study.publish.StudyPublishService; import org.labkey.api.util.Pair; import org.labkey.api.view.ActionURL; -import org.labkey.api.view.HtmlView; import org.labkey.api.view.NavTree; import org.labkey.api.view.NotFoundException; import org.springframework.validation.BindException; @@ -204,9 +203,6 @@ protected ActionURL linkToStudy(SampleTypePublishConfirmForm form, Container tar @Override public ModelAndView getView(SampleTypePublishConfirmForm form, boolean reshow, BindException errors) throws Exception { - if (_sampleType == null) - return HtmlView.err("Could not resolve the source Sample Type."); - return super.getView(form, reshow, errors); } From 8ad99c2e2157c2920fd209d20f5a426c8657f6d7 Mon Sep 17 00:00:00 2001 From: labkey-tchad Date: Thu, 22 May 2025 18:22:54 -0700 Subject: [PATCH 2/2] Remove unnecessary overrides and imports --- .../study/assay/AssayPublishConfirmAction.java | 14 -------------- .../publish/SampleTypePublishConfirmAction.java | 7 ------- 2 files changed, 21 deletions(-) diff --git a/study/src/org/labkey/study/assay/AssayPublishConfirmAction.java b/study/src/org/labkey/study/assay/AssayPublishConfirmAction.java index 4620e332975..86fbc50011a 100644 --- a/study/src/org/labkey/study/assay/AssayPublishConfirmAction.java +++ b/study/src/org/labkey/study/assay/AssayPublishConfirmAction.java @@ -35,9 +35,7 @@ import org.labkey.api.view.NavTree; import org.labkey.api.view.NotFoundException; import org.labkey.api.view.UnauthorizedException; -import org.springframework.validation.BindException; import org.springframework.validation.Errors; -import org.springframework.web.servlet.ModelAndView; import java.util.HashMap; import java.util.List; @@ -285,18 +283,6 @@ protected ActionURL linkToStudy(AssayPublishConfirmForm form, Container targetSt return form.getProvider().linkToStudy(getUser(), getContainer(), _protocol, targetStudy, form.getAutoLinkCategory(), publishData, publishErrors); } - @Override - public ModelAndView getView(AssayPublishConfirmForm form, boolean reshow, BindException errors) throws Exception - { - return super.getView(form, reshow, errors); - } - - @Override - public boolean handlePost(AssayPublishConfirmForm form, BindException errors) throws Exception - { - return super.handlePost(form, errors); - } - @Override public void addNavTrail(NavTree root) { diff --git a/study/src/org/labkey/study/controllers/publish/SampleTypePublishConfirmAction.java b/study/src/org/labkey/study/controllers/publish/SampleTypePublishConfirmAction.java index 0f40a8a7ed9..bb57c805bb8 100644 --- a/study/src/org/labkey/study/controllers/publish/SampleTypePublishConfirmAction.java +++ b/study/src/org/labkey/study/controllers/publish/SampleTypePublishConfirmAction.java @@ -27,7 +27,6 @@ import org.labkey.api.view.NotFoundException; import org.springframework.validation.BindException; import org.springframework.validation.Errors; -import org.springframework.web.servlet.ModelAndView; import java.util.ArrayList; import java.util.Collection; @@ -200,12 +199,6 @@ protected ActionURL linkToStudy(SampleTypePublishConfirmForm form, Container tar dataMaps, ROW_ID, errors); } - @Override - public ModelAndView getView(SampleTypePublishConfirmForm form, boolean reshow, BindException errors) throws Exception - { - return super.getView(form, reshow, errors); - } - @Override public void addNavTrail(NavTree root) {