use of org.oasis_open.docs.ws_tx.wscoor._2006._06.RegisterResponseType in project narayana by jbosstm.
the class RegistrationCoordinatorProcessorImpl method register.
/**
* Register the participant in the protocol.
* @param register The register request.
* @param map The addressing context.
* @param arjunaContext The arjuna context.
*/
public RegisterResponseType register(final RegisterType register, final MAP map, final ArjunaContext arjunaContext, final boolean isSecure) {
final com.arjuna.wsc11.RegistrarMapper registrarMapper = RegistrarMapper.getFactory();
try {
final String protocolIdentifier = register.getProtocolIdentifier();
final Registrar registrar = registrarMapper.getRegistrar(protocolIdentifier);
if (registrar != null) {
try {
final W3CEndpointReference participantProtocolService = register.getParticipantProtocolService();
final InstanceIdentifier instanceIdentifier = arjunaContext.getInstanceIdentifier();
final W3CEndpointReference coordinationProtocolService = registrar.register(participantProtocolService, protocolIdentifier, instanceIdentifier, isSecure);
final RegisterResponseType response = new RegisterResponseType();
response.setCoordinatorProtocolService(coordinationProtocolService);
return response;
} catch (final AlreadyRegisteredException alreadyRegisteredException) {
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(WSCLogger.i18NLogger.get_wsc11_messaging_RegistrationCoordinatorProcessorImpl_1());
throw new SOAPFaultException(soapFault);
} catch (final InvalidProtocolException invalidProtocolException) {
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_PARAMETERS_QNAME).addTextNode(WSCLogger.i18NLogger.get_wsc11_messaging_RegistrationCoordinatorProcessorImpl_2());
throw new SOAPFaultException(soapFault);
} catch (final InvalidStateException InvalidStateException) {
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(WSCLogger.i18NLogger.get_wsc11_messaging_RegistrationCoordinatorProcessorImpl_3());
throw new SOAPFaultException(soapFault);
} catch (final NoActivityException noActivityException) {
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(WSCLogger.i18NLogger.get_wsc11_messaging_RegistrationCoordinatorProcessorImpl_4());
throw new SOAPFaultException(soapFault);
} catch (final Throwable th) {
if (WSCLogger.logger.isTraceEnabled()) {
WSCLogger.logger.tracev("Unexpected exception thrown from create:", th);
}
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(th.getMessage());
throw new SOAPFaultException(soapFault);
}
} else {
if (WSCLogger.logger.isTraceEnabled()) {
WSCLogger.logger.tracev("Register called for unknown protocol identifier: {0}", new Object[] { protocolIdentifier });
}
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_PARAMETERS_QNAME).addTextNode(WSCLogger.i18NLogger.get_wsc11_messaging_RegistrationCoordinatorProcessorImpl_2());
throw new SOAPFaultException(soapFault);
}
} catch (SOAPException se) {
se.printStackTrace(System.err);
throw new ProtocolException(se);
}
}
use of org.oasis_open.docs.ws_tx.wscoor._2006._06.RegisterResponseType in project narayana by jbosstm.
the class RegistrationCoordinator method registerOperation.
private static RegisterResponseType registerOperation(String messageID, final RegistrationPortType port, final RegisterType registerType) throws CannotRegisterException, InvalidProtocolException, InvalidStateException, SoapFault {
final WSCEnvironmentBean wscEnvironmentBean = XTSPropertyManager.getWSCEnvironmentBean();
if (!WSCEnvironmentBean.NO_ASYNC_REQUEST.equals(wscEnvironmentBean.getUseAsynchronousRequest())) {
// using asynchronous request, we have to wait for the response
AsynchronousRegistrationMapper.getInstance().addClientMessage(messageID);
}
RegisterResponseType response;
if (System.getSecurityManager() == null) {
response = port.registerOperation(registerType);
} else {
response = AccessController.doPrivileged(new PrivilegedAction<RegisterResponseType>() {
@Override
public RegisterResponseType run() {
return port.registerOperation(registerType);
}
});
}
if (!WSCEnvironmentBean.NO_ASYNC_REQUEST.equals(wscEnvironmentBean.getUseAsynchronousRequest())) {
// wait until the response arrives
FaultOrResponse res = AsynchronousRegistrationMapper.getInstance().waitForResponse(messageID, wscEnvironmentBean.getAsyncRequestWait());
if (res.isFault()) {
String detail = res.getFault().getFaultstring();
if (res.getFault().getDetail() != null && res.getFault().getDetail().getAny() != null && !res.getFault().getDetail().getAny().isEmpty()) {
detail = res.getFault().getDetail().getAny().get(0).toString();
}
throwException(res.getFault().getFaultcode(), detail, null, res.getFault());
} else if (res.isEmpty()) {
throw new InvalidStateException("No response assigned to messageID " + messageID);
}
response = res.getResponse();
}
return response;
}
use of org.oasis_open.docs.ws_tx.wscoor._2006._06.RegisterResponseType in project narayana by jbosstm.
the class RegistrationCoordinator method register.
/**
* Register the participant in the protocol.
* @param coordinationContext The current coordination context
* @param messageID The messageID to use.
* @param participantProtocolService The participant protocol service.
* @param protocolIdentifier The protocol identifier.
* @return The endpoint reference of the coordinator protocol service.
* @throws com.arjuna.wsc.InvalidProtocolException If the protocol is unsupported.
* @throws com.arjuna.wsc.InvalidStateException If the state is invalid
* @throws com.arjuna.webservices.SoapFault for errors during processing.
*/
public static W3CEndpointReference register(final CoordinationContextType coordinationContext, final String messageID, final W3CEndpointReference participantProtocolService, final String protocolIdentifier) throws CannotRegisterException, InvalidProtocolException, InvalidStateException, SoapFault {
final W3CEndpointReference endpointReference = coordinationContext.getRegistrationService();
try {
final RegisterType registerType = new RegisterType();
registerType.setProtocolIdentifier(protocolIdentifier);
registerType.setParticipantProtocolService(participantProtocolService);
final RegistrationPortType port = WSCOORClient.getRegistrationPort(endpointReference, CoordinationConstants.WSCOOR_ACTION_REGISTER, messageID);
final RegisterResponseType response = registerOperation(messageID, port, registerType);
return response.getCoordinatorProtocolService();
} catch (SOAPFaultException sfe) {
final SOAPFault soapFault = sfe.getFault();
final Detail detail = soapFault.getDetail();
String message = (detail != null ? detail.getTextContent() : soapFault.getFaultString());
throwException(soapFault.getFaultCodeAsQName(), message, sfe, null);
// impossible reach here
return null;
}
}
use of org.oasis_open.docs.ws_tx.wscoor._2006._06.RegisterResponseType in project narayana by jbosstm.
the class AsynchronousRegistrationMapperTest method testMapper.
private void testMapper(String message, long millis, Object result) {
mapper.addClientMessage(message);
ClientThread client = new ClientThread(message);
Thread clientThread = new Thread(client);
Thread serverThread = new Thread(new ServerThread(message, millis, result));
clientThread.start();
if (millis >= 0) {
serverThread.start();
}
try {
clientThread.join(WAIT_TIME * 2);
} catch (InterruptedException e) {
}
Assert.assertFalse(clientThread.isAlive());
FaultOrResponse r = client.getResult();
Assert.assertNotNull(r);
Assert.assertEquals(0, mapper.size());
if (millis >= 0 && millis < WAIT_TIME) {
if (result instanceof RegisterResponseType) {
Assert.assertTrue(r.isResponse());
Assert.assertEquals(result, r.getResponse());
} else {
Assert.assertTrue(r.isFault());
Assert.assertEquals(result, r.getFault());
}
} else {
Assert.assertTrue(r.isEmpty());
}
}
use of org.oasis_open.docs.ws_tx.wscoor._2006._06.RegisterResponseType 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;
}
Aggregations