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