Search in sources :

Example 16 with HtmlTransaction

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!");
}
Also used : HtmlTransaction(com.twinsoft.convertigo.beans.transactions.HtmlTransaction) Transaction(com.twinsoft.convertigo.beans.core.Transaction) HtmlTransaction(com.twinsoft.convertigo.beans.transactions.HtmlTransaction)

Example 17 with HtmlTransaction

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;
}
Also used : HtmlConnector(com.twinsoft.convertigo.beans.connectors.HtmlConnector) HtmlTransaction(com.twinsoft.convertigo.beans.transactions.HtmlTransaction)

Example 18 with HtmlTransaction

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;
}
Also used : HtmlParser(com.twinsoft.convertigo.engine.parsers.HtmlParser) HtmlConnector(com.twinsoft.convertigo.beans.connectors.HtmlConnector) NavigationBarEvent(com.twinsoft.convertigo.engine.parsers.events.NavigationBarEvent) HtmlTransaction(com.twinsoft.convertigo.beans.transactions.HtmlTransaction)

Example 19 with HtmlTransaction

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");
    }
}
Also used : HtmlTransaction(com.twinsoft.convertigo.beans.transactions.HtmlTransaction) EngineException(com.twinsoft.convertigo.engine.EngineException) ScEntryHandlerStatement(com.twinsoft.convertigo.beans.statements.ScEntryHandlerStatement) ScExitHandlerStatement(com.twinsoft.convertigo.beans.statements.ScExitHandlerStatement) ScHandlerStatement(com.twinsoft.convertigo.beans.statements.ScHandlerStatement) HandlerStatement(com.twinsoft.convertigo.beans.statements.HandlerStatement) HTTPStatement(com.twinsoft.convertigo.beans.statements.HTTPStatement) ScExitHandlerStatement(com.twinsoft.convertigo.beans.statements.ScExitHandlerStatement) ObjectWithSameNameException(com.twinsoft.convertigo.engine.ObjectWithSameNameException) ScEntryHandlerStatement(com.twinsoft.convertigo.beans.statements.ScEntryHandlerStatement) EngineEvent(com.twinsoft.convertigo.engine.EngineEvent) HtmlScreenClass(com.twinsoft.convertigo.beans.screenclasses.HtmlScreenClass) CompositeEvent(com.twinsoft.convertigo.eclipse.editors.CompositeEvent) ScHandlerStatement(com.twinsoft.convertigo.beans.statements.ScHandlerStatement)

Example 20 with HtmlTransaction

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);
    }
}
Also used : HtmlTransaction(com.twinsoft.convertigo.beans.transactions.HtmlTransaction) EngineException(com.twinsoft.convertigo.engine.EngineException)

Aggregations

HtmlTransaction (com.twinsoft.convertigo.beans.transactions.HtmlTransaction)28 HtmlConnector (com.twinsoft.convertigo.beans.connectors.HtmlConnector)14 EngineException (com.twinsoft.convertigo.engine.EngineException)13 Transaction (com.twinsoft.convertigo.beans.core.Transaction)11 Statement (com.twinsoft.convertigo.beans.core.Statement)10 Connector (com.twinsoft.convertigo.beans.core.Connector)8 JavelinConnector (com.twinsoft.convertigo.beans.connectors.JavelinConnector)6 SiteClipperConnector (com.twinsoft.convertigo.beans.connectors.SiteClipperConnector)6 SqlConnector (com.twinsoft.convertigo.beans.connectors.SqlConnector)6 DatabaseObject (com.twinsoft.convertigo.beans.core.DatabaseObject)6 ScreenClass (com.twinsoft.convertigo.beans.core.ScreenClass)6 Sequence (com.twinsoft.convertigo.beans.core.Sequence)6 Step (com.twinsoft.convertigo.beans.core.Step)6 TreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TreeObject)6 CicsConnector (com.twinsoft.convertigo.beans.connectors.CicsConnector)5 HttpConnector (com.twinsoft.convertigo.beans.connectors.HttpConnector)5 JavelinScreenClass (com.twinsoft.convertigo.beans.screenclasses.JavelinScreenClass)5 HTTPStatement (com.twinsoft.convertigo.beans.statements.HTTPStatement)5 JavelinTransaction (com.twinsoft.convertigo.beans.transactions.JavelinTransaction)5 ScHandlerStatement (com.twinsoft.convertigo.beans.statements.ScHandlerStatement)4