if (!callback.isEmpty()) {
responseWriter.print(callback+"({");
responseWriter.flush();
}
writer.begin(response);
ManagedConnection mCon = null;
Connection con = null;
PreparedStatement st = null;
ResultSet rs = null;
try {
// initialize the query string
String table = context.getCatalogConfiguration().getResourceTableName();
StringBuffer sql = new StringBuffer();
String[] columnTags = {"id","uuid","protocol","name","url"};
sql.append("SELECT ID,DOCUUID,PROTOCOL_TYPE,TITLE,HOST_URL FROM "+table);
// build the bound query expression based upon HTTP parameter input
HttpExpressionBinder binder = new HttpExpressionBinder(request);
binder.parse("id","ID","=",",",HttpExpressionBinder.PARAMETERTYPE_INTEGER);
binder.parse("uuid","DOCUUID",",",false,false);
if(protocol.toLowerCase().equals("all")) {
binder.parse("","PROTOCOL_TYPE",",",true,false);
} else {
binder.parse("protocol","PROTOCOL_TYPE",",",true,false);
}
binder.parse("name","TITLE",null,true,true);
binder.parse("url","HOST_URL",null,true,true);
// append the bound where clause,
// create the prepared statement and apply bindings,
// exexute the query and write the response
sql.append(" ").append(binder.getExpression(true));
if(sql.toString().toLowerCase().contains(" where ")) {
sql.append(" AND ");
} else {
sql.append(" WHERE ");
}
sql.append(" ((APPROVALSTATUS = 'approved') ")
.append(" OR (APPROVALSTATUS = 'reviewed')) ");
sql.append(" AND SEARCHABLE = 'true'");
sql.append(" ORDER BY UPPER(TITLE) ASC");
mCon = context.getConnectionBroker().returnConnection("");
con = mCon.getJdbcConnection();
st = con.prepareStatement(sql.toString());
binder.applyBindings(st,1);
//rs = new RepositoriesResultSetWrapper(st.executeQuery());
if(protocol.toLowerCase().equals("all") != true) {
rs = st.executeQuery();