Login | Register
My pages Projects Community openCollabNet

Discussions > cvs > CVS update: joist/java/org/joist/util FileUpload.java RenameableFileUpload.java

Project highlights: Architectural Overview

joist
Discussion topic

Back to topic list

CVS update: joist/java/org/joist/util FileUpload.java RenameableFileUpload.java

Author dlr
Full name Daniel Rall
Date 2000-11-13 14:22:40 PST
Message User: dlr
  Date: 00/11/13 14:22:40

  Modified: java/org/joist/util FileUpload.java
                        RenameableFileUpload.java
  Log:
  Additional cleanup to make more utility-like.
  
  Revision Changes Path
  1.10 +28 -35 joist/java/org/joist​/util/FileUpload.jav​a
  
  Index: FileUpload.java
  ====================​====================​====================​=======
  RCS file: /cvs/joist/java/org/​joist/util/FileUploa​d.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- FileUpload.java 2000/11/13 22:07:21 1.9
  +++ FileUpload.java 2000/11/13 22:22:39 1.10
  @@ -73,7 +73,7 @@
    * This class is <i>not</i> thread-safe.
    *
    * @author <a href="mailto:dlr@col​lab.net">Daniel L. Rall</a>
  - * @version $Id: FileUpload.java,v 1.9 2000/11/13 22:07:21 dlr Exp $
  + * @version $Id: FileUpload.java,v 1.10 2000/11/13 22:22:39 dlr Exp $
    *
    * Copyright (c) 2000 CollabNet, Inc.
    */
  @@ -113,16 +113,15 @@
        * implement the interface of UnsecureServlet.
        * @param ctx The WebContext used by this request.
        * @param props The misc. information used by this file upload.
  - * @return The name of the template to use.
  + * @return The name of the template to use.
        *
  - * @exception HandlerException
  - * @exception RedirectException
  + * @exception JoistException
        */
  - public FileUpload (Connection conn, WebContext context, Properties props)
  - throws Exception
  + public FileUpload (Connection conn, WebContext ctx, Properties props)
  + throws JoistException
       {
           this.myProperties = props;
  - String contentType = context.getRequest()​.getContentType();
  + String contentType = ctx.getRequest().get​ContentType();
   
           // If the content type is not equal to REQ_CONTENT_TYPE, just display
           // the UI. Otherwise, also attempt to process a HTTP file upload.
  @@ -131,30 +130,26 @@
               try
               {
                   // Parse and save the uploaded files.
  - MultipartRequest mreq = getMultipartRequest(context);
  + MultipartRequest mreq = getMultipartRequest(ctx);
   
                   // Get file handles and do any extra processing.
  - this.files = processUploadedFiles(conn, context, mreq);
  + this.files = processUploadedFiles(conn, ctx, mreq);
   
                   // Set permissions appropriately.
                   setFilesystemPermissions();
  -
  - // Add references to the saved files to the WebContext.
  - context.put("fileNames", files);
               }
  - catch (JoistException e)
  - {
  - log.exception(e);
  - }
               catch (IOException e)
               {
                   log.exception(e);
  + throw new JoistException(e.getMessage());
               }
           }
           else
           {
  - log.warning("Content type not specified or invalid: " +
  - contentType);
  + String errMsg = "Content type not specified or invalid: " +
  + contentType;
  + log.warning(errMsg);
  + throw new JoistException(errMsg);
           }
       }
   
  @@ -172,39 +167,37 @@
       /**
        * Performs the desired save activities.
        *
  - * @param context The context of user interaction.
  - * @return The multipart request.
  + * @param ctx The context of user interaction.
  + * @return The multipart request.
        *
        * @exception IOException
        */
  - protected MultipartRequest getMultipartRequest (WebContext context)
  + protected MultipartRequest getMultipartRequest (WebContext ctx)
           throws IOException
       {
  - return new MultipartRequest(con​text.getRequest(), getSaveDirectory());
  + return new MultipartRequest(ctx​.getRequest(), getSaveDirectory());
       }
   
       /**
        * Performs the desired save activities.
        *
  - * @param context The context of user interaction.
  + * @param ctx The context of user interaction.
        * @param maxPostSize The maximum size of the post.
        * @return The multipart request.
        *
        * @exception IOException
        */
  - protected MultipartRequest getMultipartRequest (WebContext context,
  + protected MultipartRequest getMultipartRequest (WebContext ctx,
                                                       int maxPostSize)
           throws IOException
       {
  - return new MultipartRequest(con​text.getRequest(),
  + return new MultipartRequest(ctx​.getRequest(),
                                       getSaveDirectory(),
                                       maxPostSize);
       }
   
       /**
  - * Sets the file system permissions for the specified files.
  - *
  - * @param files The Vector of File objects to set permissions for.
  + * Sets the file system permissions for uploaded, saved files.
        *
        * @exception JoistException
        */
  @@ -223,7 +216,7 @@
               cmd.append("chmod ").append(perms).append(' ');
               cmd.append(path);
   
  - if (debug) log.debug("Path to file is '" + path + '\'');
  + if (debug) log.info("Path to file is '" + path + '\'');
   
               // Execute the command.
               try
  @@ -232,19 +225,19 @@
                   if (p.waitFor() != 0)
                   {
                       // Command did not execute successfully.
  - throw new JoistException("File​Upload.setFilesystem​" +
  - "Permissions: Could not change " +
  - "permissions for file '" + path +
  - '\'');
  + throw new JoistException("Could not change permissions " +
  + "for file '" + path + '\'');
                   }
               }
               catch (InterruptedException e)
               {
                   log.exception(e);
  + throw new JoistException(e.getMessage());
               }
               catch (IOException e)
               {
                   log.exception(e);
  + throw new JoistException(e.getMessage());
               }
   
               // Be ready for the next one!
  @@ -259,8 +252,8 @@
        * @param conn The JDBC database connection to use.
        * @param mreq The MultipartRequest to use.
        * @param ctx The WebContext to use.
  - * @return The <code>File</code> objects the uploaded files were
  - * saved as.
  + * @return The <code>File</code> objects the uploaded files were saved
  + * as.
        */
       protected List processUploadedFiles (Connection conn, WebContext ctx,
                                            MultipartRequest mreq)
  
  
  
  1.8 +10 -7 joist/java/org/joist​/util/RenameableFile​Upload.java
  
  Index: RenameableFileUpload.java
  ====================​====================​====================​=======
  RCS file: /cvs/joist/java/org/​joist/util/Renameabl​eFileUpload.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- RenameableFileUpload.java 2000/11/13 22:06:50 1.7
  +++ RenameableFileUpload.java 2000/11/13 22:22:39 1.8
  @@ -68,7 +68,7 @@
    * the file is on a different partition or physical disk.
    *
    * @author <a href="mailto:dlr@col​lab.net">Daniel L. Rall</a>
  - * @version $Id: RenameableFileUpload.java,v 1.7 2000/11/13 22:06:50 dlr Exp $
  + * @version $Id: RenameableFileUpload.java,v 1.8 2000/11/13 22:22:39 dlr Exp $
    *
    * Copyright (c) 2000 Collab.Net, Inc.
    */
  @@ -84,9 +84,12 @@
        */
       private static final boolean debug = false;
   
  + /**
  + * Creates a new instance. Does nothing more than invoke super class ctor.
  + */
       public RenameableFileUpload (Connection conn, WebContext ctx,
                                    Properties props)
  - throws Exception
  + throws JoistException
       {
           super(conn, ctx, props);
       }
  @@ -95,10 +98,10 @@
        * Performs any additional processing that may be desired, then returns
        * the names that the uploaded files were saved as.
        *
  - * @param conn The JDBC connection to use.
  - * @param mreq The MultipartRequest to use.
  - * @param context The context of user interaction.
  - * @return The File objects the uploaded files were saved as.
  + * @param conn The JDBC connection to use.
  + * @param mreq The MultipartRequest to use.
  + * @param ctx The context of user interaction.
  + * @return The File objects the uploaded files were saved as.
        */
       protected List processUploadedFiles (Connection conn, WebContext ctx,
                                            MultipartRequest mreq)
  @@ -127,7 +130,7 @@
        * @param conn The JDBC connection to use.
        * @param ctx The context of user interaction.
        * @param clntFname The client supplied file name.
  - * @return The name to save the file as.
  + * @return The name to save the file as.
        */
       protected abstract String getSaveAsFileName (Connection conn,
                                                    WebContext ctx,

« Previous message in topic | 1 of 1 | Next message in topic »

Messages

Show all messages in topic

CVS update: joist/java/org/joist/util FileUpload.java RenameableFileUpload.java dlr Daniel Rall 2000-11-13 14:22:40 PST
Messages per page: