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