com.elasticpath.service.misc.impl
Class FileServiceImpl

java.lang.Object
  extended by com.elasticpath.service.impl.AbstractEpServiceImpl
      extended by com.elasticpath.service.misc.impl.FileServiceImpl
All Implemented Interfaces:
EpService, FileService

public class FileServiceImpl
extends AbstractEpServiceImpl
implements FileService

Provide file download and upload service.


Constructor Summary
FileServiceImpl()
           
 
Method Summary
 boolean createFolder(java.lang.String rootFolder, java.lang.String subPath)
          Create the folder.
 boolean deleteEntireFolder(java.lang.String rootFolder, java.lang.String subPath)
          Delete the folder and all files under it.
 boolean deleteFile(java.lang.String rootFolder, java.lang.String filePath)
          Delete the file.
 void download(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, java.lang.String fullFilePath)
          Read the input file content and output the stream to client (Browser).
 java.util.ArrayList getFilesByFolder(java.lang.String rootFolder, java.lang.String subPath)
          Get the file list under asset sub folder.
 java.util.ArrayList getSubFolders(java.lang.String rootFolder, java.lang.String subPath)
          Read the sub folders.
 boolean isFileExist(java.lang.String rootFolder, java.lang.String filePath)
          Check if the file exists.
 boolean renameFile(java.lang.String rootFolder, java.lang.String oriFilePath, java.lang.String newFilePath)
          Rename the file.
 
Methods inherited from class com.elasticpath.service.impl.AbstractEpServiceImpl
getElasticPath, setElasticPath
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.elasticpath.service.EpService
getElasticPath, setElasticPath
 

Constructor Detail

FileServiceImpl

public FileServiceImpl()
Method Detail

createFolder

public boolean createFolder(java.lang.String rootFolder,
                            java.lang.String subPath)
Create the folder.

Specified by:
createFolder in interface FileService
Parameters:
rootFolder - the root folder for different type of asset, e.g., images for image asset
subPath - the subPath under root folder
Returns:
true if the entire folder deleted, otherwise false

deleteEntireFolder

public boolean deleteEntireFolder(java.lang.String rootFolder,
                                  java.lang.String subPath)
Delete the folder and all files under it.

Specified by:
deleteEntireFolder in interface FileService
Parameters:
rootFolder - the root folder for different type of asset, e.g., images for image asset
subPath - the subPath under root folder
Returns:
true if the entire folder deleted, otherwise false

deleteFile

public boolean deleteFile(java.lang.String rootFolder,
                          java.lang.String filePath)
Delete the file.

Specified by:
deleteFile in interface FileService
Parameters:
rootFolder - the root folder for different type of asset, e.g., images for image asset
filePath - the filePath under root folder
Returns:
true if the entire folder deleted, otherwise false

download

public void download(javax.servlet.http.HttpServletRequest request,
                     javax.servlet.http.HttpServletResponse response,
                     java.lang.String fullFilePath)
              throws EpSystemException
Read the input file content and output the stream to client (Browser).

Specified by:
download in interface FileService
Parameters:
request - the download request
response - the response
fullFilePath - the full file path on server
Throws:
EpSystemException - - if any error

getFilesByFolder

public java.util.ArrayList getFilesByFolder(java.lang.String rootFolder,
                                            java.lang.String subPath)
Get the file list under asset sub folder.

Specified by:
getFilesByFolder in interface FileService
Parameters:
rootFolder - the root folder for different type of asset, e.g., images for image asset
subPath - the subPath under root folder
Returns:
the list of file name with the sub path under root folder

getSubFolders

public java.util.ArrayList getSubFolders(java.lang.String rootFolder,
                                         java.lang.String subPath)
Read the sub folders.

Specified by:
getSubFolders in interface FileService
Parameters:
rootFolder - the root folder for different type of asset, e.g., images for image asset
subPath - the subPath under root folder
Returns:
the sub folder path

isFileExist

public boolean isFileExist(java.lang.String rootFolder,
                           java.lang.String filePath)
Check if the file exists.

Specified by:
isFileExist in interface FileService
Parameters:
rootFolder - the root folder for different type of asset, e.g., images for image asset
filePath - the filePath under root folder
Returns:
true if file exist, otherwise false

renameFile

public boolean renameFile(java.lang.String rootFolder,
                          java.lang.String oriFilePath,
                          java.lang.String newFilePath)
Rename the file.

Specified by:
renameFile in interface FileService
Parameters:
rootFolder - the root folder for different type of asset, e.g., images for image asset
oriFilePath - the filePath under root folder
newFilePath - the filePath under root folder
Returns:
true if rename successful, otherwise false