taylor      2004/08/06 16:02:51

  Modified:    portal/src/java/org/apache/jetspeed/util/descriptor
                        PortletApplicationWar.java
  Log:
  adding support for missing web.xml -- auto deploy now allows for portlet app war 
files deployed without a web.xml
  we now create a new web.xml, include it in the deployment, and infuse the jetspeed 
container servlet
  
  CVS: ----------------------------------------------------------------------
  CVS: PR:
  CVS:   If this change addresses a PR in the problem report tracking
  CVS:   database, then enter the PR number(s) here.
  CVS: Obtained from:
  CVS:   If this change has been taken from another system, such as NCSA,
  CVS:   then name the system in this line, otherwise delete it.
  CVS: Submitted by:
  CVS:   If this code has been contributed to Apache by someone else; i.e.,
  CVS:   they sent us a patch or a new module, then include their name/email
  CVS:   address here. If this is your work then delete this line.
  CVS: Reviewed by:
  CVS:   If we are doing pre-commit code reviews and someone else has
  CVS:   reviewed your changes, include their name(s) here.
  CVS:   If you have not had it reviewed then delete this line.
  
  Revision  Changes    Path
  1.15      +33 -6     
jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/util/descriptor/PortletApplicationWar.java
  
  Index: PortletApplicationWar.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/util/descriptor/PortletApplicationWar.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- PortletApplicationWar.java        23 Jul 2004 02:43:31 -0000      1.14
  +++ PortletApplicationWar.java        6 Aug 2004 23:02:51 -0000       1.15
  @@ -19,6 +19,7 @@
   import java.io.FileInputStream;
   import java.io.FileNotFoundException;
   import java.io.FileOutputStream;
  +import java.io.FileWriter;
   import java.io.IOException;
   import java.io.InputStream;
   import java.io.InputStreamReader;
  @@ -72,6 +73,13 @@
    */
   public class PortletApplicationWar
   {
  +    protected static final String WEB_XML_STRING = 
  +            "<?xml version='1.0' encoding='ISO-8859-1'?>" +
  +            "<!DOCTYPE web-app " +
  +            "PUBLIC '-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN' " + 
  +           "'http://java.sun.com/dtd/web-app_2_3.dtd'>\n" +
  +            "<web-app></web-app>";
  +
       protected static final String PORTLET_XML_PATH = "WEB-INF/portlet.xml";
       protected static final String WEB_XML_PATH = "WEB-INF/web.xml";
       protected static final String EXTENDED_PORTLET_XML_PATH = 
"WEB-INF/jetspeed-portlet.xml";
  @@ -303,11 +311,10 @@
       protected OutputStream getOutputStream( String path ) throws IOException
       {
           File child = new File(warStruct.getRootDirectory(), path);
  -        if (child == null || !child.exists())
  +        if (child == null)             
           {
               throw new FileNotFoundException("Unable to locate file or path " + 
child);
           }
  -
           FileOutputStream fileOutputStream = new FileOutputStream(child);
           openedResources.add(fileOutputStream);
           return fileOutputStream;
  @@ -466,10 +473,29 @@
                   }
               });
   
  -            webXmlIn = getInputStream(WEB_XML_PATH);
  -            Document doc = builder.build(webXmlIn);
  -
  -            webXmlIn.close();
  +            Document doc = null;
  +            
  +            try
  +            {
  +                webXmlIn = getInputStream(WEB_XML_PATH);
  +                doc = builder.build(webXmlIn);
  +            }
  +            catch (FileNotFoundException fnfe)
  +            {
  +                // web.xml does not exist, create it
  +                File file = File.createTempFile("j2-temp-", ".xml");
  +                FileWriter writer = new FileWriter(file);
  +                writer.write(WEB_XML_STRING);
  +                writer.close();
  +                doc = builder.build(file);
  +                file.delete();
  +            }
  +            
  +            
  +            if (webXmlIn != null)
  +            {
  +                webXmlIn.close();
  +            }
   
   
               JetspeedWebApplicationRewriter rewriter = new 
JetspeedWebApplicationRewriter(doc);
  @@ -488,6 +514,7 @@
           }
           catch (Exception e)
           {
  +            e.printStackTrace();
               throw new MetaDataException("Unable to process web.xml for infusion " + 
e.toString(), e);
           }
           finally
  
  
  

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

Reply via email to