Set<CommandEntry> commandEntries = invocation.getCommandEntries();
// table-driven action evaluation
UserManager userManager = new UserManager(locale,session);
User user = userManager.registerUserByMsisdn(Long.parseLong(msisdn), null, invocation.getGroup());
InteractionLogManager interactionLogManager = new InteractionLogManager(locale, session);
EventParameters eventParameters = null;
ReceivedSms receivedSms = new ReceivedSms();
receivedSms.setSender(msisdn);
receivedSms.setReceiver(invocation.getMsisdn() != null ? Long.toString(invocation.getMsisdn()) : "");
receivedSms.setOperator("SIMULATOR");
receivedSms.setContent(executionForm.getMessage());
receivedSms.setSubject(executionForm.getMmsSubject());
if (executionForm.getFile() != null && executionForm.getFile().getFileSize() > 0) {
try {
receivedSms.setAttachment(new SerialBlob(executionForm.getFile().getFileData()));
receivedSms.setAttachmentContentType(executionForm.getFile().getContentType());
receivedSms.setAttachmentName(executionForm.getFile().getFileName());
} catch (Exception e) {
LOGGER.error("Creating blob from uploaded file faild.", e);
throw new BugException("Creating blob from uploaded file faild.", e);
}
}
receivedSms.setInvocation(invocation);
SmsDbManager smsMgr = new SmsDbManager(locale, session);
smsMgr.writeIncomingMessageLog(receivedSms);
eventParameters = new SmsEventParameters(locale, session, user, invocation, receivedSms);
InteractionLog log = new InteractionLog();
eventParameters.updateInteractionLog(log);
log.setOperation(InteractionLogManager.EVENT_SMS_SIMULATED);
log.setParameter(executionForm.getMessage());
interactionLogManager.writeInteractionLog(log);
interactionLogManager.writeInteractionLog(log);
EventVariables eventVariables = new EventVariables(eventParameters);
MacroCommand macroCommand = new MacroCommand(eventParameters,eventVariables, commandEntries);
Result result = macroCommand.execute();