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 getFoldersAndFileEntriesAndFileShortcutsCount(
266                            long folderId, int status, boolean includeMountFolders)
267                    throws PortalException {
268    
269                    return _repository.getFoldersAndFileEntriesAndFileShortcutsCount(
270                            folderId, status, includeMountFolders);
271            }
272    
273            @Override
274            public int getFoldersCount(long parentFolderId, boolean includeMountfolders)
275                    throws PortalException {
276    
277                    return _repository.getFoldersCount(parentFolderId, includeMountfolders);
278            }
279    
280            @Override
281            public int getFoldersCount(
282                            long parentFolderId, int status, boolean includeMountfolders)
283                    throws PortalException {
284    
285                    return _repository.getFoldersCount(
286                            parentFolderId, status, includeMountfolders);
287            }
288    
289            @Override
290            public List<FileEntry> getRepositoryFileEntries(
291                            long userId, long rootFolderId, int start, int end,
292                            OrderByComparator<FileEntry> obc)
293                    throws PortalException {
294    
295                    return _repository.getRepositoryFileEntries(
296                            userId, rootFolderId, start, end, obc);
297            }
298    
299            @Override
300            public long getRepositoryId() {
301                    return _repository.getRepositoryId();
302            }
303    
304            @Override
305            public <T extends Capability> boolean isCapabilityProvided(
306                    Class<T> capabilityClass) {
307    
308                    return _repository.isCapabilityProvided(capabilityClass);
309            }
310    
311            @Override
312            public FileEntry moveFileEntry(
313                    long userId, long fileEntryId, long newFolderId,
314                    ServiceContext serviceContext) {
315    
316                    throw new UnsupportedOperationException();
317            }
318    
319            @Override
320            public Folder moveFolder(
321                    long userId, long folderId, long parentFolderId,
322                    ServiceContext serviceContext) {
323    
324                    throw new UnsupportedOperationException();
325            }
326    
327            @Override
328            public void revertFileEntry(
329                            long userId, long fileEntryId, String version,
330                            ServiceContext serviceContext)
331                    throws PortalException {
332    
333                    _repository.revertFileEntry(
334                            userId, fileEntryId, version, serviceContext);
335            }
336    
337            /**
338             * @deprecated As of 7.0.0
339             */
340            @Deprecated
341            @Override
342            public void updateAsset(
343                    long userId, FileEntry fileEntry, FileVersion fileVersion,
344                    long[] assetCategoryIds, String[] assetTagNames,
345                    long[] assetLinkEntryIds) {
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, File file, ServiceContext serviceContext) {
355    
356                    throw new UnsupportedOperationException();
357            }
358    
359            @Override
360            public FileEntry updateFileEntry(
361                    long userId, long fileEntryId, String sourceFileName, String mimeType,
362                    String title, String description, String changeLog,
363                    boolean majorVersion, InputStream is, long size,
364                    ServiceContext serviceContext) {
365    
366                    throw new UnsupportedOperationException();
367            }
368    
369            @Override
370            public FileShortcut updateFileShortcut(
371                    long userId, long fileShortcutId, long folderId, long toFileEntryId,
372                    ServiceContext serviceContext) {
373    
374                    throw new UnsupportedOperationException();
375            }
376    
377            @Override
378            public void updateFileShortcuts(
379                    long oldToFileEntryId, long newToFileEntryId) {
380    
381                    throw new UnsupportedOperationException();
382            }
383    
384            @Override
385            public Folder updateFolder(
386                    long folderId, long parentFolderId, String name, String description,
387                    ServiceContext serviceContext) {
388    
389                    throw new UnsupportedOperationException();
390            }
391    
392            private final Repository _repository;
393    
394    }