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