Class UpFile

java.lang.Object
overit.geocall.util.UpFile
All Implemented Interfaces:
DataSource, ReferenceOwner

public class UpFile extends Object implements DataSource, ReferenceOwner
Utility class used to manage an uploaded file
  • Field Details

    • part

      protected Part part
    • fileName

      protected String fileName
    • MULTI_PART_FILE_SIZE_THRESHOLD

      public static final int MULTI_PART_FILE_SIZE_THRESHOLD
      See Also:
    • _ufiss

      protected HashSet<InputStream> _ufiss
      Keeps the UpFileInputStreams so at the end of transaction they can be closed.
    • _error

      protected String _error
  • Constructor Details

    • UpFile

      public UpFile(Part part)
      Creates a new instance of UpFile
      Parameters:
      part - The Part
    • UpFile

      public UpFile(InputStream inputStream, String contentType, String name, long size)
      Creates a new instance of UpFile starting from an inputStream
      Parameters:
      inputStream - stream containing the file's content
      contentType - the content type of this stream
      name - the name of this stream
      size - the file size in byte
  • Method Details

    • setError

      public void setError(String error)
      Setst the error
      Parameters:
      error - String containing the error
    • getContentType

      public String getContentType()
      Specified by:
      getContentType in interface DataSource
    • getName

      public String getName()
      Specified by:
      getName in interface DataSource
    • setName

      public void setName(String n)
      Sets the name of the file
      Parameters:
      n - String containing the name of the file
    • getFileSize

      public long getFileSize()
      Returns the size of the file
      Returns:
      The size of the file
    • isValid

      public boolean isValid()
      Check if the file is valid, have a not null name and its not ""
      Returns:
      true if the file is valid, false otherwise
    • getError

      public String getError()
      If the file isValid() returns the string containing the error, otherwise return null
      Returns:
      If the file isValid() returns the string containing the error, otherwise return null
    • getInputStream

      public InputStream getInputStream() throws IOException
      Specified by:
      getInputStream in interface DataSource
      Throws:
      IOException
    • writeTo

      public void writeTo(File f) throws Exception
      Throws:
      Exception
    • writeTo

      public void writeTo(OutputStream os) throws IOException
      Throws:
      IOException
    • dispose

      public void dispose() throws IOException
      Method used to close the input stream and to delete the DiskFileItem
      Throws:
      IOException - if an I/O exception occurs
    • finalize

      protected void finalize() throws Throwable
      Overrides:
      finalize in class Object
      Throws:
      Throwable
    • getOutputStream

      public OutputStream getOutputStream()
      Specified by:
      getOutputStream in interface DataSource
    • toString

      public String toString()
      Overrides:
      toString in class Object