AcceptValidator[] validators = theContext.getValidators();
for (int i = 0; i < validators.length && ruling == null; i++) {
AcceptValidator.AcceptRuling vr = validators[i].check(theMessage);
if (!vr.isAcceptable()) {
String description = (vr.getReasons().length > 0) ? vr.getReasons()[0] : null;
Transportable ack = makeAcceptAck(theMessage, vr.getAckCode(), ErrorCode.errorCodeFor(vr.getErrorCode()), description);
ruling = new AcceptACK(false, ack);
}
}
if (ruling == null) {
try {
theContext.getSafeStorage().store(theMessage);
Transportable ack = makeAcceptAck(theMessage, Processor.CA, ErrorCode.MESSAGE_ACCEPTED, "");
ruling = new AcceptACK(true, ack);
} catch (HL7Exception e) {
log.error(e.getMessage(), e);
Transportable ack = makeAcceptAck(theMessage, Processor.CR, ErrorCode.APPLICATION_INTERNAL_ERROR, e.getMessage());
ruling = new AcceptACK(false, ack);
}
}
return ruling;