if (adapter.getUsingSingleWriter()) {
writer = adapter.newWriter();
adapter.setAutoCommitSingleWriter(false);
}
ImsMetadataAdminDao dao = new ImsMetadataAdminDao(context);
String resourceTable = context.getCatalogConfiguration().getResourceTableName();
String resourceDataTable = context.getCatalogConfiguration().getResourceDataTableName();
StringSet delUuids = new StringSet();
MetadataAcl acl = new MetadataAcl(context);
boolean bCheckAcl = !acl.isPolicyUnrestricted();
StringBuilder sbIds = new StringBuilder();
for (String sUuid: ids) {
if (sbIds.length() > 0) sbIds.append(",");
sbIds.append("'").append(sUuid).append("'");
}
StringBuilder sb = new StringBuilder("SELECT");
sb.append(" ").append(resourceTable).append(".DOCUUID");
sb.append(",").append(resourceTable).append(".APPROVALSTATUS");
sb.append(",").append(resourceTable).append(".PROTOCOL_TYPE");
sb.append(",").append(resourceTable).append(".FINDABLE");
sb.append(",").append(resourceTable).append(".UPDATEDATE");
sb.append(",").append(resourceTable).append(".ACL");
sb.append(" FROM ").append(resourceTable);
sb.append(" WHERE DOCUUID IN (").append(sbIds.toString()).append(")");
String sql = sb.toString();
LOGGER.finest(sql);
ManagedConnection mc = context.getConnectionBroker().returnConnection("");
Connection con = mc.getJdbcConnection();
IClobMutator mutator = mc.getClobMutator();
st = con.prepareStatement(sql);
ResultSet rs = st.executeQuery();
if (Thread.interrupted()) return;
while (rs.next()) {
if (Thread.interrupted()) return;
String uuid = rs.getString(1);
String status = rs.getString(2);
String protocolType = Val.chkStr(rs.getString(3));
boolean findable = Val.chkBool(rs.getString(4),false);
boolean bIndexable = (status != null) &&
(status.equalsIgnoreCase("approved") || status.equalsIgnoreCase("reviewed"));
if (bIndexable && protocolType.length()>0 && !findable) {
bIndexable = false;
}
if (!bIndexable) {
delUuids.add(uuid);
} else {
Timestamp tsDbModified = rs.getTimestamp(5);
String sDbAcl = null;
if (bCheckAcl) {
sDbAcl = rs.getString(6);
}
try {
String sXml = Val.chkStr(dao.readXml(uuid));
if (sXml.length() > 0) {
MetadataDocument mdDoc = new MetadataDocument();
Schema schema = mdDoc.prepareForView(context,sXml);
adapter.publishDocument(uuid,tsDbModified,schema,sDbAcl);
}