package eu.etaxonomy.taxeditor.store;
import java.sql.SQLException;
+import java.util.concurrent.CancellationException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import eu.etaxonomy.cdm.database.DatabaseTypeEnum;
import eu.etaxonomy.cdm.database.DbSchemaValidation;
import eu.etaxonomy.cdm.database.ICdmDataSource;
-import eu.etaxonomy.cdm.model.common.CdmMetaData;
-import eu.etaxonomy.cdm.model.common.CdmMetaData.MetaDataPropertyName;
+import eu.etaxonomy.cdm.model.metadata.CdmMetaData;
+import eu.etaxonomy.cdm.model.metadata.CdmMetaData.MetaDataPropertyName;
import eu.etaxonomy.taxeditor.model.CdmProgressMonitorAdapter;
-import eu.etaxonomy.taxeditor.ui.dialogs.LoginDialog;
+import eu.etaxonomy.taxeditor.ui.dialog.LoginDialog;
import eu.etaxonomy.taxeditor.view.datasource.CdmDataSourceViewPart;
/**
if (!monitor.isCanceled()) {
CdmProgressMonitorAdapter subprogressMonitor = CdmProgressMonitorAdapter
- .CreateSubMonitor(monitor, IProgressMonitor.UNKNOWN);
+ .CreateSubMonitor(monitor, 7);
// This is where we instantiate the application controller
try {
applicationController = CdmApplicationController.NewInstance(
applicationContextBean, dataSource, dbSchemaValidation,
false, subprogressMonitor);
} catch (Exception e) {
- StoreUtil.error(this.getClass(), e.getMessage(), e);
+ if(! causeIsCancelationExceptionRecursive(e)){
+ return new Status(IStatus.ERROR, "Could not connect to CDM Store", "An error occurred while trying to connect to datasource: " + dataSource.getName(), e);
+ }
+ } finally {
+ monitor.done();
}
}
-
- monitor.done();
+
+
if (!monitor.isCanceled()) {
CdmStore.setInstance(applicationController, dataSource);
}
}
+ private boolean causeIsCancelationExceptionRecursive(Throwable throwable){
+ if(throwable == null){
+ return false;
+ }else if(throwable instanceof CancellationException){
+ return true;
+ }else{
+ return causeIsCancelationExceptionRecursive(throwable.getCause());
+ }
+ }
+
private void checkDatabaseReachable(IProgressMonitor monitor) {
try {
monitor.subTask("Checking if datasource is reachable.");