Improved error handling for database that can not be updated because they are too old
authorn.hoffmann <n.hoffmann@localhost>
Wed, 20 Oct 2010 09:59:54 +0000 (09:59 +0000)
committern.hoffmann <n.hoffmann@localhost>
Wed, 20 Oct 2010 09:59:54 +0000 (09:59 +0000)
taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/datasource/handler/UpdateDataSourceHandler.java
taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/model/AbstractUtility.java

index 736b4065c79de07673a3fff10d60c9fcc33ced49..b32b8940bef010a0d8aee107d654bf65b3ca6461 100644 (file)
@@ -23,6 +23,7 @@ import eu.etaxonomy.taxeditor.datasource.view.CdmDataSourceViewPart;
 import eu.etaxonomy.taxeditor.datasource.view.CdmMetaDataAwareDataSourceContainer;
 import eu.etaxonomy.taxeditor.model.CdmProgressMonitorAdapter;
 import eu.etaxonomy.taxeditor.store.StoreUtil;
+import eu.etaxonomy.taxeditor.store.internal.TaxeditorStorePlugin;
 
 /**
  * @author n.hoffmann
@@ -45,22 +46,30 @@ public class UpdateDataSourceHandler extends AbstractDataSourceHandler {
                        @Override
                        protected IStatus run(IProgressMonitor monitor) {
                                CdmUpdater updater = new CdmUpdater();
-                               boolean result = updater.updateToCurrentVersion(container.getDataSource(), CdmProgressMonitorAdapter.CreateMonitor(monitor));
-                               
-                               if(result){
-                                       display.asyncExec(new Runnable(){
+                               IStatus status = null;
+                               try{
+                                       if(updater.updateToCurrentVersion(container.getDataSource(), CdmProgressMonitorAdapter.CreateMonitor(monitor))){
+                                               display.asyncExec(new Runnable(){
 
-                                               @Override
-                                               public void run() {
-                                                       CdmDataSourceViewPart view = (CdmDataSourceViewPart) StoreUtil.getView(CdmDataSourceViewPart.ID, false);
-                                                       if(view != null){
-                                                               view.getViewer().update(new CdmMetaDataAwareDataSourceContainer[]{container}, null);
+                                                       @Override
+                                                       public void run() {
+                                                               
+                                                               CdmDataSourceViewPart view = (CdmDataSourceViewPart) StoreUtil.getView(CdmDataSourceViewPart.ID, false);
+                                                               if(view != null){
+                                                                       view.getViewer().update(new CdmMetaDataAwareDataSourceContainer[]{container}, null);
+                                                               }
+                                                               
                                                        }
-                                               }
-                                       });
+                                               });
+                                               status = Status.OK_STATUS;
+                                       }
+                               }catch(Exception e){
+                                       status = new Status(IStatus.ERROR, TaxeditorStorePlugin.PLUGIN_ID, e.getMessage(), e);
+                                       StoreUtil.errorDialog("Could not run updater", getClass(), status);
                                }
                                
-                               return result ? Status.OK_STATUS : Status.CANCEL_STATUS;
+                               
+                               return status;
                        }
                        
                };
index 030fa0d1795b916c9df56a5b763be78e7a7ec646..553c69df01733e4e8abea6a950544a42ed864281 100644 (file)
@@ -210,6 +210,10 @@ public abstract class AbstractUtility {
                        }
                });
        }
+       
+       public static void errorDialog(final String title, final Object source, final IStatus status){
+               
+       }
 
        public static boolean confirmDialog(String title, String message) {
                return MessageDialog.openQuestion(getShell(), title, message);
@@ -452,7 +456,11 @@ public abstract class AbstractUtility {
         */
        public static void error(Class source, String message, Throwable t){
                IStatus status = new Status(IStatus.ERROR, getPluginId(), message, t);
-               getLog4JLogger(source).error(message, t);
+               error(source, status);
+       }
+       
+       public static void error(Class source, IStatus status){
+               getLog4JLogger(source).error(status.getMessage(), status.getException());
                log(status);
        }