[jbosstools-commits] JBoss Tools SVN: r43502 - in trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui: wizard and 1 other directory.

jbosstools-commits at lists.jboss.org jbosstools-commits at lists.jboss.org
Fri Sep 7 07:26:24 EDT 2012


Author: adietish
Date: 2012-09-07 07:26:24 -0400 (Fri, 07 Sep 2012)
New Revision: 43502

Modified:
   trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/OpenShiftUIActivator.java
   trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/OpenShiftExpressApplicationWizard.java
Log:
[JBIDE-12561] corrected check for TransportException, corrected extraction of nested exception to display causing error correctly

Modified: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/OpenShiftUIActivator.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/OpenShiftUIActivator.java	2012-09-07 11:24:49 UTC (rev 43501)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/OpenShiftUIActivator.java	2012-09-07 11:26:24 UTC (rev 43502)
@@ -1,6 +1,9 @@
 package org.jboss.tools.openshift.express.internal.ui;
 
+import java.lang.reflect.InvocationTargetException;
+
 import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.MultiStatus;
 import org.eclipse.core.runtime.Status;
 import org.eclipse.osgi.util.NLS;
 import org.eclipse.ui.plugin.AbstractUIPlugin;
@@ -71,22 +74,47 @@
 	}
 
 	public static IStatus createCancelStatus(String message) {
-		return new Status(IStatus.CANCEL, OpenShiftUIActivator.PLUGIN_ID, message);
+		return new Status(IStatus.CANCEL, PLUGIN_ID, message);
 	}
 
 	public static IStatus createCancelStatus(String message, Object... arguments) {
-		return new Status(IStatus.CANCEL, OpenShiftUIActivator.PLUGIN_ID, NLS.bind(message, arguments));
+		return new Status(IStatus.CANCEL, PLUGIN_ID, NLS.bind(message, arguments));
 	}
 
 	public static IStatus createErrorStatus(String message) {
-		return new Status(IStatus.ERROR, OpenShiftUIActivator.PLUGIN_ID, message);
+		return new Status(IStatus.ERROR, PLUGIN_ID, message);
 	}
 
 	public static IStatus createErrorStatus(String message, Throwable throwable) {
-		return new Status(IStatus.ERROR, OpenShiftUIActivator.PLUGIN_ID, message, throwable);
+		return new Status(IStatus.ERROR, PLUGIN_ID, message, throwable);
 	}
 
 	public static IStatus createErrorStatus(String message, Throwable throwable, Object... arguments) {
 		return createErrorStatus(NLS.bind(message, arguments), throwable);
 	}
+	
+	public static MultiStatus createMultiStatus(String message, Throwable t, Object... arguments) {
+		MultiStatus multiStatus = new MultiStatus(PLUGIN_ID, IStatus.ERROR, NLS.bind(message, arguments), t);
+		addStatuses(t, multiStatus);
+		return multiStatus;
+	}
+
+	private static void addStatuses(Throwable t, MultiStatus multiStatus) {
+		Throwable wrapped = getWrappedThrowable(t);
+		if (wrapped != null) {
+			multiStatus.add(createErrorStatus(wrapped.getMessage(), wrapped));
+			addStatuses(wrapped, multiStatus);
+		}
+	}
+	
+	private static Throwable getWrappedThrowable(Throwable t) {
+		if (t instanceof InvocationTargetException) {
+			return ((InvocationTargetException) t).getTargetException();
+		} else if (t instanceof Exception) {
+			return ((Exception) t).getCause();
+		}
+		return null;
+
+	}
+	
 }

Modified: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/OpenShiftExpressApplicationWizard.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/OpenShiftExpressApplicationWizard.java	2012-09-07 11:24:49 UTC (rev 43501)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/OpenShiftExpressApplicationWizard.java	2012-09-07 11:26:24 UTC (rev 43502)
@@ -30,7 +30,6 @@
 import org.eclipse.jface.wizard.IWizardContainer;
 import org.eclipse.jface.wizard.Wizard;
 import org.eclipse.jface.wizard.WizardDialog;
-import org.eclipse.jgit.api.errors.JGitInternalException;
 import org.eclipse.jgit.errors.TransportException;
 import org.eclipse.osgi.util.NLS;
 import org.eclipse.ui.IImportWizard;
@@ -84,19 +83,7 @@
 	OpenShiftExpressApplicationWizardModel getWizardModel() {
 		return wizardModel;
 	}
-
-	protected boolean isTransportException(InvocationTargetException e) {
-		return e.getTargetException() instanceof JGitInternalException
-				&& e.getTargetException().getCause() instanceof TransportException;
-	}
-
-	protected TransportException getTransportException(InvocationTargetException e) {
-		if (isTransportException(e)) {
-			return (TransportException) ((JGitInternalException) e.getTargetException()).getCause();
-		}
-		return null;
-	}
-
+	
 	protected void openError(final String title, final String message) {
 		getShell().getDisplay().syncExec(new Runnable() {
 
@@ -345,8 +332,8 @@
 			} catch (URISyntaxException e) {
 				return OpenShiftUIActivator.createErrorStatus("The url of the remote git repository is not valid", e);
 			} catch (InvocationTargetException e) {
-				if (isTransportException(e)) {
-					TransportException te = getTransportException(e);
+				TransportException te = getTransportException(e);
+				if (te != null) {
 					return OpenShiftUIActivator.createErrorStatus(
 							"Could not clone the repository. Authentication failed.\n"
 									+ " Please make sure that you added your private key to the ssh preferences.", te);
@@ -362,6 +349,17 @@
 		}
 	}
 
+	protected TransportException getTransportException(Throwable t) {
+		if (t instanceof TransportException) {
+			return (TransportException) t;
+		} else if (t instanceof InvocationTargetException) {
+			return getTransportException(((InvocationTargetException) t).getTargetException());
+		} else if (t instanceof Exception) {
+			return getTransportException(((Exception) t).getCause());
+		}
+		return null;
+	}
+
 	@Override
 	public void dispose() {
 		wizardModel.dispose();



More information about the jbosstools-commits mailing list