javazoom.download
Class DownloadImpl

java.lang.Object
  |
  +--javazoom.download.DownloadImpl

public class DownloadImpl
extends java.lang.Object

This class is the core of Download4J.
It instanciates the Debug object for traces.
It instanciates the Config object matching to XML configuration file.
It reads mime-types from XML file.
It checks data availability
It checks for WWW authentication
It checks for download hits limit
It sets the returning Content-Type
It runs the download in the incoming thread
It counts download hits
It runs as a singleton


Field Summary
static int DATABASE
           
static java.lang.String DEFAULTCONTENTDISPOSITION
          Default content-disposition : ""
static java.lang.String DEFAULTCONTENTTYPE
          Default content-type for unknown extensions : application/unknown
static int FOLDER
           
static java.lang.String LOGFILEDATEFORMAT
          Default log file date format : -yyyy-MM-dd_HH-mm
static java.lang.String LOGFILEEXTENSION
          Default log file extension : .log
static java.lang.String LOGFILENAME
          Default log file prefix : download4j
static java.lang.String REALM
          HTTP Realm name for Download4J, Default is Download4J Realm
static int UNKNOWN
           
static int ZIP
           
static java.lang.String ZIPCONTENTTYPE
          Default content-type for zip files : application/zip
 
Constructor Summary
DownloadImpl(java.lang.String configpath, java.lang.String xmlconfig, DownloadListener listener)
          Constructs and initializes Download4J.
 
Method Summary
 int checkAuth(java.lang.String base64auth, FileInfo fi)
          Checks WWW authentication for FileInfo.
 int checkAuth(java.lang.String base64auth, java.lang.String login, java.lang.String password)
          Checks WWW authentication for input login/password.
 void download(FileInfo fi, java.io.OutputStream out)
          Downloads file (in the incoming thread) and sends binary data to user's outputstream.
 int getDataLength(FileInfo fi)
          Checks if data available are for download.
 void process(java.lang.String filename, java.util.Properties HttpProps, javax.servlet.http.HttpServletResponse response)
          Runs download in the incoming thread.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

REALM

public static java.lang.String REALM
HTTP Realm name for Download4J, Default is Download4J Realm


DEFAULTCONTENTTYPE

public static java.lang.String DEFAULTCONTENTTYPE
Default content-type for unknown extensions : application/unknown


ZIPCONTENTTYPE

public static java.lang.String ZIPCONTENTTYPE
Default content-type for zip files : application/zip


DEFAULTCONTENTDISPOSITION

public static java.lang.String DEFAULTCONTENTDISPOSITION
Default content-disposition : ""


LOGFILENAME

public static java.lang.String LOGFILENAME
Default log file prefix : download4j


LOGFILEEXTENSION

public static java.lang.String LOGFILEEXTENSION
Default log file extension : .log


LOGFILEDATEFORMAT

public static java.lang.String LOGFILEDATEFORMAT
Default log file date format : -yyyy-MM-dd_HH-mm


UNKNOWN

public static int UNKNOWN

FOLDER

public static int FOLDER

ZIP

public static int ZIP

DATABASE

public static int DATABASE
Constructor Detail

DownloadImpl

public DownloadImpl(java.lang.String configpath,
                    java.lang.String xmlconfig,
                    DownloadListener listener)
             throws org.xml.sax.SAXException,
                    javax.xml.parsers.ParserConfigurationException,
                    java.io.IOException
Constructs and initializes Download4J.

Parameters:
configpath - to xmlconfig file
xmlconfig - file to read and parse
listener - to notify
Throws:
org.xml.sax.SAXException
javax.xml.parsers.ParserConfigurationException
java.io.IOException
Method Detail

process

public void process(java.lang.String filename,
                    java.util.Properties HttpProps,
                    javax.servlet.http.HttpServletResponse response)
             throws java.io.IOException
Runs download in the incoming thread.

Parameters:
filename - to download
HttpProps - Http Properties as login/password, IP address
response - for each end-user
Throws:
java.io.IOException

checkAuth

public int checkAuth(java.lang.String base64auth,
                     FileInfo fi)
Checks WWW authentication for FileInfo.

Parameters:
base64auth - base64 encoded login:password
fi - FileInfo
Returns:
0=OK, 1=NOT OK, -1=Not authentication needed.

checkAuth

public int checkAuth(java.lang.String base64auth,
                     java.lang.String login,
                     java.lang.String password)
Checks WWW authentication for input login/password.

Parameters:
base64auth - WWW authentication
login - to check
password - to check
Returns:
0=OK, 1=NOT OK, -1=Not authentication needed.

getDataLength

public int getDataLength(FileInfo fi)
Checks if data available are for download.

Parameters:
fi - FileInfo
Returns:
file's length or -1 if file is not found or not readable.

download

public void download(FileInfo fi,
                     java.io.OutputStream out)
              throws java.io.IOException
Downloads file (in the incoming thread) and sends binary data to user's outputstream.

Parameters:
fi - Input FileInfo
out - user's outputstream
Throws:
java.io.IOException