use of com.arjuna.webservices11.wsat.State in project narayana by jbosstm.
the class BusinessAgreementWithCoordinatorCompletionStub method saveState.
public boolean saveState(final OutputObjectState oos) {
try {
oos.packString(participant.getId());
// n.b. just use toString() for the endpoint -- it uses the writeTo() method which calls a suitable marshaller
final StringWriter sw = new StringWriter();
final XMLStreamWriter writer = SoapUtils.getXMLStreamWriter(sw);
StreamHelper.writeStartElement(writer, QNAME_BACCWS_PARTICIPANT);
String eprefText = participant.getParticipant().toString();
writer.writeCData(eprefText);
StreamHelper.writeEndElement(writer, null, null);
writer.close();
oos.packString(sw.toString());
final State state = participant.getStatus();
final QName stateName = state.getValue();
final String ns = stateName.getNamespaceURI();
final String localPart = stateName.getLocalPart();
final String prefix = stateName.getPrefix();
oos.packString(ns != null ? ns : "");
oos.packString(localPart != null ? localPart : "");
oos.packString(prefix != null ? prefix : "");
return true;
} catch (final Throwable th) {
WSTLogger.i18NLogger.error_wst11_stub_BusinessAgreementWithCoordinatorCompletionStub_2(th);
return false;
}
}
use of com.arjuna.webservices11.wsat.State in project narayana by jbosstm.
the class RegistrarImple method register.
/**
* Registers the interest of participant in a particular protocol.
*
* @param participantProtocolService
* the address of the participant protocol service
* @param protocolIdentifier
* the protocol identifier
*
* @return the PortReference of the coordinator protocol service
*
* @throws com.arjuna.wsc.AlreadyRegisteredException
* if the participant is already registered for this
* coordination protocol under this activity identifier
* @throws com.arjuna.wsc.InvalidProtocolException
* if the coordination protocol is not supported
* @throws com.arjuna.wsc.InvalidStateException
* if the state of the coordinator no longer allows registration
* for this coordination protocol
* @throws com.arjuna.wsc.NoActivityException
* if the activity does not exist.
*/
public W3CEndpointReference register(final W3CEndpointReference participantProtocolService, final String protocolIdentifier, final InstanceIdentifier instanceIdentifier, final boolean isSecure) throws AlreadyRegisteredException, InvalidProtocolException, InvalidStateException, NoActivityException {
Object tx = _hierarchies.get(instanceIdentifier.getInstanceIdentifier());
if (tx instanceof SubordinateBACoordinator)
return registerWithSubordinate((SubordinateBACoordinator) tx, participantProtocolService, protocolIdentifier, isSecure);
ActivityHierarchy hier = (ActivityHierarchy) tx;
if (hier == null)
throw new NoActivityException();
try {
_coordManager.resume(hier);
} catch (com.arjuna.mw.wsas.exceptions.InvalidActivityException ex) {
throw new NoActivityException();
} catch (SystemException ex) {
throw new InvalidProtocolException();
}
if (BusinessActivityConstants.WSBA_SUB_PROTOCOL_PARTICIPANT_COMPLETION.equals(protocolIdentifier)) {
// enlist participant that wraps the requester URI.
final String id = new Uid().stringForm();
try {
final ParticipantCompletionCoordinatorEngine engine = new ParticipantCompletionCoordinatorEngine(id, participantProtocolService);
BusinessAgreementWithParticipantCompletionImple participant = new BusinessAgreementWithParticipantCompletionImple(new BusinessAgreementWithParticipantCompletionStub(engine), id);
engine.setCoordinator(participant.participantManager());
_coordManager.enlistParticipant(participant);
_coordManager.suspend();
final ServiceRegistry serviceRegistry = PrivilegedServiceRegistryFactory.getInstance().getServiceRegistry();
return getParticipantManager(BusinessActivityConstants.PARTICIPANT_COMPLETION_COORDINATOR_SERVICE_QNAME, BusinessActivityConstants.PARTICIPANT_COMPLETION_COORDINATOR_PORT_QNAME, serviceRegistry.getServiceURI(BusinessActivityConstants.PARTICIPANT_COMPLETION_COORDINATOR_SERVICE_NAME, isSecure), id);
} catch (Exception ex) {
throw new InvalidStateException();
}
} else if (BusinessActivityConstants.WSBA_SUB_PROTOCOL_COORDINATOR_COMPLETION.equals(protocolIdentifier)) {
final String id = new Uid().stringForm();
try {
final CoordinatorCompletionCoordinatorEngine engine = new CoordinatorCompletionCoordinatorEngine(id, participantProtocolService);
BusinessAgreementWithCoordinatorCompletionImple participant = new BusinessAgreementWithCoordinatorCompletionImple(new BusinessAgreementWithCoordinatorCompletionStub(engine), id);
engine.setCoordinator(participant.participantManager());
_coordManager.enlistParticipant(participant);
_coordManager.suspend();
final ServiceRegistry serviceRegistry = PrivilegedServiceRegistryFactory.getInstance().getServiceRegistry();
return getParticipantManager(BusinessActivityConstants.COORDINATOR_COMPLETION_COORDINATOR_SERVICE_QNAME, BusinessActivityConstants.COORDINATOR_COMPLETION_COORDINATOR_PORT_QNAME, serviceRegistry.getServiceURI(BusinessActivityConstants.COORDINATOR_COMPLETION_COORDINATOR_SERVICE_NAME, isSecure), id);
} catch (Exception ex) {
throw new InvalidStateException();
}
} else if (com.arjuna.webservices.wsarjtx.ArjunaTXConstants.WSARJTX_PROTOCOL_TERMINATION.equals(protocolIdentifier)) {
/*
* update the server side terminator with the participant end point
*/
BusinessActivityTerminatorImple terminator;
terminator = (BusinessActivityTerminatorImple) TerminationCoordinatorProcessor.getProcessor().getParticipant(instanceIdentifier);
terminator.setEndpoint(participantProtocolService);
try {
_coordManager.suspend();
final ServiceRegistry serviceRegistry = PrivilegedServiceRegistryFactory.getInstance().getServiceRegistry();
return getParticipantManager(ArjunaTX11Constants.TERMINATION_COORDINATOR_SERVICE_QNAME, ArjunaTX11Constants.TERMINATION_COORDINATOR_PORT_QNAME, serviceRegistry.getServiceURI(ArjunaTX11Constants.TERMINATION_COORDINATOR_SERVICE_NAME, isSecure), instanceIdentifier.getInstanceIdentifier());
} catch (Exception ex) {
throw new InvalidStateException();
}
} else if (com.arjuna.webservices.wsarjtx.ArjunaTXConstants.WSARJTX_PROTOCOL_TERMINATION_RPC.equals(protocolIdentifier)) {
try {
_coordManager.suspend();
final ServiceRegistry serviceRegistry = PrivilegedServiceRegistryFactory.getInstance().getServiceRegistry();
return getParticipantManager(ArjunaTX11Constants.TERMINATION_COORDINATOR_RPC_SERVICE_QNAME, ArjunaTX11Constants.TERMINATION_COORDINATOR_RPC_PORT_QNAME, serviceRegistry.getServiceURI(ArjunaTX11Constants.TERMINATION_COORDINATOR_RPC_SERVICE_NAME, isSecure), instanceIdentifier.getInstanceIdentifier());
} catch (Exception ex) {
throw new InvalidStateException();
}
} else {
wstxLogger.i18NLogger.warn_mwlabs_wst_ba_Registrar11Imple_1(BusinessActivityConstants.WSBA_PROTOCOL_ATOMIC_OUTCOME, protocolIdentifier);
throw new InvalidProtocolException();
}
}
use of com.arjuna.webservices11.wsat.State in project narayana by jbosstm.
the class BusinessAgreementWithCoordinatorCompletionParticipantTest method testSendFault.
@Test
public void testSendFault() throws Exception {
final String messageId = "testSendFault";
final InstanceIdentifier instanceIdentifier = new InstanceIdentifier("4");
W3CEndpointReference endpoint = TestUtil.getCoordinatorCompletionCoordinatorEndpoint(instanceIdentifier.getInstanceIdentifier());
final MAP map = AddressingHelper.createRequestContext(TestUtil.coordinatorCompletionCoordinatorServiceURI, messageId);
final State state = State.STATE_FAILING_COMPENSATING;
CoordinatorCompletionCoordinatorClient.getClient().sendFail(endpoint, map, new InstanceIdentifier("sender"), state.getValue());
CoordinatorCompletionCoordinatorDetails details = testCoordinatorCompletionCoordinatorProcessor.getCoordinatorCompletionCoordinatorDetails(messageId, 10000);
assertNotNull(details.hasFail());
assertEquals(details.hasFail().getExceptionIdentifier(), state.getValue());
checkDetails(details, true, true, messageId, instanceIdentifier);
}
use of com.arjuna.webservices11.wsat.State in project narayana by jbosstm.
the class TestRegistrationCoordinatorProcessor method register.
public RegisterResponseType register(final RegisterType register, final MAP map, final ArjunaContext arjunaContext, boolean isSecure) {
final String messageId = map.getMessageID();
synchronized (messageIdMap) {
messageIdMap.put(messageId, new RegisterDetails(register, map, arjunaContext));
messageIdMap.notifyAll();
}
String protocolIdentifier = register.getProtocolIdentifier();
if (TestUtil.ALREADY_REGISTERED_PROTOCOL_IDENTIFIER.equals(protocolIdentifier)) {
try {
SOAPFactory factory = SOAPFactory.newInstance();
SOAPFault soapFault = factory.createFault(SoapFaultType.FAULT_SENDER.getValue(), CoordinationConstants.WSCOOR_ERROR_CODE_CANNOT_REGISTER_QNAME);
soapFault.addDetail().addDetailEntry(CoordinationConstants.WSCOOR_ERROR_CODE_CANNOT_REGISTER_QNAME).addTextNode("already registered");
throw new SOAPFaultException(soapFault);
} catch (Throwable th) {
throw new ProtocolException(th);
}
}
if (TestUtil.INVALID_PROTOCOL_PROTOCOL_IDENTIFIER.equals(protocolIdentifier)) {
try {
SOAPFactory factory = SOAPFactory.newInstance();
SOAPFault soapFault = factory.createFault(SoapFaultType.FAULT_SENDER.getValue(), CoordinationConstants.WSCOOR_ERROR_CODE_INVALID_PROTOCOL_QNAME);
soapFault.addDetail().addDetailEntry(CoordinationConstants.WSCOOR_ERROR_CODE_INVALID_PROTOCOL_QNAME).addTextNode("invalid protocol");
throw new SOAPFaultException(soapFault);
} catch (Throwable th) {
throw new ProtocolException(th);
}
}
if (TestUtil.INVALID_STATE_PROTOCOL_IDENTIFIER.equals(protocolIdentifier)) {
try {
SOAPFactory factory = SOAPFactory.newInstance();
SOAPFault soapFault = factory.createFault(SoapFaultType.FAULT_SENDER.getValue(), CoordinationConstants.WSCOOR_ERROR_CODE_INVALID_STATE_QNAME);
soapFault.addDetail().addDetailEntry(CoordinationConstants.WSCOOR_ERROR_CODE_INVALID_STATE_QNAME).addTextNode("invalid state");
throw new SOAPFaultException(soapFault);
} catch (Throwable th) {
throw new ProtocolException(th);
}
}
if (TestUtil.NO_ACTIVITY_PROTOCOL_IDENTIFIER.equals(protocolIdentifier)) {
try {
SOAPFactory factory = SOAPFactory.newInstance();
SOAPFault soapFault = factory.createFault(SoapFaultType.FAULT_SENDER.getValue(), CoordinationConstants.WSCOOR_ERROR_CODE_CANNOT_REGISTER_QNAME);
soapFault.addDetail().addDetailEntry(CoordinationConstants.WSCOOR_ERROR_CODE_CANNOT_REGISTER_QNAME).addTextNode("no activity");
throw new SOAPFaultException(soapFault);
} catch (Throwable th) {
throw new ProtocolException(th);
}
}
// we need to cook up a response here
RegisterResponseType registerResponseType = new RegisterResponseType();
if (arjunaContext != null) {
InstanceIdentifier instanceIdentifier = arjunaContext.getInstanceIdentifier();
registerResponseType.setCoordinatorProtocolService(TestUtil11.getProtocolCoordinatorEndpoint(instanceIdentifier.getInstanceIdentifier()));
} else {
registerResponseType.setCoordinatorProtocolService(TestUtil11.getProtocolCoordinatorEndpoint(null));
}
return registerResponseType;
}
use of com.arjuna.webservices11.wsat.State in project narayana by jbosstm.
the class BusinessAgreementWithCoordinatorCompletionCoordinatorTest method testSendStatus.
@Test
public void testSendStatus() throws Exception {
final String messageId = "testSendStatus";
final InstanceIdentifier instanceIdentifier = new InstanceIdentifier("6");
W3CEndpointReference endpoint = TestUtil.getCoordinatorCompletionParticipantEndpoint(instanceIdentifier.getInstanceIdentifier());
final MAP map = AddressingHelper.createRequestContext(TestUtil.coordinatorCompletionParticipantServiceURI, messageId);
final State state = State.STATE_ACTIVE;
CoordinatorCompletionParticipantClient.getClient().sendStatus(endpoint, map, new InstanceIdentifier("sender"), state.getValue());
final CoordinatorCompletionParticipantDetails details = testCoordinatorCompletionParticipantProcessor.getCoordinatorCompletionParticipantDetails(messageId, 10000);
assertNotNull(details.hasStatus());
assertEquals(details.hasStatus().getState(), state.getValue());
checkDetails(details, true, true, messageId, instanceIdentifier);
}
Aggregations