Skip to content

Commit eaa1788

Browse files
authored
Update query-related exceptions for consistency (#130)
1 parent ebdb7f1 commit eaa1788

File tree

1 file changed

+2
-40
lines changed

1 file changed

+2
-40
lines changed

LDK/src/org/labkey/ldk/LDKController.java

Lines changed: 2 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@
4848
import org.labkey.api.module.ModuleLoader;
4949
import org.labkey.api.query.DetailsURL;
5050
import org.labkey.api.query.QueryAction;
51-
import org.labkey.api.query.QueryException;
5251
import org.labkey.api.query.QueryForm;
5352
import org.labkey.api.query.QueryParseException;
5453
import org.labkey.api.query.QueryView;
@@ -76,7 +75,6 @@
7675
import org.labkey.api.view.ActionURL;
7776
import org.labkey.api.view.HtmlView;
7877
import org.labkey.api.view.NavTree;
79-
import org.labkey.api.view.NotFoundException;
8078
import org.labkey.api.view.Portal;
8179
import org.labkey.api.view.RedirectException;
8280
import org.labkey.api.view.UnauthorizedException;
@@ -91,14 +89,14 @@
9189
import javax.servlet.http.HttpServletResponse;
9290
import java.net.URISyntaxException;
9391
import java.text.SimpleDateFormat;
94-
import java.util.function.Predicate;
9592
import java.util.ArrayList;
9693
import java.util.Comparator;
9794
import java.util.Date;
9895
import java.util.HashMap;
9996
import java.util.List;
10097
import java.util.Map;
10198
import java.util.Set;
99+
import java.util.function.Predicate;
102100

103101

104102

@@ -832,7 +830,7 @@ public class UpdateQueryAction extends SimpleViewAction<QueryForm>
832830
@Override
833831
public ModelAndView getView(QueryForm form, BindException errors) throws Exception
834832
{
835-
ensureQueryExists(form);
833+
form.ensureQueryExists();
836834

837835
_form = form;
838836

@@ -894,42 +892,6 @@ public void addNavTrail(NavTree root)
894892

895893
root.addChild(ti == null ? _form.getQueryName() : ti.getTitle(), _form.urlFor(QueryAction.executeQuery));
896894
}
897-
898-
protected void ensureQueryExists(QueryForm form)
899-
{
900-
if (form.getSchema() == null)
901-
{
902-
throw new NotFoundException("Could not find schema: " + form.getSchemaName());
903-
}
904-
905-
if (StringUtils.isEmpty(form.getQueryName()))
906-
{
907-
throw new NotFoundException("Query not specified");
908-
}
909-
910-
if (!queryExists(form))
911-
{
912-
throw new NotFoundException("Query '" + form.getQueryName() + "' in schema '" + form.getSchemaName() + "' doesn't exist.");
913-
}
914-
}
915-
916-
protected boolean queryExists(QueryForm form)
917-
{
918-
try
919-
{
920-
return form.getSchema() != null && form.getSchema().getTable(form.getQueryName()) != null;
921-
}
922-
catch (QueryParseException x)
923-
{
924-
// exists with errors
925-
return true;
926-
}
927-
catch (QueryException x)
928-
{
929-
// exists with errors
930-
return true;
931-
}
932-
}
933895
}
934896

935897
@RequiresPermission(AdminPermission.class)

0 commit comments

Comments
 (0)