com.jurismarches.vradi.services
Class FileServiceProxy

java.lang.Object
  extended by com.jurismarches.vradi.services.FileServiceProxy
All Implemented Interfaces:
FileService

public class FileServiceProxy
extends java.lang.Object
implements FileService

This proxy can handle i/o API and manage file upload on servlet. FileService -> FileServiceProxy -> FileServlet -> FileServiceImpl. Based on commons http client. Principe:

Version:
$Revision: 1275 $ Last update : $Date: 2010-09-06 16:50:04 +0200 (lun., 06 sept. 2010) $ By : $Author: chatellier $
Author:
chatellier

Field Summary
protected  java.lang.String serviceEndpoint
          Remote service endpoint.
 
Constructor Summary
FileServiceProxy(java.lang.String serviceEndpoint)
          Constructor with remote service endpoint.
 
Method Summary
protected  java.lang.String buildUrl(java.lang.String endpoint, java.lang.String... additionalParams)
          Build post url.
protected  java.io.File downloadFile(java.lang.String fileUrl)
           
 java.io.File downloadFormAttachment(java.lang.String uri)
          Download file.
 java.io.File downloadFormEmbeddedFile(java.lang.String uri)
          Download file.
 java.io.File downloadPDF(java.lang.String uri)
          Download pdf file.
 java.io.File downloadRequestHistory(java.lang.String uri)
          Download request histiory file.
 java.io.File downloadTemplate(java.lang.String extensionName, java.lang.String templateName)
          Download file.
 java.io.File downloadWebHarvestScript(java.lang.String uri)
          Download file.
 java.lang.String getRequestHistoryURL(java.lang.String uri)
          Download request histiory file.
protected  java.lang.String uploadFile(java.io.File file, java.lang.String postUrl)
           
 java.lang.String uploadFormAttachment(java.io.File file, java.lang.String formId)
          Upload a form attachment.
 java.lang.String uploadFormEmbeddedFile(java.io.File file, java.lang.String formId)
          Upload a form attachement.
 java.lang.String uploadTempFile(java.io.File file)
          Upload a temporary file (for example for export).
 java.lang.String uploadTemplate(java.io.File file, java.lang.String extensionName)
          Upload a template on server.
 java.lang.String uploadWebHarvestScript(java.io.File file)
          Upload a web harvest script on server.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

serviceEndpoint

protected java.lang.String serviceEndpoint
Remote service endpoint. Endpoint is http://xxx/vradi/file

Constructor Detail

FileServiceProxy

public FileServiceProxy(java.lang.String serviceEndpoint)
Constructor with remote service endpoint.

Parameters:
serviceEndpoint - remote service endpoint
Method Detail

uploadTemplate

public java.lang.String uploadTemplate(java.io.File file,
                                       java.lang.String extensionName)
                                throws VradiException
Description copied from interface: FileService
Upload a template on server.

Specified by:
uploadTemplate in interface FileService
Parameters:
file - file to upload
extensionName - extension name to put file into
Returns:
file uri to reference file
Throws:
VradiException - throw VradiException if exception is occured

uploadWebHarvestScript

public java.lang.String uploadWebHarvestScript(java.io.File file)
                                        throws VradiException
Description copied from interface: FileService
Upload a web harvest script on server.

Specified by:
uploadWebHarvestScript in interface FileService
Parameters:
file - file to upload
Returns:
file uri to reference file
Throws:
VradiException - throw VradiException if exception is occured

uploadFormAttachment

public java.lang.String uploadFormAttachment(java.io.File file,
                                             java.lang.String formId)
                                      throws VradiException
Description copied from interface: FileService
Upload a form attachment.

Specified by:
uploadFormAttachment in interface FileService
Parameters:
file - file to upload
formId - form id
Returns:
file uri to reference file
Throws:
VradiException - if an exception occurred

uploadTempFile

public java.lang.String uploadTempFile(java.io.File file)
                                throws VradiException
Description copied from interface: FileService
Upload a temporary file (for example for export).

Specified by:
uploadTempFile in interface FileService
Parameters:
file - The file to upload
Returns:
an absolute URI on server file system
Throws:
VradiException - if an exception occurred

uploadFormEmbeddedFile

public java.lang.String uploadFormEmbeddedFile(java.io.File file,
                                               java.lang.String formId)
                                        throws VradiException
Description copied from interface: FileService
Upload a form attachement.

Specified by:
uploadFormEmbeddedFile in interface FileService
Parameters:
file - file to upload
formId - form id
Returns:
file uri to reference file
Throws:
VradiException - throw VradiException if exception is occured

buildUrl

protected java.lang.String buildUrl(java.lang.String endpoint,
                                    java.lang.String... additionalParams)
Build post url.

Parameters:
endpoint - endpoint
additionalParams - parameters to be added to the url
Returns:
the built url

uploadFile

protected java.lang.String uploadFile(java.io.File file,
                                      java.lang.String postUrl)
                               throws VradiException
Throws:
VradiException

downloadFile

protected java.io.File downloadFile(java.lang.String fileUrl)
                             throws VradiException
Throws:
VradiException

downloadWebHarvestScript

public java.io.File downloadWebHarvestScript(java.lang.String uri)
                                      throws VradiException
Description copied from interface: FileService
Download file. File may be temporary.

Specified by:
downloadWebHarvestScript in interface FileService
Parameters:
uri - file uri to download
Returns:
locally downloaded file
Throws:
VradiException - throw VradiException if exception is occured

downloadTemplate

public java.io.File downloadTemplate(java.lang.String extensionName,
                                     java.lang.String templateName)
                              throws VradiException
Description copied from interface: FileService
Download file. File may be temporary.

Specified by:
downloadTemplate in interface FileService
Parameters:
extensionName - extension name
templateName - template name
Returns:
locally downloaded file
Throws:
VradiException - throw VradiException if exception is occured

downloadPDF

public java.io.File downloadPDF(java.lang.String uri)
                         throws VradiException
Description copied from interface: FileService
Download pdf file. File may be temporary.

Specified by:
downloadPDF in interface FileService
Parameters:
uri - file uri to download
Returns:
locally downloaded file
Throws:
VradiException - throw VradiException if exception is occured

downloadFormAttachment

public java.io.File downloadFormAttachment(java.lang.String uri)
                                    throws VradiException
Description copied from interface: FileService
Download file. File may be temporary.

Specified by:
downloadFormAttachment in interface FileService
Parameters:
uri - file uri to download
Returns:
locally downloaded file
Throws:
VradiException - throw VradiException if exception is occured

downloadFormEmbeddedFile

public java.io.File downloadFormEmbeddedFile(java.lang.String uri)
                                      throws VradiException
Description copied from interface: FileService
Download file. File may be temporary.

Specified by:
downloadFormEmbeddedFile in interface FileService
Parameters:
uri - file uri to download
Returns:
locally downloaded file
Throws:
VradiException - throw VradiException if exception is occured

downloadRequestHistory

public java.io.File downloadRequestHistory(java.lang.String uri)
                                    throws VradiException
Description copied from interface: FileService
Download request histiory file. File may be temporary.

Specified by:
downloadRequestHistory in interface FileService
Parameters:
uri - corresponding to history
Returns:
url to go to file
Throws:
VradiException - throw VradiException if exception is occured

getRequestHistoryURL

public java.lang.String getRequestHistoryURL(java.lang.String uri)
                                      throws VradiException
Description copied from interface: FileService
Download request histiory file. File may be temporary.

Specified by:
getRequestHistoryURL in interface FileService
Parameters:
uri - corresponding to history
Returns:
url to go to file
Throws:
VradiException - throw VradiException if exception is occured


Copyright © 2009-2010 JurisMarches. All Rights Reserved.