use of com.twinsoft.convertigo.beans.transactions.HtmlTransaction in project convertigo by convertigo.
the class HtmlConnector method checkForStateless.
public void checkForStateless() {
boolean trStateLess = false;
boolean trStateFull = false;
for (Transaction transaction : getTransactionsList()) {
HtmlTransaction htmlTransaction = (HtmlTransaction) transaction;
if (htmlTransaction.isStateFull())
trStateFull = true;
else
trStateLess = true;
}
if (trStateFull && !trStateLess)
Engine.logBeans.warn("(HtmlConnector) Connector '" + getName() + "' must define at least one stateless transaction!");
}
use of com.twinsoft.convertigo.beans.transactions.HtmlTransaction in project convertigo by convertigo.
the class GetAttachmentStatement method execute.
@Override
public boolean execute(Context javascriptContext, Scriptable scope) throws EngineException {
if (isEnabled()) {
if (super.execute(javascriptContext, scope)) {
HtmlTransaction htmlTransaction = (HtmlTransaction) getParentTransaction();
HtmlConnector htmlConnector = (HtmlConnector) htmlTransaction.getParent();
evaluate(javascriptContext, scope, filename, "LogStatement", true);
String evaluated_filename = (evaluated != null && !(evaluated instanceof org.mozilla.javascript.Undefined)) ? evaluated.toString() : "";
boolean ret = htmlConnector.getHtmlParser().getAttachment(htmlTransaction.context, getPolicy(), evaluated_filename, timeout, threshold);
if (ret == false) {
// TODO: must be false, but do loop
return true;
}
return true;
}
}
return false;
}
use of com.twinsoft.convertigo.beans.transactions.HtmlTransaction in project convertigo by convertigo.
the class NavigationBarStatement method execute.
@Override
public boolean execute(Context javascriptContext, Scriptable scope) throws EngineException {
if (isEnabled()) {
if (super.execute(javascriptContext, scope)) {
HtmlTransaction htmlTransaction = (HtmlTransaction) getParentTransaction();
HtmlConnector htmlConnector = (HtmlConnector) htmlTransaction.getParent();
NavigationBarEvent evt;
if (action.equalsIgnoreCase(NavigationBarEvent.ACTION_GOTO)) {
evaluate(javascriptContext, scope, jsUrl, "jsUrl", false);
String url = evaluated.toString();
evt = new NavigationBarEvent(action, url);
} else {
evt = new NavigationBarEvent(action);
}
HtmlParser htmlParser = htmlConnector.getHtmlParser();
boolean success = htmlParser.dispatchEvent(evt, htmlTransaction.context, trigger.getTrigger());
if (!success)
Engine.logBeans.debug("NavigationBarStatement has failed");
success = true;
return success;
}
}
return false;
}
use of com.twinsoft.convertigo.beans.transactions.HtmlTransaction in project convertigo by convertigo.
the class HtmlConnectorDesignComposite method modelChanged.
public void modelChanged(HttpProxyEvent event) {
if (!checkProxySource(event)) {
return;
}
String requestString = event.getRequest();
String responseString = event.getResponse();
boolean https = event.isHttps();
int status = Integer.parseInt(event.getStatus());
// do not record client redirection
if ((status == HttpStatus.SC_MOVED_TEMPORARILY) || (status == HttpStatus.SC_MOVED_PERMANENTLY) || (status == HttpStatus.SC_SEE_OTHER) || (status == HttpStatus.SC_TEMPORARY_REDIRECT)) {
return;
}
/*if (requestString.indexOf(getServer()) == -1) {
return;
}*/
Map<String, String> headers = parseResponseString(responseString);
String contentType = headers.get(HeaderName.ContentType.value().toLowerCase());
// record only text/html or null Content-Type ...
if (contentType == null) {
return;
}
if (MimeType.Html.is(contentType) && MimeType.Plain.is(contentType)) {
return;
}
ConvertigoPlugin.logDebug2("(HtmlConnectorDesignComposite) Learning statement...");
try {
String url, method, handlerName, transactionName, statementName, scHandlerName;
String normalizedScreenClassName, screenClassName;
HtmlTransaction htmlTransaction = null;
HTTPStatement httpStatement = null;
HtmlScreenClass htmlScreenClass = null;
HandlerStatement handlerStatement = null;
ScHandlerStatement scHandlerStatement = null;
// Document dom = null;
// Log log = null;
int size, index1;
boolean bContinue;
index1 = 0;
bContinue = true;
normalizedScreenClassName = "Unknown";
htmlTransaction = (HtmlTransaction) htmlConnector.getLearningTransaction();
synchronized (htmlConnector) {
// dom = htmlConnector.getCurrentXmlDocument();
htmlScreenClass = htmlConnector.getCurrentScreenClass();
}
screenClassName = htmlScreenClass.getName();
normalizedScreenClassName = StringUtils.normalize(htmlScreenClass.getName());
ConvertigoPlugin.logDebug2("(HtmlConnectorDesignComposite) current screen class is '" + screenClassName + "'");
if (htmlTransaction != null) {
transactionName = htmlTransaction.getName();
ConvertigoPlugin.logDebug2("(HtmlConnectorDesignComposite) creating new HTTPStatement");
ConvertigoPlugin.logDebug2(requestString);
httpStatement = parseRequestString(requestString);
httpStatement.setHttps(https);
httpStatement.setPort(https ? 443 : 80);
method = httpStatement.getMethod().toLowerCase();
// size = httpStatement.getVariablesDefinitionSize();
size = httpStatement.numberOfVariables();
url = httpStatement.getUrl(htmlConnector.isHttps(), htmlConnector.getServer(), htmlConnector.getPort());
while (bContinue) {
statementName = method + ((index1 == 0) ? " " : " " + index1) + " (" + url + " - " + size + ")";
statementName = StringUtils.normalize(statementName);
httpStatement.setName(statementName);
httpStatement.hasChanged = true;
httpStatement.bNew = true;
if (htmlScreenClass == null) {
try {
httpStatement.priority = 0;
htmlTransaction.addStatement(httpStatement);
ConvertigoPlugin.logDebug2("(HtmlConnectorDesignComposite) added new HTTPStatement to default transaction '" + transactionName + "'");
fireObjectChanged(new CompositeEvent(htmlTransaction));
Engine.theApp.fireObjectDetected(new EngineEvent(httpStatement));
bContinue = false;
} catch (ObjectWithSameNameException owsne) {
index1++;
}
} else {
if (htmlConnector.isAccumulating())
handlerName = "on" + normalizedScreenClassName + "Exit";
else
handlerName = "on" + normalizedScreenClassName + "Entry";
handlerStatement = htmlTransaction.getHandlerStatement(handlerName);
if (handlerStatement != null) {
try {
handlerStatement.addStatement(httpStatement);
ConvertigoPlugin.logDebug2("(HtmlConnectorDesignComposite) added new HTTPStatement to handler '" + handlerName + "' of transaction '" + transactionName + "'");
fireObjectChanged(new CompositeEvent(handlerStatement));
Engine.theApp.fireObjectDetected(new EngineEvent(httpStatement));
bContinue = false;
} catch (ObjectWithSameNameException owsne) {
index1++;
}
} else {
try {
if (htmlConnector.isAccumulating())
scHandlerStatement = new ScExitHandlerStatement(normalizedScreenClassName);
else
scHandlerStatement = new ScEntryHandlerStatement(normalizedScreenClassName);
scHandlerName = scHandlerStatement.getName();
scHandlerStatement.setName(scHandlerName);
scHandlerStatement.hasChanged = true;
scHandlerStatement.bNew = true;
scHandlerStatement.priority = 0;
htmlTransaction.addStatement(scHandlerStatement);
ConvertigoPlugin.logDebug2("(HtmlConnectorDesignComposite) added new ScExitHandlerStatement '" + handlerName + "' of transaction '" + transactionName + "'");
try {
scHandlerStatement.addStatement(httpStatement);
ConvertigoPlugin.logDebug2("(HtmlConnectorDesignComposite) added new HTTPStatement '" + statementName + "' to ScExitHandlerStatement '" + handlerName + "'");
fireObjectChanged(new CompositeEvent(htmlTransaction));
Engine.theApp.fireObjectDetected(new EngineEvent(httpStatement));
bContinue = false;
} catch (ObjectWithSameNameException owsne) {
index1++;
}
}// Should not append
catch (ObjectWithSameNameException owsne) {
throw new EngineException(owsne.getMessage());
}
}
}
}
} else {
throw new EngineException("Found none learning transaction");
}
} catch (EngineException e) {
ConvertigoPlugin.logException(e, "An exception occured while learning");
}
}
use of com.twinsoft.convertigo.beans.transactions.HtmlTransaction in project convertigo by convertigo.
the class HtmlConnectorDesignComposite method stopLearn.
protected void stopLearn() {
if (!htmlConnector.isLearning()) {
return;
}
// remove current composite view from HTTP proxy listeners
getWebViewer().removeHttpProxyEventListener(this);
HtmlTransaction htmlTransaction = (HtmlTransaction) htmlConnector.getLearningTransaction();
htmlTransaction.setCurrentXmlDocument(null);
// unset learning flag
htmlConnector.markAsLearning(false);
ConvertigoPlugin.logDebug2("(HtmlConnector) stop learning transaction named '" + htmlTransaction.getName() + "'");
try {
htmlTransaction.markAsLearning(false);
} catch (EngineException e) {
}
if (toolLearn.isEnabled()) {
toolLearn.setEnabled(false);
}
if (toolLearn.getSelection()) {
toolLearn.setSelection(false);
}
}
Aggregations