private void handleNotifyFailure(VerticalCommand cmd)
throws JADESecurityException {
Object[] params = cmd.getParams();
GenericMessage msg = (GenericMessage) params[0];
AID receiver = (AID) params[1];
InternalError ie = (InternalError) params[2];
// If (the sender is not the AMS and the performative is not FAILURE)
ACLMessage aclmsg = msg.getACLMessage();
if ((aclmsg.getSender() == null) ||
((aclmsg.getSender().equals(myContainer.getAMS())) &&
(aclmsg.getPerformative() == ACLMessage.FAILURE))) { // sanity check to avoid infinite loops
return;
}
// Send back a failure message
final ACLMessage failure = aclmsg.createReply();
failure.setPerformative(ACLMessage.FAILURE);
//System.err.println(failure.toString());
final AID theAMS = myContainer.getAMS();
failure.setSender(theAMS);
failure.setLanguage(FIPANames.ContentLanguage.FIPA_SL);
// FIXME: the content is not completely correct, but that should
// also avoid creating wrong content
String content = "( (action " + msg.getSender().toString();
content = content + " (ACLMessage) ) (MTS-error " + receiver + " \"" +
ie.getMessage() + "\") )";
failure.setContent(content);
try {
GenericCommand command = new GenericCommand(MessagingSlice.SEND_MESSAGE,
MessagingSlice.NAME, null);