use of nl.nn.adapterframework.core.SenderException in project iaf by ibissource.
the class SapSenderBase method getDestination.
public JCoDestination getDestination(IPipeLineSession session, SapSystem sapSystem) throws SenderException, SapException, JCoException {
JCoDestination result;
if (isSynchronous()) {
if (StringUtils.isNotEmpty(getLuwHandleSessionKey())) {
SapLUWHandle handle = SapLUWHandle.retrieveHandle(session, getLuwHandleSessionKey(), true, sapSystem, false);
if (handle == null) {
throw new SenderException("cannot find LUW handle from session key [" + getLuwHandleSessionKey() + "]");
}
result = handle.getDestination();
} else {
result = sapSystem.getDestination();
}
} else {
result = DestinationFactoryUtils.getTransactionalDestination(sapSystem, true);
if (result == null) {
if (!TransactionSynchronizationManager.isSynchronizationActive()) {
throw new SenderException("can only be called from within a transaction");
}
throw new SenderException(getLogPrefix() + "Could not obtain Jco Destination");
}
}
return result;
}
use of nl.nn.adapterframework.core.SenderException in project iaf by ibissource.
the class SapSender method sendMessage.
public String sendMessage(String correlationID, String message, ParameterResolutionContext prc) throws SenderException, TimeOutException {
String tid = null;
try {
ParameterValueList pvl = null;
if (prc != null) {
pvl = prc.getValues(paramList);
}
SapSystem sapSystem = getSystem(pvl);
JCO.Function function = getFunction(sapSystem, pvl);
if (StringUtils.isEmpty(getSapSystemName())) {
pvl.removeParameterValue(getSapSystemNameParam());
}
if (StringUtils.isEmpty(getFunctionName())) {
pvl.removeParameterValue(getFunctionNameParam());
}
message2FunctionCall(function, message, correlationID, pvl);
if (log.isDebugEnabled())
log.debug(getLogPrefix() + " function call [" + functionCall2message(function) + "]");
JCO.Client client = getClient(prc.getSession(), sapSystem);
try {
tid = getTid(client, sapSystem);
if (StringUtils.isEmpty(tid)) {
client.execute(function);
} else {
client.execute(function, tid);
}
} finally {
releaseClient(client, sapSystem);
}
if (isSynchronous()) {
return functionResult2message(function);
} else {
return tid;
}
} catch (Exception e) {
throw new SenderException(e);
}
}
use of nl.nn.adapterframework.core.SenderException in project iaf by ibissource.
the class IdocSender method sendMessage.
public String sendMessage(String correlationID, String message, ParameterResolutionContext prc) throws SenderException, TimeOutException {
String tid = null;
try {
ParameterValueList pvl = null;
if (prc != null) {
pvl = prc.getValues(paramList);
}
SapSystem sapSystem = getSystem(pvl);
IDocDocument idoc = parseIdoc(sapSystem, message);
try {
log.debug(getLogPrefix() + "checking syntax");
idoc.checkSyntax();
} catch (IDocException e) {
throw new SenderException("Syntax error in idoc", e);
}
if (log.isDebugEnabled()) {
log.debug(getLogPrefix() + "parsed idoc [" + JCoIDoc.getIDocFactory().getIDocXMLProcessor().render(idoc) + "]");
}
JCoDestination destination = getDestination(prc.getSession(), sapSystem);
tid = getTid(destination, sapSystem);
if (tid == null) {
throw new SenderException("could not obtain TID to send Idoc");
}
JCoIDoc.send(idoc, IDocFactory.IDOC_VERSION_DEFAULT, destination, tid);
return tid;
} catch (Exception e) {
throw new SenderException(e);
}
}
use of nl.nn.adapterframework.core.SenderException in project iaf by ibissource.
the class IdocSender method parseIdoc.
protected IDocDocument parseIdoc(SapSystem sapSystem, String message) throws SenderException {
IdocXmlHandler handler = new IdocXmlHandler(sapSystem);
try {
log.debug(getLogPrefix() + "start parsing Idoc");
XmlUtils.parseXml(handler, message);
log.debug(getLogPrefix() + "finished parsing Idoc");
return handler.getIdoc();
} catch (Exception e) {
throw new SenderException(e);
}
}
use of nl.nn.adapterframework.core.SenderException in project iaf by ibissource.
the class IdocSender method parseIdoc.
protected IDoc.Document parseIdoc(SapSystem sapSystem, String message) throws SenderException {
IdocXmlHandler handler = new IdocXmlHandler(sapSystem);
try {
log.debug(getLogPrefix() + "start parsing Idoc");
XmlUtils.parseXml(handler, message);
log.debug(getLogPrefix() + "finished parsing Idoc");
return handler.getIdoc();
} catch (Exception e) {
throw new SenderException(e);
}
}
Aggregations