rineholt    02/02/04 12:19:06

  Modified:    java/src/org/apache/axis AxisEngine.java MessageContext.java
               java/src/org/apache/axis/attachments
                        ManagedMemoryDataSource.java
               java/src/org/apache/axis/server
                        DefaultAxisServerFactory.java
               java/src/org/apache/axis/transport/http AxisServlet.java
  Log:
  Allows directory used to store attachments to be specified.
  As a client the directory is specified in the following most overriding order:
    in messageContext.setProperty(MessageContext.ATTACHMENTS_DIR, <dir>);
    java system property "axis.attachments.Directory"
    client.wsdd file, globalConfiguration attachments.Directory parameter.
    java temporary file dir.
  
  As a servlet:
    in messageContext.setProperty(MessageContext.ATTACHMENTS_DIR, <dir>);
    java system property "axis.attachments.Directory"
    Servlet init parameter: "axis.attachments.Directory"
    Server.wsdd file, globalConfiguration attachments.Directory parameter.
    Servlet app path with "attachments" appended.
  
  Revision  Changes    Path
  1.66      +2 -0      xml-axis/java/src/org/apache/axis/AxisEngine.java
  
  Index: AxisEngine.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/AxisEngine.java,v
  retrieving revision 1.65
  retrieving revision 1.66
  diff -u -r1.65 -r1.66
  --- AxisEngine.java   28 Jan 2002 18:22:59 -0000      1.65
  +++ AxisEngine.java   4 Feb 2002 20:19:05 -0000       1.66
  @@ -97,6 +97,8 @@
       public static final String PROP_PASSWORD = "adminPassword";
       public static final String PROP_SYNC_CONFIG = "syncConfiguration";
       public static final String PROP_SEND_XSI = "sendXsiTypes";
  +    public static final String PROP_ATTACHMENT_DIR = "attachments.Directory";
  +    public static final String PROP_ATTACHMENT_CLEANUP = 
"attachment.DirectoryCleanUp";
   
       // Default admin. password
       private static final String DEFAULT_ADMIN_PASSWORD = "admin";
  
  
  
  1.70      +31 -0     xml-axis/java/src/org/apache/axis/MessageContext.java
  
  Index: MessageContext.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/MessageContext.java,v
  retrieving revision 1.69
  retrieving revision 1.70
  diff -u -r1.69 -r1.70
  --- MessageContext.java       1 Feb 2002 04:12:28 -0000       1.69
  +++ MessageContext.java       4 Feb 2002 20:19:06 -0000       1.70
  @@ -63,6 +63,7 @@
   import org.apache.log4j.Category;
   
   import java.util.Hashtable;
  +import java.io.File;
   
   /**
    * Some more general docs will go here.
  @@ -169,9 +170,36 @@
       public static MessageContext getCurrentContext() {
          return AxisEngine.getCurrentMessageContext();
       }
  +    protected static String systemTempDir= null;
  +    static {
  +            try{
  +                systemTempDir=System.getProperty("axis.attachments.Directory");
  +            } catch(Throwable t){systemTempDir= null;} 
  +
  +            if(systemTempDir== null)   
  +                try{
  +                    File tf= File.createTempFile("Axis", "Axis");
  +                    File dir= tf.getParentFile();
  +                    if(tf.exists()) tf.delete(); 
  +                    if(dir != null){
  +                      systemTempDir= dir.getCanonicalPath();
  +                    }
  +                }catch(Throwable t){systemTempDir= null;}
  +    }
   
       public MessageContext(AxisEngine engine) {
           this.axisEngine = engine;
  +
  +        if(null != engine){
  +            java.util.Hashtable opts= engine.getOptions();        
  +            String attachmentsdir= null;
  +            if(null!=opts) attachmentsdir= (String)
  +                opts.get(AxisEngine.PROP_ATTACHMENT_DIR);
  +            if(null == attachmentsdir) attachmentsdir= systemTempDir; 
  +            if(attachmentsdir != null){
  +                setProperty(ATTACHMENTS_DIR, attachmentsdir);
  +            }
  +        }
       }
       
       /**
  @@ -453,6 +481,9 @@
     
       /** If on the client - this is the Call object */
       public static String CALL                = "call_object" ;
  +
  +    /** The directory where in coming attachments are created. */
  +    public static String ATTACHMENTS_DIR   = "attachments.directory" ;
   
       /** Just a util so we don't have to cast the result
        */
  
  
  
  1.7       +6 -1      
xml-axis/java/src/org/apache/axis/attachments/ManagedMemoryDataSource.java
  
  Index: ManagedMemoryDataSource.java
  ===================================================================
  RCS file: 
/home/cvs/xml-axis/java/src/org/apache/axis/attachments/ManagedMemoryDataSource.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- ManagedMemoryDataSource.java      23 Dec 2001 14:52:36 -0000      1.6
  +++ ManagedMemoryDataSource.java      4 Feb 2002 20:19:06 -0000       1.7
  @@ -56,6 +56,8 @@
   package org.apache.axis.attachments;
   import org.apache.log4j.Category;
   import org.apache.axis.InternalException;
  +import org.apache.axis.MessageContext; 
  +import java.io.File; 
   
   /**
    * @author Rick Rineholt 
  @@ -306,7 +308,10 @@
          if( ml != null){
              if (null == cachediskstream) { //Need to create a disk cache
                   try{
  -                    diskCacheFile = java.io.File.createTempFile("Axis", "axis"); 
//Create a temporary file. TODO allow location to be configurable.
  +                    MessageContext mc= MessageContext.getCurrentContext();
  +                    String attdir= mc == null ? null :  
mc.getStrProp(MessageContext.ATTACHMENTS_DIR );
  +                    diskCacheFile = java.io.File.createTempFile("Axis", "axis",
  +                       attdir== null ? null : new File( attdir)); 
                       category.debug("Disk cache file name \"" + diskCacheFile 
.getAbsolutePath()+ "\".");
                       cachediskstream = new java.io.BufferedOutputStream(
                            new java.io.FileOutputStream(diskCacheFile));
  
  
  
  1.5       +29 -1     
xml-axis/java/src/org/apache/axis/server/DefaultAxisServerFactory.java
  
  Index: DefaultAxisServerFactory.java
  ===================================================================
  RCS file: 
/home/cvs/xml-axis/java/src/org/apache/axis/server/DefaultAxisServerFactory.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- DefaultAxisServerFactory.java     30 Jan 2002 16:19:11 -0000      1.4
  +++ DefaultAxisServerFactory.java     4 Feb 2002 20:19:06 -0000       1.5
  @@ -3,11 +3,13 @@
   import org.apache.axis.EngineConfiguration;
   import org.apache.axis.AxisFault;
   import org.apache.axis.Constants;
  +import org.apache.axis.AxisEngine;
   import org.apache.axis.configuration.FileProvider;
   
   import javax.naming.InitialContext;
   import javax.naming.NamingException;
   import java.util.Map;
  +import java.io.File;
   
   /**
    * Helper class for obtaining AxisServers.  Default implementation.
  @@ -35,8 +37,34 @@
           } catch (ClassCastException e) {
               // Just in case, fall through here.
           }
  +
           
  -        return createNewServer(config);
  +        AxisServer ret= createNewServer(config);
  +
  +        String attachmentsdirservlet=  null;
  +        if( null != ret &&  environment != null ){
  +          if( null !=  (attachmentsdirservlet= (String) 
  +                environment.get("axis.attachments.Directory"))){
  +              ret.setOption(AxisEngine.PROP_ATTACHMENT_DIR,
  +               attachmentsdirservlet);
  +          }
  +          if(null == (attachmentsdirservlet= (String)
  +                ret.getOption(AxisEngine.PROP_ATTACHMENT_DIR))){
  +              if( null !=  (attachmentsdirservlet= (String) 
  +                  environment.get("servlet.realpath"))){
  +                 ret.setOption(AxisEngine.PROP_ATTACHMENT_DIR, 
attachmentsdirservlet);
  +              }
  +          }    
  +        }
  +        if(ret != null){
  +            attachmentsdirservlet= (String) 
ret.getOption(AxisEngine.PROP_ATTACHMENT_DIR);
  +            File attdirFile= new File(attachmentsdirservlet);
  +            if( !attdirFile.isDirectory()){
  +                      attdirFile.mkdirs();
  +            }
  +        }
  +
  +        return ret;
       }
   
       /**
  
  
  
  1.74      +5 -0      
xml-axis/java/src/org/apache/axis/transport/http/AxisServlet.java
  
  Index: AxisServlet.java
  ===================================================================
  RCS file: 
/home/cvs/xml-axis/java/src/org/apache/axis/transport/http/AxisServlet.java,v
  retrieving revision 1.73
  retrieving revision 1.74
  diff -u -r1.73 -r1.74
  --- AxisServlet.java  4 Feb 2002 14:51:58 -0000       1.73
  +++ AxisServlet.java  4 Feb 2002 20:19:06 -0000       1.74
  @@ -175,6 +175,11 @@
   
               Map environment = new HashMap();
               environment.put("servletContext", context);
  +            String attdir= getInitParameter("axis.attachments.Directory");
  +            if(attdir != null) environment.put("axis.attachments.Directory",  
attdir);
  +            if(null != webInfPath){
  +                environment.put("servlet.realpath",  webInfPath + File.separator + 
"attachments");
  +            }
               environment.put(EngineConfiguration.PROPERTY_NAME, provider);
   
               // Obtain an AxisServer by using whatever AxisServerFactory is
  
  
  


Reply via email to