001    /**
002     * Copyright (c) 2000-2013 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.counter.service.CounterLocalService;
018    import com.liferay.portal.kernel.exception.PortalException;
019    import com.liferay.portal.kernel.exception.SystemException;
020    import com.liferay.portal.kernel.repository.BaseRepository;
021    import com.liferay.portal.kernel.repository.LocalRepository;
022    import com.liferay.portal.kernel.repository.model.FileEntry;
023    import com.liferay.portal.kernel.repository.model.FileVersion;
024    import com.liferay.portal.kernel.repository.model.Folder;
025    import com.liferay.portal.kernel.search.Hits;
026    import com.liferay.portal.kernel.search.Query;
027    import com.liferay.portal.kernel.search.SearchContext;
028    import com.liferay.portal.kernel.search.SearchException;
029    import com.liferay.portal.kernel.util.OrderByComparator;
030    import com.liferay.portal.kernel.util.UnicodeProperties;
031    import com.liferay.portal.model.Lock;
032    import com.liferay.portal.service.CompanyLocalService;
033    import com.liferay.portal.service.ServiceContext;
034    import com.liferay.portal.service.UserLocalService;
035    import com.liferay.portlet.asset.service.AssetEntryLocalService;
036    import com.liferay.portlet.documentlibrary.service.DLAppHelperLocalService;
037    
038    import java.io.File;
039    import java.io.InputStream;
040    
041    import java.util.List;
042    
043    /**
044     * @author Mika Koivisto
045     */
046    public class BaseRepositoryProxyBean
047            extends RepositoryModelProxyBean implements BaseRepository {
048    
049            public BaseRepositoryProxyBean(
050                    BaseRepository baseRepository, ClassLoader classLoader) {
051    
052                    super(classLoader);
053    
054                    _baseRepository = baseRepository;
055            }
056    
057            @Override
058            public FileEntry addFileEntry(
059                            long folderId, String sourceFileName, String mimeType, String title,
060                            String description, String changeLog, File file,
061                            ServiceContext serviceContext)
062                    throws PortalException, SystemException {
063    
064                    FileEntry fileEntry = _baseRepository.addFileEntry(
065                            folderId, sourceFileName, mimeType, title, description, changeLog,
066                            file, serviceContext);
067    
068                    return newFileEntryProxyBean(fileEntry);
069            }
070    
071            @Override
072            public FileEntry addFileEntry(
073                            long folderId, String sourceFileName, String mimeType, String title,
074                            String description, String changeLog, InputStream is, long size,
075                            ServiceContext serviceContext)
076                    throws PortalException, SystemException {
077    
078                    FileEntry fileEntry = _baseRepository.addFileEntry(
079                            folderId, sourceFileName, mimeType, title, description, changeLog,
080                            is, size, serviceContext);
081    
082                    return newFileEntryProxyBean(fileEntry);
083            }
084    
085            @Override
086            public Folder addFolder(
087                            long parentFolderId, String title, String description,
088                            ServiceContext serviceContext)
089                    throws PortalException, SystemException {
090    
091                    Folder folder = _baseRepository.addFolder(
092                            parentFolderId, title, description, serviceContext);
093    
094                    return newFolderProxyBean(folder);
095            }
096    
097            @Override
098            public FileVersion cancelCheckOut(long fileEntryId)
099                    throws PortalException, SystemException {
100    
101                    return _baseRepository.cancelCheckOut(fileEntryId);
102            }
103    
104            @Override
105            public void checkInFileEntry(
106                            long fileEntryId, boolean major, String changeLog,
107                            ServiceContext serviceContext)
108                    throws PortalException, SystemException {
109    
110                    _baseRepository.checkInFileEntry(
111                            fileEntryId, major, changeLog, serviceContext);
112            }
113    
114            @Override
115            public void checkInFileEntry(long fileEntryId, String lockUuid)
116                    throws PortalException, SystemException {
117    
118                    _baseRepository.checkInFileEntry(fileEntryId, lockUuid);
119            }
120    
121            @Override
122            public FileEntry checkOutFileEntry(
123                            long fileEntryId, ServiceContext serviceContext)
124                    throws PortalException, SystemException {
125    
126                    FileEntry fileEntry = _baseRepository.checkOutFileEntry(
127                            fileEntryId, serviceContext);
128    
129                    return newFileEntryProxyBean(fileEntry);
130            }
131    
132            @Override
133            public FileEntry checkOutFileEntry(
134                            long fileEntryId, String owner, long expirationTime,
135                            ServiceContext serviceContext)
136                    throws PortalException, SystemException {
137    
138                    FileEntry fileEntry = _baseRepository.checkOutFileEntry(
139                            fileEntryId, owner, expirationTime, serviceContext);
140    
141                    return newFileEntryProxyBean(fileEntry);
142            }
143    
144            @Override
145            public FileEntry copyFileEntry(
146                            long groupId, long fileEntryId, long destFolderId,
147                            ServiceContext serviceContext)
148                    throws PortalException, SystemException {
149    
150                    return _baseRepository.copyFileEntry(
151                            groupId, fileEntryId, destFolderId, serviceContext);
152            }
153    
154            @Override
155            public void deleteFileEntry(long fileEntryId)
156                    throws PortalException, SystemException {
157    
158                    _baseRepository.deleteFileEntry(fileEntryId);
159            }
160    
161            @Override
162            public void deleteFileEntry(long folderId, String title)
163                    throws PortalException, SystemException {
164    
165                    _baseRepository.deleteFileEntry(folderId, title);
166            }
167    
168            @Override
169            public void deleteFileVersion(long fileEntryId, String version)
170                    throws PortalException, SystemException {
171    
172                    _baseRepository.deleteFileVersion(fileEntryId, version);
173            }
174    
175            @Override
176            public void deleteFolder(long folderId)
177                    throws PortalException, SystemException {
178    
179                    _baseRepository.deleteFolder(folderId);
180            }
181    
182            @Override
183            public void deleteFolder(long parentFolderId, String title)
184                    throws PortalException, SystemException {
185    
186                    _baseRepository.deleteFolder(parentFolderId, title);
187            }
188    
189            @Override
190            public List<FileEntry> getFileEntries(
191                            long folderId, int start, int end, OrderByComparator obc)
192                    throws SystemException {
193    
194                    List<FileEntry> fileEntries = _baseRepository.getFileEntries(
195                            folderId, start, end, obc);
196    
197                    return toFileEntryProxyBeans(fileEntries);
198            }
199    
200            @Override
201            public List<FileEntry> getFileEntries(
202                            long folderId, long documentTypeId, int start, int end,
203                            OrderByComparator obc)
204                    throws SystemException {
205    
206                    List<FileEntry> fileEntries = _baseRepository.getFileEntries(
207                            folderId, documentTypeId, start, end, obc);
208    
209                    return toFileEntryProxyBeans(fileEntries);
210            }
211    
212            @Override
213            public List<FileEntry> getFileEntries(
214                            long folderId, String[] mimeTypes, int start, int end,
215                            OrderByComparator obc)
216                    throws PortalException, SystemException {
217    
218                    List<FileEntry> fileEntries = _baseRepository.getFileEntries(
219                            folderId, mimeTypes, start, end, obc);
220    
221                    return toFileEntryProxyBeans(fileEntries);
222            }
223    
224            @Override
225            public List<Object> getFileEntriesAndFileShortcuts(
226                            long folderId, int status, int start, int end)
227                    throws SystemException {
228    
229                    List<Object> objects = _baseRepository.getFileEntriesAndFileShortcuts(
230                            folderId, status, start, end);
231    
232                    return toObjectProxyBeans(objects);
233            }
234    
235            @Override
236            public int getFileEntriesAndFileShortcutsCount(long folderId, int status)
237                    throws SystemException {
238    
239                    return _baseRepository.getFileEntriesAndFileShortcutsCount(
240                            folderId, status);
241            }
242    
243            @Override
244            public int getFileEntriesAndFileShortcutsCount(
245                            long folderId, int status, String[] mimeTypes)
246                    throws PortalException, SystemException {
247    
248                    return _baseRepository.getFileEntriesAndFileShortcutsCount(
249                            folderId, status, mimeTypes);
250            }
251    
252            @Override
253            public int getFileEntriesCount(long folderId) throws SystemException {
254                    return _baseRepository.getFileEntriesCount(folderId);
255            }
256    
257            @Override
258            public int getFileEntriesCount(long folderId, long documentTypeId)
259                    throws SystemException {
260    
261                    return _baseRepository.getFileEntriesCount(folderId, documentTypeId);
262            }
263    
264            @Override
265            public int getFileEntriesCount(long folderId, String[] mimeTypes)
266                    throws PortalException, SystemException {
267    
268                    return _baseRepository.getFileEntriesCount(folderId, mimeTypes);
269            }
270    
271            @Override
272            public FileEntry getFileEntry(long fileEntryId)
273                    throws PortalException, SystemException {
274    
275                    FileEntry fileEntry = _baseRepository.getFileEntry(fileEntryId);
276    
277                    return newFileEntryProxyBean(fileEntry);
278            }
279    
280            @Override
281            public FileEntry getFileEntry(long folderId, String title)
282                    throws PortalException, SystemException {
283    
284                    FileEntry fileEntry = _baseRepository.getFileEntry(folderId, title);
285    
286                    return newFileEntryProxyBean(fileEntry);
287            }
288    
289            @Override
290            public FileEntry getFileEntryByUuid(String uuid)
291                    throws PortalException, SystemException {
292    
293                    FileEntry fileEntry = _baseRepository.getFileEntryByUuid(uuid);
294    
295                    return newFileEntryProxyBean(fileEntry);
296            }
297    
298            @Override
299            public FileVersion getFileVersion(long fileVersionId)
300                    throws PortalException, SystemException {
301    
302                    FileVersion fileVersion = _baseRepository.getFileVersion(fileVersionId);
303    
304                    return newFileVersionProxyBean(fileVersion);
305            }
306    
307            @Override
308            public Folder getFolder(long folderId)
309                    throws PortalException, SystemException {
310    
311                    Folder folder = _baseRepository.getFolder(folderId);
312    
313                    return newFolderProxyBean(folder);
314            }
315    
316            @Override
317            public Folder getFolder(long parentFolderId, String title)
318                    throws PortalException, SystemException {
319    
320                    Folder folder = _baseRepository.getFolder(parentFolderId, title);
321    
322                    return newFolderProxyBean(folder);
323            }
324    
325            @Override
326            public List<Folder> getFolders(
327                            long parentFolderId, boolean includeMountfolders, int start,
328                            int end, OrderByComparator obc)
329                    throws PortalException, SystemException {
330    
331                    List<Folder> folders = _baseRepository.getFolders(
332                            parentFolderId, includeMountfolders, start, end, obc);
333    
334                    return toFolderProxyBeans(folders);
335            }
336    
337            @Override
338            public List<Object> getFoldersAndFileEntriesAndFileShortcuts(
339                            long folderId, int status, boolean includeMountFolders, int start,
340                            int end, OrderByComparator obc)
341                    throws SystemException {
342    
343                    List<Object> objects =
344                            _baseRepository.getFoldersAndFileEntriesAndFileShortcuts(
345                                    folderId, status, includeMountFolders, start, end, obc);
346    
347                    return toObjectProxyBeans(objects);
348            }
349    
350            @Override
351            public List<Object> getFoldersAndFileEntriesAndFileShortcuts(
352                            long folderId, int status, String[] mimeTypes,
353                            boolean includeMountFolders, int start, int end,
354                            OrderByComparator obc)
355                    throws PortalException, SystemException {
356    
357                    List<Object> objects =
358                            _baseRepository.getFoldersAndFileEntriesAndFileShortcuts(
359                                    folderId, status, mimeTypes, includeMountFolders, start, end,
360                                    obc);
361    
362                    return toObjectProxyBeans(objects);
363            }
364    
365            @Override
366            public int getFoldersAndFileEntriesAndFileShortcutsCount(
367                            long folderId, int status, boolean includeMountFolders)
368                    throws SystemException {
369    
370                    return _baseRepository.getFoldersAndFileEntriesAndFileShortcutsCount(
371                            folderId, status, includeMountFolders);
372            }
373    
374            @Override
375            public int getFoldersAndFileEntriesAndFileShortcutsCount(
376                            long folderId, int status, String[] mimeTypes,
377                            boolean includeMountFolders)
378                    throws PortalException, SystemException {
379    
380                    return _baseRepository.getFoldersAndFileEntriesAndFileShortcutsCount(
381                            folderId, status, mimeTypes, includeMountFolders);
382            }
383    
384            @Override
385            public int getFoldersCount(long parentFolderId, boolean includeMountfolders)
386                    throws PortalException, SystemException {
387    
388                    return _baseRepository.getFoldersCount(
389                            parentFolderId, includeMountfolders);
390            }
391    
392            @Override
393            public int getFoldersFileEntriesCount(List<Long> folderIds, int status)
394                    throws SystemException {
395    
396                    return _baseRepository.getFoldersFileEntriesCount(folderIds, status);
397            }
398    
399            @Override
400            public LocalRepository getLocalRepository() {
401                    LocalRepository localRepository = _baseRepository.getLocalRepository();
402    
403                    return newLocalRepositoryProxyBean(localRepository);
404            }
405    
406            @Override
407            public List<Folder> getMountFolders(
408                            long parentFolderId, int start, int end, OrderByComparator obc)
409                    throws SystemException {
410    
411                    List<Folder> folders = _baseRepository.getMountFolders(
412                            parentFolderId, start, end, obc);
413    
414                    return toFolderProxyBeans(folders);
415            }
416    
417            @Override
418            public int getMountFoldersCount(long parentFolderId)
419                    throws SystemException {
420    
421                    return _baseRepository.getMountFoldersCount(parentFolderId);
422            }
423    
424            public BaseRepository getProxyBean() {
425                    return _baseRepository;
426            }
427    
428            @Override
429            public List<FileEntry> getRepositoryFileEntries(
430                            long userId, long rootFolderId, int start, int end,
431                            OrderByComparator obc)
432                    throws SystemException {
433    
434                    List<FileEntry> fileEntries = _baseRepository.getRepositoryFileEntries(
435                            userId, rootFolderId, start, end, obc);
436    
437                    return toFileEntryProxyBeans(fileEntries);
438            }
439    
440            @Override
441            public List<FileEntry> getRepositoryFileEntries(
442                            long userId, long rootFolderId, String[] mimeTypes, int status,
443                            int start, int end, OrderByComparator obc)
444                    throws PortalException, SystemException {
445    
446                    List<FileEntry> fileEntries = _baseRepository.getRepositoryFileEntries(
447                            userId, rootFolderId, mimeTypes, status, start, end, obc);
448    
449                    return toFileEntryProxyBeans(fileEntries);
450            }
451    
452            @Override
453            public int getRepositoryFileEntriesCount(long userId, long rootFolderId)
454                    throws SystemException {
455    
456                    return _baseRepository.getRepositoryFileEntriesCount(
457                            userId, rootFolderId);
458            }
459    
460            @Override
461            public int getRepositoryFileEntriesCount(
462                            long userId, long rootFolderId, String[] mimeTypes, int status)
463                    throws PortalException, SystemException {
464    
465                    return _baseRepository.getRepositoryFileEntriesCount(
466                            userId, rootFolderId, mimeTypes, status);
467            }
468    
469            @Override
470            public long getRepositoryId() {
471                    return _baseRepository.getRepositoryId();
472            }
473    
474            @Override
475            public void getSubfolderIds(List<Long> folderIds, long folderId)
476                    throws SystemException {
477    
478                    _baseRepository.getSubfolderIds(folderIds, folderId);
479            }
480    
481            @Override
482            public List<Long> getSubfolderIds(long folderId, boolean recurse)
483                    throws SystemException {
484    
485                    return _baseRepository.getSubfolderIds(folderId, recurse);
486            }
487    
488            @Override
489            public String[] getSupportedConfigurations() {
490                    return _baseRepository.getSupportedConfigurations();
491            }
492    
493            @Override
494            public String[][] getSupportedParameters() {
495                    return _baseRepository.getSupportedParameters();
496            }
497    
498            @Override
499            public void initRepository() throws PortalException, SystemException {
500                    _baseRepository.initRepository();
501            }
502    
503            /**
504             * @deprecated {@link #checkOutFileEntry(long, ServiceContext)}
505             */
506            @Override
507            public Lock lockFileEntry(long fileEntryId)
508                    throws PortalException, SystemException {
509    
510                    Lock lock = _baseRepository.lockFileEntry(fileEntryId);
511    
512                    return (Lock)newProxyInstance(lock, Lock.class);
513            }
514    
515            /**
516             * @deprecated {@link #checkOutFileEntry(long, String, long,
517             *             ServiceContext)}
518             */
519            @Override
520            public Lock lockFileEntry(
521                            long fileEntryId, String owner, long expirationTime)
522                    throws PortalException, SystemException {
523    
524                    Lock lock = _baseRepository.lockFileEntry(
525                            fileEntryId, owner, expirationTime);
526    
527                    return (Lock)newProxyInstance(lock, Lock.class);
528            }
529    
530            @Override
531            public Lock lockFolder(long folderId)
532                    throws PortalException, SystemException {
533    
534                    Lock lock = _baseRepository.lockFolder(folderId);
535    
536                    return (Lock)newProxyInstance(lock, Lock.class);
537            }
538    
539            @Override
540            public Lock lockFolder(
541                            long folderId, String owner, boolean inheritable,
542                            long expirationTime)
543                    throws PortalException, SystemException {
544    
545                    Lock lock = _baseRepository.lockFolder(
546                            folderId, owner, inheritable, expirationTime);
547    
548                    return (Lock)newProxyInstance(lock, Lock.class);
549            }
550    
551            @Override
552            public FileEntry moveFileEntry(
553                            long fileEntryId, long newFolderId, ServiceContext serviceContext)
554                    throws PortalException, SystemException {
555    
556                    FileEntry fileEntry = _baseRepository.moveFileEntry(
557                            fileEntryId, newFolderId, serviceContext);
558    
559                    return newFileEntryProxyBean(fileEntry);
560            }
561    
562            @Override
563            public Folder moveFolder(
564                            long folderId, long newParentFolderId,
565                            ServiceContext serviceContext)
566                    throws PortalException, SystemException {
567    
568                    Folder folder = _baseRepository.moveFolder(
569                            folderId, newParentFolderId, serviceContext);
570    
571                    return newFolderProxyBean(folder);
572            }
573    
574            @Override
575            public Lock refreshFileEntryLock(String lockUuid, long expirationTime)
576                    throws PortalException, SystemException {
577    
578                    Lock lock = _baseRepository.refreshFileEntryLock(
579                            lockUuid, expirationTime);
580    
581                    return (Lock)newProxyInstance(lock, Lock.class);
582            }
583    
584            @Override
585            public Lock refreshFolderLock(String lockUuid, long expirationTime)
586                    throws PortalException, SystemException {
587    
588                    Lock lock = _baseRepository.refreshFolderLock(lockUuid, expirationTime);
589    
590                    return (Lock)newProxyInstance(lock, Lock.class);
591            }
592    
593            @Override
594            public void revertFileEntry(
595                            long fileEntryId, String version, ServiceContext serviceContext)
596                    throws PortalException, SystemException {
597    
598                    _baseRepository.revertFileEntry(fileEntryId, version, serviceContext);
599            }
600    
601            @Override
602            public Hits search(SearchContext searchContext) throws SearchException {
603                    return _baseRepository.search(searchContext);
604            }
605    
606            @Override
607            public Hits search(SearchContext searchContext, Query query)
608                    throws SearchException {
609    
610                    return _baseRepository.search(searchContext, query);
611            }
612    
613            @Override
614            public void setAssetEntryLocalService(
615                    AssetEntryLocalService assetEntryLocalService) {
616    
617                    _baseRepository.setAssetEntryLocalService(assetEntryLocalService);
618            }
619    
620            @Override
621            public void setCompanyId(long companyId) {
622                    _baseRepository.setCompanyId(companyId);
623            }
624    
625            @Override
626            public void setCompanyLocalService(
627                    CompanyLocalService companyLocalService) {
628    
629                    _baseRepository.setCompanyLocalService(companyLocalService);
630            }
631    
632            @Override
633            public void setCounterLocalService(
634                    CounterLocalService counterLocalService) {
635    
636                    _baseRepository.setCounterLocalService(counterLocalService);
637            }
638    
639            @Override
640            public void setDLAppHelperLocalService(
641                    DLAppHelperLocalService dlAppHelperLocalService) {
642    
643                    _baseRepository.setDLAppHelperLocalService(dlAppHelperLocalService);
644            }
645    
646            @Override
647            public void setGroupId(long groupId) {
648                    _baseRepository.setGroupId(groupId);
649            }
650    
651            @Override
652            public void setRepositoryId(long repositoryId) {
653                    _baseRepository.setRepositoryId(repositoryId);
654            }
655    
656            @Override
657            public void setTypeSettingsProperties(
658                    UnicodeProperties typeSettingsProperties) {
659    
660                    _baseRepository.setTypeSettingsProperties(typeSettingsProperties);
661            }
662    
663            @Override
664            public void setUserLocalService(UserLocalService userLocalService) {
665                    _baseRepository.setUserLocalService(userLocalService);
666            }
667    
668            @Override
669            public void unlockFolder(long folderId, String lockUuid)
670                    throws PortalException, SystemException {
671    
672                    _baseRepository.unlockFolder(folderId, lockUuid);
673            }
674    
675            @Override
676            public void unlockFolder(long parentFolderId, String title, String lockUuid)
677                    throws PortalException, SystemException {
678    
679                    _baseRepository.unlockFolder(parentFolderId, title, lockUuid);
680            }
681    
682            @Override
683            public FileEntry updateFileEntry(
684                            long fileEntryId, String sourceFileName, String mimeType,
685                            String title, String description, String changeLog,
686                            boolean majorVersion, File file, ServiceContext serviceContext)
687                    throws PortalException, SystemException {
688    
689                    FileEntry fileEntry = _baseRepository.updateFileEntry(
690                            fileEntryId, sourceFileName, mimeType, title, description,
691                            changeLog, majorVersion, file, serviceContext);
692    
693                    return newFileEntryProxyBean(fileEntry);
694            }
695    
696            @Override
697            public FileEntry updateFileEntry(
698                            long fileEntryId, String sourceFileName, String mimeType,
699                            String title, String description, String changeLog,
700                            boolean majorVersion, InputStream is, long size,
701                            ServiceContext serviceContext)
702                    throws PortalException, SystemException {
703    
704                    FileEntry fileEntry = _baseRepository.updateFileEntry(
705                            fileEntryId, sourceFileName, mimeType, title, description,
706                            changeLog, majorVersion, is, size, serviceContext);
707    
708                    return newFileEntryProxyBean(fileEntry);
709            }
710    
711            @Override
712            public Folder updateFolder(
713                            long folderId, String title, String description,
714                            ServiceContext serviceContext)
715                    throws PortalException, SystemException {
716    
717                    Folder folder = _baseRepository.updateFolder(
718                            folderId, title, description, serviceContext);
719    
720                    return newFolderProxyBean(folder);
721            }
722    
723            @Override
724            public boolean verifyFileEntryCheckOut(long fileEntryId, String lockUuid)
725                    throws PortalException, SystemException {
726    
727                    return _baseRepository.verifyFileEntryCheckOut(fileEntryId, lockUuid);
728            }
729    
730            @Override
731            public boolean verifyFileEntryLock(long fileEntryId, String lockUuid)
732                    throws PortalException, SystemException {
733    
734                    return _baseRepository.verifyFileEntryLock(fileEntryId, lockUuid);
735            }
736    
737            @Override
738            public boolean verifyInheritableLock(long folderId, String lockUuid)
739                    throws PortalException, SystemException {
740    
741                    return _baseRepository.verifyInheritableLock(folderId, lockUuid);
742            }
743    
744            private BaseRepository _baseRepository;
745    
746    }