bindCommands(commandList, bindings);
String id = participantId("CoordinatorCompletionParticipant");
CoordinatorCompletionTestParticipant participant = new CoordinatorCompletionTestParticipant(id);
BusinessActivityManager baman = BusinessActivityManagerFactory.businessActivityManager();
try {
BAParticipantManager partMan;
partMan = baman.enlistForBusinessAgreementWithCoordinatorCompletion(participant, id);
managerMap.put(id, partMan);
} catch (Exception e) {
throw new WebServiceException("enlistCoordinatorCompletion failed ", e);
}
for (idx = 0; idx < size; idx++) {
participant.addCommand(commandList.get(idx));
}
participantMap.put(id, participant);
resultsList.add(id);
} else if (command.equals("enlistParticipantCompletion")) {
bindCommands(commandList, bindings);
String id = participantId("ParticipantCompletionParticipant");
ParticipantCompletionTestParticipant participant = new ParticipantCompletionTestParticipant(id);
BusinessActivityManager baman = BusinessActivityManagerFactory.businessActivityManager();
try {
BAParticipantManager partMan;
partMan = baman.enlistForBusinessAgreementWithParticipantCompletion(participant, id);
managerMap.put(id, partMan);
} catch (Exception e) {
throw new WebServiceException("enlistParticipantCompletion failed ", e);
}
for (idx = 0; idx < size; idx++) {
participant.addCommand(commandList.get(idx));
}
participantMap.put(id, participant);
resultsList.add(id);
} else if (command.equals("addCommands")) {
// add extra commands to a participant script
bindCommands(commandList, bindings);
String id = commandList.remove(idx);
size--;
ScriptedTestParticipant participant = participantMap.get(id);
if (participant != null) {
for (idx = 0; idx < size; idx++)
{
participant.addCommand(commandList.get(idx));
}
resultsList.add("ok");
} else {
throw new WebServiceException("addCommands failed to find participant " + id);
}
} else if (command.equals("exit")) {
// initiate BA manager activities
bindCommands(commandList, bindings);
String id = commandList.remove(idx);
size--;
ScriptedTestParticipant participant = participantMap.get(id);
if (participant != null ) {
if (participant instanceof ParticipantCompletionTestParticipant) {
ParticipantCompletionTestParticipant baparticipant = (ParticipantCompletionTestParticipant)participant;
BAParticipantManager manager = managerMap.get(id);
try {
manager.exit();
} catch (Exception e) {
throw new WebServiceException("exit " + id + " failed with exception " + e);
}
resultsList.add("ok");
} else {
throw new WebServiceException("exit invalid participant type " + id);
}
} else {
throw new WebServiceException("exit unknown participant " + id);
}
} else if (command.equals("completed")) {
bindCommands(commandList, bindings);
String id = commandList.remove(idx);
size--;
ScriptedTestParticipant participant = participantMap.get(id);
if (participant != null ) {
if (participant instanceof ParticipantCompletionTestParticipant) {
ParticipantCompletionTestParticipant baparticipant = (ParticipantCompletionTestParticipant)participant;
BAParticipantManager manager = managerMap.get(id);
try {
manager.completed();
resultsList.add("ok");
} catch (Exception e) {
throw new WebServiceException("completed " + id + " failed with exception " + e);
}
} else {
throw new WebServiceException("completed invalid participant type " + id);
}
} else {
throw new WebServiceException("completed unknown participant " + id);
}
} else if (command.equals("fail")) {
bindCommands(commandList, bindings);
String id = commandList.remove(idx);
size--;
ScriptedTestParticipant participant = participantMap.get(id);
if (participant != null ) {
if (participant instanceof ParticipantCompletionTestParticipant) {
ParticipantCompletionTestParticipant baparticipant = (ParticipantCompletionTestParticipant)participant;
BAParticipantManager manager = managerMap.get(id);
QName qname = new QName("http://jbossts.jboss.org/xts/servicetests/", "fail");
try {
manager.fail(qname);
resultsList.add("ok");
} catch (Exception e) {
throw new WebServiceException("fail " + id + " failed with exception " + e);
}
} else {
throw new WebServiceException("fail invalid participant type " + id);
}
} else {
throw new WebServiceException("fail unknown participant " + id);
}
} else if (command.equals("cannotComplete")) {
bindCommands(commandList, bindings);
String id = commandList.remove(idx);
size--;
ScriptedTestParticipant participant = participantMap.get(id);
if (participant != null ) {
if (participant instanceof ParticipantCompletionTestParticipant) {
ParticipantCompletionTestParticipant baparticipant = (ParticipantCompletionTestParticipant)participant;
BAParticipantManager manager = managerMap.get(id);
try {
manager.cannotComplete();
resultsList.add("ok");
} catch (Exception e) {
throw new WebServiceException("cannotComplete " + id + " failed with exception " + e);
}
} else {