com.jurismarches.vradi.services
Class FileServiceProxy

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

public class FileServiceProxy
extends 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: 1798 $ Last update : $Date: 2010-11-17 18:04:16 +0100 (mer., 17 nov. 2010) $ By : $Author: sletellier $
Author:
chatellier

Field Summary
protected  String serviceEndpoint
          Remote service endpoint.
 
Constructor Summary
FileServiceProxy(String serviceEndpoint)
          Constructor with remote service endpoint.
 
Method Summary
protected  String buildUrl(String endpoint, boolean convertUrl, String... additionalParams)
          Build post url.
protected  File downloadFile(String fileUrl)
           
 File downloadFormAttachment(boolean convertUrl, String fileName, String formId)
          Download file.
 File downloadFormAttachment(String uri)
          Download file.
 File downloadFormAttachment(String fileName, String formId)
          Download file.
 File downloadFormEmbeddedFile(boolean convertUrl, String fileName, String formId)
          Download file.
 File downloadFormEmbeddedFile(String uri)
          Download file.
 File downloadFormEmbeddedFile(String fileName, String formId)
          Download file.
 File downloadPDF(boolean convertUrl, String uri)
          Download pdf file.
 File downloadPDF(String uri)
          Download pdf file.
 File downloadRequestHistory(boolean convretUrl, String uri)
          Download request histiory file.
 File downloadRequestHistory(String uri)
          Download request histiory file.
 File downloadTemplate(boolean convertUrl, String extensionName, String templateName)
          Download file.
 File downloadTemplate(String extensionName, String templateName)
          Download file.
 File downloadWebHarvestScript(boolean convertUrl, String uri)
          Download file.
 File downloadWebHarvestScript(String uri)
          Download file.
 String getFormEmbeddedUrl(String fileName, String formId)
           
 String getRequestHistoryURL(String uri)
          Download request histiory file.
protected  String uploadFile(File file, String postUrl)
           
 String uploadFormAttachment(File file, String formId)
          Upload a form attachment.
 String uploadFormEmbeddedFile(File file, String formId)
          Upload a form attachement.
 String uploadTempFile(File file)
          Upload a temporary file (for example for export).
 String uploadTemplate(File file, String extensionName)
          Upload a template on server.
 String uploadWebHarvestScript(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 String serviceEndpoint
Remote service endpoint. Endpoint is http://xxx/vradi/file

Constructor Detail

FileServiceProxy

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

Parameters:
serviceEndpoint - remote service endpoint
Method Detail

uploadTemplate

public String uploadTemplate(File file,
                             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 String uploadWebHarvestScript(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 String uploadFormAttachment(File file,
                                   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 String uploadTempFile(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 String uploadFormEmbeddedFile(File file,
                                     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 String buildUrl(String endpoint,
                          boolean convertUrl,
                          String... additionalParams)
                   throws VradiException
Build post url.

Parameters:
endpoint - endpoint
convertUrl - if url must be encode
additionalParams - parameters to be added to the url
Returns:
the built url
Throws:
VradiException - if url error

uploadFile

protected String uploadFile(File file,
                            String postUrl)
                     throws VradiException
Throws:
VradiException

downloadFile

protected File downloadFile(String fileUrl)
                     throws VradiException
Throws:
VradiException

downloadWebHarvestScript

public File downloadWebHarvestScript(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

downloadWebHarvestScript

public File downloadWebHarvestScript(boolean convertUrl,
                                     String uri)
                              throws VradiException
Description copied from interface: FileService
Download file. File may be temporary.

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

downloadTemplate

public File downloadTemplate(String extensionName,
                             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

downloadTemplate

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

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

downloadPDF

public File downloadPDF(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

downloadPDF

public File downloadPDF(boolean convertUrl,
                        String uri)
                 throws VradiException
Description copied from interface: FileService
Download pdf file. File may be temporary.

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

downloadFormAttachment

public File downloadFormAttachment(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

downloadFormAttachment

public File downloadFormAttachment(String fileName,
                                   String formId)
                            throws VradiException
Description copied from interface: FileService
Download file. File may be temporary.

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

downloadFormAttachment

public File downloadFormAttachment(boolean convertUrl,
                                   String fileName,
                                   String formId)
                            throws VradiException
Description copied from interface: FileService
Download file. File may be temporary.

Specified by:
downloadFormAttachment in interface FileService
Parameters:
convertUrl - if convertion url is necessary
Returns:
locally downloaded file
Throws:
VradiException - throw VradiException if exception is occured

downloadFormEmbeddedFile

public File downloadFormEmbeddedFile(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

downloadFormEmbeddedFile

public File downloadFormEmbeddedFile(String fileName,
                                     String formId)
                              throws VradiException
Description copied from interface: FileService
Download file. File may be temporary.

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

downloadFormEmbeddedFile

public File downloadFormEmbeddedFile(boolean convertUrl,
                                     String fileName,
                                     String formId)
                              throws VradiException
Description copied from interface: FileService
Download file. File may be temporary.

Specified by:
downloadFormEmbeddedFile in interface FileService
Parameters:
convertUrl - if convertion url is necessary
fileName - to download
formId - form id
Returns:
locally downloaded file
Throws:
VradiException - throw VradiException if exception is occured

getFormEmbeddedUrl

public String getFormEmbeddedUrl(String fileName,
                                 String formId)
                          throws VradiException
Specified by:
getFormEmbeddedUrl in interface FileService
Throws:
VradiException

downloadRequestHistory

public File downloadRequestHistory(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

downloadRequestHistory

public File downloadRequestHistory(boolean convretUrl,
                                   String uri)
                            throws VradiException
Description copied from interface: FileService
Download request histiory file. File may be temporary.

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

getRequestHistoryURL

public String getRequestHistoryURL(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.