}
public String[] give(SourceInfo info, MessageLogger logger)
throws FailTransferException, AbortTransferException {
ExportResult exportResult = null;
StringBuffer hqlResult = new StringBuffer("");
// If we have already output all data, no need for further communication
// with OpenInterface. Simply return null as an EOF signal to the Pipe framework.
if( this.allDataOutput == true ) return null;
// Counter used in the all results at once mode to determine whether
// a single HQL result should have the XML declaration line or not
int allResultsAtOnceIndex = 0;
// Increment iteration number
this.iterationNumber++;
Boolean xmlDeclarationForEachBlock = getXMLdeclarationForEachBlock();
OpenInterfaceIF oi = WorkspaceOIUtils.getOpenInterfaceIF(
this.oiEndpointAddress,
getOpenInterfaceHost()
);
do {
try {
exportResult = oi.iterate(this.login, oiIteratorId, resultsPerIteration);
} catch (AccessDeniedException e) {
logger.logMessage(
"Access to OpenInterface was denied. Check your username and password settings.",
this,
MessageLogger.ERROR);
PipeComponentUtils.failTransfer();
} catch (IteratorClosedException e) {
// Invalidate OpenInterface iterator's number so that we don't attempt to close it later
this.oiIteratorId = null;
logger.logMessage(
"OpenInterface HQL iterator had been closed due to inactivity. Try increasing session timeout value.",
this,
MessageLogger.ERROR);
PipeComponentUtils.failTransfer();
} catch (OpenInterfaceException e) {
logger.logMessage("OpenInterfaceException while iterating over the HQL query's result set",
this, MessageLogger.ERROR);
logger.logMessage(e.getMessage(), this, MessageLogger.ERROR);
Environment.getInstance().log(
"OpenInterfaceException while iterating over the HQL query's result set", e);
PipeComponentUtils.failTransfer();
} catch (RemoteException e) {
logger.logMessage("RemoteException from OpenInterface while iterating over the HQL query's result set",
this, MessageLogger.ERROR);
Environment.getInstance().log(
"RemoteException from OpenInterface while iterating over the HQL query's result set", e);
PipeComponentUtils.failTransfer();
}
if(exportResult != null) {
if(this.allResultsAtOnce == false) {
// Normal iteration mode
if((this.iterationNumber > 1) &&
(xmlDeclarationForEachBlock.booleanValue() == false)) {
hqlResult.append(Utils.stripXMLdeclaration(exportResult.getXml()));
} else {
hqlResult.append(exportResult.getXml());
}
} else {
// All results at once mode
allResultsAtOnceIndex++;
// Only the first HQL result will keep its XML declaration line
if(allResultsAtOnceIndex == 1) {
hqlResult.append(stripResultCloseTag(exportResult.getXml()));
} else if(allResultsAtOnceIndex > 1) {
hqlResult.append(stripResultTag(Utils.stripXMLdeclaration(exportResult.getXml())));
}
}
}
} while((this.allResultsAtOnce == true) && (exportResult != null));