/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.ode.bpel.runtime;
import org.apache.ode.bpel.common.FaultException;
import org.apache.ode.bpel.o.OReply;
import org.apache.ode.bpel.o.OScope;
import org.apache.ode.bpel.runtime.channels.FaultData;
import org.apache.ode.bpel.runtime.history.ODEPolicyViolationHandler;
import org.apache.ode.bpel.runtime.history.ODEReadVarialeFact;
import java.util.Iterator;
import javax.xml.namespace.QName;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import tud.st.bpel.history.PolicyViolatedException;
class REPLY extends ACTIVITY {
private static final long serialVersionUID = 3040651951885161304L;
private static final Log __log = LogFactory.getLog(REPLY.class);
REPLY(ActivityInfo self, ScopeFrame scopeFrame, LinkFrame linkFrame) {
super(self, scopeFrame, linkFrame);
}
public void run() {
final OReply oreply = (OReply)_self.o;
if (__log.isDebugEnabled()) {
__log.debug("<reply> partnerLink=" + oreply.partnerLink + ", operation=" + oreply.operation);
}
FaultData fault = null;
// TODO: Check for fault without message.
try {
VariableInstance vinst = _scopeFrame.resolve(oreply.variable);
// AL: GetVar
try {
history.getVar(getBpelRuntimeContext().getPid(),
new ODEReadVarialeFact(oreply, vinst),
new ODEPolicyViolationHandler(_self));
}
catch(PolicyViolatedException e) {
return;
}
sendVariableReadEvent(vinst);
Node msg = fetchVariableData(_scopeFrame.resolve(oreply.variable), false);
assert msg instanceof Element;
for (Iterator<OScope.CorrelationSet> i = oreply.initCorrelations.iterator(); i.hasNext(); ) {
OScope.CorrelationSet cset = i.next();
initializeCorrelation(_scopeFrame.resolve(cset),
_scopeFrame.resolve(oreply.variable));
}
// send reply
getBpelRuntimeContext()
.reply(_scopeFrame.resolve(oreply.partnerLink), oreply.operation.getName(),
oreply.messageExchangeId, (Element)msg,
(oreply.fault != null) ? oreply.fault : null);
} catch (FaultException e) {
__log.error(e);
fault = createFault(e.getQName(), oreply);
}
_self.parent.completed(fault, CompensationHandler.emptySet());
}
}