public Map<String, HrRecord> readHarvestRecords(StringSet rids,
RequestContext context) throws SearchException {
// TODO: Sort out exception issues
HrRecord record = null;
PreparedStatement st = null;
ManagedConnection mcon = null;
ResultSet rs = null;
Map<String, HrRecord> mpRidRecords = new
TreeMap<String, HrRecord>(String.CASE_INSENSITIVE_ORDER);
Map<String, String> idFields = new
TreeMap<String, String>(String.CASE_INSENSITIVE_ORDER);
for (String rid : rids) {
rid = Val.chkStr(rid);
if (rid.length() < 1) {
continue;
}
String field = "DOCUUID";
try {
Integer.parseInt(rid);
field = "ID";
} catch (NumberFormatException nfe) {
if (!UuidUtil.isUuid(rid)) {
rid = rid.toUpperCase();
field = "UPPER(TITLE)";
}
}
idFields.put(rid, field);
}
// Create sql to query db
String table = context.getCatalogConfiguration().getResourceTableName();
String sql = "SELECT PROTOCOL_TYPE, HOST_URL, PROTOCOL, TITLE, " +
"DOCUUID, ID FROM "
+ table + " WHERE ";
int i = 0;
int maxEntries = idFields.size();
for (Map.Entry<String, String> entry : idFields.entrySet()) {
sql += entry.getValue() + "= ?";
if (i >= 0 && i < maxEntries - 1) {
sql += " or ";
}
i++;
}
sql += " AND ((APPROVALSTATUS = 'approved') OR (APPROVALSTATUS = 'reviewed'))";
sql += " AND SEARCHABLE = 'true'";
LOG.info("DB Query " + sql);
ArrayList<HrRecord> arrHrRecords = new ArrayList<HrRecord>();
try {
mcon = context.getConnectionBroker().returnConnection("");
st = mcon.getJdbcConnection().prepareStatement(sql);
int parNum = 1;
for (Map.Entry<String, String> entry : idFields.entrySet()) {
String field = entry.getValue();
String rid = entry.getKey();
if (field.equalsIgnoreCase("ID")) {