Search in sources :

Example 1 with JCoDestination

use of com.sap.conn.jco.JCoDestination 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;
}
Also used : JCoDestination(com.sap.conn.jco.JCoDestination) SenderException(nl.nn.adapterframework.core.SenderException)

Example 2 with JCoDestination

use of com.sap.conn.jco.JCoDestination 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);
    }
}
Also used : ParameterValueList(nl.nn.adapterframework.parameters.ParameterValueList) JCoDestination(com.sap.conn.jco.JCoDestination) IDocDocument(com.sap.conn.idoc.IDocDocument) SenderException(nl.nn.adapterframework.core.SenderException) IDocException(com.sap.conn.idoc.IDocException) IDocException(com.sap.conn.idoc.IDocException) SenderException(nl.nn.adapterframework.core.SenderException) TimeOutException(nl.nn.adapterframework.core.TimeOutException)

Example 3 with JCoDestination

use of com.sap.conn.jco.JCoDestination in project iaf by ibissource.

the class SapSenderBase method getDestination.

public JCoDestination getDestination(PipeLineSession 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;
}
Also used : JCoDestination(com.sap.conn.jco.JCoDestination) SenderException(nl.nn.adapterframework.core.SenderException)

Example 4 with JCoDestination

use of com.sap.conn.jco.JCoDestination 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);
        JCoFunction 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) + "]");
        JCoDestination destination = getDestination(prc.getSession(), sapSystem);
        tid = getTid(destination, sapSystem);
        if (StringUtils.isEmpty(tid)) {
            function.execute(destination);
        } else {
            function.execute(destination, tid);
        }
        if (isSynchronous()) {
            return functionResult2message(function);
        } else {
            return tid;
        }
    } catch (Exception e) {
        throw new SenderException(e);
    }
}
Also used : ParameterValueList(nl.nn.adapterframework.parameters.ParameterValueList) JCoFunction(com.sap.conn.jco.JCoFunction) JCoDestination(com.sap.conn.jco.JCoDestination) SenderException(nl.nn.adapterframework.core.SenderException) SenderException(nl.nn.adapterframework.core.SenderException) ConfigurationException(nl.nn.adapterframework.configuration.ConfigurationException) TimeOutException(nl.nn.adapterframework.core.TimeOutException)

Example 5 with JCoDestination

use of com.sap.conn.jco.JCoDestination in project iaf by ibissource.

the class IdocSender method sendMessage.

@Override
public Message sendMessage(Message message, PipeLineSession session) throws SenderException, TimeoutException {
    String tid = null;
    try {
        ParameterValueList pvl = null;
        if (paramList != null) {
            pvl = paramList.getValues(message, session);
        }
        SapSystem sapSystem = getSystem(pvl);
        IDocDocument idoc = parseIdoc(sapSystem, message);
        try {
            log.trace(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(session, 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 new Message(tid);
    } catch (Exception e) {
        throw new SenderException(e);
    }
}
Also used : ParameterValueList(nl.nn.adapterframework.parameters.ParameterValueList) Message(nl.nn.adapterframework.stream.Message) JCoDestination(com.sap.conn.jco.JCoDestination) IDocDocument(com.sap.conn.idoc.IDocDocument) SenderException(nl.nn.adapterframework.core.SenderException) IDocException(com.sap.conn.idoc.IDocException) IDocException(com.sap.conn.idoc.IDocException) SenderException(nl.nn.adapterframework.core.SenderException) TimeoutException(nl.nn.adapterframework.core.TimeoutException)

Aggregations

JCoDestination (com.sap.conn.jco.JCoDestination)9 SenderException (nl.nn.adapterframework.core.SenderException)6 ParameterValueList (nl.nn.adapterframework.parameters.ParameterValueList)4 IDocDocument (com.sap.conn.idoc.IDocDocument)2 IDocException (com.sap.conn.idoc.IDocException)2 JCoFunction (com.sap.conn.jco.JCoFunction)2 ConfigurationException (nl.nn.adapterframework.configuration.ConfigurationException)2 TimeOutException (nl.nn.adapterframework.core.TimeOutException)2 TimeoutException (nl.nn.adapterframework.core.TimeoutException)2 SapException (nl.nn.adapterframework.extensions.sap.SapException)2 Message (nl.nn.adapterframework.stream.Message)2