001    /**
002     * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portlet.documentlibrary.store;
016    
017    import com.liferay.portal.kernel.exception.PortalException;
018    import com.liferay.portal.kernel.exception.SystemException;
019    import com.liferay.portal.kernel.transaction.Transactional;
020    
021    import java.io.File;
022    import java.io.InputStream;
023    
024    /**
025     * @author Brian Wing Shun Chan
026     * @author Alexander Chow
027     * @author Edward Han
028     */
029    @Transactional(rollbackFor = {PortalException.class, SystemException.class})
030    public interface DLStore {
031    
032            public void addDirectory(long companyId, long repositoryId, String dirName)
033                    throws PortalException, SystemException;
034    
035            public void addFile(
036                            long companyId, long repositoryId, String fileName,
037                            boolean validateFileExtension, byte[] bytes)
038                    throws PortalException, SystemException;
039    
040            public void addFile(
041                            long companyId, long repositoryId, String fileName,
042                            boolean validateFileExtension, File file)
043                    throws PortalException, SystemException;
044    
045            public void addFile(
046                            long companyId, long repositoryId, String fileName,
047                            boolean validateFileExtension, InputStream is)
048                    throws PortalException, SystemException;
049    
050            public void addFile(
051                            long companyId, long repositoryId, String fileName, byte[] bytes)
052                    throws PortalException, SystemException;
053    
054            public void addFile(
055                            long companyId, long repositoryId, String fileName, File file)
056                    throws PortalException, SystemException;
057    
058            public void addFile(
059                            long companyId, long repositoryId, String fileName, InputStream is)
060                    throws PortalException, SystemException;
061    
062            public void checkRoot(long companyId) throws SystemException;
063    
064            public void copyFileVersion(
065                            long companyId, long repositoryId, String fileName,
066                            String fromVersionLabel, String toVersionLabel)
067                    throws PortalException, SystemException;
068    
069            public void deleteDirectory(
070                            long companyId, long repositoryId, String dirName)
071                    throws PortalException, SystemException;
072    
073            public void deleteFile(long companyId, long repositoryId, String fileName)
074                    throws PortalException, SystemException;
075    
076            public void deleteFile(
077                            long companyId, long repositoryId, String fileName,
078                            String versionLabel)
079                    throws PortalException, SystemException;
080    
081            public File getFile(long companyId, long repositoryId, String fileName)
082                    throws PortalException, SystemException;
083    
084            public File getFile(
085                            long companyId, long repositoryId, String fileName,
086                            String versionLabel)
087                    throws PortalException, SystemException;
088    
089            public byte[] getFileAsBytes(
090                            long companyId, long repositoryId, String fileName)
091                    throws PortalException, SystemException;
092    
093            public byte[] getFileAsBytes(
094                            long companyId, long repositoryId, String fileName,
095                            String versionLabel)
096                    throws PortalException, SystemException;
097    
098            public InputStream getFileAsStream(
099                            long companyId, long repositoryId, String fileName)
100                    throws PortalException, SystemException;
101    
102            public InputStream getFileAsStream(
103                            long companyId, long repositoryId, String fileName,
104                            String versionLabel)
105                    throws PortalException, SystemException;
106    
107            public String[] getFileNames(
108                            long companyId, long repositoryId, String dirName)
109                    throws PortalException, SystemException;
110    
111            public long getFileSize(long companyId, long repositoryId, String fileName)
112                    throws PortalException, SystemException;
113    
114            public boolean hasDirectory(
115                            long companyId, long repositoryId, String dirName)
116                    throws PortalException, SystemException;
117    
118            public boolean hasFile(long companyId, long repositoryId, String fileName)
119                    throws PortalException, SystemException;
120    
121            public boolean hasFile(
122                            long companyId, long repositoryId, String fileName,
123                            String versionLabel)
124                    throws PortalException, SystemException;
125    
126            public void move(String srcDir, String destDir) throws SystemException;
127    
128            public void updateFile(
129                            long companyId, long repositoryId, long newRepositoryId,
130                            String fileName)
131                    throws PortalException, SystemException;
132    
133            public void updateFile(
134                            long companyId, long repositoryId, String fileName,
135                            String newFileName)
136                    throws PortalException, SystemException;
137    
138            public void updateFile(
139                            long companyId, long repositoryId, String fileName,
140                            String fileExtension, boolean validateFileExtension,
141                            String versionLabel, String sourceFileName, File file)
142                    throws PortalException, SystemException;
143    
144            public void updateFile(
145                            long companyId, long repositoryId, String fileName,
146                            String fileExtension, boolean validateFileExtension,
147                            String versionLabel, String sourceFileName, InputStream is)
148                    throws PortalException, SystemException;
149    
150            public void updateFileVersion(
151                            long companyId, long repositoryId, String fileName,
152                            String fromVersionLabel, String toVersionLabel)
153                    throws PortalException, SystemException;
154    
155            public void validate(String fileName, boolean validateFileExtension)
156                    throws PortalException, SystemException;
157    
158            public void validate(
159                            String fileName, boolean validateFileExtension, byte[] bytes)
160                    throws PortalException, SystemException;
161    
162            public void validate(
163                            String fileName, boolean validateFileExtension, File file)
164                    throws PortalException, SystemException;
165    
166            public void validate(
167                            String fileName, boolean validateFileExtension, InputStream is)
168                    throws PortalException, SystemException;
169    
170            public void validate(
171                            String fileName, String fileExtension, String sourceFileName,
172                            boolean validateFileExtension, File file)
173                    throws PortalException, SystemException;
174    
175            public void validate(
176                            String fileName, String fileExtension, String sourceFileName,
177                            boolean validateFileExtension, InputStream is)
178                    throws PortalException, SystemException;
179    
180    }