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.portal.kernel.repository;
016    
017    import com.liferay.portal.kernel.exception.PortalException;
018    import com.liferay.portal.kernel.exception.SystemException;
019    import com.liferay.portal.kernel.repository.model.FileEntry;
020    import com.liferay.portal.kernel.repository.model.FileVersion;
021    import com.liferay.portal.kernel.repository.model.Folder;
022    import com.liferay.portal.kernel.util.OrderByComparator;
023    import com.liferay.portal.service.ServiceContext;
024    
025    import java.io.File;
026    import java.io.InputStream;
027    
028    import java.util.List;
029    
030    /**
031     * This class is designed for third party repository implementations. Since the
032     * paradigm of remote and local services exists only within Liferay, the
033     * assumption is that all permission checking will be delegated to the specific
034     * repository.
035     *
036     * There are also many calls within this class that pass in a user ID as a
037     * parameter. These methods should only be called for administration of Liferay
038     * repositories and are hence not supported in all third party repositories.
039     * This includes moving between document library hooks and LAR import/export.
040     * Calling these methods will throw an
041     * <code>UnsupportedOperationException</code>.
042     *
043     * @author Alexander Chow
044     */
045    public class DefaultLocalRepositoryImpl implements LocalRepository {
046    
047            public DefaultLocalRepositoryImpl(Repository repository) {
048                    _repository = repository;
049            }
050    
051            @Override
052            public FileEntry addFileEntry(
053                    long userId, long folderId, String sourceFileName, String mimeType,
054                    String title, String description, String changeLog, File file,
055                    ServiceContext serviceContext) {
056    
057                    throw new UnsupportedOperationException();
058            }
059    
060            @Override
061            public FileEntry addFileEntry(
062                    long userId, long folderId, String sourceFileName, String mimeType,
063                    String title, String description, String changeLog, InputStream is,
064                    long size, ServiceContext serviceContext) {
065    
066                    throw new UnsupportedOperationException();
067            }
068    
069            @Override
070            public Folder addFolder(
071                    long userId, long parentFolderId, String title, String description,
072                    ServiceContext serviceContext) {
073    
074                    throw new UnsupportedOperationException();
075            }
076    
077            @Override
078            public void deleteAll() {
079                    throw new UnsupportedOperationException();
080            }
081    
082            @Override
083            public void deleteFileEntry(long fileEntryId)
084                    throws PortalException, SystemException {
085    
086                    _repository.deleteFileEntry(fileEntryId);
087            }
088    
089            @Override
090            public void deleteFolder(long folderId)
091                    throws PortalException, SystemException {
092    
093                    _repository.deleteFolder(folderId);
094            }
095    
096            @Override
097            public List<FileEntry> getFileEntries(
098                            long folderId, int start, int end, OrderByComparator obc)
099                    throws SystemException {
100    
101                    return _repository.getFileEntries(folderId, start, end, obc);
102            }
103    
104            @Override
105            public List<Object> getFileEntriesAndFileShortcuts(
106                            long folderId, int status, int start, int end)
107                    throws SystemException {
108    
109                    return _repository.getFileEntriesAndFileShortcuts(
110                            folderId, status, start, end);
111            }
112    
113            @Override
114            public int getFileEntriesAndFileShortcutsCount(long folderId, int status)
115                    throws SystemException {
116    
117                    return _repository.getFileEntriesAndFileShortcutsCount(
118                            folderId, status);
119            }
120    
121            @Override
122            public int getFileEntriesCount(long folderId) throws SystemException {
123                    return _repository.getFileEntriesCount(folderId);
124            }
125    
126            @Override
127            public FileEntry getFileEntry(long fileEntryId)
128                    throws PortalException, SystemException {
129    
130                    return _repository.getFileEntry(fileEntryId);
131            }
132    
133            @Override
134            public FileEntry getFileEntry(long folderId, String title)
135                    throws PortalException, SystemException {
136    
137                    return _repository.getFileEntry(folderId, title);
138            }
139    
140            @Override
141            public FileEntry getFileEntryByUuid(String uuid)
142                    throws PortalException, SystemException {
143    
144                    return _repository.getFileEntryByUuid(uuid);
145            }
146    
147            @Override
148            public FileVersion getFileVersion(long fileVersionId)
149                    throws PortalException, SystemException {
150    
151                    return _repository.getFileVersion(fileVersionId);
152            }
153    
154            @Override
155            public Folder getFolder(long folderId)
156                    throws PortalException, SystemException {
157    
158                    return _repository.getFolder(folderId);
159            }
160    
161            @Override
162            public Folder getFolder(long parentFolderId, String title)
163                    throws PortalException, SystemException {
164    
165                    return _repository.getFolder(parentFolderId, title);
166            }
167    
168            @Override
169            public List<Folder> getFolders(
170                            long parentFolderId, boolean includeMountfolders, int start,
171                            int end, OrderByComparator obc)
172                    throws PortalException, SystemException {
173    
174                    return _repository.getFolders(
175                            parentFolderId, includeMountfolders, start, end, obc);
176            }
177    
178            @Override
179            public List<Object> getFoldersAndFileEntriesAndFileShortcuts(
180                            long folderId, int status, boolean includeMountFolders, int start,
181                            int end, OrderByComparator obc)
182                    throws SystemException {
183    
184                    return _repository.getFoldersAndFileEntriesAndFileShortcuts(
185                            folderId, status, includeMountFolders, start, end, obc);
186            }
187    
188            public List<Object> getFoldersAndFileEntriesAndFileShortcuts(
189                            long folderId, int status, int start, int end,
190                            OrderByComparator obc)
191                    throws SystemException {
192    
193                    return getFoldersAndFileEntriesAndFileShortcuts(
194                            folderId, status, true, start, end, obc);
195            }
196    
197            @Override
198            public List<Object> getFoldersAndFileEntriesAndFileShortcuts(
199                            long folderId, int status, String[] mimeTypes,
200                            boolean includeMountFolders, int start, int end,
201                            OrderByComparator obc)
202                    throws PortalException, SystemException {
203    
204                    return _repository.getFoldersAndFileEntriesAndFileShortcuts(
205                            folderId, status, mimeTypes, includeMountFolders, start, end, obc);
206            }
207    
208            public int getFoldersAndFileEntriesAndFileShortcutsCount(
209                            long folderId, int status)
210                    throws SystemException {
211    
212                    return getFoldersAndFileEntriesAndFileShortcutsCount(
213                            folderId, status, true);
214            }
215    
216            @Override
217            public int getFoldersAndFileEntriesAndFileShortcutsCount(
218                            long folderId, int status, boolean includeMountFolders)
219                    throws SystemException {
220    
221                    return _repository.getFoldersAndFileEntriesAndFileShortcutsCount(
222                            folderId, status, includeMountFolders);
223            }
224    
225            @Override
226            public int getFoldersAndFileEntriesAndFileShortcutsCount(
227                            long folderId, int status, String[] mimeTypes,
228                            boolean includeMountFolders)
229                    throws PortalException, SystemException {
230    
231                    return _repository.getFoldersAndFileEntriesAndFileShortcutsCount(
232                            folderId, status, mimeTypes, includeMountFolders);
233            }
234    
235            @Override
236            public int getFoldersCount(long parentFolderId, boolean includeMountfolders)
237                    throws PortalException, SystemException {
238    
239                    return _repository.getFoldersCount(parentFolderId, includeMountfolders);
240            }
241    
242            @Override
243            public int getFoldersFileEntriesCount(List<Long> folderIds, int status)
244                    throws SystemException {
245    
246                    return _repository.getFoldersFileEntriesCount(folderIds, status);
247            }
248    
249            @Override
250            public List<Folder> getMountFolders(
251                            long parentFolderId, int start, int end, OrderByComparator obc)
252                    throws SystemException {
253    
254                    return _repository.getMountFolders(parentFolderId, start, end, obc);
255            }
256    
257            @Override
258            public int getMountFoldersCount(long parentFolderId)
259                    throws SystemException {
260    
261                    return _repository.getMountFoldersCount(parentFolderId);
262            }
263    
264            @Override
265            public long getRepositoryId() {
266                    return _repository.getRepositoryId();
267            }
268    
269            @Override
270            public FileEntry moveFileEntry(
271                    long userId, long fileEntryId, long newFolderId,
272                    ServiceContext serviceContext) {
273    
274                    throw new UnsupportedOperationException();
275            }
276    
277            @Override
278            public void updateAsset(
279                    long userId, FileEntry fileEntry, FileVersion fileVersion,
280                    long[] assetCategoryIds, String[] assetTagNames,
281                    long[] assetLinkEntryIds) {
282    
283                    throw new UnsupportedOperationException();
284            }
285    
286            @Override
287            public FileEntry updateFileEntry(
288                    long userId, long fileEntryId, String sourceFileName, String mimeType,
289                    String title, String description, String changeLog,
290                    boolean majorVersion, File file, ServiceContext serviceContext) {
291    
292                    throw new UnsupportedOperationException();
293            }
294    
295            @Override
296            public FileEntry updateFileEntry(
297                    long userId, long fileEntryId, String sourceFileName, String mimeType,
298                    String title, String description, String changeLog,
299                    boolean majorVersion, InputStream is, long size,
300                    ServiceContext serviceContext) {
301    
302                    throw new UnsupportedOperationException();
303            }
304    
305            @Override
306            public Folder updateFolder(
307                    long folderId, long parentFolderId, String title, String description,
308                    ServiceContext serviceContext) {
309    
310                    throw new UnsupportedOperationException();
311            }
312    
313            private Repository _repository;
314    
315    }