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 boolean isValidName(String name);
127    
128            public void move(String srcDir, String destDir) throws SystemException;
129    
130            public void updateFile(
131                            long companyId, long repositoryId, long newRepositoryId,
132                            String fileName)
133                    throws PortalException, SystemException;
134    
135            public void updateFile(
136                            long companyId, long repositoryId, String fileName,
137                            String newFileName)
138                    throws PortalException, SystemException;
139    
140            public void updateFile(
141                            long companyId, long repositoryId, String fileName,
142                            String fileExtension, boolean validateFileExtension,
143                            String versionLabel, String sourceFileName, File file)
144                    throws PortalException, SystemException;
145    
146            public void updateFile(
147                            long companyId, long repositoryId, String fileName,
148                            String fileExtension, boolean validateFileExtension,
149                            String versionLabel, String sourceFileName, InputStream is)
150                    throws PortalException, SystemException;
151    
152            public void updateFileVersion(
153                            long companyId, long repositoryId, String fileName,
154                            String fromVersionLabel, String toVersionLabel)
155                    throws PortalException, SystemException;
156    
157            public void validate(String fileName, boolean validateFileExtension)
158                    throws PortalException, SystemException;
159    
160            public void validate(
161                            String fileName, boolean validateFileExtension, byte[] bytes)
162                    throws PortalException, SystemException;
163    
164            public void validate(
165                            String fileName, boolean validateFileExtension, File file)
166                    throws PortalException, SystemException;
167    
168            public void validate(
169                            String fileName, boolean validateFileExtension, InputStream is)
170                    throws PortalException, SystemException;
171    
172            public void validate(
173                            String fileName, String fileExtension, String sourceFileName,
174                            boolean validateFileExtension, File file)
175                    throws PortalException, SystemException;
176    
177            public void validate(
178                            String fileName, String fileExtension, String sourceFileName,
179                            boolean validateFileExtension, InputStream is)
180                    throws PortalException, SystemException;
181    
182            public void validateDirectoryName(String directoryName)
183                    throws PortalException;
184    
185    }