diff --git a/designer/src/main/java/org/restcomm/connect/rvd/interpreter/Interpreter.java b/designer/src/main/java/org/restcomm/connect/rvd/interpreter/Interpreter.java index cb8171c..09a5f7c 100644 --- a/designer/src/main/java/org/restcomm/connect/rvd/interpreter/Interpreter.java +++ b/designer/src/main/java/org/restcomm/connect/rvd/interpreter/Interpreter.java @@ -44,7 +44,6 @@ import org.restcomm.connect.rvd.storage.FsProjectStorage; import org.restcomm.connect.rvd.storage.WorkspaceStorage; import org.restcomm.connect.rvd.storage.exceptions.StorageException; -import org.restcomm.connect.rvd.utils.RvdUtils; import com.google.gson.Gson; import com.google.gson.GsonBuilder; @@ -72,6 +71,7 @@ public class Interpreter { private Map variables = new HashMap(); private List nodeNames; + private RcmlResponse rcmlResult; public static RcmlResponse rcmlOnException() { RcmlResponse response = new RcmlResponse(); @@ -132,20 +132,7 @@ public void setVariables(Map variables) { this.variables = variables; } - - public Target getTarget() { - return target; - } - - - public void setTarget(Target target) { - this.target = target; - } - - public RcmlResponse interpret() throws RvdException { - RcmlResponse response = null; - ProjectOptions projectOptions = FsProjectStorage.loadProjectOptions(appName, workspaceStorage); //rvdContext.getRuntimeProjectOptions(); nodeNames = projectOptions.getNodeNames(); @@ -163,11 +150,10 @@ public RcmlResponse interpret() throws RvdException { //processRequestHeaders(httpRequest); //handleStickyParameters(); // create local copies of sticky_* parameters - response = interpret(targetParam, null, null, null); - return response; + dispatch(targetParam); + return rcmlResult; } - public MultivaluedMap getRequestParams() { return requestParams; } @@ -176,71 +162,78 @@ public String getContextPath() { return contextPath; } - public RcmlResponse interpret(String targetParam, RcmlResponse rcmlModel, Step prependStep, Target originTarget ) throws InterpreterException, StorageException { + public void dispatch(String targetParam) throws StorageException, InterpreterException { if (RvdLoggers.local.isTraceEnabled()) RvdLoggers.local.log(Level.TRACE, LoggingHelper.buildMessage(getClass(),"interpret", loggingContext.getPrefix(), "starting interpeter for " + targetParam)); if ( projectSettings.getLogging() ) projectLogger.log("Running target: " + targetParam).tag("app",appName).done(); - target = Interpreter.parseTarget(targetParam); + target = Interpreter.parseTarget(targetParam); // TODO - target can be made local variable (?) + if (target.action != null) { + // Event handling + loadStep(target.stepname, target.getNodename()).handleAction(this, target.getNodename()); + } else { + interpret(target.getNodename(),null,null,null); + } + } + + /** + * Interprets module moduleName. If startingStepName is provided, interpretation will start from there. In case there is a 'prependStep' + * it will render it first. originModuleName is the invoking module. + * + * @param moduleName - not null + * @param startingStepName + * @param prependStep + * @param originModuleName - can be null + * @throws StorageException + * @throws InterpreterException + */ + public void interpret(String moduleName, String startingStepName, Step prependStep, String originModuleName) throws StorageException, InterpreterException { + // make sure there is a valid RcmlResponse object. We will definitely return an block. + if ( this.rcmlResult == null ) + this.rcmlResult = new RcmlResponse(); // if we are switching modules, remove module-scoped variables - if ( originTarget != null && ! RvdUtils.safeEquals(target.getNodename(), originTarget.getNodename() ) ) { + if (originModuleName != null && ! originModuleName.equals(moduleName) ) clearModuleVariables(); + // load steps for this module + List nodeStepnames = FsProjectStorage.loadNodeStepnames(appName, moduleName, workspaceStorage); + // if no starting step has been specified in the target, use the first step of the node as default + if (startingStepName == null && !nodeStepnames.isEmpty()) + startingStepName = nodeStepnames.get(0); + // Prepend step if required. Usually used for error messages + if ( prependStep != null ) { + RcmlStep rcmlStep = prependStep.render(this, moduleName ); + if(RvdLoggers.local.isTraceEnabled()) + RvdLoggers.local.log(Level.TRACE,LoggingHelper.buildMessage(getClass(),"interpret", "Prepending say step: " + rcmlStep )); + this.rcmlResult.steps.add( rcmlStep ); } + boolean startstep_found = false; + for (String stepname : nodeStepnames) { - // TODO make sure all the required components of the target are available here - - if (target.action != null) { - // Event handling - loadStep(target.stepname).handleAction(this, target); - } else { - // RCML Generation - if (rcmlModel == null ) - rcmlModel = new RcmlResponse(); - List nodeStepnames = FsProjectStorage.loadNodeStepnames(appName, target.getNodename(), workspaceStorage); - - // if no starting step has been specified in the target, use the first step of the node as default - if (target.getStepname() == null && !nodeStepnames.isEmpty()) - target.setStepname(nodeStepnames.get(0)); - - // Prepend step if required. Usually used for error messages - if ( prependStep != null ) { - RcmlStep rcmlStep = prependStep.render(this); - if(RvdLoggers.local.isTraceEnabled()) - RvdLoggers.local.log(Level.TRACE,LoggingHelper.buildMessage(getClass(),"interpret", "Prepending say step: " + rcmlStep )); - rcmlModel.steps.add( rcmlStep ); - } + if (stepname.equals(startingStepName)) + startstep_found = true; - boolean startstep_found = false; - for (String stepname : nodeStepnames) { - - if (stepname.equals(target.getStepname())) - startstep_found = true; - - if (startstep_found) { - // we found our starting step. Let's start processing - Step step = loadStep(stepname); - String rerouteTo = step.process(this, httpRequest); // is meaningful only for some of the steps like ExternalService steps - // check if we have to break the currently rendered module - if ( rerouteTo != null ) - return interpret(rerouteTo, rcmlModel, null, target); - // otherwise continue rendering the current module - RcmlStep rcmlStep = step.render(this); - if ( rcmlStep != null) - rcmlModel.steps.add(rcmlStep); + if (startstep_found) { + // we found our starting step. Let's start processing + Step step = loadStep(stepname, moduleName); + String rerouteTo = step.process(this, httpRequest); // is meaningful only for some of the steps like ExternalService steps + // check if we have to break the currently rendered module + if ( rerouteTo != null ) { + interpret(rerouteTo, null, null, moduleName); + return; } + // otherwise continue rendering the current module + RcmlStep rcmlStep = step.render(this, moduleName); + if ( rcmlStep != null) + this.rcmlResult.steps.add(rcmlStep); } - - //rcmlResult = xstream.toXML(rcmlModel); } - - //return rcmlResult; // this is in case of an error - return rcmlModel; } - private Step loadStep(String stepname) throws StorageException { - String stepfile_json = FsProjectStorage.loadStep(appName, target.getNodename(), stepname, workspaceStorage); + + private Step loadStep(String stepname, String moduleName) throws StorageException { + String stepfile_json = FsProjectStorage.loadStep(appName, moduleName, stepname, workspaceStorage); Step step = gson.fromJson(stepfile_json, Step.class); return step; diff --git a/designer/src/main/java/org/restcomm/connect/rvd/interpreter/serialization/RcmlSerializer.java b/designer/src/main/java/org/restcomm/connect/rvd/interpreter/serialization/RcmlSerializer.java index e1edc43..fd6bcdf 100644 --- a/designer/src/main/java/org/restcomm/connect/rvd/interpreter/serialization/RcmlSerializer.java +++ b/designer/src/main/java/org/restcomm/connect/rvd/interpreter/serialization/RcmlSerializer.java @@ -122,6 +122,9 @@ public RcmlSerializer() { } public String serialize(RcmlResponse rcmlResponse) { - return xstream.toXML(rcmlResponse); + if (rcmlResponse == null) + return null; + else + return xstream.toXML(rcmlResponse); } } diff --git a/designer/src/main/java/org/restcomm/connect/rvd/model/project/Step.java b/designer/src/main/java/org/restcomm/connect/rvd/model/project/Step.java index 4e31c03..2486c96 100644 --- a/designer/src/main/java/org/restcomm/connect/rvd/model/project/Step.java +++ b/designer/src/main/java/org/restcomm/connect/rvd/model/project/Step.java @@ -4,7 +4,6 @@ import org.restcomm.connect.rvd.exceptions.InterpreterException; import org.restcomm.connect.rvd.interpreter.Interpreter; -import org.restcomm.connect.rvd.interpreter.Target; import org.restcomm.connect.rvd.interpreter.exceptions.RVDUnsupportedHandlerVerb; import org.restcomm.connect.rvd.jsonvalidation.ValidationErrorItem; import org.restcomm.connect.rvd.model.rcml.RcmlStep; @@ -51,9 +50,9 @@ public void setName(String name) { this.name = name; } - public abstract RcmlStep render(Interpreter interpreter) throws InterpreterException; + public abstract RcmlStep render(Interpreter interpreter, String containerModule) throws InterpreterException; - public void handleAction(Interpreter interpreter, Target originTarget) throws InterpreterException, StorageException { + public void handleAction(Interpreter interpreter, String handlerModule) throws InterpreterException, StorageException { throw new RVDUnsupportedHandlerVerb(); } diff --git a/designer/src/main/java/org/restcomm/connect/rvd/model/steps/control/ControlStep.java b/designer/src/main/java/org/restcomm/connect/rvd/model/steps/control/ControlStep.java index 9c72e6a..b7eebbb 100644 --- a/designer/src/main/java/org/restcomm/connect/rvd/model/steps/control/ControlStep.java +++ b/designer/src/main/java/org/restcomm/connect/rvd/model/steps/control/ControlStep.java @@ -46,7 +46,7 @@ public class ControlStep extends Step { @Override - public RcmlStep render(Interpreter interpreter) throws InterpreterException { + public RcmlStep render(Interpreter interpreter, String containerModule) throws InterpreterException { return null; } diff --git a/designer/src/main/java/org/restcomm/connect/rvd/model/steps/dial/DialStep.java b/designer/src/main/java/org/restcomm/connect/rvd/model/steps/dial/DialStep.java index 9720feb..9a2389c 100644 --- a/designer/src/main/java/org/restcomm/connect/rvd/model/steps/dial/DialStep.java +++ b/designer/src/main/java/org/restcomm/connect/rvd/model/steps/dial/DialStep.java @@ -13,7 +13,6 @@ import org.restcomm.connect.rvd.utils.RvdUtils; import org.restcomm.connect.rvd.exceptions.InterpreterException; import org.restcomm.connect.rvd.interpreter.Interpreter; -import org.restcomm.connect.rvd.interpreter.Target; import org.restcomm.connect.rvd.model.project.Step; import org.restcomm.connect.rvd.storage.exceptions.StorageException; @@ -28,7 +27,7 @@ public class DialStep extends Step { private String nextModule; private Boolean record; - public RcmlDialStep render(Interpreter interpreter) throws InterpreterException { + public RcmlDialStep render(Interpreter interpreter, String containerModule) throws InterpreterException { RcmlDialStep rcmlStep = new RcmlDialStep(); for ( DialNoun noun: dialNouns ) { @@ -36,7 +35,7 @@ public RcmlDialStep render(Interpreter interpreter) throws InterpreterException } if ( ! RvdUtils.isEmpty(nextModule) ) { - String newtarget = interpreter.getTarget().getNodename() + "." + getName() + ".actionhandler"; + String newtarget = containerModule + "." + getName() + ".actionhandler"; Map pairs = new HashMap(); pairs.put("target", newtarget); String action = interpreter.buildAction(pairs); @@ -53,7 +52,7 @@ public RcmlDialStep render(Interpreter interpreter) throws InterpreterException } @Override - public void handleAction(Interpreter interpreter, Target originTarget) throws InterpreterException, StorageException { + public void handleAction(Interpreter interpreter, String handlerModule) throws InterpreterException, StorageException { LoggingContext logging = interpreter.getLoggingContext(); if (RvdLoggers.local.isEnabledFor(Level.INFO)) RvdLoggers.local.log(Level.INFO, LoggingHelper.buildMessage(getClass(),"handleAction", logging.getPrefix(), "handling dial action")); @@ -91,7 +90,7 @@ public void handleAction(Interpreter interpreter, Target originTarget) throws In if ( DialRingDuration != null ) interpreter.getVariables().put(RvdConfiguration.CORE_VARIABLE_PREFIX + "DialRingDuration", DialRingDuration); - interpreter.interpret( nextModule, null, null, originTarget ); + interpreter.interpret( nextModule, null, null, handlerModule); } } diff --git a/designer/src/main/java/org/restcomm/connect/rvd/model/steps/email/EmailStep.java b/designer/src/main/java/org/restcomm/connect/rvd/model/steps/email/EmailStep.java index d4a97c7..f297fa7 100644 --- a/designer/src/main/java/org/restcomm/connect/rvd/model/steps/email/EmailStep.java +++ b/designer/src/main/java/org/restcomm/connect/rvd/model/steps/email/EmailStep.java @@ -3,7 +3,6 @@ import org.restcomm.connect.rvd.RvdConfiguration; import org.restcomm.connect.rvd.exceptions.InterpreterException; import org.restcomm.connect.rvd.interpreter.Interpreter; -import org.restcomm.connect.rvd.interpreter.Target; import org.restcomm.connect.rvd.logging.system.LoggingContext; import org.restcomm.connect.rvd.logging.system.LoggingHelper; import org.restcomm.connect.rvd.logging.system.RvdLoggers; @@ -85,11 +84,11 @@ public void setText(String text) { this.text = text; } - public RcmlEmailStep render(Interpreter interpreter) { + public RcmlEmailStep render(Interpreter interpreter, String containerModule) { RcmlEmailStep rcmlStep = new RcmlEmailStep(); if ( ! RvdUtils.isEmpty(getNext()) ) { - String newtarget = interpreter.getTarget().getNodename() + "." + getName() + ".actionhandler"; + String newtarget = containerModule + "." + getName() + ".actionhandler"; Map pairs = new HashMap(); pairs.put("target", newtarget); String action = interpreter.buildAction(pairs); @@ -109,7 +108,7 @@ public RcmlEmailStep render(Interpreter interpreter) { } @Override - public void handleAction(Interpreter interpreter, Target originTarget) throws InterpreterException, StorageException { + public void handleAction(Interpreter interpreter, String handlerModule) throws InterpreterException, StorageException { LoggingContext logging = interpreter.getLoggingContext(); if (RvdLoggers.local.isEnabledFor(Level.INFO)) RvdLoggers.local.log(Level.INFO, LoggingHelper.buildMessage(getClass(),"handleAction", logging.getPrefix(), "handling email action")); @@ -125,7 +124,7 @@ public void handleAction(Interpreter interpreter, Target originTarget) throws In if (EmailStatus != null ) interpreter.getVariables().put(RvdConfiguration.CORE_VARIABLE_PREFIX + "EmailStatus", EmailStatus); - interpreter.interpret( getNext(), null, null, originTarget ); + interpreter.interpret( getNext(), null, null, handlerModule); } } \ No newline at end of file diff --git a/designer/src/main/java/org/restcomm/connect/rvd/model/steps/es/ExternalServiceStep.java b/designer/src/main/java/org/restcomm/connect/rvd/model/steps/es/ExternalServiceStep.java index f9ae166..4753b37 100644 --- a/designer/src/main/java/org/restcomm/connect/rvd/model/steps/es/ExternalServiceStep.java +++ b/designer/src/main/java/org/restcomm/connect/rvd/model/steps/es/ExternalServiceStep.java @@ -184,7 +184,7 @@ public Integer getTimeout() { } @Override - public RcmlStep render(Interpreter interpreter) throws InterpreterException { + public RcmlStep render(Interpreter interpreter, String containerModule) throws InterpreterException { // TODO Auto-generated method stub return null; } diff --git a/designer/src/main/java/org/restcomm/connect/rvd/model/steps/fax/FaxStep.java b/designer/src/main/java/org/restcomm/connect/rvd/model/steps/fax/FaxStep.java index 3ed7ea3..219e67b 100644 --- a/designer/src/main/java/org/restcomm/connect/rvd/model/steps/fax/FaxStep.java +++ b/designer/src/main/java/org/restcomm/connect/rvd/model/steps/fax/FaxStep.java @@ -11,7 +11,6 @@ import org.restcomm.connect.rvd.utils.RvdUtils; import org.restcomm.connect.rvd.exceptions.InterpreterException; import org.restcomm.connect.rvd.interpreter.Interpreter; -import org.restcomm.connect.rvd.interpreter.Target; import org.restcomm.connect.rvd.model.project.Step; import org.restcomm.connect.rvd.storage.exceptions.StorageException; @@ -60,11 +59,11 @@ public void setStatusCallback(String statusCallback) { this.statusCallback = statusCallback; } - public RcmlFaxStep render(Interpreter interpreter) { + public RcmlFaxStep render(Interpreter interpreter, String containerModule) { RcmlFaxStep rcmlStep = new RcmlFaxStep(); if ( ! RvdUtils.isEmpty(getNext()) ) { - String newtarget = interpreter.getTarget().getNodename() + "." + getName() + ".actionhandler"; + String newtarget = containerModule + "." + getName() + ".actionhandler"; Map pairs = new HashMap(); pairs.put("target", newtarget); String action = interpreter.buildAction(pairs); @@ -81,7 +80,7 @@ public RcmlFaxStep render(Interpreter interpreter) { } @Override - public void handleAction(Interpreter interpreter, Target originTarget) throws InterpreterException, StorageException { + public void handleAction(Interpreter interpreter, String handlerModule) throws InterpreterException, StorageException { LoggingContext logging = interpreter.getLoggingContext(); if (RvdLoggers.local.isEnabledFor(Level.INFO)) RvdLoggers.local.log(Level.INFO, LoggingHelper.buildMessage(getClass(),"handleAction", logging.getPrefix(), "handling fax action")); @@ -97,6 +96,6 @@ public void handleAction(Interpreter interpreter, Target originTarget) throws In if (FaxStatus != null ) interpreter.getVariables().put(RvdConfiguration.CORE_VARIABLE_PREFIX + "FaxStatus", FaxStatus); - interpreter.interpret( getNext(), null, null, originTarget ); + interpreter.interpret( getNext(), null, null, handlerModule); } } diff --git a/designer/src/main/java/org/restcomm/connect/rvd/model/steps/gather/GatherStep.java b/designer/src/main/java/org/restcomm/connect/rvd/model/steps/gather/GatherStep.java index af089bb..160bd14 100644 --- a/designer/src/main/java/org/restcomm/connect/rvd/model/steps/gather/GatherStep.java +++ b/designer/src/main/java/org/restcomm/connect/rvd/model/steps/gather/GatherStep.java @@ -24,7 +24,6 @@ import org.restcomm.connect.rvd.RvdConfiguration; import org.restcomm.connect.rvd.exceptions.InterpreterException; import org.restcomm.connect.rvd.interpreter.Interpreter; -import org.restcomm.connect.rvd.interpreter.Target; import org.restcomm.connect.rvd.logging.system.LoggingContext; import org.restcomm.connect.rvd.logging.system.LoggingHelper; import org.restcomm.connect.rvd.logging.system.RvdLoggers; @@ -133,10 +132,10 @@ public final class Validation { private String regexPattern; } - public RcmlGatherStep render(Interpreter interpreter) throws InterpreterException { + public RcmlGatherStep render(Interpreter interpreter, String containerModule) throws InterpreterException { RcmlGatherStep rcmlStep = new RcmlGatherStep(); - String newtarget = interpreter.getTarget().getNodename() + "." + getName() + ".handle"; + String newtarget = containerModule + "." + getName() + ".handle"; Map pairs = new HashMap(); pairs.put("target", newtarget); String action = interpreter.buildAction(pairs); @@ -158,12 +157,12 @@ public RcmlGatherStep render(Interpreter interpreter) throws InterpreterExceptio } for (Step nestedStep : steps) - rcmlStep.getSteps().add(nestedStep.render(interpreter)); + rcmlStep.getSteps().add(nestedStep.render(interpreter, containerModule)); return rcmlStep; } - private boolean handleMapping(Interpreter interpreter, Target originTarget, String key, List mappings, boolean isPattern) throws StorageException, InterpreterException { + private boolean handleMapping(Interpreter interpreter, String originModule, String key, List mappings, boolean isPattern) throws StorageException, InterpreterException { LoggingContext logging = interpreter.getLoggingContext(); if (mappings != null) { for (Mapping mapping : mappings) { @@ -177,7 +176,7 @@ private boolean handleMapping(Interpreter interpreter, Target originTarget, Stri // seems we found out menu selection if (RvdLoggers.local.isTraceEnabled()) RvdLoggers.local.log(Level.TRACE, LoggingHelper.buildMessage(getClass(), "handleAction", logging.getPrefix(), " seems we found our menu selection: " + key)); - interpreter.interpret(mapping.getNext(), null, null, originTarget); + interpreter.interpret(mapping.getNext(), null, null, originModule); return true; } } @@ -229,7 +228,7 @@ private boolean isMatchesPattern(String pattern, String value, final LoggingCont return !StringUtils.isEmpty(value) && value.matches(pattern); } - private boolean handleCollect(final Interpreter interpreter, Target originTarget, final Collectdigits collect, String newValue, Validation validation) throws StorageException, InterpreterException { + private boolean handleCollect(final Interpreter interpreter, String originModule, final Collectdigits collect, String newValue, Validation validation) throws StorageException, InterpreterException { LoggingContext logging = interpreter.getLoggingContext(); String effectivePattern = getPattern(interpreter, validation); String variableName = collect.collectVariable; @@ -242,7 +241,7 @@ private boolean handleCollect(final Interpreter interpreter, Target originTarget // validation if (effectivePattern == null || isMatchesPattern(effectivePattern, variableValue, logging)) { putVariable(interpreter, collect, variableName, variableValue); - interpreter.interpret(collect.next, null, null, originTarget); + interpreter.interpret(collect.next, null, null, originModule); return true; } else { if (RvdLoggers.local.isTraceEnabled()) @@ -251,7 +250,7 @@ private boolean handleCollect(final Interpreter interpreter, Target originTarget } } - public void handleAction(Interpreter interpreter, Target originTarget) throws InterpreterException, StorageException { + public void handleAction(Interpreter interpreter, String handlerModule) throws InterpreterException, StorageException { LoggingContext logging = interpreter.getLoggingContext(); if (RvdLoggers.local.isEnabledFor(Level.INFO)) RvdLoggers.local.log(Level.INFO, LoggingHelper.buildMessage(getClass(), "handleAction", logging.getPrefix(), "handling gather action")); @@ -273,7 +272,7 @@ public void handleAction(Interpreter interpreter, Target originTarget) throws In if ("menu".equals(gatherType)) { switch (inputTypeE) { case DTMF: - isValid = handleMapping(interpreter, originTarget, digitsString, menu.mappings, false); + isValid = handleMapping(interpreter, handlerModule, digitsString, menu.mappings, false); actualInputType = InputType.DTMF; break; case SPEECH: @@ -282,19 +281,19 @@ public void handleAction(Interpreter interpreter, Target originTarget) throws In return; } if (!StringUtils.isEmpty(speechResultString)) { - isValid = handleMapping(interpreter, originTarget, speechResultString, menu.speechMappings, true); + isValid = handleMapping(interpreter, handlerModule, speechResultString, menu.speechMappings, true); } actualInputType = InputType.SPEECH; break; case DTMF_SPEECH: if (!StringUtils.isEmpty(digitsString)) { - isValid = handleMapping(interpreter, originTarget, digitsString, menu.mappings, false); + isValid = handleMapping(interpreter, handlerModule, digitsString, menu.mappings, false); actualInputType = InputType.DTMF; } else if (!StringUtils.isEmpty(unstableSpeechString)) { //UnstableSpeechResult is not used for now return; }else if (!StringUtils.isEmpty(speechResultString)) { - isValid = handleMapping(interpreter, originTarget, speechResultString, menu.speechMappings, true); + isValid = handleMapping(interpreter, handlerModule, speechResultString, menu.speechMappings, true); actualInputType = InputType.SPEECH; } else { actualInputType = InputType.DTMF; // use this by default @@ -305,7 +304,7 @@ public void handleAction(Interpreter interpreter, Target originTarget) throws In } else if ("collectdigits".equals(gatherType)) { switch (inputTypeE) { case DTMF: - isValid = handleCollect(interpreter, originTarget, collectdigits, digitsString, validation); + isValid = handleCollect(interpreter, handlerModule, collectdigits, digitsString, validation); actualInputType = InputType.DTMF; break; case SPEECH: @@ -314,19 +313,19 @@ public void handleAction(Interpreter interpreter, Target originTarget) throws In return; } if (!StringUtils.isEmpty(speechResultString)) { - isValid = handleCollect(interpreter, originTarget, collectspeech, speechResultString, speechValidation); + isValid = handleCollect(interpreter, handlerModule, collectspeech, speechResultString, speechValidation); } actualInputType = InputType.SPEECH; break; case DTMF_SPEECH: if (!StringUtils.isEmpty(digitsString)) { - isValid = handleCollect(interpreter, originTarget, collectdigits, digitsString, validation); + isValid = handleCollect(interpreter, handlerModule, collectdigits, digitsString, validation); actualInputType = InputType.DTMF; } else if (!StringUtils.isEmpty(unstableSpeechString)) { //UnstableSpeechResult is not used for now return; } else if (!StringUtils.isEmpty(speechResultString)) { - isValid = handleCollect(interpreter, originTarget, collectspeech, speechResultString, speechValidation); + isValid = handleCollect(interpreter, handlerModule, collectspeech, speechResultString, speechValidation); actualInputType = InputType.SPEECH; } else { actualInputType = InputType.DTMF; // use this by default @@ -338,7 +337,7 @@ public void handleAction(Interpreter interpreter, Target originTarget) throws In if (!isValid) { // this should always be true Step invalidMessage = getInvalidMessage(actualInputType); - interpreter.interpret(interpreter.getTarget().getNodename() + "." + interpreter.getTarget().getStepname(), null, (invalidMessage != null) ? invalidMessage : null, originTarget); + interpreter.interpret(handlerModule, this.getName(), (invalidMessage != null) ? invalidMessage : null, handlerModule); } } diff --git a/designer/src/main/java/org/restcomm/connect/rvd/model/steps/hangup/HungupStep.java b/designer/src/main/java/org/restcomm/connect/rvd/model/steps/hangup/HungupStep.java index 2a38285..df7ddd2 100644 --- a/designer/src/main/java/org/restcomm/connect/rvd/model/steps/hangup/HungupStep.java +++ b/designer/src/main/java/org/restcomm/connect/rvd/model/steps/hangup/HungupStep.java @@ -8,7 +8,7 @@ public class HungupStep extends Step { @Override - public RcmlStep render(Interpreter interpreter) throws InterpreterException { + public RcmlStep render(Interpreter interpreter, String containerModule) throws InterpreterException { return new RcmlHungupStep(); } diff --git a/designer/src/main/java/org/restcomm/connect/rvd/model/steps/log/LogStep.java b/designer/src/main/java/org/restcomm/connect/rvd/model/steps/log/LogStep.java index 8c9aa4f..821a0b8 100644 --- a/designer/src/main/java/org/restcomm/connect/rvd/model/steps/log/LogStep.java +++ b/designer/src/main/java/org/restcomm/connect/rvd/model/steps/log/LogStep.java @@ -31,7 +31,7 @@ public class LogStep extends Step { private String message; @Override - public RcmlStep render(Interpreter interpreter) throws InterpreterException { + public RcmlStep render(Interpreter interpreter, String containerModule) throws InterpreterException { // TODO Auto-generated method stub return null; } diff --git a/designer/src/main/java/org/restcomm/connect/rvd/model/steps/pause/PauseStep.java b/designer/src/main/java/org/restcomm/connect/rvd/model/steps/pause/PauseStep.java index e70310e..78f7d10 100644 --- a/designer/src/main/java/org/restcomm/connect/rvd/model/steps/pause/PauseStep.java +++ b/designer/src/main/java/org/restcomm/connect/rvd/model/steps/pause/PauseStep.java @@ -13,7 +13,7 @@ public Integer getLength() { public void setLength(Integer length) { this.length = length; } - public RcmlPauseStep render(Interpreter interpreter) { + public RcmlPauseStep render(Interpreter interpreter, String containerModule) { RcmlPauseStep rcmlStep = new RcmlPauseStep(); if ( getLength() != null ) rcmlStep.setLength(getLength()); diff --git a/designer/src/main/java/org/restcomm/connect/rvd/model/steps/play/PlayStep.java b/designer/src/main/java/org/restcomm/connect/rvd/model/steps/play/PlayStep.java index aa383f7..04aeb23 100644 --- a/designer/src/main/java/org/restcomm/connect/rvd/model/steps/play/PlayStep.java +++ b/designer/src/main/java/org/restcomm/connect/rvd/model/steps/play/PlayStep.java @@ -45,7 +45,7 @@ public final class Remote { @Override - public RcmlStep render(Interpreter interpreter) { + public RcmlStep render(Interpreter interpreter, String containerModule) { LoggingContext logging = interpreter.getLoggingContext(); RcmlPlayStep playStep = new RcmlPlayStep(); String url = ""; diff --git a/designer/src/main/java/org/restcomm/connect/rvd/model/steps/record/RecordStep.java b/designer/src/main/java/org/restcomm/connect/rvd/model/steps/record/RecordStep.java index 273f655..1724872 100644 --- a/designer/src/main/java/org/restcomm/connect/rvd/model/steps/record/RecordStep.java +++ b/designer/src/main/java/org/restcomm/connect/rvd/model/steps/record/RecordStep.java @@ -31,7 +31,6 @@ import org.restcomm.connect.rvd.utils.RvdUtils; import org.restcomm.connect.rvd.exceptions.InterpreterException; import org.restcomm.connect.rvd.interpreter.Interpreter; -import org.restcomm.connect.rvd.interpreter.Target; import org.restcomm.connect.rvd.model.project.Step; import org.restcomm.connect.rvd.storage.exceptions.StorageException; @@ -103,11 +102,11 @@ public String getMedia() { return media; } - public RcmlRecordStep render(Interpreter interpreter) { + public RcmlRecordStep render(Interpreter interpreter, String containerModule) { RcmlRecordStep rcmlStep = new RcmlRecordStep(); if ( ! RvdUtils.isEmpty(getNext()) ) { - String newtarget = interpreter.getTarget().getNodename() + "." + getName() + ".actionhandler"; + String newtarget = containerModule + "." + getName() + ".actionhandler"; Map pairs = new HashMap(); pairs.put("target", newtarget); String action = interpreter.buildAction(pairs); @@ -129,7 +128,7 @@ public RcmlRecordStep render(Interpreter interpreter) { } @Override - public void handleAction(Interpreter interpreter, Target originTarget) throws InterpreterException, StorageException { + public void handleAction(Interpreter interpreter, String handlerModule) throws InterpreterException, StorageException { LoggingContext logging = interpreter.getLoggingContext(); if (RvdLoggers.local.isEnabledFor(Level.INFO)) RvdLoggers.local.log(Level.INFO, LoggingHelper.buildMessage(getClass(),"handleAction", logging.getPrefix(), "handling record action")); @@ -161,6 +160,6 @@ public void handleAction(Interpreter interpreter, Target originTarget) throws In if (Digits != null ) interpreter.getVariables().put(RvdConfiguration.CORE_VARIABLE_PREFIX + "Digits", Digits); - interpreter.interpret( getNext(), null, null, originTarget ); + interpreter.interpret( getNext(), null, null, handlerModule); } } diff --git a/designer/src/main/java/org/restcomm/connect/rvd/model/steps/redirect/RedirectStep.java b/designer/src/main/java/org/restcomm/connect/rvd/model/steps/redirect/RedirectStep.java index 29b4bbf..9b8deb0 100644 --- a/designer/src/main/java/org/restcomm/connect/rvd/model/steps/redirect/RedirectStep.java +++ b/designer/src/main/java/org/restcomm/connect/rvd/model/steps/redirect/RedirectStep.java @@ -21,7 +21,7 @@ public void setMethod(String method) { this.method = method; } - public RcmlRedirectStep render(Interpreter interpreter ) { + public RcmlRedirectStep render(Interpreter interpreter, String containerModule) { RcmlRedirectStep rcmlStep = new RcmlRedirectStep(); rcmlStep.setUrl(interpreter.populateVariables(getUrl())); if ( getMethod() != null && !"".equals(getMethod()) ) diff --git a/designer/src/main/java/org/restcomm/connect/rvd/model/steps/reject/RejectStep.java b/designer/src/main/java/org/restcomm/connect/rvd/model/steps/reject/RejectStep.java index 1b5c844..c12ba40 100644 --- a/designer/src/main/java/org/restcomm/connect/rvd/model/steps/reject/RejectStep.java +++ b/designer/src/main/java/org/restcomm/connect/rvd/model/steps/reject/RejectStep.java @@ -13,7 +13,7 @@ public String getReason() { public void setReason(String reason) { this.reason = reason; } - public RcmlRejectStep render(Interpreter interpreter) { + public RcmlRejectStep render(Interpreter interpreter, String containerModule) { RcmlRejectStep rcmlStep = new RcmlRejectStep(); if ( getReason() != null && !"".equals(getReason())) rcmlStep.setReason(getReason()); diff --git a/designer/src/main/java/org/restcomm/connect/rvd/model/steps/say/SayStep.java b/designer/src/main/java/org/restcomm/connect/rvd/model/steps/say/SayStep.java index f6289bd..2a8338e 100644 --- a/designer/src/main/java/org/restcomm/connect/rvd/model/steps/say/SayStep.java +++ b/designer/src/main/java/org/restcomm/connect/rvd/model/steps/say/SayStep.java @@ -54,7 +54,7 @@ public void setLoop(Integer loop) { this.loop = loop; } - public RcmlStep render(Interpreter interpreter) { + public RcmlStep render(Interpreter interpreter, String containerModule) { RcmlSayStep sayStep = new RcmlSayStep(); sayStep.setPhrase(interpreter.populateVariables(getPhrase())); diff --git a/designer/src/main/java/org/restcomm/connect/rvd/model/steps/sms/SmsStep.java b/designer/src/main/java/org/restcomm/connect/rvd/model/steps/sms/SmsStep.java index e37d67c..7b56ba7 100644 --- a/designer/src/main/java/org/restcomm/connect/rvd/model/steps/sms/SmsStep.java +++ b/designer/src/main/java/org/restcomm/connect/rvd/model/steps/sms/SmsStep.java @@ -30,7 +30,6 @@ import org.restcomm.connect.rvd.utils.RvdUtils; import org.restcomm.connect.rvd.exceptions.InterpreterException; import org.restcomm.connect.rvd.interpreter.Interpreter; -import org.restcomm.connect.rvd.interpreter.Target; import org.restcomm.connect.rvd.model.project.Step; import org.restcomm.connect.rvd.storage.exceptions.StorageException; @@ -92,11 +91,11 @@ public String getStatusCallback() { public void setStatusCallback(String statusCallback) { this.statusCallback = statusCallback; } - public RcmlSmsStep render(Interpreter interpreter) { + public RcmlSmsStep render(Interpreter interpreter, String containerModule) { RcmlSmsStep rcmlStep = new RcmlSmsStep(); if ( ! RvdUtils.isEmpty(getNext()) ) { - String newtarget = interpreter.getTarget().getNodename() + "." + getName() + ".actionhandler"; + String newtarget = containerModule + "." + getName() + ".actionhandler"; Map pairs = new HashMap(); pairs.put("target", newtarget); String action = interpreter.buildAction(pairs); @@ -113,7 +112,7 @@ public RcmlSmsStep render(Interpreter interpreter) { } @Override - public void handleAction(Interpreter interpreter, Target originTarget) throws InterpreterException, StorageException { + public void handleAction(Interpreter interpreter, String handlerModule) throws InterpreterException, StorageException { LoggingContext logging = interpreter.getLoggingContext(); if (RvdLoggers.local.isEnabledFor(Level.INFO)) RvdLoggers.local.log(Level.INFO, LoggingHelper.buildMessage(getClass(),"handleAction", logging.getPrefix(), "handling sms action")); @@ -129,6 +128,6 @@ public void handleAction(Interpreter interpreter, Target originTarget) throws In if (SmsStatus != null ) interpreter.getVariables().put(RvdConfiguration.CORE_VARIABLE_PREFIX + "SmsStatus", SmsStatus); - interpreter.interpret( getNext(), null, null, originTarget ); + interpreter.interpret( getNext(), null, null, handlerModule); } } diff --git a/designer/src/main/java/org/restcomm/connect/rvd/model/steps/ussdcollect/UssdCollectStep.java b/designer/src/main/java/org/restcomm/connect/rvd/model/steps/ussdcollect/UssdCollectStep.java index c7342e7..2aa7a0f 100644 --- a/designer/src/main/java/org/restcomm/connect/rvd/model/steps/ussdcollect/UssdCollectStep.java +++ b/designer/src/main/java/org/restcomm/connect/rvd/model/steps/ussdcollect/UssdCollectStep.java @@ -27,7 +27,6 @@ import org.restcomm.connect.rvd.RvdConfiguration; import org.restcomm.connect.rvd.exceptions.InterpreterException; import org.restcomm.connect.rvd.interpreter.Interpreter; -import org.restcomm.connect.rvd.interpreter.Target; import org.restcomm.connect.rvd.logging.system.LoggingContext; import org.restcomm.connect.rvd.logging.system.LoggingHelper; import org.restcomm.connect.rvd.logging.system.RvdLoggers; @@ -65,23 +64,23 @@ public UssdCollectStep() { } @Override - public UssdCollectRcml render(Interpreter interpreter) throws InterpreterException { + public UssdCollectRcml render(Interpreter interpreter, String containerModule) throws InterpreterException { // TODO Auto-generated method stub UssdCollectRcml rcml = new UssdCollectRcml(); - String newtarget = interpreter.getTarget().getNodename() + "." + getName() + ".handle"; + String newtarget = containerModule + "." + getName() + ".handle"; Map pairs = new HashMap(); pairs.put("target", newtarget); rcml.action = interpreter.buildAction(pairs); for ( UssdSayStep message : messages ) { - rcml.messages.add(message.render(interpreter)); + rcml.messages.add(message.render(interpreter, containerModule )); } return rcml; } @Override - public void handleAction(Interpreter interpreter, Target originTarget) throws InterpreterException, StorageException { + public void handleAction(Interpreter interpreter, String handlerModule) throws InterpreterException, StorageException { LoggingContext logging = interpreter.getLoggingContext(); if (RvdLoggers.local.isEnabledFor(Level.INFO)) RvdLoggers.local.log(Level.INFO, LoggingHelper.buildMessage(getClass(),"handleAction", logging.getPrefix(), "handling UssdCollect action")); @@ -100,12 +99,12 @@ public void handleAction(Interpreter interpreter, Target originTarget) throws In // seems we found out menu selection if (RvdLoggers.local.isTraceEnabled()) RvdLoggers.local.log(Level.TRACE, LoggingHelper.buildMessage(getClass(),"handleAction","{0} seems we found our menu selection", new Object[] {logging.getPrefix(), digits})); - interpreter.interpret(mapping.next,null,null, originTarget); + interpreter.interpret(mapping.next,null,null, handlerModule); handled = true; } } if (!handled) { - interpreter.interpret(interpreter.getTarget().getNodename() + "." + interpreter.getTarget().getStepname(),null,null, originTarget); + interpreter.interpret(handlerModule,this.getName(),null, handlerModule); } } if ("collectdigits".equals(gatherType)) { @@ -124,7 +123,7 @@ public void handleAction(Interpreter interpreter, Target originTarget) throws In // in any case initialize the module-scoped variable interpreter.getVariables().put(variableName, variableValue); - interpreter.interpret(collectdigits.next,null,null, originTarget); + interpreter.interpret(collectdigits.next,null,null, handlerModule); } } } diff --git a/designer/src/main/java/org/restcomm/connect/rvd/model/steps/ussdlanguage/UssdLanguageStep.java b/designer/src/main/java/org/restcomm/connect/rvd/model/steps/ussdlanguage/UssdLanguageStep.java index 9fea849..15ea4ba 100644 --- a/designer/src/main/java/org/restcomm/connect/rvd/model/steps/ussdlanguage/UssdLanguageStep.java +++ b/designer/src/main/java/org/restcomm/connect/rvd/model/steps/ussdlanguage/UssdLanguageStep.java @@ -35,7 +35,7 @@ public UssdLanguageStep() { } @Override - public UssdLanguageRcml render(Interpreter interpreter) throws InterpreterException { + public UssdLanguageRcml render(Interpreter interpreter, String containerModule) throws InterpreterException { UssdLanguageRcml rcml = new UssdLanguageRcml(); rcml.language = language; return rcml; diff --git a/designer/src/main/java/org/restcomm/connect/rvd/model/steps/ussdsay/UssdSayStep.java b/designer/src/main/java/org/restcomm/connect/rvd/model/steps/ussdsay/UssdSayStep.java index b168a67..e3b366e 100644 --- a/designer/src/main/java/org/restcomm/connect/rvd/model/steps/ussdsay/UssdSayStep.java +++ b/designer/src/main/java/org/restcomm/connect/rvd/model/steps/ussdsay/UssdSayStep.java @@ -56,7 +56,7 @@ public void setText(String text) { } @Override - public UssdSayRcml render(Interpreter interpreter) throws InterpreterException { + public UssdSayRcml render(Interpreter interpreter, String containerModule) throws InterpreterException { UssdSayRcml rcmlModel = new UssdSayRcml(); rcmlModel.text = interpreter.populateVariables(getText());