try {
feedType = DocUtils.getFeedType(document);
} catch (RuntimeException e) {
LOGGER.log(Level.WARNING,
"Rethrowing RuntimeException as RepositoryDocumentException", e);
throw new RepositoryDocumentException(e);
}
// All feeds in a feed file must be of the same type.
// If the feed would change type, send the feed off to the GSA
// and start a new one.
// TODO: Fix this check to allow ACLs in any type feed.
if (xmlFeed != null && !feedType.isCompatible(xmlFeed.getFeedType())) {
if (LOGGER.isLoggable(Level.FINE)) {
LOGGER.fine("A new feedType, " + feedType + ", requires a new feed for "
+ connectorName + ". Closing feed and sending to GSA.");
}
submitFeed();
}
if (xmlFeed == null) {
if (LOGGER.isLoggable(Level.FINE)) {
LOGGER.fine("Creating new " + feedType + " feed for " + connectorName);
}
try {
startNewFeed(feedType);
} catch (OutOfMemoryError me) {
throw new PushException("Unable to allocate feed buffer. Try reducing"
+ " the maxFeedSize setting, reducing the number of connector"
+ " intances, or adjusting the JVM heap size parameters.", me);
}
}
boolean isThrowing = false;
int resetPoint = xmlFeed.size();
int resetCount = xmlFeed.getRecordCount();
try {
if (LOGGER.isLoggable(Level.FINER)) {
LOGGER.log(Level.FINER, "DOCUMENT: Adding document with docid={0} and "
+ "searchurl={1} from connector {2} to feed.", new Object[] {
DocUtils.getOptionalString(document, SpiConstants.PROPNAME_DOCID),
DocUtils.getOptionalString(document,
SpiConstants.PROPNAME_SEARCHURL),
connectorName});
}
// Add this document to the feed.
xmlFeed.addRecord(document);
// If the feed is full, send it off to the GSA.
if (xmlFeed.isFull() || lowMemory()) {
if (LOGGER.isLoggable(Level.FINE)) {
LOGGER.fine("Feed for " + connectorName + " has grown to "
+ xmlFeed.size() + " bytes. Closing feed and sending to GSA.");
}
submitFeed();
return getPusherStatus();
}
// Indicate that this Pusher may accept more documents.
return PusherStatus.OK;
} catch (OutOfMemoryError me) {
resetFeed(resetPoint, resetCount);
throw new PushException("Out of memory building feed, retrying.", me);
} catch (RuntimeException e) {
resetFeed(resetPoint, resetCount);
LOGGER.log(Level.WARNING,
"Rethrowing RuntimeException as RepositoryDocumentException", e);
throw new RepositoryDocumentException(e);
} catch (RepositoryDocumentException rde) {
// Skipping this document, remove it from the feed.
resetFeed(resetPoint, resetCount);
throw rde;
} catch (IOException ioe) {
LOGGER.log(Level.SEVERE, "IOException while reading: skipping", ioe);
resetFeed(resetPoint, resetCount);
Throwable t = ioe.getCause();
isThrowing = true;
if (t != null && (t instanceof RepositoryException)) {
throw (RepositoryException) t;
} else {
throw new RepositoryDocumentException("I/O error reading data", ioe);
}
}
}