Search in sources :

Example 61 with EngineException

use of com.twinsoft.convertigo.engine.EngineException in project convertigo by convertigo.

the class PropertyTableTreeObject method read.

public static Object read(Node node) throws EngineException {
    String classname = null;
    XMLVector<Object> xmlv = null;
    try {
        if (node.getNodeType() == Node.ELEMENT_NODE) {
            Element element = (Element) node;
            classname = element.getAttribute("classname");
            xmlv = new XMLVector<Object>();
        }
    } catch (Exception e) {
        String message = "Unable to set the object properties from the serialized XML data.\n" + "Object class: '" + classname;
        EngineException ee = new EngineException(message, e);
        throw ee;
    }
    if (xmlv != null)
        return new PropertyData(PropertyTableTreeObject.class, xmlv);
    return null;
}
Also used : PropertyData(com.twinsoft.convertigo.eclipse.views.projectexplorer.PropertyData) Element(org.w3c.dom.Element) EngineException(com.twinsoft.convertigo.engine.EngineException) DatabaseObject(com.twinsoft.convertigo.beans.core.DatabaseObject) EngineException(com.twinsoft.convertigo.engine.EngineException)

Example 62 with EngineException

use of com.twinsoft.convertigo.engine.EngineException in project convertigo by convertigo.

the class VariableTreeObject2 method handlesBeanNameChanged.

protected void handlesBeanNameChanged(TreeObjectEvent treeObjectEvent) {
    DatabaseObjectTreeObject treeObject = (DatabaseObjectTreeObject) treeObjectEvent.getSource();
    DatabaseObject databaseObject = (DatabaseObject) treeObject.getObject();
    Object oldValue = treeObjectEvent.oldValue;
    Object newValue = treeObjectEvent.newValue;
    int update = treeObjectEvent.update;
    // Updates variables references
    if (update != TreeObjectEvent.UPDATE_NONE) {
        boolean isLocalProject = false;
        boolean isSameValue = false;
        boolean shouldUpdate = false;
        try {
            if (getObject() instanceof Variable) {
                Variable variable = (Variable) getObject();
                if (databaseObject instanceof RequestableVariable) {
                    isLocalProject = variable.getProject().equals(databaseObject.getProject());
                    isSameValue = variable.getName().equals(oldValue);
                    shouldUpdate = (update == TreeObjectEvent.UPDATE_ALL) || ((update == TreeObjectEvent.UPDATE_LOCAL) && (isLocalProject));
                    // Verify if parent of databaseObject is a transaction
                    if (databaseObject.getParent() instanceof Transaction) {
                        Transaction transaction = (Transaction) databaseObject.getParent();
                        // Case of rename for Call Transaction
                        if (variable.getParent() instanceof TransactionStep) {
                            TransactionStep transactionStep = (TransactionStep) variable.getParent();
                            if (transactionStep.getSourceTransaction().equals(transaction.getProject() + "." + transaction.getConnector() + "." + transaction.getName())) {
                                updateNameReference(isSameValue, shouldUpdate, variable, newValue);
                            }
                        }
                        /*
							 * propagation to testCases of variable renaming in a transaction
							 */
                        if (variable.getParent() instanceof TransactionWithVariables) {
                            propagateVariableRename(true, true, treeObjectEvent, ((TransactionWithVariables) transaction).getTestCasesList(), transaction.getName());
                        }
                    }
                    // Verify if parent of databaseObject is a sequence
                    if (databaseObject.getParent() instanceof Sequence) {
                        Sequence sequence = (Sequence) databaseObject.getParent();
                        // Case of rename for Call Sequence
                        if (variable.getParent() instanceof SequenceStep) {
                            SequenceStep sequenceStep = (SequenceStep) variable.getParent();
                            if (sequenceStep.getSourceSequence().equals(sequence.getProject() + "." + sequence.getName())) {
                                updateNameReference(isSameValue, shouldUpdate, variable, newValue);
                            }
                        }
                        /*
							 * propagation to testCases of variable renaming in a sequence
							 */
                        if (variable.getParent() instanceof Sequence) {
                            propagateVariableRename(true, true, treeObjectEvent, sequence.getTestCasesList(), sequence.getName());
                        }
                    }
                }
            }
        } catch (EngineException e) {
            ConvertigoPlugin.logException(e, "Unable to rename the variable references of '" + databaseObject.getName() + "'!");
        }
    }
}
Also used : SequenceStep(com.twinsoft.convertigo.beans.steps.SequenceStep) TestCaseVariable(com.twinsoft.convertigo.beans.variables.TestCaseVariable) Variable(com.twinsoft.convertigo.beans.core.Variable) RequestableVariable(com.twinsoft.convertigo.beans.variables.RequestableVariable) EngineException(com.twinsoft.convertigo.engine.EngineException) RequestableVariable(com.twinsoft.convertigo.beans.variables.RequestableVariable) Sequence(com.twinsoft.convertigo.beans.core.Sequence) TransactionStep(com.twinsoft.convertigo.beans.steps.TransactionStep) Transaction(com.twinsoft.convertigo.beans.core.Transaction) DatabaseObject(com.twinsoft.convertigo.beans.core.DatabaseObject) TransactionWithVariables(com.twinsoft.convertigo.beans.core.TransactionWithVariables) DatabaseObject(com.twinsoft.convertigo.beans.core.DatabaseObject)

Example 63 with EngineException

use of com.twinsoft.convertigo.engine.EngineException in project convertigo by convertigo.

the class AbstractRestOperation method addParameter.

@Override
protected void addParameter(UrlMappingParameter parameter) throws EngineException {
    List<UrlMappingParameter> l = getParameterList();
    if (hasBodyParameter) {
        Type type = parameter.getType();
        if (type != Type.Path && type != Type.Header) {
            if (type == Type.Body) {
                throw new EngineException("The REST operation already contains a 'body' parameter");
            } else {
                if (!isChangeTo || (isChangeTo && l.size() != 1)) {
                    throw new EngineException("The REST operation contains a 'body' parameter. You can only add 'header' parameters");
                }
            }
        }
    } else if (parameter.getType() == Type.Body) {
        for (UrlMappingParameter param : l) {
            Type type = param.getType();
            if (type == Type.Query || type == Type.Form) {
                if (!isChangeTo || (isChangeTo && l.size() != 1)) {
                    throw new EngineException("The REST operation contains a '" + type + "' parameter. You can not add a 'body' parameter");
                }
            }
        }
    }
    super.addParameter(parameter);
    if (!hasBodyParameter && parameter.getType() == Type.Body) {
        hasBodyParameter = true;
    }
}
Also used : DataType(com.twinsoft.convertigo.beans.core.UrlMappingParameter.DataType) HttpMethodType(com.twinsoft.convertigo.engine.enums.HttpMethodType) Type(com.twinsoft.convertigo.beans.core.UrlMappingParameter.Type) MimeType(com.twinsoft.convertigo.engine.enums.MimeType) UrlMappingParameter(com.twinsoft.convertigo.beans.core.UrlMappingParameter) EngineException(com.twinsoft.convertigo.engine.EngineException)

Example 64 with EngineException

use of com.twinsoft.convertigo.engine.EngineException in project convertigo by convertigo.

the class BrowserPropertyChangeStatement method configure.

@Override
public void configure(Element element) throws Exception {
    super.configure(element);
    String version = element.getAttribute("version");
    if (version == null) {
        String s = XMLUtils.prettyPrintDOM(element);
        EngineException ee = new EngineException("Unable to find version number for the database object \"" + getName() + "\".\n" + "XML data: " + s);
        throw ee;
    }
    if (VersionUtils.compare(version, "4.4.1") < 0) {
        javascriptMode = bJavascriptChange ? (bJavascriptStat ? JavascriptMode.forceOn : JavascriptMode.forceOff) : JavascriptMode.noChange;
        imageMode = bImageChange ? (bImageStat ? ImageMode.forceOn : ImageMode.forceOff) : ImageMode.noChange;
        pluginMode = bPluginChange ? (bPluginStat ? PluginMode.forceOn : PluginMode.forceOff) : PluginMode.noChange;
        attachmentMode = bAttachmentChange ? (bAttachmentStat ? AttachmentMode.forceOn : AttachmentMode.forceOff) : AttachmentMode.noChange;
        windowOpenMode = bWindowOpenChange ? (bWindowOpenStat ? WindowOpenMode.forceOnSameWindow : WindowOpenMode.forceOff) : WindowOpenMode.noChange;
        hasChanged = true;
        Engine.logBeans.warn("[HttpStatement] The object \"" + getName() + "\" has been updated to version 4.4.1");
    }
}
Also used : EngineException(com.twinsoft.convertigo.engine.EngineException)

Example 65 with EngineException

use of com.twinsoft.convertigo.engine.EngineException in project convertigo by convertigo.

the class CredentialsStatement method execute.

@Override
public boolean execute(Context javascriptContext, Scriptable scope) throws EngineException {
    String _user = null;
    String _password = null;
    if (isEnabled()) {
        if (super.execute(javascriptContext, scope)) {
            if (user != null && user.length() != 0) {
                // evaluate user
                evaluate(javascriptContext, scope, user, "user", true);
                try {
                    _user = evaluated.toString();
                } catch (Exception e) {
                    EngineException ee = new EngineException("Invalid user.\n" + "CredentialsStatement: \"" + getName() + "\"", e);
                    throw ee;
                }
            }
            if (password != null && password.length() != 0) {
                // evaluate password
                evaluate(javascriptContext, scope, password, "password", true);
                try {
                    _password = evaluated.toString();
                } catch (Exception e) {
                    EngineException ee = new EngineException("Invalid password.\n" + "CredentialsStatement: \"" + getName() + "\"", e);
                    throw ee;
                }
            }
            // Set basic credentials on connector
            HtmlConnector htmlConnector = (HtmlConnector) getParentTransaction().getParent();
            htmlConnector.setGivenAuthUser(_user);
            Engine.logBeans.debug("(CredentialsStatement) User '" + _user + "' has been set on http connector.");
            htmlConnector.setGivenAuthPassword(_password);
            Engine.logBeans.debug("(CredentialsStatement) Password '******' has been set on http connector.");
            htmlConnector.getHtmlParser().setCredentials(htmlConnector.context, _user, _password, forceBasic);
            return true;
        }
    }
    return false;
}
Also used : HtmlConnector(com.twinsoft.convertigo.beans.connectors.HtmlConnector) EngineException(com.twinsoft.convertigo.engine.EngineException) EngineException(com.twinsoft.convertigo.engine.EngineException)

Aggregations

EngineException (com.twinsoft.convertigo.engine.EngineException)426 IOException (java.io.IOException)155 File (java.io.File)117 Element (org.w3c.dom.Element)84 NodeList (org.w3c.dom.NodeList)64 DatabaseObject (com.twinsoft.convertigo.beans.core.DatabaseObject)62 Document (org.w3c.dom.Document)43 JSONObject (org.codehaus.jettison.json.JSONObject)41 Node (org.w3c.dom.Node)40 Project (com.twinsoft.convertigo.beans.core.Project)35 ArrayList (java.util.ArrayList)35 JSONException (org.codehaus.jettison.json.JSONException)33 Sequence (com.twinsoft.convertigo.beans.core.Sequence)31 RequestableVariable (com.twinsoft.convertigo.beans.variables.RequestableVariable)29 TreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TreeObject)27 DatabaseObjectTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DatabaseObjectTreeObject)25 Connector (com.twinsoft.convertigo.beans.core.Connector)24 HashMap (java.util.HashMap)23 Transaction (com.twinsoft.convertigo.beans.core.Transaction)21 ObjectWithSameNameException (com.twinsoft.convertigo.engine.ObjectWithSameNameException)20