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