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    
019    import java.io.File;
020    import java.io.InputStream;
021    
022    /**
023     * The interface for all file store implementations. Most, if not all
024     * implementations should extend from the class {@link BaseStore}.
025     *
026     * @author Brian Wing Shun Chan
027     * @author Edward Han
028     * @see    BaseStore
029     */
030    public interface Store {
031    
032            public static final String VERSION_DEFAULT = "1.0";
033    
034            public void addDirectory(long companyId, long repositoryId, String dirName)
035                    throws PortalException;
036    
037            public void addFile(
038                            long companyId, long repositoryId, String fileName, byte[] bytes)
039                    throws PortalException;
040    
041            public void addFile(
042                            long companyId, long repositoryId, String fileName, File file)
043                    throws PortalException;
044    
045            public void addFile(
046                            long companyId, long repositoryId, String fileName, InputStream is)
047                    throws PortalException;
048    
049            public void checkRoot(long companyId);
050    
051            public void copyFileVersion(
052                            long companyId, long repositoryId, String fileName,
053                            String fromVersionLabel, String toVersionLabel)
054                    throws PortalException;
055    
056            public void deleteDirectory(
057                            long companyId, long repositoryId, String dirName)
058                    throws PortalException;
059    
060            public void deleteFile(long companyId, long repositoryId, String fileName)
061                    throws PortalException;
062    
063            public void deleteFile(
064                            long companyId, long repositoryId, String fileName,
065                            String versionLabel)
066                    throws PortalException;
067    
068            public File getFile(long companyId, long repositoryId, String fileName)
069                    throws PortalException;
070    
071            public File getFile(
072                            long companyId, long repositoryId, String fileName,
073                            String versionLabel)
074                    throws PortalException;
075    
076            public byte[] getFileAsBytes(
077                            long companyId, long repositoryId, String fileName)
078                    throws PortalException;
079    
080            public byte[] getFileAsBytes(
081                            long companyId, long repositoryId, String fileName,
082                            String versionLabel)
083                    throws PortalException;
084    
085            public InputStream getFileAsStream(
086                            long companyId, long repositoryId, String fileName)
087                    throws PortalException;
088    
089            public InputStream getFileAsStream(
090                            long companyId, long repositoryId, String fileName,
091                            String versionLabel)
092                    throws PortalException;
093    
094            public String[] getFileNames(long companyId, long repositoryId);
095    
096            public String[] getFileNames(
097                            long companyId, long repositoryId, String dirName)
098                    throws PortalException;
099    
100            public long getFileSize(long companyId, long repositoryId, String fileName)
101                    throws PortalException;
102    
103            public boolean hasDirectory(
104                            long companyId, long repositoryId, String dirName)
105                    throws PortalException;
106    
107            public boolean hasFile(long companyId, long repositoryId, String fileName)
108                    throws PortalException;
109    
110            public boolean hasFile(
111                            long companyId, long repositoryId, String fileName,
112                            String versionLabel)
113                    throws PortalException;
114    
115            public void move(String srcDir, String destDir);
116    
117            public void updateFile(
118                            long companyId, long repositoryId, long newRepositoryId,
119                            String fileName)
120                    throws PortalException;
121    
122            public void updateFile(
123                            long companyId, long repositoryId, String fileName,
124                            String newFileName)
125                    throws PortalException;
126    
127            public void updateFile(
128                            long companyId, long repositoryId, String fileName,
129                            String versionLabel, byte[] bytes)
130                    throws PortalException;
131    
132            public void updateFile(
133                            long companyId, long repositoryId, String fileName,
134                            String versionLabel, File file)
135                    throws PortalException;
136    
137            public void updateFile(
138                            long companyId, long repositoryId, String fileName,
139                            String versionLabel, InputStream is)
140                    throws PortalException;
141    
142            public void updateFileVersion(
143                            long companyId, long repositoryId, String fileName,
144                            String fromVersionLabel, String toVersionLabel)
145                    throws PortalException;
146    
147    }