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.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 name, String description,
072                    ServiceContext serviceContext) {
073    
074                    throw new UnsupportedOperationException();
075            }
076    
077            @Override
078            public void checkInFileEntry(
079                            long userId, long fileEntryId, boolean major, String changeLog,
080                            ServiceContext serviceContext)
081                    throws PortalException {
082    
083                    _repository.checkInFileEntry(
084                            userId, fileEntryId, major, changeLog, serviceContext);
085            }
086    
087            @Override
088            public void checkInFileEntry(
089                            long userId, long fileEntryId, String lockUuid,
090                            ServiceContext serviceContext)
091                    throws PortalException {
092    
093                    _repository.checkInFileEntry(
094                            userId, fileEntryId, lockUuid, serviceContext);
095            }
096    
097            @Override
098            public FileEntry copyFileEntry(
099                            long userId, long groupId, long fileEntryId, long destFolderId,
100                            ServiceContext serviceContext)
101                    throws PortalException {
102    
103                    return _repository.copyFileEntry(
104                            userId, groupId, fileEntryId, destFolderId, serviceContext);
105            }
106    
107            @Override
108            public void deleteAll() {
109                    throw new UnsupportedOperationException();
110            }
111    
112            @Override
113            public void deleteFileEntry(long fileEntryId) throws PortalException {
114                    _repository.deleteFileEntry(fileEntryId);
115            }
116    
117            @Override
118            public void deleteFolder(long folderId) throws PortalException {
119                    _repository.deleteFolder(folderId);
120            }
121    
122            @Override
123            public <T extends Capability> T getCapability(Class<T> capabilityClass) {
124                    return _repository.getCapability(capabilityClass);
125            }
126    
127            @Override
128            public FileEntry getFileEntry(long fileEntryId) throws PortalException {
129                    return _repository.getFileEntry(fileEntryId);
130            }
131    
132            @Override
133            public FileEntry getFileEntry(long folderId, String title)
134                    throws PortalException {
135    
136                    return _repository.getFileEntry(folderId, title);
137            }
138    
139            @Override
140            public FileEntry getFileEntryByUuid(String uuid) throws PortalException {
141                    return _repository.getFileEntryByUuid(uuid);
142            }
143    
144            @Override
145            public FileVersion getFileVersion(long fileVersionId)
146                    throws PortalException {
147    
148                    return _repository.getFileVersion(fileVersionId);
149            }
150    
151            @Override
152            public Folder getFolder(long folderId) throws PortalException {
153                    return _repository.getFolder(folderId);
154            }
155    
156            @Override
157            public Folder getFolder(long parentFolderId, String name)
158                    throws PortalException {
159    
160                    return _repository.getFolder(parentFolderId, name);
161            }
162    
163            @Override
164            public List<FileEntry> getRepositoryFileEntries(
165                            long userId, long rootFolderId, int start, int end,
166                            OrderByComparator<FileEntry> obc)
167                    throws PortalException {
168    
169                    return _repository.getRepositoryFileEntries(
170                            userId, rootFolderId, start, end, obc);
171            }
172    
173            @Override
174            public long getRepositoryId() {
175                    return _repository.getRepositoryId();
176            }
177    
178            @Override
179            public <T extends Capability> boolean isCapabilityProvided(
180                    Class<T> capabilityClass) {
181    
182                    return _repository.isCapabilityProvided(capabilityClass);
183            }
184    
185            @Override
186            public FileEntry moveFileEntry(
187                    long userId, long fileEntryId, long newFolderId,
188                    ServiceContext serviceContext) {
189    
190                    throw new UnsupportedOperationException();
191            }
192    
193            @Override
194            public Folder moveFolder(
195                    long userId, long folderId, long parentFolderId,
196                    ServiceContext serviceContext) {
197    
198                    throw new UnsupportedOperationException();
199            }
200    
201            @Override
202            public void revertFileEntry(
203                            long userId, long fileEntryId, String version,
204                            ServiceContext serviceContext)
205                    throws PortalException {
206    
207                    _repository.revertFileEntry(
208                            userId, fileEntryId, version, serviceContext);
209            }
210    
211            @Override
212            public void updateAsset(
213                    long userId, FileEntry fileEntry, FileVersion fileVersion,
214                    long[] assetCategoryIds, String[] assetTagNames,
215                    long[] assetLinkEntryIds) {
216    
217                    throw new UnsupportedOperationException();
218            }
219    
220            @Override
221            public FileEntry updateFileEntry(
222                    long userId, long fileEntryId, String sourceFileName, String mimeType,
223                    String title, String description, String changeLog,
224                    boolean majorVersion, File file, ServiceContext serviceContext) {
225    
226                    throw new UnsupportedOperationException();
227            }
228    
229            @Override
230            public FileEntry updateFileEntry(
231                    long userId, long fileEntryId, String sourceFileName, String mimeType,
232                    String title, String description, String changeLog,
233                    boolean majorVersion, InputStream is, long size,
234                    ServiceContext serviceContext) {
235    
236                    throw new UnsupportedOperationException();
237            }
238    
239            @Override
240            public Folder updateFolder(
241                    long folderId, long parentFolderId, String name, String description,
242                    ServiceContext serviceContext) {
243    
244                    throw new UnsupportedOperationException();
245            }
246    
247            private final Repository _repository;
248    
249    }