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.FileShortcut;
022    import com.liferay.portal.kernel.repository.model.FileVersion;
023    import com.liferay.portal.kernel.repository.model.Folder;
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     * @author Mika Koivisto
034     */
035    public class LocalRepositoryProxyBean
036            extends RepositoryModelProxyBean implements LocalRepository {
037    
038            public LocalRepositoryProxyBean(
039                    LocalRepository localRepository, ClassLoader classLoader) {
040    
041                    super(classLoader);
042    
043                    _localRepository = localRepository;
044            }
045    
046            @Override
047            public FileEntry addFileEntry(
048                            long userId, long folderId, String sourceFileName, String mimeType,
049                            String title, String description, String changeLog, File file,
050                            ServiceContext serviceContext)
051                    throws PortalException {
052    
053                    FileEntry fileEntry = _localRepository.addFileEntry(
054                            userId, folderId, sourceFileName, mimeType, title, description,
055                            changeLog, file, serviceContext);
056    
057                    return newFileEntryProxyBean(fileEntry);
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                    throws PortalException {
066    
067                    FileEntry fileEntry = _localRepository.addFileEntry(
068                            userId, folderId, sourceFileName, mimeType, title, description,
069                            changeLog, is, size, serviceContext);
070    
071                    return newFileEntryProxyBean(fileEntry);
072            }
073    
074            @Override
075            public FileShortcut addFileShortcut(
076                            long userId, long folderId, long toFileEntryId,
077                            ServiceContext serviceContext)
078                    throws PortalException {
079    
080                    FileShortcut fileShortcut = _localRepository.addFileShortcut(
081                            userId, folderId, toFileEntryId, serviceContext);
082    
083                    return newFileShortcutProxyBean(fileShortcut);
084            }
085    
086            @Override
087            public Folder addFolder(
088                            long userId, long parentFolderId, String name, String description,
089                            ServiceContext serviceContext)
090                    throws PortalException {
091    
092                    Folder folder = _localRepository.addFolder(
093                            userId, parentFolderId, name, description, serviceContext);
094    
095                    return newFolderProxyBean(folder);
096            }
097    
098            @Override
099            public void checkInFileEntry(
100                            long userId, long fileEntryId, boolean major, String changeLog,
101                            ServiceContext serviceContext)
102                    throws PortalException {
103    
104                    _localRepository.checkInFileEntry(
105                            userId, fileEntryId, major, changeLog, serviceContext);
106            }
107    
108            @Override
109            public void checkInFileEntry(
110                            long userId, long fileEntryId, String lockUuid,
111                            ServiceContext serviceContext)
112                    throws PortalException {
113    
114                    _localRepository.checkInFileEntry(
115                            userId, fileEntryId, lockUuid, serviceContext);
116            }
117    
118            @Override
119            public FileEntry copyFileEntry(
120                            long userId, long groupId, long fileEntryId, long destFolderId,
121                            ServiceContext serviceContext)
122                    throws PortalException {
123    
124                    FileEntry fileEntry = _localRepository.copyFileEntry(
125                            userId, groupId, fileEntryId, destFolderId, serviceContext);
126    
127                    return newFileEntryProxyBean(fileEntry);
128            }
129    
130            @Override
131            public void deleteAll() throws PortalException {
132                    _localRepository.deleteAll();
133            }
134    
135            @Override
136            public void deleteFileEntry(long fileEntryId) throws PortalException {
137                    _localRepository.deleteFileEntry(fileEntryId);
138            }
139    
140            @Override
141            public void deleteFileShortcut(long fileShortcutId) throws PortalException {
142                    _localRepository.deleteFileShortcut(fileShortcutId);
143            }
144    
145            @Override
146            public void deleteFileShortcuts(long toFileEntryId) throws PortalException {
147                    _localRepository.deleteFileShortcuts(toFileEntryId);
148            }
149    
150            @Override
151            public void deleteFolder(long folderId) throws PortalException {
152                    _localRepository.deleteFolder(folderId);
153            }
154    
155            @Override
156            public <T extends Capability> T getCapability(Class<T> capabilityClass) {
157                    return _localRepository.getCapability(capabilityClass);
158            }
159    
160            @Override
161            public List<FileEntry> getFileEntries(
162                            long folderId, int status, int start, int end,
163                            OrderByComparator<FileEntry> obc)
164                    throws PortalException {
165    
166                    return _localRepository.getFileEntries(
167                            folderId, status, start, end, obc);
168            }
169    
170            @Override
171            public List<FileEntry> getFileEntries(
172                            long folderId, int start, int end, OrderByComparator<FileEntry> obc)
173                    throws PortalException {
174    
175                    return _localRepository.getFileEntries(folderId, start, end, obc);
176            }
177    
178            @Override
179            public int getFileEntriesCount(long folderId) throws PortalException {
180                    return _localRepository.getFileEntriesCount(folderId);
181            }
182    
183            @Override
184            public int getFileEntriesCount(long folderId, int status)
185                    throws PortalException {
186    
187                    return _localRepository.getFileEntriesCount(folderId, status);
188            }
189    
190            @Override
191            public FileEntry getFileEntry(long fileEntryId) throws PortalException {
192                    FileEntry fileEntry = _localRepository.getFileEntry(fileEntryId);
193    
194                    return newFileEntryProxyBean(fileEntry);
195            }
196    
197            @Override
198            public FileEntry getFileEntry(long folderId, String title)
199                    throws PortalException {
200    
201                    FileEntry fileEntry = _localRepository.getFileEntry(folderId, title);
202    
203                    return newFileEntryProxyBean(fileEntry);
204            }
205    
206            @Override
207            public FileEntry getFileEntryByUuid(String uuid) throws PortalException {
208                    FileEntry fileEntry = _localRepository.getFileEntryByUuid(uuid);
209    
210                    return newFileEntryProxyBean(fileEntry);
211            }
212    
213            @Override
214            public FileShortcut getFileShortcut(long fileShortcutId)
215                    throws PortalException {
216    
217                    FileShortcut fileShortcut = _localRepository.getFileShortcut(
218                            fileShortcutId);
219    
220                    return newFileShortcutProxyBean(fileShortcut);
221            }
222    
223            @Override
224            public FileVersion getFileVersion(long fileVersionId)
225                    throws PortalException {
226    
227                    FileVersion fileVersion = _localRepository.getFileVersion(
228                            fileVersionId);
229    
230                    return newFileVersionProxyBean(fileVersion);
231            }
232    
233            @Override
234            public Folder getFolder(long folderId) throws PortalException {
235                    Folder folder = _localRepository.getFolder(folderId);
236    
237                    return newFolderProxyBean(folder);
238            }
239    
240            @Override
241            public Folder getFolder(long parentFolderId, String name)
242                    throws PortalException {
243    
244                    return _localRepository.getFolder(parentFolderId, name);
245            }
246    
247            @Override
248            public List<FileEntry> getRepositoryFileEntries(
249                            long userId, long rootFolderId, int start, int end,
250                            OrderByComparator<FileEntry> obc)
251                    throws PortalException {
252    
253                    return _localRepository.getRepositoryFileEntries(
254                            userId, rootFolderId, start, end, obc);
255            }
256    
257            @Override
258            public long getRepositoryId() {
259                    return _localRepository.getRepositoryId();
260            }
261    
262            @Override
263            public <T extends Capability> boolean isCapabilityProvided(
264                    Class<T> capabilityClass) {
265    
266                    return _localRepository.isCapabilityProvided(capabilityClass);
267            }
268    
269            @Override
270            public FileEntry moveFileEntry(
271                            long userId, long fileEntryId, long newFolderId,
272                            ServiceContext serviceContext)
273                    throws PortalException {
274    
275                    FileEntry fileEntry = _localRepository.moveFileEntry(
276                            userId, fileEntryId, newFolderId, serviceContext);
277    
278                    return newFileEntryProxyBean(fileEntry);
279            }
280    
281            @Override
282            public Folder moveFolder(
283                            long userId, long folderId, long parentFolderId,
284                            ServiceContext serviceContext)
285                    throws PortalException {
286    
287                    Folder folder = _localRepository.moveFolder(
288                            userId, folderId, parentFolderId, serviceContext);
289    
290                    return newFolderProxyBean(folder);
291            }
292    
293            @Override
294            public void revertFileEntry(
295                            long userId, long fileEntryId, String version,
296                            ServiceContext serviceContext)
297                    throws PortalException {
298    
299                    _localRepository.revertFileEntry(
300                            userId, fileEntryId, version, serviceContext);
301            }
302    
303            /**
304             * @deprecated As of 7.0.0, with no direct replacement
305             */
306            @Deprecated
307            @Override
308            public void updateAsset(
309                            long userId, FileEntry fileEntry, FileVersion fileVersion,
310                            long[] assetCategoryIds, String[] assetTagNames,
311                            long[] assetLinkEntryIds)
312                    throws PortalException {
313    
314                    _localRepository.updateAsset(
315                            userId, fileEntry, fileVersion, assetCategoryIds, assetTagNames,
316                            assetLinkEntryIds);
317            }
318    
319            @Override
320            public FileEntry updateFileEntry(
321                            long userId, long fileEntryId, String sourceFileName,
322                            String mimeType, String title, String description, String changeLog,
323                            boolean majorVersion, File file, ServiceContext serviceContext)
324                    throws PortalException {
325    
326                    FileEntry fileEntry = _localRepository.updateFileEntry(
327                            userId, fileEntryId, sourceFileName, mimeType, title, description,
328                            changeLog, majorVersion, file, serviceContext);
329    
330                    return newFileEntryProxyBean(fileEntry);
331            }
332    
333            @Override
334            public FileEntry updateFileEntry(
335                            long userId, long fileEntryId, String sourceFileName,
336                            String mimeType, String title, String description, String changeLog,
337                            boolean majorVersion, InputStream is, long size,
338                            ServiceContext serviceContext)
339                    throws PortalException {
340    
341                    FileEntry fileEntry = _localRepository.updateFileEntry(
342                            userId, fileEntryId, sourceFileName, mimeType, title, description,
343                            changeLog, majorVersion, is, size, serviceContext);
344    
345                    return newFileEntryProxyBean(fileEntry);
346            }
347    
348            @Override
349            public FileShortcut updateFileShortcut(
350                            long userId, long fileShortcutId, long folderId, long toFileEntryId,
351                            ServiceContext serviceContext)
352                    throws PortalException {
353    
354                    FileShortcut fileShortcut = _localRepository.updateFileShortcut(
355                            userId, fileShortcutId, folderId, toFileEntryId, serviceContext);
356    
357                    return newFileShortcutProxyBean(fileShortcut);
358            }
359    
360            @Override
361            public void updateFileShortcuts(
362                            long oldToFileEntryId, long newToFileEntryId)
363                    throws PortalException {
364    
365                    _localRepository.updateFileShortcuts(
366                            oldToFileEntryId, newToFileEntryId);
367            }
368    
369            @Override
370            public Folder updateFolder(
371                            long folderId, long parentFolderId, String name, String description,
372                            ServiceContext serviceContext)
373                    throws PortalException {
374    
375                    return _localRepository.updateFolder(
376                            folderId, parentFolderId, name, description, serviceContext);
377            }
378    
379            private final LocalRepository _localRepository;
380    
381    }