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 int getFoldersCount(long parentFolderId, boolean includeMountfolders)
287                    throws PortalException {
288    
289                    return _localRepository.getFoldersCount(
290                            parentFolderId, includeMountfolders);
291            }
292    
293            @Override
294            public int getFoldersCount(
295                            long parentFolderId, int status, boolean includeMountfolders)
296                    throws PortalException {
297    
298                    return _localRepository.getFoldersCount(
299                            parentFolderId, status, includeMountfolders);
300            }
301    
302            @Override
303            public List<FileEntry> getRepositoryFileEntries(
304                            long userId, long rootFolderId, int start, int end,
305                            OrderByComparator<FileEntry> obc)
306                    throws PortalException {
307    
308                    return _localRepository.getRepositoryFileEntries(
309                            userId, rootFolderId, start, end, obc);
310            }
311    
312            @Override
313            public long getRepositoryId() {
314                    return _localRepository.getRepositoryId();
315            }
316    
317            @Override
318            public <T extends Capability> boolean isCapabilityProvided(
319                    Class<T> capabilityClass) {
320    
321                    return _localRepository.isCapabilityProvided(capabilityClass);
322            }
323    
324            @Override
325            public FileEntry moveFileEntry(
326                            long userId, long fileEntryId, long newFolderId,
327                            ServiceContext serviceContext)
328                    throws PortalException {
329    
330                    FileEntry fileEntry = _localRepository.moveFileEntry(
331                            userId, fileEntryId, newFolderId, serviceContext);
332    
333                    return newFileEntryProxyBean(fileEntry);
334            }
335    
336            @Override
337            public Folder moveFolder(
338                            long userId, long folderId, long parentFolderId,
339                            ServiceContext serviceContext)
340                    throws PortalException {
341    
342                    Folder folder = _localRepository.moveFolder(
343                            userId, folderId, parentFolderId, serviceContext);
344    
345                    return newFolderProxyBean(folder);
346            }
347    
348            @Override
349            public void revertFileEntry(
350                            long userId, long fileEntryId, String version,
351                            ServiceContext serviceContext)
352                    throws PortalException {
353    
354                    _localRepository.revertFileEntry(
355                            userId, fileEntryId, version, serviceContext);
356            }
357    
358            /**
359             * @deprecated As of 7.0.0, with no direct replacement
360             */
361            @Deprecated
362            @Override
363            public void updateAsset(
364                            long userId, FileEntry fileEntry, FileVersion fileVersion,
365                            long[] assetCategoryIds, String[] assetTagNames,
366                            long[] assetLinkEntryIds)
367                    throws PortalException {
368    
369                    _localRepository.updateAsset(
370                            userId, fileEntry, fileVersion, assetCategoryIds, assetTagNames,
371                            assetLinkEntryIds);
372            }
373    
374            @Override
375            public FileEntry updateFileEntry(
376                            long userId, long fileEntryId, String sourceFileName,
377                            String mimeType, String title, String description, String changeLog,
378                            boolean majorVersion, File file, ServiceContext serviceContext)
379                    throws PortalException {
380    
381                    FileEntry fileEntry = _localRepository.updateFileEntry(
382                            userId, fileEntryId, sourceFileName, mimeType, title, description,
383                            changeLog, majorVersion, file, serviceContext);
384    
385                    return newFileEntryProxyBean(fileEntry);
386            }
387    
388            @Override
389            public FileEntry updateFileEntry(
390                            long userId, long fileEntryId, String sourceFileName,
391                            String mimeType, String title, String description, String changeLog,
392                            boolean majorVersion, InputStream is, long size,
393                            ServiceContext serviceContext)
394                    throws PortalException {
395    
396                    FileEntry fileEntry = _localRepository.updateFileEntry(
397                            userId, fileEntryId, sourceFileName, mimeType, title, description,
398                            changeLog, majorVersion, is, size, serviceContext);
399    
400                    return newFileEntryProxyBean(fileEntry);
401            }
402    
403            @Override
404            public FileShortcut updateFileShortcut(
405                            long userId, long fileShortcutId, long folderId, long toFileEntryId,
406                            ServiceContext serviceContext)
407                    throws PortalException {
408    
409                    FileShortcut fileShortcut = _localRepository.updateFileShortcut(
410                            userId, fileShortcutId, folderId, toFileEntryId, serviceContext);
411    
412                    return newFileShortcutProxyBean(fileShortcut);
413            }
414    
415            @Override
416            public void updateFileShortcuts(
417                            long oldToFileEntryId, long newToFileEntryId)
418                    throws PortalException {
419    
420                    _localRepository.updateFileShortcuts(
421                            oldToFileEntryId, newToFileEntryId);
422            }
423    
424            @Override
425            public Folder updateFolder(
426                            long folderId, long parentFolderId, String name, String description,
427                            ServiceContext serviceContext)
428                    throws PortalException {
429    
430                    return _localRepository.updateFolder(
431                            folderId, parentFolderId, name, description, serviceContext);
432            }
433    
434            private final LocalRepository _localRepository;
435    
436    }