miless.webservices
Class FileService

java.lang.Object
  extended by miless.webservices.FileService

public class FileService
extends Object

Implements web service methods to create/update/delete derivates and files.

Version:
$Revision: 15128 $ $Date: 2009-04-30 15:25:35 +0200 (Thu, 30 Apr 2009) $
Author:
Frank L´┐Żtzenkirchen

Constructor Summary
FileService()
           
 
Method Summary
 int createFileDerivate(int documentID)
          Creates a new, empty internal derivate for the given document
 int createLinkDerivate(int documentID, String url)
          Creates a new, external derivate for the given document.
 void deleteDerivate(int derivateID)
          Deletes a derivate and all its files
 void deleteFile(int derivateID, String path)
          Deletes a file from an internal derivate
 boolean derivateExists(int derivateID)
          Checks if a derivate exists
 boolean fileExists(int derivateID, String path)
          Checks if a file within a derivate exists.
 Document getDerivateData(int derivateID)
          Returns the data of a derivate and all its files as XML document.
 String startUpload(int documentID, int derivateID, String returnURL)
          Starts a new file upload session that can be used in combination with the MyCoRe upload applet.
 String storeFile(int derivateID, String path, String uri)
          Creates a new file or updates an existing file.
 int storeZipFileContents(int derivateID, String uri)
          Creates new files or updates existing files from the contents of a zip file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileService

public FileService()
Method Detail

createFileDerivate

public int createFileDerivate(int documentID)
                       throws Exception
Creates a new, empty internal derivate for the given document

Parameters:
documentID - the ID of the document
Returns:
the ID of the newly created derivate
Throws:
Exception

createLinkDerivate

public int createLinkDerivate(int documentID,
                              String url)
                       throws Exception
Creates a new, external derivate for the given document.

Parameters:
documentID - the ID of the document
url - the URL this derivate links to (web address)
Returns:
the ID of the newly created derivate
Throws:
Exception

deleteDerivate

public void deleteDerivate(int derivateID)
                    throws Exception
Deletes a derivate and all its files

Parameters:
derivateID - the ID of the derivate to be deleted
Throws:
Exception

getDerivateData

public Document getDerivateData(int derivateID)
                         throws Exception
Returns the data of a derivate and all its files as XML document. For the XML schema, see class miless.datamodel.XMLExporter.

Parameters:
derivateID - the ID of the derivate
Returns:
a W3C DOM document containing all derivate data
Throws:
Exception

storeFile

public String storeFile(int derivateID,
                        String path,
                        String uri)
                 throws Exception
Creates a new file or updates an existing file. This method allows to upload file contents from the given URI, which is in Apache Commons VFS syntax. See http://jakarta.apache.org/commons/vfs/filesystems.html Here are some samples for the URI syntax: Local filesystem (just for testing locally running server): [file://]/absolute-path HTTP Server: http://[username[:password]@]hostname[:port][/absolute-path] FTP Server: ftp://[username[:password]@]hostname[:port][/absolute-path] SFTP / SCP / SSH Server: sftp://[username[:password]@]hostname[:port][/absolute-path] CIFS / Samba / Windows share: smb://[username[:password]@]hostname[:port][/absolute-path]

Parameters:
derivateID - the ID of the internal derivate
path - the target path (filename) for the new file
uri - the uri where to import the file content from
Returns:
the MD5 checksum that has been built while uploading file content
Throws:
Exception

storeZipFileContents

public int storeZipFileContents(int derivateID,
                                String uri)
                         throws Exception
Creates new files or updates existing files from the contents of a zip file. This method allows to upload zip file contents from the given URI, which is in Apache Commons VFS syntax. See http://jakarta.apache.org/commons/vfs/filesystems.html Here are some samples for the URI syntax: Local filesystem (just for testing locally running server): [file://]/absolute-path HTTP Server: http://[username[:password]@]hostname[:port][/absolute-path] FTP Server: ftp://[username[:password]@]hostname[:port][/absolute-path] SFTP / SCP / SSH Server: sftp://[username[:password]@]hostname[:port][/absolute-path] CIFS / Samba / Windows share: smb://[username[:password]@]hostname[:port][/absolute-path]

Parameters:
derivateID - the ID of the internal derivate
uri - the uri where to import the zip file from
Returns:
the number of files stored from the zip file
Throws:
Exception

derivateExists

public boolean derivateExists(int derivateID)
                       throws Exception
Checks if a derivate exists

Parameters:
derivateID - the ID of the derivate
Returns:
true, if the derivate exists, false otherwise
Throws:
Exception

fileExists

public boolean fileExists(int derivateID,
                          String path)
                   throws Exception
Checks if a file within a derivate exists.

Parameters:
derivateID - the ID of the derivate
path - the file's path and filename
Returns:
true, if the file exists, false otherwise
Throws:
Exception

deleteFile

public void deleteFile(int derivateID,
                       String path)
                throws Exception
Deletes a file from an internal derivate

Parameters:
derivateID - the ID of the derivate
path - the file's path and filename
Throws:
Exception

startUpload

public String startUpload(int documentID,
                          int derivateID,
                          String returnURL)
                   throws Exception
Starts a new file upload session that can be used in combination with the MyCoRe upload applet. Calling this method returns a new upload session ID. This ID must be given to the applet, that can be started from a remote webpage. After upload is done, the applet returns the browser to the given url.

Parameters:
documentID - the ID of the document
derivateID - the ID of an existing internal derivate, or 0 if a new derivate should be created
returnURL - the URL the applet should return to after upload is done
Returns:
the upload session ID needed to start the applet
Throws:
Exception