Search in sources :

Example 6 with ConvertigoException

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

the class ClipboardAction method paste.

public void paste(String source, Shell shell, ProjectExplorerView explorerView, TreeObject selectedTreeObject, boolean isDND) throws ConvertigoException, IOException, ParserConfigurationException, SAXException, CoreException {
    if ((explorerView != null) && (selectedTreeObject != null)) {
        TreeObject targetTreeObject = null;
        Object targetObject = null;
        if (selectedTreeObject instanceof FolderTreeObject) {
            if (selectedTreeObject.getParent() instanceof IDesignTreeObject) {
                selectedTreeObject = selectedTreeObject.getParent();
            }
        }
        if (selectedTreeObject instanceof IPropertyTreeObject) {
            targetTreeObject = selectedTreeObject;
            targetObject = selectedTreeObject;
        } else if (selectedTreeObject instanceof IDesignTreeObject) {
            targetTreeObject = selectedTreeObject;
            targetObject = selectedTreeObject;
            if (clipboardManager.objectsType == ProjectExplorerView.TREE_OBJECT_TYPE_DBO_DOCUMENT) {
                targetTreeObject = ((IDesignTreeObject) selectedTreeObject).getTreeObjectOwner();
                targetObject = (DatabaseObject) targetTreeObject.getObject();
            }
        } else {
            // case of folder, retrieve owner object
            targetTreeObject = explorerView.getFirstSelectedDatabaseObjectTreeObject(selectedTreeObject);
            targetObject = (DatabaseObject) targetTreeObject.getObject();
            // i.e. without having to select the parent database object.
            if (clipboardManager.objectsType == ProjectExplorerView.getTreeObjectType(new TreePath(targetTreeObject))) {
                // it must be different from the currently selected object.
                if (clipboardManager.objectsType == ProjectExplorerView.TREE_OBJECT_TYPE_DBO_SCREEN_CLASS) {
                    CustomDialog customDialog = new CustomDialog(shell, "Paste a Screenclass", "Do you want to paste the Screenclass as a sibling or as an inherited ScreenClass?", 500, 150, new ButtonSpec("As a sibling", true), new ButtonSpec("As an iherited", false), new ButtonSpec(IDialogConstants.CANCEL_LABEL, false));
                    int response = customDialog.open();
                    if (response == 0)
                        targetObject = ((DatabaseObject) targetObject).getParent();
                    else if (response == 2)
                        return;
                } else if (clipboardManager.objectsType == ProjectExplorerView.TREE_OBJECT_TYPE_DBO_STATEMENT_WITH_EXPRESSIONS) {
                    if (clipboardManager.objectsType == ProjectExplorerView.TREE_OBJECT_TYPE_FUNCTION) {
                        targetObject = ((DatabaseObject) targetObject).getParent();
                    } else {
                        CustomDialog customDialog = new CustomDialog(shell, "Paste a statement", "Do you want to paste the statement as a sibling or a child statement?", 500, 150, new ButtonSpec("As a sibling", true), new ButtonSpec("As a child", false), new ButtonSpec(IDialogConstants.CANCEL_LABEL, false));
                        int response = customDialog.open();
                        if (response == 0) {
                            targetObject = ((DatabaseObject) targetObject).getParent();
                        } else if (response == 2) {
                            return;
                        }
                    }
                } else if (clipboardManager.objectsType == ProjectExplorerView.TREE_OBJECT_TYPE_DBO_MOBILE_UICOMPONENT) {
                    if (!clipboardManager.isCut) {
                        CustomDialog customDialog = new CustomDialog(shell, "Paste a Component", "Do you want to paste the Component as a sibling or as a child component?", 500, 150, new ButtonSpec("As a sibling", true), new ButtonSpec("As a child", false), new ButtonSpec(IDialogConstants.CANCEL_LABEL, false));
                        int response = customDialog.open();
                        if (response == 0) {
                            targetObject = ((DatabaseObject) targetObject).getParent();
                        } else if (response == 2) {
                            return;
                        }
                    }
                } else if (clipboardManager.objectsType == ProjectExplorerView.TREE_OBJECT_TYPE_DBO_STEP_WITH_EXPRESSIONS || clipboardManager.objectsType == ProjectExplorerView.TREE_OBJECT_TYPE_DBO_STEP) {
                    targetObject = pasteStep(shell, source, (DatabaseObject) targetObject);
                    if (targetObject == null)
                        return;
                } else if (isDND && clipboardManager.objectsType == ProjectExplorerView.TREE_OBJECT_TYPE_DBO_SEQUENCE) {
                // Do not change target to parent
                } else {
                    targetObject = ((DatabaseObject) targetObject).getParent();
                }
                targetTreeObject = explorerView.findTreeObjectByUserObject(((DatabaseObject) targetObject));
            } else {
                if (clipboardManager.objectsType == ProjectExplorerView.TREE_OBJECT_TYPE_DBO_STEP_WITH_EXPRESSIONS || clipboardManager.objectsType == ProjectExplorerView.TREE_OBJECT_TYPE_DBO_STEP) {
                    targetObject = pasteStep(shell, source, (DatabaseObject) targetObject);
                    if (targetObject == null)
                        return;
                }
            }
        }
        if (clipboardManager.isCut) {
            TreeParent targetTreeParent = null;
            String targetPath = targetTreeObject.getPath();
            if (targetTreeObject instanceof DatabaseObjectTreeObject) {
                targetTreeParent = ((DatabaseObjectTreeObject) targetTreeObject).getOwnerDatabaseObjectTreeObject();
            } else if (targetTreeObject instanceof IPropertyTreeObject) {
                targetTreeParent = ((IPropertyTreeObject) targetTreeObject).getTreeObjectOwner();
            } else if (targetTreeObject instanceof IDesignTreeObject) {
                targetTreeParent = ((IDesignTreeObject) targetTreeObject).getTreeObjectOwner();
            }
            for (int i = 0; i < clipboardManager.objects.length; i++) {
                // Cut & paste
                clipboardManager.cutAndPaste(clipboardManager.objects[i], targetTreeObject);
                // Updating the tree
                // Report 4.5: fix #401
                // explorerView.reloadTreeObject(clipboardManager.parentTreeNodeOfCutObjects[i]);
                TreeObject parentTreeNodeOfCutObjects = clipboardManager.parentTreeNodeOfCutObjects[i];
                parentTreeNodeOfCutObjects.getProjectTreeObject().hasBeenModified(true);
                if (!(parentTreeNodeOfCutObjects instanceof IDesignTreeObject)) {
                    explorerView.reloadTreeObject(parentTreeNodeOfCutObjects);
                }
            }
            if (targetTreeObject != null) {
                if (targetTreeObject.getParent() == null)
                    targetTreeObject = explorerView.findTreeObjectByPath(targetTreeParent, targetPath);
                if (targetTreeObject != null)
                    // Report 4.5: fix #401
                    targetTreeObject.getProjectTreeObject().hasBeenModified(true);
            }
            clipboardManager.reset();
        } else if (source != null) {
            // Paste
            clipboardManager.paste(source, targetObject, true);
            // Case of project copy
            if (clipboardManager.objectsType == ProjectExplorerView.TREE_OBJECT_TYPE_DBO_PROJECT) {
                Object[] pastedObjects = clipboardManager.pastedObjects;
                for (int i = 0; i < pastedObjects.length; i++) {
                    Object object = pastedObjects[i];
                    if ((object != null) && (object instanceof Project)) {
                        Project project = (Project) object;
                        String oldName = project.getName();
                        try {
                            Project importedProject = importProjectTempArchive(oldName, explorerView);
                            if (importedProject != null) {
                                String newName = importedProject.getName();
                                explorerView.importProjectTreeObject(newName, true, oldName);
                            } else
                                throw new EngineException("Unable to import project temporary archive");
                        } catch (Exception e) {
                            throw new EngineException("Unable to paste project", e);
                        }
                    }
                }
            }
        }
        // Updating the tree
        if (targetTreeObject != null) {
            TreeObject treeObjectToReload = targetTreeObject;
            TreeObject treeObjectToSelect = targetTreeObject;
            if (targetTreeObject instanceof IPropertyTreeObject) {
                treeObjectToSelect = ((IPropertyTreeObject) targetTreeObject).getTreeObjectOwner();
                treeObjectToReload = treeObjectToSelect;
                if (treeObjectToReload instanceof DatabaseObjectTreeObject) {
                    treeObjectToReload = treeObjectToReload.getParent();
                    if (treeObjectToReload instanceof FolderTreeObject)
                        treeObjectToReload = treeObjectToReload.getParent();
                }
            }
            if (targetTreeObject instanceof IDesignTreeObject) {
                treeObjectToSelect = ((IDesignTreeObject) targetTreeObject).getTreeObjectOwner();
                treeObjectToReload = treeObjectToSelect;
                if (treeObjectToReload instanceof DatabaseObjectTreeObject) {
                    treeObjectToReload = treeObjectToReload.getParent();
                    if (treeObjectToReload instanceof FolderTreeObject)
                        treeObjectToReload = treeObjectToReload.getParent();
                }
            }
            if (treeObjectToReload != null) {
                // explorerView.reloadTreeObject(targetTreeObject);
                // explorerView.setSelectedTreeObject(targetTreeObject);
                explorerView.objectChanged(new CompositeEvent(treeObjectToReload.getObject(), treeObjectToSelect.getPath()));
            }
        }
    }
}
Also used : DatabaseObjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DatabaseObjectTreeObject) IDesignTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.IDesignTreeObject) TreeParent(com.twinsoft.convertigo.eclipse.views.projectexplorer.TreeParent) EngineException(com.twinsoft.convertigo.engine.EngineException) CoreException(org.eclipse.core.runtime.CoreException) ConvertigoException(com.twinsoft.convertigo.engine.ConvertigoException) IOException(java.io.IOException) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) SAXException(org.xml.sax.SAXException) EngineException(com.twinsoft.convertigo.engine.EngineException) Project(com.twinsoft.convertigo.beans.core.Project) TreePath(com.twinsoft.convertigo.eclipse.views.projectexplorer.TreePath) CustomDialog(com.twinsoft.convertigo.eclipse.dialogs.CustomDialog) IPropertyTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.IPropertyTreeObject) TreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TreeObject) DatabaseObjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DatabaseObjectTreeObject) ProjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ProjectTreeObject) IDesignTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.IDesignTreeObject) FolderTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.FolderTreeObject) DatabaseObject(com.twinsoft.convertigo.beans.core.DatabaseObject) IPropertyTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.IPropertyTreeObject) DatabaseObject(com.twinsoft.convertigo.beans.core.DatabaseObject) TreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TreeObject) DatabaseObjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DatabaseObjectTreeObject) ProjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ProjectTreeObject) IDesignTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.IDesignTreeObject) FolderTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.FolderTreeObject) FolderTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.FolderTreeObject) ButtonSpec(com.twinsoft.convertigo.eclipse.dialogs.ButtonSpec) CompositeEvent(com.twinsoft.convertigo.eclipse.editors.CompositeEvent) IPropertyTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.IPropertyTreeObject)

Example 7 with ConvertigoException

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

the class ClipboardManager method cutAndPaste.

public void cutAndPaste(final DatabaseObject object, DatabaseObject parentDatabaseObject) throws ConvertigoException {
    // Verifying if a sheet with the same browser does not already exist
    if (object instanceof Sheet) {
        String browser = ((Sheet) object).getBrowser();
        Sheet sheet = null;
        if (parentDatabaseObject instanceof ScreenClass) {
            sheet = ((ScreenClass) parentDatabaseObject).getLocalSheet(browser);
        } else if (parentDatabaseObject instanceof RequestableObject) {
            sheet = ((RequestableObject) parentDatabaseObject).getSheet(browser);
        }
        if (sheet != null) {
            throw new EngineException("You cannot cut and paste the sheet because a sheet is already defined for the browser \"" + browser + "\" in the screen class \"" + parentDatabaseObject.getName() + "\".");
        }
    }
    if (object instanceof Step) {
        if (object instanceof ThenStep) {
            throw new EngineException("You cannot cut the \"Then\" step");
        }
        if (object instanceof ElseStep) {
            throw new EngineException("You cannot cut the \"Else\" step");
        }
    }
    if (object instanceof Statement) {
        if (object instanceof ThenStatement)
            throw new EngineException("You cannot cut the \"Then\" statement");
        if (object instanceof ElseStatement)
            throw new EngineException("You cannot cut the \"Else\" statement");
    }
    // Verify object is accepted for paste
    if (!DatabaseObjectsManager.acceptDatabaseObjects(parentDatabaseObject, object)) {
        throw new EngineException("You cannot cut and paste to a " + parentDatabaseObject.getClass().getSimpleName() + " a database object of type " + object.getClass().getSimpleName());
    }
    if (parentDatabaseObject instanceof com.twinsoft.convertigo.beans.mobile.components.MobileComponent) {
        if (!com.twinsoft.convertigo.beans.mobile.components.dynamic.ComponentManager.acceptDatabaseObjects(parentDatabaseObject, object)) {
            throw new EngineException("You cannot cut and paste to a " + parentDatabaseObject.getClass().getSimpleName() + " a database object of type " + object.getClass().getSimpleName());
        }
        if (!com.twinsoft.convertigo.beans.mobile.components.dynamic.ComponentManager.isTplCompatible(parentDatabaseObject, object)) {
            String tplVersion = com.twinsoft.convertigo.beans.mobile.components.dynamic.ComponentManager.getTplRequired(object);
            throw new EngineException("Template project " + tplVersion + " compatibility required");
        }
    } else if (parentDatabaseObject instanceof com.twinsoft.convertigo.beans.ngx.components.MobileComponent) {
        if (!com.twinsoft.convertigo.beans.ngx.components.dynamic.ComponentManager.acceptDatabaseObjects(parentDatabaseObject, object)) {
            throw new EngineException("You cannot cut and paste to a " + parentDatabaseObject.getClass().getSimpleName() + " a database object of type " + object.getClass().getSimpleName());
        }
        if (!com.twinsoft.convertigo.beans.ngx.components.dynamic.ComponentManager.isTplCompatible(parentDatabaseObject, object)) {
            String tplVersion = com.twinsoft.convertigo.beans.ngx.components.dynamic.ComponentManager.getTplRequired(object);
            throw new EngineException("Template project " + tplVersion + " compatibility required");
        }
    }
    // Verify if a child object with same name exist
    boolean bContinue = true;
    boolean bIncName = false;
    String dboName = object.getName();
    while (bContinue) {
        try {
            if (bIncName) {
                dboName = DatabaseObject.incrementName(dboName);
                object.setName(dboName);
            }
            new WalkHelper() {

                boolean root = true;

                boolean find = false;

                @Override
                protected boolean before(DatabaseObject databaseObject, Class<? extends DatabaseObject> dboClass) {
                    boolean isInstance = dboClass.isInstance(object);
                    find |= isInstance;
                    return isInstance;
                }

                @Override
                protected void walk(DatabaseObject databaseObject) throws Exception {
                    if (root) {
                        root = false;
                        if (databaseObject instanceof Project) {
                            if (object instanceof Connector && ((Connector) object).isDefault) {
                                throw new EngineException("You cannot cut the default connector to another project");
                            }
                        } else if (databaseObject instanceof Connector) {
                            if (object instanceof ScreenClass) {
                                throw new EngineException("You cannot cut the default screen class to another connector");
                            } else if (object instanceof Transaction && ((Transaction) object).isDefault) {
                                throw new EngineException("You cannot cut the default transaction to another connector");
                            }
                        } else if (databaseObject instanceof ScreenClass) {
                            if (object instanceof Criteria && databaseObject.getParent() instanceof Connector) {
                                throw new EngineException("You cannot cut the criterion of default screen class");
                            }
                        } else if (databaseObject instanceof MobileObject) {
                            if (databaseObject instanceof com.twinsoft.convertigo.beans.mobile.components.ApplicationComponent) {
                                if (object instanceof com.twinsoft.convertigo.beans.mobile.components.PageComponent) {
                                    com.twinsoft.convertigo.beans.mobile.components.PageComponent pc = GenericUtils.cast(object);
                                    if (pc.isRoot) {
                                        throw new EngineException("You cannot cut the root page to another application");
                                    }
                                }
                            } else if (databaseObject instanceof com.twinsoft.convertigo.beans.ngx.components.ApplicationComponent) {
                                if (object instanceof com.twinsoft.convertigo.beans.ngx.components.PageComponent) {
                                    com.twinsoft.convertigo.beans.ngx.components.PageComponent pc = GenericUtils.cast(object);
                                    if (pc.isRoot) {
                                        throw new EngineException("You cannot cut the root page to another application");
                                    }
                                }
                            }
                        }
                        super.walk(databaseObject);
                        if (!find) {
                            throw new EngineException("You cannot cut and paste to a " + databaseObject.getClass().getSimpleName() + " a database object of type " + object.getClass().getSimpleName());
                        }
                    } else {
                        if (object != databaseObject && object.getName().equalsIgnoreCase(databaseObject.getName())) {
                            throw new ObjectWithSameNameException("Unable to cut the object because an object with the same name already exists in target.");
                        }
                    }
                }
            }.init(parentDatabaseObject);
            bContinue = false;
        } catch (ObjectWithSameNameException e) {
            bIncName = true;
        } catch (EngineException e) {
            throw e;
        } catch (Exception e) {
            throw new EngineException("Exception in cutAndPaste", e);
        }
    }
    move(object, parentDatabaseObject);
}
Also used : Connector(com.twinsoft.convertigo.beans.core.Connector) ElseStep(com.twinsoft.convertigo.beans.steps.ElseStep) JavelinScreenClass(com.twinsoft.convertigo.beans.screenclasses.JavelinScreenClass) ScreenClass(com.twinsoft.convertigo.beans.core.ScreenClass) EngineException(com.twinsoft.convertigo.engine.EngineException) Step(com.twinsoft.convertigo.beans.core.Step) ElseStep(com.twinsoft.convertigo.beans.steps.ElseStep) RequestableStep(com.twinsoft.convertigo.beans.core.RequestableStep) ThenStep(com.twinsoft.convertigo.beans.steps.ThenStep) WalkHelper(com.twinsoft.convertigo.engine.helpers.WalkHelper) Criteria(com.twinsoft.convertigo.beans.core.Criteria) ThenStep(com.twinsoft.convertigo.beans.steps.ThenStep) DatabaseObject(com.twinsoft.convertigo.beans.core.DatabaseObject) MobileObject(com.twinsoft.convertigo.beans.core.MobileObject) RequestableObject(com.twinsoft.convertigo.beans.core.RequestableObject) ElseStatement(com.twinsoft.convertigo.beans.statements.ElseStatement) FunctionStatement(com.twinsoft.convertigo.beans.statements.FunctionStatement) HTTPStatement(com.twinsoft.convertigo.beans.statements.HTTPStatement) Statement(com.twinsoft.convertigo.beans.core.Statement) ThenStatement(com.twinsoft.convertigo.beans.statements.ThenStatement) ThenStatement(com.twinsoft.convertigo.beans.statements.ThenStatement) SAXException(org.xml.sax.SAXException) EngineException(com.twinsoft.convertigo.engine.EngineException) ConvertigoException(com.twinsoft.convertigo.engine.ConvertigoException) IOException(java.io.IOException) JSONException(org.codehaus.jettison.json.JSONException) InvalidOperationException(com.twinsoft.convertigo.engine.InvalidOperationException) ObjectWithSameNameException(com.twinsoft.convertigo.engine.ObjectWithSameNameException) Project(com.twinsoft.convertigo.beans.core.Project) ObjectWithSameNameException(com.twinsoft.convertigo.engine.ObjectWithSameNameException) Transaction(com.twinsoft.convertigo.beans.core.Transaction) HtmlTransaction(com.twinsoft.convertigo.beans.transactions.HtmlTransaction) ElseStatement(com.twinsoft.convertigo.beans.statements.ElseStatement) Sheet(com.twinsoft.convertigo.beans.core.Sheet)

Example 8 with ConvertigoException

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

the class DesignDocumentFilterTreeObject method rename.

@Override
public boolean rename(String newName, Boolean bDialog) {
    if (getName().equals(newName))
        return true;
    DesignDocumentTreeObject dto = getParentDesignTreeObject();
    if (dto.hasFilter(newName)) {
        ConvertigoPlugin.logException(new ConvertigoException("The function named \"" + newName + "\" already exists."), "Unable to change the object name.", bDialog);
        return false;
    }
    getObject().setName(newName);
    hasBeenModified();
    TreeViewer viewer = (TreeViewer) getAdapter(TreeViewer.class);
    viewer.update(this, null);
    return true;
}
Also used : ConvertigoException(com.twinsoft.convertigo.engine.ConvertigoException) TreeViewer(org.eclipse.jface.viewers.TreeViewer)

Example 9 with ConvertigoException

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

the class DesignDocumentViewTreeObject method rename.

public boolean rename(String newName, Boolean bDialog) {
    if (getName().equals(newName))
        return true;
    if (getParentDesignTreeObject().hasView(newName)) {
        ConvertigoPlugin.logException(new ConvertigoException("The view named \"" + newName + "\" already exists."), "Unable to change the object name.", bDialog);
        return false;
    }
    getObject().setName(newName);
    hasBeenModified();
    TreeViewer viewer = (TreeViewer) getAdapter(TreeViewer.class);
    viewer.update(this, null);
    return true;
}
Also used : ConvertigoException(com.twinsoft.convertigo.engine.ConvertigoException) TreeViewer(org.eclipse.jface.viewers.TreeViewer)

Example 10 with ConvertigoException

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

the class XmlHttpTransaction method makeDocument.

@Override
public void makeDocument(byte[] httpData) throws Exception {
    Engine.logBeans.trace("makeDocument : " + getEncodingCharSet());
    Charset charset = XMLUtils.getEncoding(httpData, Charset.forName(xmlEncoding));
    String sdata = new String(httpData, charset);
    sdata = sdata.replaceFirst("[\\d\\D]*?<", "<");
    Engine.logBeans.trace("makeDocument afternewString: " + sdata);
    Document xmlHttpDocument = requester.parseDOM(sdata);
    if (Engine.logBeans.isTraceEnabled())
        Engine.logBeans.trace("makeDocument after parseDom: " + XMLUtils.prettyPrintDOM(xmlHttpDocument));
    // Replace SOAP fault by an c8o error element
    if (isErrorOnSoapFault()) {
        Element soapFaultElement = null;
        soapFaultElement = getSoapFaultElement(xmlHttpDocument);
        if (soapFaultElement != null) {
            String sfm = getSoapFaultMessage(soapFaultElement);
            ConvertigoException ex = new ConvertigoException("The Web Service returned a SOAP Fault", new SOAPException(sfm));
            ConvertigoError err = ConvertigoError.initError(ErrorType.Project, ex);
            Document errDocument = err.buildErrorDocument(getRequester(), context);
            Node error = context.outputDocument.importNode(errDocument.getDocumentElement().getFirstChild(), true);
            context.outputDocument.getDocumentElement().appendChild(error);
            return;
        }
    }
    if (getAllowDownloadAttachment()) {
        Element attachmentInfo = (Element) XPathAPI.selectSingleNode(context.outputDocument, "/document/AttachmentInfo");
        if (attachmentInfo != null) {
            NodeList nl = XPathAPI.selectNodeList(attachmentInfo, "attachment");
            for (int i = 0; i < nl.getLength(); i++) {
                Element attachment = (Element) nl.item(i);
                String cid = attachment.getAttribute("cid");
                if (StringUtils.isNotBlank(cid)) {
                    Element include = (Element) XPathAPI.selectSingleNode(xmlHttpDocument, "//*[local-name()='Include' and @href='" + cid + "']");
                    if (include != null) {
                        include.appendChild(xmlHttpDocument.importNode(attachment, true));
                        XMLUtils.removeNode(attachment);
                    }
                }
            }
            if (XPathAPI.selectSingleNode(attachmentInfo, "attachment") == null) {
                XMLUtils.removeNode(attachmentInfo);
            }
        }
    }
    // Removes soap elements if needed
    if (isIgnoreSoapEnveloppe()) {
        Element soapBodyResponseElement = null;
        soapBodyResponseElement = getSoapBodyResponseElement(xmlHttpDocument.getDocumentElement());
        if (soapBodyResponseElement != null) {
            NamedNodeMap attributes = ((Element) soapBodyResponseElement.getParentNode()).getAttributes();
            NodeList childNodes = soapBodyResponseElement.getChildNodes();
            int len = childNodes.getLength();
            Node child, node;
            for (int i = 0; i < len; i++) {
                node = childNodes.item(i);
                if (node instanceof Element) {
                    // child = importNodeWithNoPrefix(context.outputDocument, node, true);
                    child = context.outputDocument.importNode(node, true);
                    // add envelope attributes (e.g namespace declarations to avoid unbound prefixes for XSL transformation)
                    for (int j = 0; j < attributes.getLength(); j++) {
                        Node attr = attributes.item(j);
                        ((Element) child).setAttributeNode((Attr) context.outputDocument.importNode(attr, true));
                    }
                    context.outputDocument.getDocumentElement().appendChild(child);
                }
            }
        } else {
            XMLUtils.copyDocument(xmlHttpDocument, context.outputDocument);
        }
    } else
        // Normal case
        XMLUtils.copyDocument(xmlHttpDocument, context.outputDocument);
}
Also used : ConvertigoException(com.twinsoft.convertigo.engine.ConvertigoException) NamedNodeMap(org.w3c.dom.NamedNodeMap) XmlSchemaElement(org.apache.ws.commons.schema.XmlSchemaElement) Element(org.w3c.dom.Element) SOAPException(javax.xml.soap.SOAPException) Node(org.w3c.dom.Node) NodeList(org.w3c.dom.NodeList) Charset(java.nio.charset.Charset) ConvertigoError(com.twinsoft.convertigo.engine.ConvertigoError) Document(org.w3c.dom.Document)

Aggregations

ConvertigoException (com.twinsoft.convertigo.engine.ConvertigoException)11 DatabaseObject (com.twinsoft.convertigo.beans.core.DatabaseObject)4 Project (com.twinsoft.convertigo.beans.core.Project)4 TreeViewer (org.eclipse.jface.viewers.TreeViewer)3 RequestableObject (com.twinsoft.convertigo.beans.core.RequestableObject)2 ScreenClass (com.twinsoft.convertigo.beans.core.ScreenClass)2 TreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TreeObject)2 EngineException (com.twinsoft.convertigo.engine.EngineException)2 IOException (java.io.IOException)2 CoreException (org.eclipse.core.runtime.CoreException)2 SAXException (org.xml.sax.SAXException)2 Connector (com.twinsoft.convertigo.beans.core.Connector)1 Criteria (com.twinsoft.convertigo.beans.core.Criteria)1 IScreenClassContainer (com.twinsoft.convertigo.beans.core.IScreenClassContainer)1 IVariableContainer (com.twinsoft.convertigo.beans.core.IVariableContainer)1 MobileObject (com.twinsoft.convertigo.beans.core.MobileObject)1 RequestableStep (com.twinsoft.convertigo.beans.core.RequestableStep)1 Sheet (com.twinsoft.convertigo.beans.core.Sheet)1 Statement (com.twinsoft.convertigo.beans.core.Statement)1 Step (com.twinsoft.convertigo.beans.core.Step)1