Handle NPE when no datarow is provided in queryData request

This commit is contained in:
Elaine Tan 2013-04-04 16:26:44 +08:00
parent 454495f198
commit e14cfc212a
1 changed files with 23 additions and 17 deletions

View File

@ -1384,6 +1384,8 @@ public class ModelADServiceImpl extends AbstractService implements ModelADServic
String sqlquery = "SELECT * FROM " + tableName; String sqlquery = "SELECT * FROM " + tableName;
sqlquery = role.addAccessSQL(sqlquery, tableName, true, true); sqlquery = role.addAccessSQL(sqlquery, tableName, true, true);
if (modelCRUD.getDataRow() != null)
{
for (DataField field : modelCRUD.getDataRow().getFieldArray()) { for (DataField field : modelCRUD.getDataRow().getFieldArray()) {
if (m_webservicetype.isInputColumnNameAllowed(field.getColumn())) { if (m_webservicetype.isInputColumnNameAllowed(field.getColumn())) {
sqlquery += " AND " + field.getColumn() + "=?"; sqlquery += " AND " + field.getColumn() + "=?";
@ -1393,6 +1395,7 @@ public class ModelADServiceImpl extends AbstractService implements ModelADServic
+ field.getColumn() + " not allowed", new QName("queryData")); + field.getColumn() + " not allowed", new QName("queryData"));
} }
} }
}
if (modelCRUD.getFilter() != null && modelCRUD.getFilter().length() > 0) if (modelCRUD.getFilter() != null && modelCRUD.getFilter().length() > 0)
sqlquery += " AND " + modelCRUD.getFilter(); sqlquery += " AND " + modelCRUD.getFilter();
@ -1406,6 +1409,8 @@ public class ModelADServiceImpl extends AbstractService implements ModelADServic
{ {
pstmtquery = DB.prepareStatement (sqlquery, null); pstmtquery = DB.prepareStatement (sqlquery, null);
int p = 1; int p = 1;
if (modelCRUD.getDataRow() != null)
{
for (DataField field : modelCRUD.getDataRow().getFieldArray()) { for (DataField field : modelCRUD.getDataRow().getFieldArray()) {
int idx = poinfo.getColumnIndex(field.getColumn()); int idx = poinfo.getColumnIndex(field.getColumn());
Class<?> c = poinfo.getColumnClass(idx); Class<?> c = poinfo.getColumnClass(idx);
@ -1416,6 +1421,7 @@ public class ModelADServiceImpl extends AbstractService implements ModelADServic
else if (c == Boolean.class || c == String.class) else if (c == Boolean.class || c == String.class)
pstmtquery.setString(p++, field.getVal()); pstmtquery.setString(p++, field.getVal());
} }
}
rsquery = pstmtquery.executeQuery (); rsquery = pstmtquery.executeQuery ();
// Angelo Dabala' (genied) must create just one DataSet, moved outside of the while loop // Angelo Dabala' (genied) must create just one DataSet, moved outside of the while loop
DataSet ds = resp.addNewDataSet(); DataSet ds = resp.addNewDataSet();