portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wea...@apache.org
Subject cvs commit: jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/tools/pamanager DeployUtilities.java
Date Fri, 16 Jan 2004 19:47:32 GMT
weaver      2004/01/16 11:47:32

  Modified:    portal/src/java/org/apache/jetspeed/tools/pamanager
                        DeployUtilities.java
  Log:
  deployArchive now throws an IOException instead of a PAE.  This makes
  a little more sense from the stand point that deployArchive is a file operation
  method.
  
  An IOException is now thrown if the target for extracting the archive 
  already exists.
  
  Revision  Changes    Path
  1.5       +35 -36    jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/tools/pamanager/DeployUtilities.java
  
  Index: DeployUtilities.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/tools/pamanager/DeployUtilities.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- DeployUtilities.java	15 Jan 2004 16:06:10 -0000	1.4
  +++ DeployUtilities.java	16 Jan 2004 19:47:31 -0000	1.5
  @@ -57,6 +57,7 @@
   import java.io.FileInputStream;
   import java.io.FileOutputStream;
   import java.io.FileWriter;
  +import java.io.IOException;
   import java.io.InputStream;
   import java.util.Enumeration;
   import java.util.jar.JarEntry;
  @@ -94,10 +95,11 @@
        * Deploys archives from a war file to the WebApps directory
        * @param webAppsDir The application server directory
        * @param warFile The war file to deploy
  -     * @throws PortletApplicationException
  +     * @throws java.lang.IOException if the target for deployment already exists
  +     * or there is a problem locating, reading or expanding the source archive.
        */
   
  -    public void deployArchive(String webAppsDir, String warFile, String appName) throws
PortletApplicationException
  +    public void deployArchive(String webAppsDir, String warFile, String appName) throws
IOException
       {
           String warFileName = warFile;
           if (warFileName.indexOf("/") != -1)
  @@ -109,48 +111,45 @@
   
           log.info("deploying WAR file'" + warFileName + ".war' to WEB-INF/...");
   
  -        try
  +        String destination = webAppsDir + appName;
  +        if (new File(destination).exists())
           {
  -            String destination = webAppsDir + appName;
  +            throw new IOException(
  +                "The portlet application archive target, "
  +                    + destination
  +                    + ", already exists.  Please remove it before attempting to deploy.");
  +        }
   
  -            JarFile jarFile = new JarFile(warFile);
  -            Enumeration files = jarFile.entries();
  -            while (files.hasMoreElements())
  -            {
  -                JarEntry entry = (JarEntry) files.nextElement();
  +        JarFile jarFile = new JarFile(warFile);
  +        Enumeration files = jarFile.entries();
  +        while (files.hasMoreElements())
  +        {
  +            JarEntry entry = (JarEntry) files.nextElement();
   
  -                File file = new File(destination, entry.getName());
  -                File dirF = new File(file.getParent());
  -                dirF.mkdirs();
  -                if (entry.isDirectory())
  -                {
  -                    file.mkdirs();
  -                }
  -                else
  +            File file = new File(destination, entry.getName());
  +            File dirF = new File(file.getParent());
  +            dirF.mkdirs();
  +            if (entry.isDirectory())
  +            {
  +                file.mkdirs();
  +            }
  +            else
  +            {
  +                byte[] buffer = new byte[1024];
  +                int length = 0;
  +                InputStream fis = jarFile.getInputStream(entry);
  +                FileOutputStream fos = new FileOutputStream(file);
  +                while ((length = fis.read(buffer)) >= 0)
                   {
  -                    byte[] buffer = new byte[1024];
  -                    int length = 0;
  -                    InputStream fis = jarFile.getInputStream(entry);
  -                    FileOutputStream fos = new FileOutputStream(file);
  -                    while ((length = fis.read(buffer)) >= 0)
  -                    {
  -                        fos.write(buffer, 0, length);
  -                    }
  -                    fos.close();
  +                    fos.write(buffer, 0, length);
                   }
  -
  +                fos.close();
               }
   
  -            log.info("Libraries and classes deployment finished!");
           }
  -        catch (Exception e)
  -        {
   
  -            String msg = "Exception while copying jar files to web apps directory '" +
webAppsDir + "'" + e.getMessage();
  -            log.error(msg, e);
  -            PortletApplicationException pe = new PortletApplicationException(msg);
  -            throw pe;
  -        }
  +        log.info("Libraries and classes deployment finished!");
  +
       }
   
       /**
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jetspeed-dev-help@jakarta.apache.org


Mime
View raw message