Skip to content

Commit 0d66ea9

Browse files
authored
Update query-related exceptions for consistency (#457)
1 parent f3b9136 commit 0d66ea9

1 file changed

Lines changed: 2 additions & 40 deletions

File tree

snprc_ehr/src/org/labkey/snprc_ehr/SNPRC_EHRController.java

Lines changed: 2 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
package org.labkey.snprc_ehr;
1818

19-
import org.apache.commons.lang3.StringUtils;
2019
import org.json.JSONObject;
2120
import org.labkey.api.action.ApiResponse;
2221
import org.labkey.api.action.ApiSimpleResponse;
@@ -39,7 +38,6 @@
3938
import org.labkey.api.query.FieldKey;
4039
import org.labkey.api.query.InvalidKeyException;
4140
import org.labkey.api.query.QueryAction;
42-
import org.labkey.api.query.QueryException;
4341
import org.labkey.api.query.QueryForm;
4442
import org.labkey.api.query.QueryParseException;
4543
import org.labkey.api.query.QueryUpdateService;
@@ -57,7 +55,6 @@
5755
import org.labkey.api.view.ActionURL;
5856
import org.labkey.api.view.JspView;
5957
import org.labkey.api.view.NavTree;
60-
import org.labkey.api.view.NotFoundException;
6158
import org.labkey.api.view.Portal;
6259
import org.labkey.api.view.WebPartFactory;
6360
import org.labkey.api.view.WebPartView;
@@ -202,7 +199,7 @@ public class UpdateQueryAction extends SimpleViewAction<QueryForm>
202199
@Override
203200
public ModelAndView getView(QueryForm form, BindException errors) throws Exception
204201
{
205-
ensureQueryExists(form);
202+
form.ensureQueryExists();
206203

207204
_form = form;
208205

@@ -264,43 +261,8 @@ public void addNavTrail(NavTree root)
264261

265262
root.addChild(ti == null ? _form.getQueryName() : ti.getTitle(), _form.urlFor(QueryAction.executeQuery));
266263
}
267-
268-
protected void ensureQueryExists(QueryForm form)
269-
{
270-
if (form.getSchema() == null)
271-
{
272-
throw new NotFoundException("Could not find schema: " + form.getSchemaName());
273-
}
274-
275-
if (StringUtils.isEmpty(form.getQueryName()))
276-
{
277-
throw new NotFoundException("Query not specified");
278-
}
279-
280-
if (!queryExists(form))
281-
{
282-
throw new NotFoundException("Query '" + form.getQueryName() + "' in schema '" + form.getSchemaName() + "' doesn't exist.");
283-
}
284-
}
285-
286-
protected boolean queryExists(QueryForm form)
287-
{
288-
try
289-
{
290-
return form.getSchema() != null && form.getSchema().getTable(form.getQueryName()) != null;
291-
}
292-
catch (QueryParseException x)
293-
{
294-
// exists with errors
295-
return true;
296-
}
297-
catch (QueryException x)
298-
{
299-
// exists with errors
300-
return true;
301-
}
302-
}
303264
}
265+
304266
// http://localhost:8080/labkey/snprc_ehr/snprc/getNextAnimalId
305267
@RequiresPermission(EHRDataEntryPermission.class)
306268
public class getNextAnimalIdAction extends MutatingApiAction<SimpleApiJsonForm>

0 commit comments

Comments
 (0)