|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectsimple.http.serve.Component
simple.http.load.Service
trackerBT.UploadService
public class UploadService
Service called to upload a torrent file to the tracker
Titre : TrackerBT
Description : Bittorrent Tracker
Copyright : Copyright (c) 2007
Field Summary | |
---|---|
(package private) org.jdom.Document |
torrents
|
Fields inherited from class simple.http.load.Service |
---|
engine |
Fields inherited from class simple.http.serve.Component |
---|
context |
Constructor Summary | |
---|---|
UploadService(simple.http.serve.Context context)
Default constructor needed by Simple server |
Method Summary | |
---|---|
private void |
addTorrent(org.jdom.Element root,
java.lang.String name,
java.lang.String infoFile,
java.lang.String comment,
java.lang.String hash)
Add a torrent to the torrent database according to the given parameters |
private void |
createEmptyTrackerXML(java.io.File xmlTorrent)
Create new XML document for registering torrents |
private byte[] |
generateResponse(int id)
Generate the html file bytes representing the answer. |
private boolean |
isNewTorrent(org.jdom.Element root,
java.lang.String hash)
Look if the torrent is already registered on this tracker |
private java.util.Map |
mapParameters(java.util.List l)
Creates a Map representing the parameters listed in l |
void |
process(simple.http.Request req,
simple.http.Response resp)
Process the client upload request and returns the corresponding answer. |
private java.util.List |
processRequest(simple.http.Request req)
Process the request and retrieves the parameters and file contained in it. |
int |
registerTorrent(java.lang.String name,
java.lang.String infoFile,
java.lang.String comment,
java.lang.String hash)
Try to register the torrent given with the parameters |
Methods inherited from class simple.http.load.Service |
---|
prepare |
Methods inherited from class simple.http.serve.Component |
---|
handle, handle, handle, process, process |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
org.jdom.Document torrents
Constructor Detail |
---|
public UploadService(simple.http.serve.Context context)
context
- The context of the serverMethod Detail |
---|
private void addTorrent(org.jdom.Element root, java.lang.String name, java.lang.String infoFile, java.lang.String comment, java.lang.String hash)
root
- Root element of the XML document representing the torrents databasename
- Name of the torrentinfoFile
- Name of an optional info file (.nfo, .txt, ...)comment
- Comment about the torrenthash
- Torrent id. It is the hash of the 'info' dictionary in the torrentprivate void createEmptyTrackerXML(java.io.File xmlTorrent) throws java.io.IOException
xmlTorrent
- The file the document will be saved in
java.io.IOException
private byte[] generateResponse(int id)
id
- Represent the response status. 0 means upload was successful.
Otherwise id represent the kind of error that occured and a corresponding
answer is created.
private boolean isNewTorrent(org.jdom.Element root, java.lang.String hash)
root
- Root element of the XML document representing the torrent databasehash
- Id of the file being uploaded
private java.util.Map mapParameters(java.util.List l)
l
- List The list of parameters
public void process(simple.http.Request req, simple.http.Response resp) throws java.io.IOException
process
in class simple.http.serve.Component
req
- The request received from the client. It must be a multipart data-form type requestresp
- HTML file representing the result of the request
java.io.IOException
private java.util.List processRequest(simple.http.Request req)
req
- The received request
public int registerTorrent(java.lang.String name, java.lang.String infoFile, java.lang.String comment, java.lang.String hash)
name
- Name of the torrentinfoFile
- Potential info file namecomment
- Comment about the torrenthash
- Torrent id
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |