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;
}
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() + "'!");
}
}
}
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;
}
}
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");
}
}
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;
}
Aggregations