001    /**
002     * Copyright (c) 2000-present 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;
034    
035            public void addFile(
036                            long companyId, long repositoryId, String fileName,
037                            boolean validateFileExtension, byte[] bytes)
038                    throws PortalException;
039    
040            public void addFile(
041                            long companyId, long repositoryId, String fileName,
042                            boolean validateFileExtension, File file)
043                    throws PortalException;
044    
045            public void addFile(
046                            long companyId, long repositoryId, String fileName,
047                            boolean validateFileExtension, InputStream is)
048                    throws PortalException;
049    
050            public void addFile(
051                            long companyId, long repositoryId, String fileName, byte[] bytes)
052                    throws PortalException;
053    
054            public void addFile(
055                            long companyId, long repositoryId, String fileName, File file)
056                    throws PortalException;
057    
058            public void addFile(
059                            long companyId, long repositoryId, String fileName, InputStream is)
060                    throws PortalException;
061    
062            public void checkRoot(long companyId);
063    
064            public void copyFileVersion(
065                            long companyId, long repositoryId, String fileName,
066                            String fromVersionLabel, String toVersionLabel)
067                    throws PortalException;
068    
069            public void deleteDirectory(
070                    long companyId, long repositoryId, String dirName);
071    
072            public void deleteFile(long companyId, long repositoryId, String fileName)
073                    throws PortalException;
074    
075            public void deleteFile(
076                            long companyId, long repositoryId, String fileName,
077                            String versionLabel)
078                    throws PortalException;
079    
080            public File getFile(long companyId, long repositoryId, String fileName)
081                    throws PortalException;
082    
083            public File getFile(
084                            long companyId, long repositoryId, String fileName,
085                            String versionLabel)
086                    throws PortalException;
087    
088            public byte[] getFileAsBytes(
089                            long companyId, long repositoryId, String fileName)
090                    throws PortalException;
091    
092            public byte[] getFileAsBytes(
093                            long companyId, long repositoryId, String fileName,
094                            String versionLabel)
095                    throws PortalException;
096    
097            public InputStream getFileAsStream(
098                            long companyId, long repositoryId, String fileName)
099                    throws PortalException;
100    
101            public InputStream getFileAsStream(
102                            long companyId, long repositoryId, String fileName,
103                            String versionLabel)
104                    throws PortalException;
105    
106            public String[] getFileNames(
107                            long companyId, long repositoryId, String dirName)
108                    throws PortalException;
109    
110            public long getFileSize(long companyId, long repositoryId, String fileName)
111                    throws PortalException;
112    
113            public boolean hasDirectory(
114                            long companyId, long repositoryId, String dirName)
115                    throws PortalException;
116    
117            public boolean hasFile(long companyId, long repositoryId, String fileName)
118                    throws PortalException;
119    
120            public boolean hasFile(
121                            long companyId, long repositoryId, String fileName,
122                            String versionLabel)
123                    throws PortalException;
124    
125            public boolean isValidName(String name);
126    
127            public void move(String srcDir, String destDir);
128    
129            public void updateFile(
130                            long companyId, long repositoryId, long newRepositoryId,
131                            String fileName)
132                    throws PortalException;
133    
134            public void updateFile(
135                            long companyId, long repositoryId, String fileName,
136                            String newFileName)
137                    throws PortalException;
138    
139            public void updateFile(
140                            long companyId, long repositoryId, String fileName,
141                            String fileExtension, boolean validateFileExtension,
142                            String versionLabel, String sourceFileName, File file)
143                    throws PortalException;
144    
145            public void updateFile(
146                            long companyId, long repositoryId, String fileName,
147                            String fileExtension, boolean validateFileExtension,
148                            String versionLabel, String sourceFileName, InputStream is)
149                    throws PortalException;
150    
151            public void updateFileVersion(
152                            long companyId, long repositoryId, String fileName,
153                            String fromVersionLabel, String toVersionLabel)
154                    throws PortalException;
155    
156            public void validate(String fileName, boolean validateFileExtension)
157                    throws PortalException;
158    
159            public void validate(
160                            String fileName, boolean validateFileExtension, byte[] bytes)
161                    throws PortalException;
162    
163            public void validate(
164                            String fileName, boolean validateFileExtension, File file)
165                    throws PortalException;
166    
167            public void validate(
168                            String fileName, boolean validateFileExtension, InputStream is)
169                    throws PortalException;
170    
171            public void validate(
172                            String fileName, String fileExtension, String sourceFileName,
173                            boolean validateFileExtension)
174                    throws PortalException;
175    
176            public void validate(
177                            String fileName, String fileExtension, String sourceFileName,
178                            boolean validateFileExtension, File file)
179                    throws PortalException;
180    
181            public void validate(
182                            String fileName, String fileExtension, String sourceFileName,
183                            boolean validateFileExtension, InputStream is)
184                    throws PortalException;
185    
186            public void validateDirectoryName(String directoryName)
187                    throws PortalException;
188    
189    }