Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 23 additions & 6 deletions query/src/org/labkey/query/controllers/GetQueryDetailsAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,15 @@
import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.jetbrains.annotations.NotNull;
import org.json.JSONArray;
import org.json.JSONObject;
import org.labkey.api.action.Action;
import org.labkey.api.action.ActionType;
import org.labkey.api.action.ApiResponse;
import org.labkey.api.action.ApiSimpleResponse;
import org.labkey.api.action.BaseViewAction;
import org.labkey.api.action.HasBindParameters;
import org.labkey.api.action.ReadOnlyApiAction;
import org.labkey.api.collections.CaseInsensitiveHashMap;
import org.labkey.api.collections.CaseInsensitiveHashSet;
Expand Down Expand Up @@ -63,6 +66,7 @@
import org.labkey.query.CustomViewUtil;
import org.labkey.query.QueryDefinitionImpl;
import org.labkey.query.persist.QueryDef;
import org.springframework.beans.PropertyValues;
import org.springframework.validation.BindException;

import java.util.ArrayList;
Expand Down Expand Up @@ -460,7 +464,7 @@ protected List<Map<String,Object>> getDefViewColProps(QueryView view)
return colProps;
}

public static class Form
public static class Form implements HasBindParameters
{
private String _queryName;
private String _schemaName;
Expand Down Expand Up @@ -496,11 +500,6 @@ public String[] getViewName()
return _viewName;
}

public void setViewName(String[] viewName)
{
_viewName = viewName;
}

public String getFk()
{
return _fk;
Expand Down Expand Up @@ -550,5 +549,23 @@ public void setIncludeTriggers(boolean includeTriggers)
{
_includeTriggers = includeTriggers;
}

@Override
public @NotNull BindException bindParameters(PropertyValues params)
{
// GitHub Issue #936 : manually bind the viewName parameter
var viewName = params.getPropertyValue("viewName");
if (viewName != null)
{
var value = viewName.getValue();
if (value instanceof String[] strs)
_viewName = strs;
else if (value instanceof String str)
_viewName = new String[] { str };
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't think of a way that we'd get here without it being a string or string[] but do we need an else that throws an error / or logs an error? Maybe we have presedence from other bindParameters overrides.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can log an error.

else
LOG.error("Unexpected viewName parameter type: " + value);
}
return BaseViewAction.springBindParameters(this, "form", params);
}
}
}
Loading