jruaux      2003/01/17 07:22:38

  Modified:    Eclipse-Plugin/src/java/org/apache/cactus/eclipse/launcher
                        CactusLaunchShortcut.java WarBuilder.java
  Log:
  Improved error handling and reporting
  
  Revision  Changes    Path
  1.28      +52 -30    
jakarta-cactus/Eclipse-Plugin/src/java/org/apache/cactus/eclipse/launcher/CactusLaunchShortcut.java
  
  Index: CactusLaunchShortcut.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-cactus/Eclipse-Plugin/src/java/org/apache/cactus/eclipse/launcher/CactusLaunchShortcut.java,v
  retrieving revision 1.27
  retrieving revision 1.28
  diff -u -r1.27 -r1.28
  --- CactusLaunchShortcut.java 16 Jan 2003 11:37:45 -0000      1.27
  +++ CactusLaunchShortcut.java 17 Jan 2003 15:22:38 -0000      1.28
  @@ -67,8 +67,6 @@
   import org.apache.cactus.eclipse.ui.CactusPreferences;
   import org.eclipse.core.runtime.CoreException;
   import org.eclipse.core.runtime.IProgressMonitor;
  -import org.eclipse.core.runtime.IStatus;
  -import org.eclipse.core.runtime.Status;
   import org.eclipse.debug.core.DebugPlugin;
   import org.eclipse.debug.core.ILaunchConfigurationType;
   import org.eclipse.debug.core.ILaunchManager;
  @@ -199,12 +197,22 @@
               catch (InvocationTargetException e)
               {
                   dialog.close();
  +                CactusPlugin.displayErrorMessage(
  +                    CactusMessages.getString(
  +                        "CactusLaunch.message.prepare.error"),
  +                    e.getTargetException().getMessage(),
  +                    null);
                   cancelPreparation();
                   return;
               }
               catch (InterruptedException e)
               {
                   dialog.close();
  +                CactusPlugin.displayErrorMessage(
  +                    CactusMessages.getString(
  +                        "CactusLaunch.message.prepare.error"),
  +                    e.getMessage(),
  +                    null);
                   cancelPreparation();
                   return;
               }
  @@ -221,7 +229,14 @@
           {
               public void run(IProgressMonitor thePM) throws InterruptedException
               {
  -                teardownCactusTests(thePM);
  +                try
  +                {
  +                    teardownCactusTests(thePM);
  +                }
  +                catch (CoreException e)
  +                {
  +                    throw new InterruptedException(e.getMessage());
  +                }
               }
           };
           try
  @@ -233,13 +248,18 @@
               CactusPlugin
                   .displayErrorMessage(
                       CactusMessages.getString(
  -                        "CactusLaunch.message.teardown.failed"),
  +                        "CactusLaunch.message.teardown.error"),
                       tearDownE.getTargetException().getMessage(),
                   null);
           }
           catch (InterruptedException tearDownE)
           {
  -            // Do nothing
  +            CactusPlugin
  +                .displayErrorMessage(
  +                    CactusMessages.getString(
  +                        "CactusLaunch.message.teardown.error"),
  +                    tearDownE.getMessage(),
  +                null);
           }
       }
       
  @@ -262,10 +282,15 @@
           {
               WarBuilder newWar = new WarBuilder(theJavaProject);
               war = newWar.createWar(thePM);
  -
               URL warURL = war.toURL();
  +            String contextURLPath = CactusPreferences.getContextURLPath();
  +            if (contextURLPath.equals(""))
  +            {
  +                CactusPlugin.throwCoreException(
  +                    "CactusLaunch.message.invalidproperty.contextpath", null);
  +            }
               provider.deploy(
  -                CactusPreferences.getContextURLPath(),
  +                contextURLPath,
                   warURL,
                   null,
                   thePM);
  @@ -274,14 +299,9 @@
           catch (MalformedURLException e)
           {
               CactusPlugin.log(e);
  -            throw new CoreException(
  -                new Status(
  -                    IStatus.ERROR,
  -                    CactusPlugin.getPluginId(),
  -                    IStatus.OK,
  -                    CactusMessages.getString(
  -                        "CactusLaunch.message.war.malformed"),
  -                    e));
  +            CactusPlugin.throwCoreException(
  +                "CactusLaunch.message.war.malformed",
  +                e);
           }
           thePM.done();
       }
  @@ -290,25 +310,16 @@
        * Stops the container and undeploys (cleans) it.
        * @param thePM a progress monitor that reflects progress made while tearing
        * down the container setup
  +     * @throws CoreException if an error occurs when tearing down
        */
       private void teardownCactusTests(IProgressMonitor thePM)
  +        throws CoreException
       {
           // The commented code is linked to the crashing VM problem
           //thePM.beginTask("Tearing down Cactus tests", 10);
  -        try
  -        {
  -            provider.stop(null, thePM);
  -            provider.undeploy(null, null, thePM);
  -            war.delete();
  -        }
  -        catch (CoreException e)
  -        {
  -            CactusPlugin.displayErrorMessage(
  -                CactusMessages.getString(
  -                    "CactusLaunch.message.teardown.error"),
  -                e.getMessage(),
  -                e.getStatus());
  -        }
  +        provider.stop(null, thePM);
  +        provider.undeploy(null, null, thePM);
  +        war.delete();
           //thePM.done();
       }
       /**
  @@ -329,7 +340,18 @@
           // after the JUnit tests ended.
           // The commented code below should be used when this problem
           // has been addressed.
  -        teardownCactusTests(null);
  +        // TODO: Address the crashing problem
  +        try
  +        {
  +            teardownCactusTests(null);
  +        }
  +        catch (CoreException e)
  +        {
  +            CactusPlugin.displayErrorMessage(
  +                CactusMessages.getString("CactusLaunch.message.teardown.error"),
  +                e.getMessage(),
  +                null);
  +            }
   //        ProgressMonitorDialog dialog =
   //            new ProgressMonitorDialog(getShell());
   //        try
  
  
  
  1.12      +5 -10     
jakarta-cactus/Eclipse-Plugin/src/java/org/apache/cactus/eclipse/launcher/WarBuilder.java
  
  Index: WarBuilder.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-cactus/Eclipse-Plugin/src/java/org/apache/cactus/eclipse/launcher/WarBuilder.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- WarBuilder.java   15 Jan 2003 09:20:36 -0000      1.11
  +++ WarBuilder.java   17 Jan 2003 15:22:38 -0000      1.12
  @@ -60,14 +60,13 @@
   import java.io.IOException;
   import java.util.Vector;
   
  +import org.apache.cactus.eclipse.ui.CactusMessages;
   import org.apache.cactus.eclipse.ui.CactusPlugin;
   import org.eclipse.ant.core.AntRunner;
   import org.eclipse.core.runtime.CoreException;
   import org.eclipse.core.runtime.IPath;
   import org.eclipse.core.runtime.IProgressMonitor;
  -import org.eclipse.core.runtime.IStatus;
   import org.eclipse.core.runtime.Path;
  -import org.eclipse.core.runtime.Status;
   import org.eclipse.core.runtime.SubProgressMonitor;
   import org.eclipse.jdt.core.IJavaProject;
   import org.eclipse.jdt.core.JavaModelException;
  @@ -168,7 +167,7 @@
        */
       public File createWar(IProgressMonitor thePM) throws CoreException
       {
  -        thePM.subTask("Creating the WAR file");
  +        thePM.subTask(CactusMessages.getString("CactusLaunch.message.war"));
           File testWar = null;
           try
           {
  @@ -176,13 +175,9 @@
           }
           catch (IOException e)
           {
  -            throw new CoreException(
  -                new Status(
  -                    IStatus.ERROR,
  -                    CactusPlugin.getPluginId(),
  -                    IStatus.OK,
  -                    e.getMessage(),
  -                    e));
  +            CactusPlugin.throwCoreException(
  +                "CactusLaunch.message.war.error",
  +                e);
           }
           Vector arguments = new Vector();
           String jarFilesPath = jarFilesDir.getAbsolutePath();
  
  
  

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to