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