use of com.twinsoft.convertigo.engine.Context in project convertigo by convertigo.
the class GenericRequester method handleParameter.
protected void handleParameter(Context context, String parameterName, String parameterValue) {
// This gives the required context name
if (parameterName.equals(Parameter.Context.getName())) {
Engine.logContext.debug("Required context: " + parameterValue);
// This parameter is not handled here
} else // Parameter for removing namespaces
if (parameterName.equals(Parameter.RemoveNamespaces.getName())) {
Engine.logContext.debug("Namespaces removal required");
context.removeNamespaces = true;
} else // This means "Async mode"
if (parameterName.equals(Parameter.Async.getName())) {
context.isAsync = (parameterValue.equalsIgnoreCase("true") || parameterValue.equalsIgnoreCase("1")) ? true : false;
if (context.isAsync)
Engine.logContext.debug("The transaction will be or is being processed asynchroneously.");
} else // This is the overridden sequence
if (parameterName.equals(Parameter.Sequence.getName())) {
if ((parameterValue != null) && (!parameterValue.equals(""))) {
if (!parameterValue.equals(context.sequenceName)) {
// context.isNewSession = true;
context.sequenceName = parameterValue;
Engine.logContext.debug("The sequence is overridden to \"" + context.sequenceName + "\".");
}
}
} else // This is the overridden connector
if (parameterName.equals(Parameter.Connector.getName())) {
if ((parameterValue != null) && (!parameterValue.equals(""))) {
context.connectorName = parameterValue;
Engine.logContext.debug("The connector is overridden to \"" + context.connectorName + "\".");
}
} else // This is the overridden transaction
if (parameterName.equals(Parameter.Transaction.getName())) {
if ((parameterValue != null) && (!parameterValue.equals(""))) {
context.transactionName = parameterValue;
Engine.logContext.debug("The transaction is overridden to \"" + context.transactionName + "\".");
}
} else // This is the overridden service code
if (parameterName.equals(Parameter.CariocaService.getName())) {
if ((context.tasServiceCode == null) || (!context.tasServiceCode.equalsIgnoreCase(parameterValue))) {
Engine.logContext.debug("Service code differs from previous one; requiring new session");
context.isNewSession = true;
context.tasServiceCode = parameterValue;
Engine.logContext.debug("The service code is overidden to \"" + parameterValue + "\".");
}
} else // This is the key given by a Carioca request
if (parameterName.equals(Parameter.CariocaSesskey.getName())) {
if ((parameterValue != null) && (parameterValue.length() > 0)) {
context.tasSessionKey = parameterValue;
Engine.logContext.debug("The Carioca key is \"" + parameterValue + "\".");
// given key must be verified
context.tasSessionKeyVerified = false;
}
} else // Carioca trusted request
if (parameterName.equals(Parameter.Carioca.getName())) {
if ((parameterValue != null) && (parameterValue.length() > 0)) {
context.isTrustedRequest = (parameterValue.equalsIgnoreCase("true") ? true : false);
Engine.logContext.debug("Is Carioca trusted request: " + parameterValue);
}
} else // This is the Carioca user name
if (parameterName.equals(Parameter.CariocaUser.getName())) {
if ((parameterValue != null) && (parameterValue.length() > 0)) {
context.tasUserName = parameterValue;
Engine.logContext.debug("The Carioca user name is \"" + parameterValue + "\".");
}
} else // This is the Carioca user password
if (parameterName.equals(Parameter.CariocaPassword.getName())) {
if ((parameterValue != null) && (parameterValue.length() > 0)) {
context.tasUserPassword = parameterValue;
Engine.logContext.debug("The Carioca user password is \"" + parameterValue + "\".");
}
} else // VIC trusted request
if (parameterName.equals(Parameter.Vic.getName())) {
if ((parameterValue != null) && (parameterValue.length() > 0)) {
context.isTrustedRequest = (parameterValue.equalsIgnoreCase("true") ? true : false);
Engine.logContext.debug("Is VIC trusted request: " + parameterValue);
}
} else // This is the VIC user name
if (parameterName.equals(Parameter.VicUser.getName())) {
if ((parameterValue != null) && (parameterValue.length() > 0)) {
context.tasUserName = parameterValue;
Engine.logContext.debug("The VIC user name is \"" + parameterValue + "\".");
context.isRequestFromVic = true;
}
} else // This is the VIC group
if (parameterName.equals(Parameter.VicGroup.getName())) {
if ((parameterValue != null) && (parameterValue.length() > 0)) {
int index = parameterValue.indexOf('@');
if (index == -1) {
context.tasUserGroup = parameterValue;
context.tasVirtualServerName = "";
} else {
context.tasUserGroup = parameterValue.substring(0, index);
context.tasVirtualServerName = parameterValue.substring(index + 1);
}
Engine.logContext.debug("The VIC group is \"" + context.tasUserGroup + "\".");
Engine.logContext.debug("The VIC virtual server is \"" + context.tasVirtualServerName + "\".");
}
context.isRequestFromVic = true;
} else // This is the VIC service code
if (parameterName.equals(Parameter.VicServiceCode.getName())) {
if ((parameterValue != null) && (parameterValue.length() > 0)) {
Engine.logContext.debug("Vic service code differs from previous one; requiring new session");
context.isNewSession = true;
context.tasServiceCode = parameterValue;
Engine.logContext.debug("The VIC service code is \"" + parameterValue + "\".");
}
context.isRequestFromVic = true;
} else // This is the VIC dte address
if (parameterName.equals(Parameter.VicDteAddress.getName())) {
if ((parameterValue != null) && (parameterValue.length() > 0)) {
context.tasDteAddress = parameterValue;
Engine.logContext.debug("The VIC dte address is \"" + parameterValue + "\".");
}
context.isRequestFromVic = true;
} else // This is the VIC comm device
if (parameterName.equals(Parameter.VicCommDevice.getName())) {
if ((parameterValue != null) && (parameterValue.length() > 0)) {
context.tasCommDevice = parameterValue;
Engine.logContext.debug("The VIC comm device is \"" + parameterValue + "\".");
}
context.isRequestFromVic = true;
} else if (parameterName.startsWith(Parameter.NoCache.getName())) {
context.noCache = (parameterValue.equalsIgnoreCase("true") ? true : false);
Engine.logContext.debug("Ignoring cache required: " + parameterValue);
} else if (parameterName.startsWith(Parameter.MotherSequenceContext.getName())) {
String motherContextID = parameterValue;
Context parentContext = Engine.theApp.contextManager.get(motherContextID);
if (parentContext != null) {
if (context.httpSession == null) {
context.httpSession = parentContext.httpSession;
}
if (context.httpServletRequest == null) {
context.httpServletRequest = parentContext.httpServletRequest;
}
context.userAgent = parentContext.userAgent;
context.remoteAddr = parentContext.remoteAddr;
context.remoteHost = parentContext.remoteHost;
context.parentContext = parentContext;
Engine.logContext.debug("Setting mother sequence context: " + parameterValue);
}
} else if (parameterName.startsWith(Parameter.SequenceInheritedTransactionContext.getName())) {
String inheritedContextName = parameterValue;
if (inheritedContextName != null) {
if (inheritedContextName.equals(""))
context.remove("inheritedContext");
else {
context.set("inheritedContext", inheritedContextName);
Engine.logContext.debug("Setting inherited transaction context: " + parameterValue);
}
}
} else // This is the overidden transaction
if (parameterName.equals(Parameter.Lang.getName())) {
if (parameterValue != null) {
context.lang = parameterValue;
Engine.logContext.debug("The translation language requested is \"" + context.lang + "\".");
}
} else // This is the overidden of cache lifetime
if (parameterName.equals(Parameter.ResponseExpiryDate.getName())) {
if (parameterValue != null) {
context.set(Parameter.ResponseExpiryDate.getName(), parameterValue);
}
} else // This is a stub's value
if (parameterName.equals(Parameter.Stub.getName())) {
if (parameterValue != null && Boolean.parseBoolean(parameterValue)) {
context.isStubRequested = true;
}
} else // This is the user reference
if (parameterName.equals(Parameter.UserReference.getName())) {
if (parameterValue != null) {
context.userReference = parameterValue;
Engine.logContext.info("User reference = '" + parameterValue + "'");
}
} else // This is the user UI id
if (parameterName.equals(Parameter.UIid.getName())) {
if (parameterValue != null && context.httpSession != null) {
context.httpSession.setAttribute(Parameter.UIid.name(), parameterValue);
Engine.logContext.info("User UI id = '" + parameterValue + "'");
}
} else // This is the Device UUID
if (parameterName.equals(Parameter.DeviceUUID.getName())) {
if (parameterValue != null) {
context.httpSession.setAttribute(Parameter.DeviceUUID.name(), parameterValue);
Engine.logContext.info("User device UUID = '" + parameterValue + "'");
}
}
}
use of com.twinsoft.convertigo.engine.Context in project convertigo by convertigo.
the class Sequence method abort.
// TODO: see how to synchronize if context.arbortRequestable() is used trough
// javascript under parallel steps
@Override
public void abort() {
if (isRunning()) {
if (Engine.logBeans.isDebugEnabled())
Engine.logBeans.debug("Sequence '" + getName() + "' is aborting...");
// Sets abort flag
arborting = true;
// Abort children's contexts
if (this.useSameJSessionForSteps()) {
try {
Collection<Context> contexts = Engine.theApp.contextManager.getContexts();
for (Context ctx : contexts) {
if (ctx.parentContext == context) {
ctx.abortRequestable();
}
// if (!this.context.equals(ctx)) {
// if (ctx.contextID.startsWith(getSessionId())) {
// ctx.abortRequestable();
// }
// }
}
} catch (Exception e) {
}
} else {
String contextName;
for (int i = 0; i < stepContextNames.size(); i++) {
contextName = (String) stepContextNames.get(i);
Context ctx = Engine.theApp.contextManager.getContextByName(contextName);
if (ctx != null) {
try {
if (Engine.logBeans.isDebugEnabled())
Engine.logBeans.debug("(Sequence) Aborting requestable for context (" + contextName + ") " + ctx.contextID);
ctx.abortRequestable();
} catch (Exception e) {
}
}
}
}
}
}
use of com.twinsoft.convertigo.engine.Context in project convertigo by convertigo.
the class Url method isMatching0.
@Override
protected boolean isMatching0(Connector connector) {
try {
Context context = connector.context;
String referer = ((HtmlConnector) connector).getHtmlParser().getReferer(context);
Matcher regex_matcher = getRegexPattern().matcher(referer);
return regex_matcher.find();
} catch (Exception e) {
}
return false;
}
use of com.twinsoft.convertigo.engine.Context in project convertigo by convertigo.
the class SequenceEditorPart method getStudioContext.
private Context getStudioContext(boolean bForce) {
String projectName = sequence.getParent().getName();
String sequenceName = sequence.getName();
String contextType = ContextManager.CONTEXT_TYPE_SEQUENCE;
String contextID = Engine.theApp.contextManager.computeStudioContextName(contextType, projectName, sequenceName);
Context ctx = Engine.theApp.contextManager.get(contextID);
if ((ctx == null) || bForce) {
ctx = new Context(contextID);
ctx.cleanXpathApi();
ctx.contextID = contextID;
ctx.name = contextID;
ctx.projectName = projectName;
ctx.sequenceName = sequenceName;
ctx.requestedObject = sequence;
//
ctx.requestedObject.context = ctx;
ctx.lastAccessTime = System.currentTimeMillis();
Engine.theApp.contextManager.add(ctx);
}
return ctx;
}
use of com.twinsoft.convertigo.engine.Context in project convertigo by convertigo.
the class GenericServlet method removeContext.
protected void removeContext(HttpServletRequest request) {
if (Engine.isEngineMode()) {
Context context = (Context) request.getAttribute("convertigo.context");
if (context != null) {
Engine.logContext.debug("[GenericServlet] End of context " + context.contextID + " (" + context + ") required => removing context");
Engine.theApp.contextManager.remove(context);
}
}
request.removeAttribute("convertigo.context");
}
Aggregations