} finally {
closeStatement(st);
}
// publish to or remove from the index
CatalogIndexAdapter indexAdapter = getCatalogIndexAdapter();
if ((indexAdapter != null) && (uuids.size() > 0)) {
if (MmdEnums.ApprovalStatus.isPubliclyVisible(approvalStatus.toString())) {
StringAttributeMap params = this.getRequestContext().getCatalogConfiguration().getParameters();
String param = Val.chkStr(params.getValue("lucene.useRemoteWriter"));
boolean bUseRemoteWriter = param.equalsIgnoreCase("true");
param = Val.chkStr(params.getValue("lucene.useLocalWriter"));
boolean bUseLocalWriter = !param.equalsIgnoreCase("false");
if (bUseRemoteWriter) {
RemoteIndexer remoteIndexer = new RemoteIndexer();
remoteIndexer.send(this.getRequestContext(),"publish",
uuids.toArray(new String[0]));
}
if (bUseLocalWriter) {
boolean bHadException = false;
for (String uuid: uuids) {
try {
boolean indexAllowed = queryIndexEnabled(uuid);
if (indexAllowed) {
String xml = indexAdapter.publishDocument(uuid,publisher);
if (cswRemoteRepository.isActive()) {
cswRemoteRepository.onRecordUpdated(xml);
}
}
} catch (CatalogIndexException e) {
bHadException = true;
LogUtil.getLogger().log(Level.SEVERE,"Error publishing document to index.",e);
}
}
if (bHadException) {
throw new CatalogIndexException("Error publishing document to index.");
}
}
} else {
indexAdapter.deleteDocuments(uuids.toArray(new String[0]));
if (cswRemoteRepository.isActive()) {
StringSet fids = queryFileIdentifiers(uuids);
if (fids.size() > 0) cswRemoteRepository.onRecordsDeleted(fids);
}