use of com.arjuna.wsc.InvalidCreateParametersException in project narayana by jbosstm.
the class ActivationCoordinator method createCoordinationContext.
/**
* Create the coordination context.
* @param activationCoordinatorURI The URI of the activation coordinator.
* @param messageID The messageID to use.
* @param coordinationTypeURI The coordination type.
* @param expires The expiry time or null.
* @param currentContext The currnt context or null.
* @return The coordination context.
* @throws com.arjuna.wsc.InvalidCreateParametersException if the create parameters are invalid.
* @throws SoapFault for errors during processing.
*/
public static CoordinationContextType createCoordinationContext(final String activationCoordinatorURI, final String messageID, final String coordinationTypeURI, final Long expires, final CoordinationContext currentContext) throws InvalidCreateParametersException, SoapFault {
final MAP map = AddressingHelper.createRequestContext(activationCoordinatorURI, messageID);
final Expires expiresValue;
if (expires == null) {
expiresValue = null;
} else {
expiresValue = new Expires();
expiresValue.setValue(expires.longValue());
}
try {
CreateCoordinationContextResponseType response;
ActivationCoordinatorClient client = ActivationCoordinatorClient.getClient();
response = client.sendCreateCoordination(map, coordinationTypeURI, expiresValue, currentContext);
return response.getCoordinationContext();
} catch (final IOException ioe) {
throw new SoapFault11(ioe);
} catch (SOAPFaultException sfe) {
// TODO -- work out which faults we should really throw. in particular do we need to retain SoapFault
final SOAPFault soapFault = sfe.getFault();
final QName subcode = soapFault.getFaultCodeAsQName();
if (CoordinationConstants.WSCOOR_ERROR_CODE_INVALID_PARAMETERS_QNAME.equals(subcode)) {
Detail detail = soapFault.getDetail();
String message = (detail != null ? detail.getTextContent() : soapFault.getFaultString());
throw new InvalidCreateParametersException(message);
}
throw SoapFault11.create(sfe);
}
}
use of com.arjuna.wsc.InvalidCreateParametersException in project narayana by jbosstm.
the class ActivationCoordinatorProcessorImpl method createCoordinationContext.
/**
* Create the coordination context.
* @param createCoordinationContext The create coordination context request.
* @param map The addressing context.
*/
public CreateCoordinationContextResponseType createCoordinationContext(final CreateCoordinationContextType createCoordinationContext, final MAP map, final boolean isSecure) {
final ContextFactoryMapper contextFactoryMapper = ContextFactoryMapper.getMapper();
try {
final String coordinationType = createCoordinationContext.getCoordinationType();
final ContextFactory contextFactory = contextFactoryMapper.getContextFactory(coordinationType);
if (contextFactory != null) {
final CoordinationContext coordinationContext;
try {
final Expires expiresElement = createCoordinationContext.getExpires();
final Long expires = (expiresElement == null ? null : new Long(expiresElement.getValue()));
coordinationContext = contextFactory.create(coordinationType, expires, createCoordinationContext.getCurrentContext(), isSecure);
final CreateCoordinationContextResponseType response = new CreateCoordinationContextResponseType();
response.setCoordinationContext(coordinationContext);
return response;
} catch (final InvalidCreateParametersException invalidCreateParametersException) {
SOAPFactory factory = SOAPFactory.newInstance();
SOAPFault soapFault = factory.createFault(SoapFaultType.FAULT_SENDER.getValue(), CoordinationConstants.WSCOOR_ERROR_CODE_INVALID_PARAMETERS_QNAME);
soapFault.addDetail().addDetailEntry(CoordinationConstants.WSCOOR_ERROR_CODE_INVALID_PARAMETERS_QNAME).addTextNode(WSCLogger.i18NLogger.get_wsc11_messaging_ActivationCoordinatorProcessorImpl_1());
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_CREATE_CONTEXT_QNAME);
soapFault.addDetail().addDetailEntry(CoordinationConstants.WSCOOR_ERROR_CODE_CANNOT_CREATE_CONTEXT_QNAME).addTextNode(th.getMessage());
throw new SOAPFaultException(soapFault);
}
} else {
if (WSCLogger.logger.isTraceEnabled()) {
WSCLogger.logger.tracev("CreateCoordinationContext called for unknown coordination type: {0}", new Object[] { coordinationType });
}
SOAPFactory factory = SOAPFactory.newInstance();
SOAPFault soapFault = factory.createFault(SoapFaultType.FAULT_SENDER.getValue(), CoordinationConstants.WSCOOR_ERROR_CODE_INVALID_PARAMETERS_QNAME);
soapFault.addDetail().addDetailEntry(CoordinationConstants.WSCOOR_ERROR_CODE_INVALID_PARAMETERS_QNAME).addTextNode(WSCLogger.i18NLogger.get_wsc11_messaging_ActivationCoordinatorProcessorImpl_1());
throw new SOAPFaultException(soapFault);
}
} catch (SOAPException se) {
se.printStackTrace(System.err);
throw new ProtocolException(se);
}
}
use of com.arjuna.wsc.InvalidCreateParametersException in project narayana by jbosstm.
the class UserBusinessActivityStandaloneImple method begin.
public void begin(int timeout) throws WrongStateException, SystemException {
try {
if (_ctxManager.currentTransaction() != null)
throw new WrongStateException();
Context ctx = startTransaction(timeout, null);
_ctxManager.resume(new TxContextImple(ctx));
} catch (InvalidCreateParametersException ex) {
tidyup();
throw new SystemException(ex.toString());
} catch (UnknownTransactionException ex) {
tidyup();
throw new SystemException(ex.toString());
} catch (SystemException ex) {
tidyup();
throw ex;
}
}
use of com.arjuna.wsc.InvalidCreateParametersException in project narayana by jbosstm.
the class UserBusinessActivityStandaloneImple method startTransaction.
private final Context startTransaction(int timeout, TxContextImple current) throws InvalidCreateParametersException, SystemException {
try {
final Long expires = (timeout > 0 ? new Long(timeout) : null);
final String messageId = MessageId.getMessageId();
final CoordinationContext currentContext = (current != null ? getContext(current) : null);
final CoordinationContextType coordinationContext = ActivationCoordinator.createCoordinationContext(_activationCoordinatorService, messageId, BusinessActivityConstants.WSBA_PROTOCOL_ATOMIC_OUTCOME, expires, currentContext);
if (coordinationContext == null) {
throw new SystemException(wstxLogger.i18NLogger.get_mwlabs_wst11_ba_remote_UserBusinessActivityImple_2());
}
return new ContextImple(coordinationContext);
} catch (final InvalidCreateParametersException icpe) {
throw icpe;
} catch (final SoapFault sf) {
throw new SystemException(sf.getMessage());
} catch (final Exception ex) {
throw new SystemException(ex.toString());
}
}
use of com.arjuna.wsc.InvalidCreateParametersException in project narayana by jbosstm.
the class ContextFactoryImple method create.
/**
* Creates a coordination context.
*
* @param coordinationTypeURI
* the coordination type uri
* @param expires
* the expire date/time for the returned context, can be null
* @param currentContext
* the current context, can be null
*
* @return the created coordination context
*
* @throws com.arjuna.wsc.InvalidCreateParametersException
* if a parameter passed is invalid this activity identifier.
*/
public CoordinationContext create(final String coordinationTypeURI, final Long expires, final CoordinationContextType currentContext, final boolean isSecure) throws InvalidCreateParametersException {
if (coordinationTypeURI.equals(AtomicTransactionConstants.WSAT_PROTOCOL)) {
try {
if (currentContext == null) {
// make sure no transaction is currently associated
_coordManager.suspend();
final int timeout;
if (expires == null) {
timeout = 0;
} else {
final long timeoutVal = expires.longValue();
timeout = (timeoutVal > Integer.MAX_VALUE ? Integer.MAX_VALUE : (int) timeoutVal);
}
_coordManager.begin(ArjunaContextImple.serviceType, timeout);
final ArjunaContextImple arjunaContext = ArjunaContextImple.getContext();
final ServiceRegistry serviceRegistry = PrivilegedServiceRegistryFactory.getInstance().getServiceRegistry();
final String registrationCoordinatorURI = serviceRegistry.getServiceURI(CoordinationConstants.REGISTRATION_SERVICE_NAME, isSecure);
final CoordinationContext coordinationContext = new CoordinationContext();
coordinationContext.setCoordinationType(coordinationTypeURI);
CoordinationContextType.Identifier identifier = new CoordinationContextType.Identifier();
identifier.setValue("urn:" + arjunaContext.getTransactionIdentifier());
coordinationContext.setIdentifier(identifier);
final int transactionExpires = arjunaContext.getTransactionExpires();
if (transactionExpires > 0) {
Expires expiresInstance = new Expires();
expiresInstance.setValue(transactionExpires);
coordinationContext.setExpires(expiresInstance);
}
W3CEndpointReference registrationCoordinator = getRegistrationCoordinator(registrationCoordinatorURI, arjunaContext);
coordinationContext.setRegistrationService(registrationCoordinator);
/*
* Now add the registrar for this specific coordinator to the
* mapper.
*/
_coordManager.enlistSynchronization(new CleanupSynchronization(_coordManager.identifier().toString(), _theRegistrar));
/*
* TODO Uughh! This does a suspend for us! Left over from original
* WS-AS stuff.
*
* TODO
* REFACTOR, REFACTOR, REFACTOR.
*/
_theRegistrar.associate();
return coordinationContext;
} else {
// we need to create a subordinate transaction and register it as both a durable and volatile
// participant with the registration service defined in the current context
SubordinateATCoordinator subTx = (SubordinateATCoordinator) createSubordinate();
// hmm, need to create wrappers here as the subTx is in WSCF which only knows
// about WSAS and WS-C and the participant is in WS-T
String vtppid = subTx.getVolatile2PhaseId();
String dtppid = subTx.getDurable2PhaseId();
Volatile2PCParticipant vtpp = new SubordinateVolatile2PCStub(subTx);
Durable2PCParticipant dtpp = new SubordinateDurable2PCStub(subTx);
final String messageId = MessageId.getMessageId();
W3CEndpointReference participant;
W3CEndpointReference coordinator;
participant = getParticipant(vtppid, isSecure);
coordinator = RegistrationCoordinator.register(currentContext, messageId, participant, AtomicTransactionConstants.WSAT_SUB_PROTOCOL_VOLATILE_2PC);
ParticipantProcessor.getProcessor().activateParticipant(new ParticipantEngine(vtpp, vtppid, coordinator), vtppid);
participant = getParticipant(dtppid, isSecure);
coordinator = RegistrationCoordinator.register(currentContext, messageId, participant, AtomicTransactionConstants.WSAT_SUB_PROTOCOL_DURABLE_2PC);
ParticipantProcessor.getProcessor().activateParticipant(new ParticipantEngine(dtpp, dtppid, coordinator), dtppid);
// ok now create the context
final ServiceRegistry serviceRegistry = PrivilegedServiceRegistryFactory.getInstance().getServiceRegistry();
final String registrationCoordinatorURI = serviceRegistry.getServiceURI(CoordinationConstants.REGISTRATION_SERVICE_NAME, isSecure);
final CoordinationContext coordinationContext = new CoordinationContext();
coordinationContext.setCoordinationType(coordinationTypeURI);
CoordinationContextType.Identifier identifier = new CoordinationContextType.Identifier();
String txId = subTx.get_uid().stringForm();
identifier.setValue("urn:" + txId);
coordinationContext.setIdentifier(identifier);
Expires expiresInstance = currentContext.getExpires();
final long transactionExpires = (expiresInstance != null ? expiresInstance.getValue() : 0);
if (transactionExpires > 0) {
expiresInstance = new Expires();
expiresInstance.setValue(transactionExpires);
coordinationContext.setExpires(expiresInstance);
}
W3CEndpointReference registrationCoordinator = getRegistrationCoordinator(registrationCoordinatorURI, txId);
coordinationContext.setRegistrationService(registrationCoordinator);
// now associate the tx id with the sub transaction
_theRegistrar.associate(subTx);
return coordinationContext;
}
} catch (NoActivityException ex) {
ex.printStackTrace();
throw new InvalidCreateParametersException();
} catch (SystemException ex) {
ex.printStackTrace();
} catch (com.arjuna.mw.wsas.exceptions.WrongStateException ex) {
ex.printStackTrace();
throw new InvalidCreateParametersException();
} catch (Exception ex) {
// TODO handle properly
ex.printStackTrace();
}
} else {
wstxLogger.i18NLogger.warn_mwlabs_wst_at_Context11FactoryImple_1(AtomicTransactionConstants.WSAT_PROTOCOL, coordinationTypeURI);
throw new InvalidCreateParametersException(wstxLogger.i18NLogger.get_mwlabs_wst_at_Context11FactoryImple_3() + " < " + AtomicTransactionConstants.WSAT_PROTOCOL + ", " + coordinationTypeURI + " >");
}
return null;
}
Aggregations