Search in sources :

Example 71 with EngineException

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

the class DatabaseObjectDeleteAction method delete.

private void delete(DatabaseObject databaseObject, boolean deleteProjectOnDisk) throws EngineException, CoreException {
    if (databaseObject instanceof Connector) {
        if (((Connector) databaseObject).isDefault) {
            throw new EngineException("Cannot delete the default connector!");
        }
        String dirPath, projectName;
        File dir;
        projectName = databaseObject.getParent().getName();
        MessageBox messageBox = new MessageBox(getParentShell(), SWT.ICON_QUESTION | SWT.YES | SWT.NO);
        messageBox.setText("Also delete linked resources?");
        // Delete soap templates for this connector
        dirPath = Engine.projectDir(projectName) + "/soap-templates/" + databaseObject.getName();
        dir = new File(dirPath);
        if (dir.exists()) {
            messageBox.setMessage("Some resources are linked to the deleted connector.\n\n" + "Do you also want to delete folder:\n\n\"" + dirPath + "\"");
            if (messageBox.open() == SWT.YES) {
                try {
                    DatabaseObjectsManager.deleteDir(dir);
                } catch (IOException e) {
                    ConvertigoPlugin.logDebug("Unable to delete directory \"" + dirPath + "\"!");
                }
            }
        }
        // Delete directory corresponding to connector under Traces directory
        dirPath = Engine.projectDir(projectName) + "/Traces/" + databaseObject.getName();
        dir = new File(dirPath);
        if (dir.exists()) {
            messageBox.setMessage("Some resources are linked to the deleted connector.\n\n" + "Do you also want to delete folder:\n\n\"" + dirPath + "\"");
            if (messageBox.open() == SWT.YES) {
                try {
                    DatabaseObjectsManager.deleteDir(dir);
                } catch (IOException e) {
                    ConvertigoPlugin.logDebug("Unable to delete directory \"" + dirPath + "\"!");
                }
            }
        }
    } else if (databaseObject instanceof Transaction) {
        if (((Transaction) databaseObject).isDefault) {
            throw new EngineException("Cannot delete the default transaction!");
        }
    } else if (databaseObject instanceof ScreenClass) {
        if ((databaseObject.getParent()) instanceof Project) {
            throw new EngineException("Cannot delete the root screen class!");
        }
    } else if (databaseObject instanceof Statement) {
        if ((databaseObject instanceof ThenStatement) || (databaseObject instanceof ElseStatement)) {
            throw new EngineException("Cannot delete this statement!");
        }
    } else if (databaseObject instanceof Step) {
        if ((databaseObject instanceof ThenStep) || (databaseObject instanceof ElseStep)) {
            throw new EngineException("Cannot delete this step!");
        }
    } else if (databaseObject instanceof MobilePlatform) {
        MobilePlatform mobilePlatform = (MobilePlatform) databaseObject;
        File resourceFolder = mobilePlatform.getResourceFolder();
        if (resourceFolder.exists()) {
            MessageBox messageBox = new MessageBox(getParentShell(), SWT.ICON_QUESTION | SWT.YES | SWT.NO);
            messageBox.setMessage("Do you want to delete the whole resource folder \"" + mobilePlatform.getRelativeResourcePath() + "\"?");
            messageBox.setText("Delete the \"" + resourceFolder.getName() + "\" folder?");
            if (messageBox.open() == SWT.YES) {
                FileUtils.deleteQuietly(resourceFolder);
            }
        }
    } else if (databaseObject instanceof PageComponent) {
        if (((PageComponent) databaseObject).isRoot) {
            throw new EngineException("Cannot delete the root page!");
        }
    }
    String dboQName = databaseObject.getQName();
    if (databaseObject instanceof Project) {
        // Engine.theApp.databaseObjectsManager.deleteProject(databaseObject.getName());
        if (deleteProjectOnDisk) {
            Engine.theApp.databaseObjectsManager.deleteProjectAndCar(databaseObject.getName(), DeleteProjectOption.unloadOnly);
        } else {
            Engine.theApp.databaseObjectsManager.deleteProject(databaseObject.getName(), DeleteProjectOption.unloadOnly);
        }
        ConvertigoPlugin.getDefault().deleteProjectPluginResource(deleteProjectOnDisk, databaseObject.getName());
    } else {
        databaseObject.delete();
    }
    if (databaseObject instanceof CouchDbConnector) {
        CouchDbConnector couchDbConnector = (CouchDbConnector) databaseObject;
        String db = couchDbConnector.getDatabaseName();
        if (!db.isEmpty()) {
            MessageBox messageBox = new MessageBox(getParentShell(), SWT.ICON_QUESTION | SWT.YES | SWT.NO);
            messageBox.setMessage("Do you want to delete the \"" + db + "\" database from the CouchDb server?");
            messageBox.setText("Delete the database?");
            if (messageBox.open() == SWT.YES) {
                couchDbConnector.getCouchClient().deleteDatabase(db);
            }
        }
    }
    ConvertigoPlugin.logDebug("The object \"" + dboQName + "\" has been deleted from the database repository!");
}
Also used : CouchDbConnector(com.twinsoft.convertigo.beans.connectors.CouchDbConnector) Connector(com.twinsoft.convertigo.beans.core.Connector) ElseStep(com.twinsoft.convertigo.beans.steps.ElseStep) ScreenClass(com.twinsoft.convertigo.beans.core.ScreenClass) ElseStatement(com.twinsoft.convertigo.beans.statements.ElseStatement) Statement(com.twinsoft.convertigo.beans.core.Statement) ThenStatement(com.twinsoft.convertigo.beans.statements.ThenStatement) EngineException(com.twinsoft.convertigo.engine.EngineException) ThenStatement(com.twinsoft.convertigo.beans.statements.ThenStatement) IOException(java.io.IOException) Step(com.twinsoft.convertigo.beans.core.Step) ElseStep(com.twinsoft.convertigo.beans.steps.ElseStep) ThenStep(com.twinsoft.convertigo.beans.steps.ThenStep) SimpleStep(com.twinsoft.convertigo.beans.steps.SimpleStep) CouchDbConnector(com.twinsoft.convertigo.beans.connectors.CouchDbConnector) PageComponent(com.twinsoft.convertigo.beans.mobile.components.PageComponent) MessageBox(org.eclipse.swt.widgets.MessageBox) ThenStep(com.twinsoft.convertigo.beans.steps.ThenStep) Project(com.twinsoft.convertigo.beans.core.Project) MobilePlatform(com.twinsoft.convertigo.beans.core.MobilePlatform) Transaction(com.twinsoft.convertigo.beans.core.Transaction) ElseStatement(com.twinsoft.convertigo.beans.statements.ElseStatement) File(java.io.File)

Example 72 with EngineException

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

the class EmulatorTechnologyWizardPage method dialogChanged.

private void dialogChanged() {
    String emTech = getEmulatorTechnology();
    if (emTech.length() == 0) {
        updateStatus("Emulator technology must be specified");
        return;
    }
    try {
        DatabaseObject dbo = ((ObjectExplorerWizardPage) getWizard().getPage("ObjectExplorerWizardPage")).getCreatedBean();
        if (dbo != null) {
            if (dbo instanceof JavelinConnector) {
                ((JavelinConnector) dbo).setEmulatorTechnology(emTech);
                ((JavelinConnector) dbo).emulatorID = ((JavelinConnector) dbo).findEmulatorId();
            }
        }
        ServiceCodeWizardPage servCodeWP = (ServiceCodeWizardPage) getWizard().getPage("ServiceCodeWizardPage");
        servCodeWP.update();
    } catch (NullPointerException e) {
        updateStatus("New Bean has not been instantiated");
        return;
    } catch (EngineException e) {
        updateStatus("Emulmator id couldn't be found from emulator technology.");
        return;
    }
    updateStatus(null);
}
Also used : JavelinConnector(com.twinsoft.convertigo.beans.connectors.JavelinConnector) EngineException(com.twinsoft.convertigo.engine.EngineException) DatabaseObject(com.twinsoft.convertigo.beans.core.DatabaseObject) ObjectExplorerWizardPage(com.twinsoft.convertigo.eclipse.wizards.new_object.ObjectExplorerWizardPage)

Example 73 with EngineException

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

the class SetupWizard method prepareHttpClient.

private HttpClient prepareHttpClient(String[] url) throws EngineException, MalformedURLException {
    HttpClient client = new HttpClient();
    HostConfiguration hostConfiguration = client.getHostConfiguration();
    HttpState httpState = new HttpState();
    client.setState(httpState);
    if (proxyManager != null) {
        proxyManager.getEngineProperties();
        proxyManager.setProxy(hostConfiguration, httpState, new URL(url[0]));
    }
    Matcher matcher = scheme_host_pattern.matcher(url[0]);
    if (matcher.matches()) {
        String host = matcher.group(1);
        String sPort = matcher.group(2);
        int port = 443;
        try {
            port = Integer.parseInt(sPort);
        } catch (Exception e) {
        }
        try {
            Protocol myhttps = new Protocol("https", MySSLSocketFactory.getSSLSocketFactory(null, null, null, null, true), port);
            hostConfiguration.setHost(host, port, myhttps);
            url[0] = matcher.group(3);
        } catch (Exception e) {
            e.printStackTrace();
            e.printStackTrace();
        }
    }
    return client;
}
Also used : Matcher(java.util.regex.Matcher) HostConfiguration(org.apache.commons.httpclient.HostConfiguration) HttpClient(org.apache.commons.httpclient.HttpClient) HttpState(org.apache.commons.httpclient.HttpState) Protocol(org.apache.commons.httpclient.protocol.Protocol) URL(java.net.URL) HttpException(org.apache.commons.httpclient.HttpException) MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException) EngineException(com.twinsoft.convertigo.engine.EngineException)

Example 74 with EngineException

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

the class SetupWizard method addPages.

@Override
public void addPages() {
    Engine.CONFIGURATION_PATH = Engine.USER_WORKSPACE_PATH;
    // empty workspace folder
    if (new File(Engine.USER_WORKSPACE_PATH).list().length == 0) {
        // installer
        if (!System.getProperties().containsKey("convertigo.license.accepted")) {
            licensePage = new LicensePage();
            addPage(licensePage);
        } else {
            System.getProperties().remove("convertigo.license.accepted");
        }
        boolean pre6_2 = false;
        for (String pathToCheck : Arrays.asList("configuration/engine.properties", "minime/Java/login.txt", "cache", "projects", "logs")) {
            pre6_2 = new File(Engine.PROJECTS_PATH, pathToCheck).exists();
            if (!pre6_2) {
                break;
            }
        }
        if (pre6_2) {
            Engine.CONFIGURATION_PATH = Engine.PROJECTS_PATH;
            workspaceMigrationPage = new WorkspaceMigrationPage();
            addPage(workspaceMigrationPage);
        } else {
            workspaceCreationPage = new WorkspaceCreationPage();
            addPage(workspaceCreationPage);
        }
    }
    Engine.CONFIGURATION_PATH += "/configuration";
    try {
        EnginePropertiesManager.loadProperties(false);
        proxyManager = new ProxyManager();
        proxyManager.init();
    } catch (EngineException e) {
        ConvertigoPlugin.logInfo("Unexpected EngineException: " + e.getMessage());
    }
    configureProxyPage = new ConfigureProxyPage(proxyManager);
    addPage(configureProxyPage);
    // alreadyPscKeyPage = new AlreadyPscKeyPage();
    // addPage(alreadyPscKeyPage);
    pscKeyValidationPage = new PscKeyValidationPage();
    addPage(pscKeyValidationPage);
    // registrationPage = new RegistrationPage();
    // addPage(registrationPage);
    // pscKeyPage = new PscKeyPage();
    // addPage(pscKeyPage);
    summaryPage = new SummaryPage();
    addPage(summaryPage);
}
Also used : ProxyManager(com.twinsoft.convertigo.engine.ProxyManager) EngineException(com.twinsoft.convertigo.engine.EngineException) File(java.io.File)

Example 75 with EngineException

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

the class StatementInfoWizardPage method dialogChanged.

private void dialogChanged(boolean increment) {
    String name = getBeanName();
    if (name.length() == 0) {
        updateStatus("Name must be specified");
        return;
    }
    if (!StringUtils.isNormalized(name)) {
        updateStatus("Name must be normalized.\nDon't start with number and don't use non ASCII caracters.");
        return;
    }
    Matcher m = Pattern.compile("\\d+$").matcher("");
    boolean sameName;
    do {
        sameName = false;
        try {
            ((StatementGeneratorWizardPage) getWizard().getPage("StatementGeneratorWizardPage")).getCreatedBean().setName(name);
        } catch (ObjectWithSameNameException e) {
            if (!increment) {
                updateStatus("Name already used by siblings");
                return;
            }
            sameName = true;
            m.reset(name);
            if (m.find()) {
                name = name.substring(0, m.start()) + (Integer.parseInt(m.group()) + 1);
            } else {
                name = name + "_1";
            }
            setBeanName(name);
        } catch (EngineException e) {
            updateStatus("Name could not be set on bean");
            return;
        } catch (NullPointerException e) {
            updateStatus("New Bean has not been instanciated");
            return;
        }
    } while (sameName);
    updateStatus(null);
}
Also used : ObjectWithSameNameException(com.twinsoft.convertigo.engine.ObjectWithSameNameException) Matcher(java.util.regex.Matcher) 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