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