Liferay 6.1.2-ce-ga3

com.liferay.portlet.documentlibrary.store
Class BaseStore

java.lang.Object
  extended by com.liferay.portlet.documentlibrary.store.BaseStore
All Implemented Interfaces:
Store
Direct Known Subclasses:
CMISStore, DBStore, FileSystemStore, JCRStore, S3Store

public abstract class BaseStore
extends Object
implements Store

The abstract base class for all file store implementations. Most, if not all implementations should extend this class.


Field Summary
 
Fields inherited from interface com.liferay.portlet.documentlibrary.store.Store
VERSION_DEFAULT
 
Constructor Summary
BaseStore()
           
 
Method Summary
abstract  void addDirectory(long companyId, long repositoryId, String dirName)
          Adds a directory.
 void addFile(long companyId, long repositoryId, String fileName, byte[] bytes)
          Adds a file based on a byte array.
 void addFile(long companyId, long repositoryId, String fileName, File file)
          Adds a file based on a File object.
abstract  void addFile(long companyId, long repositoryId, String fileName, InputStream is)
          Adds a file based on an InputStream object.
abstract  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.
abstract  void deleteDirectory(long companyId, long repositoryId, String dirName)
          Deletes a directory.
abstract  void deleteFile(long companyId, long repositoryId, String fileName)
          Deletes a file.
abstract  void deleteFile(long companyId, long repositoryId, String fileName, String versionLabel)
          Deletes a file at a particular version.
 File getFile(long companyId, long repositoryId, String fileName)
          Returns the file as a File object.
 File getFile(long companyId, long repositoryId, String fileName, String versionLabel)
          Returns the file as a File object.
 byte[] getFileAsBytes(long companyId, long repositoryId, String fileName)
          Returns the file as a byte array.
 byte[] getFileAsBytes(long companyId, long repositoryId, String fileName, String versionLabel)
          Returns the file as a byte array.
 InputStream getFileAsStream(long companyId, long repositoryId, String fileName)
          Returns the file as an InputStream object.
abstract  InputStream getFileAsStream(long companyId, long repositoryId, String fileName, String versionLabel)
          Returns the file as an InputStream object.
abstract  String[] getFileNames(long companyId, long repositoryId, String dirName)
          Returns all files of the directory.
abstract  long getFileSize(long companyId, long repositoryId, String fileName)
          Returns the size of the file.
abstract  boolean hasDirectory(long companyId, long repositoryId, String dirName)
          Returns true if the directory exists.
 boolean hasFile(long companyId, long repositoryId, String fileName)
          Returns true if the file exists.
abstract  boolean hasFile(long companyId, long repositoryId, String fileName, String versionLabel)
          Returns true if the file exists.
abstract  void move(String srcDir, String destDir)
          Moves an existing directory.
abstract  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 versionLabel, byte[] bytes)
          Updates a file based on a byte array.
 void updateFile(long companyId, long repositoryId, String fileName, String versionLabel, File file)
          Updates a file based on a File object.
abstract  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 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.liferay.portlet.documentlibrary.store.Store
getFileNames, updateFile
 

Constructor Detail

BaseStore

public BaseStore()
Method Detail

addDirectory

public abstract void addDirectory(long companyId,
                                  long repositoryId,
                                  String dirName)
                           throws PortalException,
                                  SystemException
Adds a directory.

Specified by:
addDirectory in interface Store
Parameters:
companyId - the primary key of the company
repositoryId - the primary key of the data repository (optionally CompanyConstants#SYSTEM)
dirName - the directory's name
Throws:
PortalException - if the directory's information was invalid
SystemException - if a system exception occurred

addFile

public void addFile(long companyId,
                    long repositoryId,
                    String fileName,
                    byte[] bytes)
             throws PortalException,
                    SystemException
Adds a file based on a byte array.

Specified by:
addFile in interface Store
Parameters:
companyId - the primary key of the company
repositoryId - the primary key of the data repository (optionally CompanyConstants#SYSTEM)
fileName - the file name
bytes - the files's data
Throws:
PortalException - if the file's information was invalid
SystemException - if a system exception occurred

addFile

public void addFile(long companyId,
                    long repositoryId,
                    String fileName,
                    File file)
             throws PortalException,
                    SystemException
Adds a file based on a File object.

Specified by:
addFile in interface Store
Parameters:
companyId - the primary key of the company
repositoryId - the primary key of the data repository (optionally CompanyConstants#SYSTEM)
fileName - the file name
file - Name the file name
Throws:
PortalException - if the file's information was invalid
SystemException - if a system exception occurred

addFile

public abstract void addFile(long companyId,
                             long repositoryId,
                             String fileName,
                             InputStream is)
                      throws PortalException,
                             SystemException
Adds a file based on an InputStream object.

Specified by:
addFile in interface Store
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:
PortalException - if the file's information was invalid
SystemException - if a system exception occurred

checkRoot

public abstract void checkRoot(long companyId)
                        throws SystemException
Ensures company's root directory exists. Only implemented by JCRStore.checkRoot(long).

Specified by:
checkRoot in interface Store
Parameters:
companyId - the primary key of the company
Throws:
SystemException - if a system exception occurred

copyFileVersion

public void copyFileVersion(long companyId,
                            long repositoryId,
                            String fileName,
                            String fromVersionLabel,
                            String toVersionLabel)
                     throws PortalException,
                            SystemException
Creates a new copy of the file version.

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

Specified by:
copyFileVersion in interface Store
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:
PortalException - if the file's information was invalid
SystemException - if a system exception occurred

deleteDirectory

public abstract void deleteDirectory(long companyId,
                                     long repositoryId,
                                     String dirName)
                              throws PortalException,
                                     SystemException
Deletes a directory.

Specified by:
deleteDirectory in interface Store
Parameters:
companyId - the primary key of the company
repositoryId - the primary key of the data repository (optionally CompanyConstants#SYSTEM)
dirName - the directory's name
Throws:
PortalException - if the directory's information was invalid
SystemException - if a system exception occurred

deleteFile

public abstract void deleteFile(long companyId,
                                long repositoryId,
                                String fileName)
                         throws PortalException,
                                SystemException
Deletes a file. If a file has multiple versions, all versions will be deleted.

Specified by:
deleteFile in interface Store
Parameters:
companyId - the primary key of the company
repositoryId - the primary key of the data repository (optionally CompanyConstants#SYSTEM)
fileName - the file's name
Throws:
PortalException - if the file's information was invalid
SystemException - if a system exception occurred

deleteFile

public abstract void deleteFile(long companyId,
                                long repositoryId,
                                String fileName,
                                String versionLabel)
                         throws PortalException,
                                SystemException
Deletes a file at a particular version.

Specified by:
deleteFile in interface Store
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
Throws:
PortalException - if the file's information was invalid
SystemException - if a system exception occurred

getFile

public File getFile(long companyId,
                    long repositoryId,
                    String fileName)
             throws PortalException,
                    SystemException
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.

Specified by:
getFile in interface Store
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 File object with the file's name
Throws:
PortalException - if the file's information was invalid
SystemException - if a system exception occurred

getFile

public File getFile(long companyId,
                    long repositoryId,
                    String fileName,
                    String versionLabel)
             throws PortalException,
                    SystemException
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., FileSystemStore.getFile(long, long, String, String)).

Specified by:
getFile in interface Store
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:
PortalException - if the file's information was invalid
SystemException - if a system exception occurred

getFileAsBytes

public byte[] getFileAsBytes(long companyId,
                             long repositoryId,
                             String fileName)
                      throws PortalException,
                             SystemException
Returns the file as a byte array.

Specified by:
getFileAsBytes in interface Store
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 byte array with the file's name
Throws:
PortalException - if the file's information was invalid
SystemException - if a system exception occurred

getFileAsBytes

public byte[] getFileAsBytes(long companyId,
                             long repositoryId,
                             String fileName,
                             String versionLabel)
                      throws PortalException,
                             SystemException
Returns the file as a byte array.

Specified by:
getFileAsBytes in interface Store
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 byte array with the file's name
Throws:
PortalException - if the file's information was invalid
SystemException - if a system exception occurred

getFileAsStream

public InputStream getFileAsStream(long companyId,
                                   long repositoryId,
                                   String fileName)
                            throws PortalException,
                                   SystemException
Returns the file as an InputStream object.

Specified by:
getFileAsStream in interface Store
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 InputStream object with the file's name
Throws:
PortalException - if the file's information was invalid
SystemException - if a system exception occurred

getFileAsStream

public abstract InputStream getFileAsStream(long companyId,
                                            long repositoryId,
                                            String fileName,
                                            String versionLabel)
                                     throws PortalException,
                                            SystemException
Returns the file as an InputStream object.

Specified by:
getFileAsStream in interface Store
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:
PortalException - if the file's information was invalid
SystemException - if a system exception occurred

getFileNames

public abstract String[] getFileNames(long companyId,
                                      long repositoryId,
                                      String dirName)
                               throws PortalException,
                                      SystemException
Returns all files of the directory.

Specified by:
getFileNames in interface Store
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
Throws:
PortalException - if the directory's information was invalid
SystemException - if a system exception occurred

getFileSize

public abstract long getFileSize(long companyId,
                                 long repositoryId,
                                 String fileName)
                          throws PortalException,
                                 SystemException
Returns the size of the file.

Specified by:
getFileSize in interface Store
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:
PortalException - if the file's information was invalid
SystemException - if a system exception occurred

hasDirectory

public abstract boolean hasDirectory(long companyId,
                                     long repositoryId,
                                     String dirName)
                              throws PortalException,
                                     SystemException
Returns true if the directory exists.

Specified by:
hasDirectory in interface Store
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
Throws:
PortalException - if the directory's information was invalid
SystemException - if a system exception occurred

hasFile

public boolean hasFile(long companyId,
                       long repositoryId,
                       String fileName)
                throws PortalException,
                       SystemException
Returns true if the file exists.

Specified by:
hasFile in interface Store
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:
true if the file exists; false otherwise
Throws:
PortalException - if the file's information was invalid
SystemException - if a system exception occurred

hasFile

public abstract boolean hasFile(long companyId,
                                long repositoryId,
                                String fileName,
                                String versionLabel)
                         throws PortalException,
                                SystemException
Returns true if the file exists.

Specified by:
hasFile in interface Store
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
Throws:
PortalException - if the file's information was invalid
SystemException - if a system exception occurred

move

public abstract void move(String srcDir,
                          String destDir)
                   throws SystemException
Moves an existing directory. Only implemented by JCRStore.move(String, String).

Specified by:
move in interface Store
Parameters:
srcDir - the original directory's name
destDir - the new directory's name
Throws:
SystemException - if a system exception occurred

updateFile

public abstract void updateFile(long companyId,
                                long repositoryId,
                                long newRepositoryId,
                                String fileName)
                         throws PortalException,
                                SystemException
Moves a file to a new data repository.

Specified by:
updateFile in interface Store
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:
PortalException - if the file's information was invalid
SystemException - if a system exception occurred

updateFile

public void updateFile(long companyId,
                       long repositoryId,
                       String fileName,
                       String versionLabel,
                       byte[] bytes)
                throws PortalException,
                       SystemException
Updates a file based on a byte array.

Specified by:
updateFile in interface Store
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
bytes - the new file's data
Throws:
PortalException - if the file's information was invalid
SystemException - if a system exception occurred

updateFile

public void updateFile(long companyId,
                       long repositoryId,
                       String fileName,
                       String versionLabel,
                       File file)
                throws PortalException,
                       SystemException
Updates a file based on a File object.

Specified by:
updateFile in interface Store
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
file - Name the file name
Throws:
PortalException - if the file's information was invalid
SystemException - if a system exception occurred

updateFile

public abstract void updateFile(long companyId,
                                long repositoryId,
                                String fileName,
                                String versionLabel,
                                InputStream is)
                         throws PortalException,
                                SystemException
Updates a file based on an InputStream object.

Specified by:
updateFile in interface Store
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:
PortalException - if the file's information was invalid
SystemException - if a system exception occurred

updateFileVersion

public void updateFileVersion(long companyId,
                              long repositoryId,
                              String fileName,
                              String fromVersionLabel,
                              String toVersionLabel)
                       throws PortalException,
                              SystemException
Update's a file version label. Similar to #copyFileVersion(long, long, String, String, String, String) except that the old file version is deleted.

Specified by:
updateFileVersion in interface Store
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:
PortalException - if the file's information was invalid
SystemException - if a system exception occurred

Liferay 6.1.2-ce-ga3