use of com.arjuna.wst.SystemException in project narayana by jbosstm.
the class BusinessActivityTerminatorStub method complete.
public void complete() throws FaultedException, UnknownTransactionException, SystemException {
final MAP map = AddressingHelper.createNotificationContext(MessageId.getMessageId());
final RequestCallback callback = new RequestCallback();
final TerminationParticipantProcessor terminationParticipantProcessor = TerminationParticipantProcessor.getProcessor();
terminationParticipantProcessor.registerCallback(_id, callback);
try {
TerminationCoordinatorClient.getClient().sendComplete(_terminationCoordinator, map, new InstanceIdentifier(_id));
callback.waitUntilTriggered();
} catch (final Throwable th) {
throw new SystemException();
} finally {
terminationParticipantProcessor.removeCallback(_id);
}
if (callback.hasTriggered()) {
if (callback.receivedCompleted()) {
return;
} else if (callback.receivedFaulted()) {
throw new FaultedException();
}
final SoapFault soapFault = callback.getSoapFault();
if (soapFault != null) {
final QName subcode = soapFault.getSubcode();
if (ArjunaTXConstants.UNKNOWNTRANSACTION_ERROR_CODE_QNAME.equals(subcode)) {
throw new UnknownTransactionException();
}
}
}
throw new SystemException();
}
use of com.arjuna.wst.SystemException in project narayana by jbosstm.
the class CompletionRPCStub method commit.
public void commit() throws TransactionRolledBackException, UnknownTransactionException, SystemException {
final MAP map = AddressingHelper.createNotificationContext(MessageId.getMessageId());
boolean result;
try {
result = CompletionCoordinatorRPCClient.getClient().sendCommit(_completionCoordinator, map);
} catch (final SoapFault soapFault) {
if (ArjunaTXConstants.UNKNOWNTRANSACTION_ERROR_CODE_QNAME.equals(soapFault.getSubcode())) {
throw new UnknownTransactionException(soapFault.getMessage());
}
throw new SystemException(soapFault.getMessage());
} catch (final Exception e) {
throw new SystemException(e.getMessage());
} catch (final Throwable th) {
th.printStackTrace();
throw new SystemException(th.getMessage());
}
if (!result) {
throw new TransactionRolledBackException();
}
}
use of com.arjuna.wst.SystemException in project narayana by jbosstm.
the class SubordinateCoordinatorCompletionParticipantStub method close.
public void close() throws WrongStateException, SystemException {
if (!recovered) {
int result;
try {
result = coordinator.close();
} catch (com.arjuna.mw.wsas.exceptions.SystemException se) {
throw new SystemException(se.getMessage());
}
if (result != ActionStatus.COMMITTED) {
throw new SystemException("failed to close subordinate transaction " + coordinatorId);
}
} else {
XTSBARecoveryManager recoveryManager = null;
boolean isRecoveryScanStarted = false;
if (coordinator == null) {
// try fetching coordinator from the recovery manager
recoveryManager = XTSBARecoveryManager.getRecoveryManager();
// check whether recovery has started before we check for the presence
// of the subordinate coordinator
isRecoveryScanStarted = recoveryManager.isSubordinateCoordinatorRecoveryStarted();
coordinator = SubordinateBACoordinator.getRecoveredCoordinator(coordinatorId);
}
if (coordinator == null) {
// hmm, still null -- see if we have finished recovery scanning
if (!isRecoveryScanStarted) {
// throw an exception causing the commit to be retried later
throw new SystemException();
}
// ok we have no transaction to commit so assume we already committed it and
// return without error
} else if (!coordinator.isActivated()) {
// throw an exception causing the commit to be retried later
throw new SystemException();
} else {
int status = coordinator.status();
if (status == ActionStatus.PREPARED || status == ActionStatus.COMMITTING) {
// ok, the commit process was not previously initiated so start it now
try {
coordinator.close();
SubordinateBACoordinator.removeActiveProxy(coordinatorId);
} catch (com.arjuna.mw.wsas.exceptions.SystemException e) {
// throw an exception causing the commit to be retried later
throw new SystemException();
}
status = coordinator.status();
}
if (status == ActionStatus.COMMITTING) {
// throw an exception causing the commit to be retried later
throw new SystemException();
}
}
}
}
use of com.arjuna.wst.SystemException in project narayana by jbosstm.
the class SubordinateCoordinatorCompletionParticipantStub method compensate.
public void compensate() throws FaultedException, WrongStateException, SystemException {
if (!recovered) {
int result = coordinator.cancel();
// test result and throw a SystemException if the compensate was delayed
} else {
XTSBARecoveryManager recoveryManager = null;
boolean isRecoveryScanStarted = false;
if (coordinator == null) {
// try fetching coordinator from the recovery manager
recoveryManager = XTSBARecoveryManager.getRecoveryManager();
// check whether recovery has started before we check for the presence
// of the subordinate coordinator
isRecoveryScanStarted = recoveryManager.isSubordinateCoordinatorRecoveryStarted();
coordinator = SubordinateBACoordinator.getRecoveredCoordinator(coordinatorId);
}
if (coordinator == null) {
// hmm, still null -- see if we have finished recovery scanning
if (!isRecoveryScanStarted) {
// throw an exception causing the commit to be retried later
throw new SystemException();
}
// ok we have no transaction to commit so assume we already committed it and
// return without error
} else if (!coordinator.isActivated()) {
// throw an exception causing the commit to be retried later
throw new SystemException();
} else {
int status = coordinator.status();
if (status == ActionStatus.PREPARED || status == ActionStatus.COMMITTING) {
// ok, the commit process was not previously initiated so start it now
coordinator.cancel();
SubordinateBACoordinator.removeActiveProxy(coordinatorId);
status = coordinator.status();
}
if (status == ActionStatus.COMMITTING) {
// throw an exception causing the commit to be retried later
throw new SystemException();
} else if (status != ActionStatus.ABORTED) {
throw new FaultedException();
}
}
}
}
use of com.arjuna.wst.SystemException in project narayana by jbosstm.
the class UserTransactionStandaloneImple method commitWithoutAck.
private final void commitWithoutAck() throws TransactionRolledBackException, UnknownTransactionException, SecurityException, SystemException, WrongStateException {
TxContextImple ctx = null;
String id = null;
try {
ctx = (TxContextImple) _ctxManager.suspend();
if (ctx == null) {
throw new WrongStateException();
}
id = ctx.identifier();
/*
* By default the completionParticipantURL won't be set for an interposed (imported)
* bridged transaction. This is fine, because you shouldn't be able to commit that
* transaction from a node in the tree, only from the root. So, we can prevent commit
* or rollback at this stage. The alternative would be to setup the completionParticipantURL
* and throw the exception from the remote coordinator side (see enlistCompletionParticipants
* for how to do this).
*
* The same applies for an interposed subordinate transaction created via beginSubordinate.
*/
final W3CEndpointReference completionCoordinator = (W3CEndpointReference) _completionCoordinators.get(id);
if (completionCoordinator == null)
throw new WrongStateException();
CompletionRPCStub completionStub = new CompletionRPCStub(id, completionCoordinator);
completionStub.commit();
} catch (SystemException ex) {
throw ex;
} catch (TransactionRolledBackException ex) {
throw ex;
} catch (UnknownTransactionException ex) {
throw ex;
} catch (SecurityException ex) {
throw ex;
} catch (WrongStateException ex) {
throw ex;
} catch (Exception ex) {
ex.printStackTrace();
throw new SystemException(ex.toString());
} finally {
try {
if (ctx != null)
_ctxManager.resume(ctx);
} catch (Exception ex) {
ex.printStackTrace();
}
if (id != null)
_completionCoordinators.remove(id);
}
}
Aggregations