Liferay 7.0-ce-m6

com.liferay.portlet.documentlibrary.store
Class FileSystemStore

java.lang.Object
  extended by com.liferay.portlet.documentlibrary.store.BaseStore
      extended by com.liferay.portlet.documentlibrary.store.FileSystemStore
All Implemented Interfaces:
Store
Direct Known Subclasses:
AdvancedFileSystemStore

public class FileSystemStore
extends BaseStore


Field Summary
 
Fields inherited from interface com.liferay.portlet.documentlibrary.store.Store
VERSION_DEFAULT
 
Constructor Summary
FileSystemStore()
           
 
Method Summary
 void addDirectory(long companyId, long repositoryId, String dirName)
          Adds a directory.
 void addFile(long companyId, long repositoryId, String fileName, InputStream is)
          Adds a file based on an InputStream object.
 void checkRoot(long companyId)
          Ensures company's root directory exists.
 void copyFileVersion(long companyId, long repositoryId, String fileName, String fromVersionLabel, String toVersionLabel)
          Creates a new copy of the file version.
 void deleteDirectory(long companyId, long repositoryId, String dirName)
          Deletes a directory.
protected  void deleteEmptyAncestors(File file)
           
protected  void deleteEmptyAncestors(long companyId, long repositoryId, File file)
           
 void deleteFile(long companyId, long repositoryId, String fileName)
          Deletes a file.
 void deleteFile(long companyId, long repositoryId, String fileName, String versionLabel)
          Deletes a file at a particular version.
protected  File getCompanyDir(long companyId)
           
protected  File getDirNameDir(long companyId, long repositoryId, String dirName)
           
 File getFile(long companyId, long repositoryId, String fileName, String versionLabel)
          Returns the file as a File object.
 InputStream getFileAsStream(long companyId, long repositoryId, String fileName, String versionLabel)
          Returns the file as an InputStream object.
protected  File getFileNameDir(long companyId, long repositoryId, String fileName)
           
protected  void getFileNames(List<String> fileNames, String dirName, String path)
           
 String[] getFileNames(long companyId, long repositoryId)
           
 String[] getFileNames(long companyId, long repositoryId, String dirName)
          Returns all files of the directory.
protected  File getFileNameVersionFile(long companyId, long repositoryId, String fileName, String version)
           
 long getFileSize(long companyId, long repositoryId, String fileName)
          Returns the size of the file.
protected  String getHeadVersionLabel(long companyId, long repositoryId, String fileName)
           
protected  File getRepositoryDir(long companyId, long repositoryId)
           
protected  String getRootDirName()
           
 boolean hasDirectory(long companyId, long repositoryId, String dirName)
          Returns true if the directory exists.
 boolean hasFile(long companyId, long repositoryId, String fileName, String versionLabel)
          Returns true if the file exists.
 void updateFile(long companyId, long repositoryId, long newRepositoryId, String fileName)
          Moves a file to a new data repository.
 void updateFile(long companyId, long repositoryId, String fileName, String newFileName)
           
 void updateFile(long companyId, long repositoryId, String fileName, String versionLabel, InputStream is)
          Updates a file based on an InputStream object.
 void updateFileVersion(long companyId, long repositoryId, String fileName, String fromVersionLabel, String toVersionLabel)
          Update's a file version label.
 
Methods inherited from class com.liferay.portlet.documentlibrary.store.BaseStore
addFile, addFile, getFile, getFileAsBytes, getFileAsBytes, getFileAsStream, hasFile, logFailedDeletion, logFailedDeletion, move, updateFile, updateFile
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileSystemStore

public FileSystemStore()
Method Detail

addDirectory

public void addDirectory(long companyId,
                         long repositoryId,
                         String dirName)
Description copied from class: BaseStore
Adds a directory.

Specified by:
addDirectory in interface Store
Specified by:
addDirectory in class BaseStore
Parameters:
companyId - the primary key of the company
repositoryId - the primary key of the data repository (optionally CompanyConstants.SYSTEM)
dirName - the directory's name

addFile

public void addFile(long companyId,
                    long repositoryId,
                    String fileName,
                    InputStream is)
             throws DuplicateFileException
Description copied from class: BaseStore
Adds a file based on an InputStream object.

Specified by:
addFile in interface Store
Specified by:
addFile in class BaseStore
Parameters:
companyId - the primary key of the company
repositoryId - the primary key of the data repository (optionally CompanyConstants.SYSTEM)
fileName - the file name
is - the files's data
Throws:
DuplicateFileException

checkRoot

public void checkRoot(long companyId)
Description copied from class: BaseStore
Ensures company's root directory exists. Only implemented by JCRStore.checkRoot(long).

Specified by:
checkRoot in interface Store
Specified by:
checkRoot in class BaseStore
Parameters:
companyId - the primary key of the company

copyFileVersion

public void copyFileVersion(long companyId,
                            long repositoryId,
                            String fileName,
                            String fromVersionLabel,
                            String toVersionLabel)
                     throws DuplicateFileException,
                            NoSuchFileException
Description copied from class: BaseStore
Creates a new copy of the file version.

This method should be overrided if a more optimized approach can be used (e.g., copyFileVersion(long, long, String, String, String)).

Specified by:
copyFileVersion in interface Store
Overrides:
copyFileVersion in class BaseStore
Parameters:
companyId - the primary key of the company
repositoryId - the primary key of the data repository (optionally CompanyConstants.SYSTEM)
fileName - the original's file name
fromVersionLabel - the original file's version label
toVersionLabel - the new version label
Throws:
DuplicateFileException
NoSuchFileException

deleteDirectory

public void deleteDirectory(long companyId,
                            long repositoryId,
                            String dirName)
Description copied from class: BaseStore
Deletes a directory.

Specified by:
deleteDirectory in interface Store
Specified by:
deleteDirectory in class BaseStore
Parameters:
companyId - the primary key of the company
repositoryId - the primary key of the data repository (optionally CompanyConstants.SYSTEM)
dirName - the directory's name

deleteFile

public void deleteFile(long companyId,
                       long repositoryId,
                       String fileName)
Description copied from class: BaseStore
Deletes a file. If a file has multiple versions, all versions will be deleted.

Specified by:
deleteFile in interface Store
Specified by:
deleteFile in class BaseStore
Parameters:
companyId - the primary key of the company
repositoryId - the primary key of the data repository (optionally CompanyConstants.SYSTEM)
fileName - the file's name

deleteFile

public void deleteFile(long companyId,
                       long repositoryId,
                       String fileName,
                       String versionLabel)
Description copied from class: BaseStore
Deletes a file at a particular version.

Specified by:
deleteFile in interface Store
Specified by:
deleteFile in class BaseStore
Parameters:
companyId - the primary key of the company
repositoryId - the primary key of the data repository (optionally CompanyConstants.SYSTEM)
fileName - the file's name
versionLabel - the file's version label

getFile

public File getFile(long companyId,
                    long repositoryId,
                    String fileName,
                    String versionLabel)
             throws NoSuchFileException
Description copied from class: BaseStore
Returns the file as a File object.

This method is useful when optimizing low-level file operations like copy. The client must not delete or change the returned File object in any way. This method is only supported in certain stores. If not supported, this method will throw an UnsupportedOperationException.

This method should be overrided if a more optimized approach can be used (e.g., getFile(long, long, String, String)).

Specified by:
getFile in interface Store
Overrides:
getFile in class BaseStore
Parameters:
companyId - the primary key of the company
repositoryId - the primary key of the data repository (optionally CompanyConstants.SYSTEM)
fileName - the file's name
versionLabel - the file's version label
Returns:
Returns the File object with the file's name
Throws:
NoSuchFileException

getFileAsStream

public InputStream getFileAsStream(long companyId,
                                   long repositoryId,
                                   String fileName,
                                   String versionLabel)
                            throws NoSuchFileException
Description copied from class: BaseStore
Returns the file as an InputStream object.

Specified by:
getFileAsStream in interface Store
Specified by:
getFileAsStream in class BaseStore
Parameters:
companyId - the primary key of the company
repositoryId - the primary key of the data repository (optionally CompanyConstants.SYSTEM)
fileName - the file's name
versionLabel - the file's version label
Returns:
Returns the InputStream object with the file's name
Throws:
NoSuchFileException

getFileNames

public String[] getFileNames(long companyId,
                             long repositoryId)

getFileNames

public String[] getFileNames(long companyId,
                             long repositoryId,
                             String dirName)
Description copied from class: BaseStore
Returns all files of the directory.

Specified by:
getFileNames in interface Store
Specified by:
getFileNames in class BaseStore
Parameters:
companyId - the primary key of the company
repositoryId - the primary key of the data repository (optionally CompanyConstants.SYSTEM)
dirName - the directory's name
Returns:
Returns all files of the directory

getFileSize

public long getFileSize(long companyId,
                        long repositoryId,
                        String fileName)
                 throws NoSuchFileException
Description copied from class: BaseStore
Returns the size of the file.

Specified by:
getFileSize in interface Store
Specified by:
getFileSize in class BaseStore
Parameters:
companyId - the primary key of the company
repositoryId - the primary key of the data repository (optionally CompanyConstants.SYSTEM)
fileName - the file's name
Returns:
Returns the size of the file
Throws:
NoSuchFileException

hasDirectory

public boolean hasDirectory(long companyId,
                            long repositoryId,
                            String dirName)
Description copied from class: BaseStore
Returns true if the directory exists.

Specified by:
hasDirectory in interface Store
Specified by:
hasDirectory in class BaseStore
Parameters:
companyId - the primary key of the company
repositoryId - the primary key of the data repository (optionally CompanyConstants.SYSTEM)
dirName - the directory's name
Returns:
true if the directory exists; false otherwise

hasFile

public boolean hasFile(long companyId,
                       long repositoryId,
                       String fileName,
                       String versionLabel)
Description copied from class: BaseStore
Returns true if the file exists.

Specified by:
hasFile in interface Store
Specified by:
hasFile in class BaseStore
Parameters:
companyId - the primary key of the company
repositoryId - the primary key of the data repository (optionally CompanyConstants.SYSTEM)
fileName - the file's name
versionLabel - the file's version label
Returns:
true if the file exists; false otherwise

updateFile

public void updateFile(long companyId,
                       long repositoryId,
                       long newRepositoryId,
                       String fileName)
                throws DuplicateFileException,
                       NoSuchFileException
Description copied from class: BaseStore
Moves a file to a new data repository.

Specified by:
updateFile in interface Store
Specified by:
updateFile in class BaseStore
Parameters:
companyId - the primary key of the company
repositoryId - the primary key of the data repository
newRepositoryId - the primary key of the new data repository
fileName - the file's name
Throws:
DuplicateFileException
NoSuchFileException

updateFile

public void updateFile(long companyId,
                       long repositoryId,
                       String fileName,
                       String newFileName)
                throws DuplicateFileException,
                       NoSuchFileException
Throws:
DuplicateFileException
NoSuchFileException

updateFile

public void updateFile(long companyId,
                       long repositoryId,
                       String fileName,
                       String versionLabel,
                       InputStream is)
                throws DuplicateFileException
Description copied from class: BaseStore
Updates a file based on an InputStream object.

Specified by:
updateFile in interface Store
Specified by:
updateFile in class BaseStore
Parameters:
companyId - the primary key of the company
repositoryId - the primary key of the data repository (optionally CompanyConstants.SYSTEM)
fileName - the file name
versionLabel - the file's new version label
is - the new file's data
Throws:
DuplicateFileException

updateFileVersion

public void updateFileVersion(long companyId,
                              long repositoryId,
                              String fileName,
                              String fromVersionLabel,
                              String toVersionLabel)
                       throws DuplicateFileException,
                              NoSuchFileException
Description copied from class: BaseStore
Update's a file version label. Similar to BaseStore.copyFileVersion(long, long, String, String, String) except that the old file version is deleted.

Specified by:
updateFileVersion in interface Store
Overrides:
updateFileVersion in class BaseStore
Parameters:
companyId - the primary key of the company
repositoryId - the primary key of the data repository (optionally CompanyConstants.SYSTEM)
fileName - the file's name
fromVersionLabel - the file's version label
toVersionLabel - the file's new version label
Throws:
DuplicateFileException
NoSuchFileException

deleteEmptyAncestors

protected void deleteEmptyAncestors(File file)

deleteEmptyAncestors

protected void deleteEmptyAncestors(long companyId,
                                    long repositoryId,
                                    File file)

getCompanyDir

protected File getCompanyDir(long companyId)

getDirNameDir

protected File getDirNameDir(long companyId,
                             long repositoryId,
                             String dirName)

getFileNameDir

protected File getFileNameDir(long companyId,
                              long repositoryId,
                              String fileName)

getFileNames

protected void getFileNames(List<String> fileNames,
                            String dirName,
                            String path)

getFileNameVersionFile

protected File getFileNameVersionFile(long companyId,
                                      long repositoryId,
                                      String fileName,
                                      String version)

getHeadVersionLabel

protected String getHeadVersionLabel(long companyId,
                                     long repositoryId,
                                     String fileName)

getRepositoryDir

protected File getRepositoryDir(long companyId,
                                long repositoryId)

getRootDirName

protected String getRootDirName()

Liferay 7.0-ce-m6