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.repository.proxy;
016    
017    import com.liferay.portal.kernel.exception.PortalException;
018    import com.liferay.portal.kernel.repository.LocalRepository;
019    import com.liferay.portal.kernel.repository.capabilities.Capability;
020    import com.liferay.portal.kernel.repository.model.FileEntry;
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     * @author Mika Koivisto
033     */
034    public class LocalRepositoryProxyBean
035            extends RepositoryModelProxyBean implements LocalRepository {
036    
037            public LocalRepositoryProxyBean(
038                    LocalRepository localRepository, ClassLoader classLoader) {
039    
040                    super(classLoader);
041    
042                    _localRepository = localRepository;
043            }
044    
045            @Override
046            public FileEntry addFileEntry(
047                            long userId, long folderId, String sourceFileName, String mimeType,
048                            String title, String description, String changeLog, File file,
049                            ServiceContext serviceContext)
050                    throws PortalException {
051    
052                    FileEntry fileEntry = _localRepository.addFileEntry(
053                            userId, folderId, sourceFileName, mimeType, title, description,
054                            changeLog, file, serviceContext);
055    
056                    return newFileEntryProxyBean(fileEntry);
057            }
058    
059            @Override
060            public FileEntry addFileEntry(
061                            long userId, long folderId, String sourceFileName, String mimeType,
062                            String title, String description, String changeLog, InputStream is,
063                            long size, ServiceContext serviceContext)
064                    throws PortalException {
065    
066                    FileEntry fileEntry = _localRepository.addFileEntry(
067                            userId, folderId, sourceFileName, mimeType, title, description,
068                            changeLog, is, size, serviceContext);
069    
070                    return newFileEntryProxyBean(fileEntry);
071            }
072    
073            @Override
074            public Folder addFolder(
075                            long userId, long parentFolderId, String name, String description,
076                            ServiceContext serviceContext)
077                    throws PortalException {
078    
079                    Folder folder = _localRepository.addFolder(
080                            userId, parentFolderId, name, description, serviceContext);
081    
082                    return newFolderProxyBean(folder);
083            }
084    
085            @Override
086            public void checkInFileEntry(
087                            long userId, long fileEntryId, boolean major, String changeLog,
088                            ServiceContext serviceContext)
089                    throws PortalException {
090    
091                    _localRepository.checkInFileEntry(
092                            userId, fileEntryId, major, changeLog, serviceContext);
093            }
094    
095            @Override
096            public void checkInFileEntry(
097                            long userId, long fileEntryId, String lockUuid,
098                            ServiceContext serviceContext)
099                    throws PortalException {
100    
101                    _localRepository.checkInFileEntry(
102                            userId, fileEntryId, lockUuid, serviceContext);
103            }
104    
105            @Override
106            public FileEntry copyFileEntry(
107                            long userId, long groupId, long fileEntryId, long destFolderId,
108                            ServiceContext serviceContext)
109                    throws PortalException {
110    
111                    FileEntry fileEntry = _localRepository.copyFileEntry(
112                            userId, groupId, fileEntryId, destFolderId, serviceContext);
113    
114                    return newFileEntryProxyBean(fileEntry);
115            }
116    
117            @Override
118            public void deleteAll() throws PortalException {
119                    _localRepository.deleteAll();
120            }
121    
122            @Override
123            public void deleteFileEntry(long fileEntryId) throws PortalException {
124                    _localRepository.deleteFileEntry(fileEntryId);
125            }
126    
127            @Override
128            public void deleteFolder(long folderId) throws PortalException {
129                    _localRepository.deleteFolder(folderId);
130            }
131    
132            @Override
133            public <T extends Capability> T getCapability(Class<T> capabilityClass) {
134                    return _localRepository.getCapability(capabilityClass);
135            }
136    
137            @Override
138            public FileEntry getFileEntry(long fileEntryId) throws PortalException {
139                    FileEntry fileEntry = _localRepository.getFileEntry(fileEntryId);
140    
141                    return newFileEntryProxyBean(fileEntry);
142            }
143    
144            @Override
145            public FileEntry getFileEntry(long folderId, String title)
146                    throws PortalException {
147    
148                    FileEntry fileEntry = _localRepository.getFileEntry(folderId, title);
149    
150                    return newFileEntryProxyBean(fileEntry);
151            }
152    
153            @Override
154            public FileEntry getFileEntryByUuid(String uuid) throws PortalException {
155                    FileEntry fileEntry = _localRepository.getFileEntryByUuid(uuid);
156    
157                    return newFileEntryProxyBean(fileEntry);
158            }
159    
160            @Override
161            public FileVersion getFileVersion(long fileVersionId)
162                    throws PortalException {
163    
164                    FileVersion fileVersion = _localRepository.getFileVersion(
165                            fileVersionId);
166    
167                    return newFileVersionProxyBean(fileVersion);
168            }
169    
170            @Override
171            public Folder getFolder(long folderId) throws PortalException {
172                    Folder folder = _localRepository.getFolder(folderId);
173    
174                    return newFolderProxyBean(folder);
175            }
176    
177            @Override
178            public Folder getFolder(long parentFolderId, String name)
179                    throws PortalException {
180    
181                    return _localRepository.getFolder(parentFolderId, name);
182            }
183    
184            @Override
185            public List<FileEntry> getRepositoryFileEntries(
186                            long userId, long rootFolderId, int start, int end,
187                            OrderByComparator<FileEntry> obc)
188                    throws PortalException {
189    
190                    return _localRepository.getRepositoryFileEntries(
191                            userId, rootFolderId, start, end, obc);
192            }
193    
194            @Override
195            public long getRepositoryId() {
196                    return _localRepository.getRepositoryId();
197            }
198    
199            @Override
200            public <T extends Capability> boolean isCapabilityProvided(
201                    Class<T> capabilityClass) {
202    
203                    return _localRepository.isCapabilityProvided(capabilityClass);
204            }
205    
206            @Override
207            public FileEntry moveFileEntry(
208                            long userId, long fileEntryId, long newFolderId,
209                            ServiceContext serviceContext)
210                    throws PortalException {
211    
212                    FileEntry fileEntry = _localRepository.moveFileEntry(
213                            userId, fileEntryId, newFolderId, serviceContext);
214    
215                    return newFileEntryProxyBean(fileEntry);
216            }
217    
218            @Override
219            public Folder moveFolder(
220                            long userId, long folderId, long parentFolderId,
221                            ServiceContext serviceContext)
222                    throws PortalException {
223    
224                    Folder folder = _localRepository.moveFolder(
225                            userId, folderId, parentFolderId, serviceContext);
226    
227                    return newFolderProxyBean(folder);
228            }
229    
230            @Override
231            public void revertFileEntry(
232                            long userId, long fileEntryId, String version,
233                            ServiceContext serviceContext)
234                    throws PortalException {
235    
236                    _localRepository.revertFileEntry(
237                            userId, fileEntryId, version, serviceContext);
238            }
239    
240            /**
241             * @deprecated As of 7.0.0, with no direct replacement
242             */
243            @Deprecated
244            @Override
245            public void updateAsset(
246                            long userId, FileEntry fileEntry, FileVersion fileVersion,
247                            long[] assetCategoryIds, String[] assetTagNames,
248                            long[] assetLinkEntryIds)
249                    throws PortalException {
250    
251                    _localRepository.updateAsset(
252                            userId, fileEntry, fileVersion, assetCategoryIds, assetTagNames,
253                            assetLinkEntryIds);
254            }
255    
256            @Override
257            public FileEntry updateFileEntry(
258                            long userId, long fileEntryId, String sourceFileName,
259                            String mimeType, String title, String description, String changeLog,
260                            boolean majorVersion, File file, ServiceContext serviceContext)
261                    throws PortalException {
262    
263                    FileEntry fileEntry = _localRepository.updateFileEntry(
264                            userId, fileEntryId, sourceFileName, mimeType, title, description,
265                            changeLog, majorVersion, file, serviceContext);
266    
267                    return newFileEntryProxyBean(fileEntry);
268            }
269    
270            @Override
271            public FileEntry updateFileEntry(
272                            long userId, long fileEntryId, String sourceFileName,
273                            String mimeType, String title, String description, String changeLog,
274                            boolean majorVersion, InputStream is, long size,
275                            ServiceContext serviceContext)
276                    throws PortalException {
277    
278                    FileEntry fileEntry = _localRepository.updateFileEntry(
279                            userId, fileEntryId, sourceFileName, mimeType, title, description,
280                            changeLog, majorVersion, is, size, serviceContext);
281    
282                    return newFileEntryProxyBean(fileEntry);
283            }
284    
285            @Override
286            public Folder updateFolder(
287                            long folderId, long parentFolderId, String name, String description,
288                            ServiceContext serviceContext)
289                    throws PortalException {
290    
291                    return _localRepository.updateFolder(
292                            folderId, parentFolderId, name, description, serviceContext);
293            }
294    
295            private final LocalRepository _localRepository;
296    
297    }