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