001    /**
002     * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.repository.capabilities;
016    
017    import com.liferay.portal.kernel.exception.PortalException;
018    import com.liferay.portal.kernel.lock.Lock;
019    import com.liferay.portal.kernel.repository.Repository;
020    import com.liferay.portal.kernel.repository.capabilities.CapabilityProvider;
021    import com.liferay.portal.kernel.repository.event.RepositoryEventTrigger;
022    import com.liferay.portal.kernel.repository.event.RepositoryEventType;
023    import com.liferay.portal.kernel.repository.model.FileEntry;
024    import com.liferay.portal.kernel.repository.model.FileShortcut;
025    import com.liferay.portal.kernel.repository.model.FileVersion;
026    import com.liferay.portal.kernel.repository.model.Folder;
027    import com.liferay.portal.kernel.repository.model.RepositoryEntry;
028    import com.liferay.portal.kernel.search.Hits;
029    import com.liferay.portal.kernel.search.Query;
030    import com.liferay.portal.kernel.search.SearchContext;
031    import com.liferay.portal.kernel.search.SearchException;
032    import com.liferay.portal.kernel.util.OrderByComparator;
033    import com.liferay.portal.service.ServiceContext;
034    import com.liferay.portlet.documentlibrary.model.DLFolderConstants;
035    
036    import java.io.File;
037    import java.io.InputStream;
038    
039    import java.util.List;
040    
041    /**
042     * @author Adolfo P??rez
043     */
044    public class CapabilityRepository
045            extends BaseCapabilityRepository<Repository> implements Repository {
046    
047            public CapabilityRepository(
048                    Repository repository, CapabilityProvider capabilityProvider,
049                    RepositoryEventTrigger repositoryEventTrigger) {
050    
051                    super(repository, capabilityProvider);
052    
053                    _repositoryEventTrigger = repositoryEventTrigger;
054            }
055    
056            @Override
057            public FileEntry addFileEntry(
058                            long userId, long folderId, String sourceFileName, String mimeType,
059                            String title, String description, String changeLog, File file,
060                            ServiceContext serviceContext)
061                    throws PortalException {
062    
063                    Repository repository = getRepository();
064    
065                    FileEntry fileEntry = repository.addFileEntry(
066                            userId, folderId, sourceFileName, mimeType, title, description,
067                            changeLog, file, serviceContext);
068    
069                    _repositoryEventTrigger.trigger(
070                            RepositoryEventType.Add.class, FileEntry.class, fileEntry);
071    
072                    return fileEntry;
073            }
074    
075            @Override
076            public FileEntry addFileEntry(
077                            long userId, long folderId, String sourceFileName, String mimeType,
078                            String title, String description, String changeLog, InputStream is,
079                            long size, ServiceContext serviceContext)
080                    throws PortalException {
081    
082                    Repository repository = getRepository();
083    
084                    FileEntry fileEntry = repository.addFileEntry(
085                            userId, folderId, sourceFileName, mimeType, title, description,
086                            changeLog, is, size, serviceContext);
087    
088                    _repositoryEventTrigger.trigger(
089                            RepositoryEventType.Add.class, FileEntry.class, fileEntry);
090    
091                    return fileEntry;
092            }
093    
094            /**
095             * @deprecated As of 7.0.0, see {@link #addFileEntry(long, long, String,
096             *             String, String, String, String, File, ServiceContext)}
097             */
098            @Deprecated
099            @Override
100            public FileEntry addFileEntry(
101                            long folderId, String sourceFileName, String mimeType, String title,
102                            String description, String changeLog, File file,
103                            ServiceContext serviceContext)
104                    throws PortalException {
105    
106                    return addFileEntry(
107                            com.liferay.portal.kernel.repository.util.RepositoryUserUtil.
108                                    getUserId(),
109                            folderId, sourceFileName, mimeType, title, description, changeLog,
110                            file, serviceContext);
111            }
112    
113            /**
114             * @deprecated As of 7.0.0, see {@link #addFileEntry(long, long, String,
115             *             String, String, String, String, InputStream, long,
116             *             ServiceContext)}
117             */
118            @Deprecated
119            @Override
120            public FileEntry addFileEntry(
121                            long folderId, String sourceFileName, String mimeType, String title,
122                            String description, String changeLog, InputStream is, long size,
123                            ServiceContext serviceContext)
124                    throws PortalException {
125    
126                    return addFileEntry(
127                            com.liferay.portal.kernel.repository.util.RepositoryUserUtil.
128                                    getUserId(),
129                            folderId, sourceFileName, mimeType, title, description, changeLog,
130                            is, size, serviceContext);
131            }
132    
133            @Override
134            public FileShortcut addFileShortcut(
135                            long userId, long folderId, long toFileEntryId,
136                            ServiceContext serviceContext)
137                    throws PortalException {
138    
139                    Repository repository = getRepository();
140    
141                    FileShortcut fileShortcut = repository.addFileShortcut(
142                            userId, folderId, toFileEntryId, serviceContext);
143    
144                    _repositoryEventTrigger.trigger(
145                            RepositoryEventType.Add.class, FileShortcut.class, fileShortcut);
146    
147                    return fileShortcut;
148            }
149    
150            @Override
151            public Folder addFolder(
152                            long userId, long parentFolderId, String name, String description,
153                            ServiceContext serviceContext)
154                    throws PortalException {
155    
156                    Repository repository = getRepository();
157    
158                    Folder folder = repository.addFolder(
159                            userId, parentFolderId, name, description, serviceContext);
160    
161                    _repositoryEventTrigger.trigger(
162                            RepositoryEventType.Add.class, Folder.class, folder);
163    
164                    return folder;
165            }
166    
167            /**
168             * @deprecated As of 7.0.0, replaced by {@link #addFolder(long, long,
169             *             String, String, ServiceContext)}
170             */
171            @Deprecated
172            @Override
173            public Folder addFolder(
174                            long parentFolderId, String name, String description,
175                            ServiceContext serviceContext)
176                    throws PortalException {
177    
178                    return addFolder(
179                            com.liferay.portal.kernel.repository.util.RepositoryUserUtil.
180                                    getUserId(),
181                            parentFolderId, name, description, serviceContext);
182            }
183    
184            @Override
185            public FileVersion cancelCheckOut(long fileEntryId) throws PortalException {
186                    Repository repository = getRepository();
187    
188                    FileVersion fileVersion = repository.cancelCheckOut(fileEntryId);
189    
190                    _repositoryEventTrigger.trigger(
191                            RepositoryEventType.Update.class, FileEntry.class,
192                            fileVersion.getFileEntry());
193    
194                    return fileVersion;
195            }
196    
197            /**
198             * @deprecated As of 7.0.0, replaced by {@link #checkInFileEntry(long, long,
199             *             boolean, String, ServiceContext)}
200             */
201            @Deprecated
202            @Override
203            public void checkInFileEntry(
204                            long fileEntryId, boolean major, String changeLog,
205                            ServiceContext serviceContext)
206                    throws PortalException {
207    
208                    checkInFileEntry(
209                            com.liferay.portal.kernel.repository.util.RepositoryUserUtil.
210                                    getUserId(),
211                            fileEntryId, major, changeLog, serviceContext);
212            }
213    
214            @Override
215            public void checkInFileEntry(
216                            long userId, long fileEntryId, boolean major, String changeLog,
217                            ServiceContext serviceContext)
218                    throws PortalException {
219    
220                    Repository repository = getRepository();
221    
222                    repository.checkInFileEntry(
223                            userId, fileEntryId, major, changeLog, serviceContext);
224    
225                    FileEntry fileEntry = repository.getFileEntry(fileEntryId);
226    
227                    _repositoryEventTrigger.trigger(
228                            RepositoryEventType.Update.class, FileEntry.class, fileEntry);
229            }
230    
231            @Override
232            public void checkInFileEntry(
233                            long userId, long fileEntryId, String lockUuid,
234                            ServiceContext serviceContext)
235                    throws PortalException {
236    
237                    Repository repository = getRepository();
238    
239                    repository.checkInFileEntry(
240                            userId, fileEntryId, lockUuid, serviceContext);
241    
242                    FileEntry fileEntry = repository.getFileEntry(fileEntryId);
243    
244                    _repositoryEventTrigger.trigger(
245                            RepositoryEventType.Update.class, FileEntry.class, fileEntry);
246            }
247    
248            @Deprecated
249            @Override
250            public void checkInFileEntry(long fileEntryId, String lockUuid)
251                    throws PortalException {
252    
253                    Repository repository = getRepository();
254    
255                    repository.checkInFileEntry(fileEntryId, lockUuid);
256    
257                    FileEntry fileEntry = repository.getFileEntry(fileEntryId);
258    
259                    _repositoryEventTrigger.trigger(
260                            RepositoryEventType.Update.class, FileEntry.class, fileEntry);
261            }
262    
263            /**
264             * @deprecated As of 7.0.0, replaced by {@link #checkInFileEntry(long, long,
265             *             String, ServiceContext)}
266             */
267            @Deprecated
268            @Override
269            public void checkInFileEntry(
270                            long fileEntryId, String lockUuid, ServiceContext serviceContext)
271                    throws PortalException {
272    
273                    checkInFileEntry(
274                            com.liferay.portal.kernel.repository.util.RepositoryUserUtil.
275                                    getUserId(),
276                            fileEntryId, lockUuid, serviceContext);
277            }
278    
279            @Override
280            public FileEntry checkOutFileEntry(
281                            long fileEntryId, ServiceContext serviceContext)
282                    throws PortalException {
283    
284                    Repository repository = getRepository();
285    
286                    FileEntry fileEntry = repository.checkOutFileEntry(
287                            fileEntryId, serviceContext);
288    
289                    _repositoryEventTrigger.trigger(
290                            RepositoryEventType.Update.class, FileEntry.class, fileEntry);
291    
292                    return fileEntry;
293            }
294    
295            @Override
296            public FileEntry checkOutFileEntry(
297                            long fileEntryId, String owner, long expirationTime,
298                            ServiceContext serviceContext)
299                    throws PortalException {
300    
301                    Repository repository = getRepository();
302    
303                    FileEntry fileEntry = repository.checkOutFileEntry(
304                            fileEntryId, owner, expirationTime, serviceContext);
305    
306                    _repositoryEventTrigger.trigger(
307                            RepositoryEventType.Update.class, FileEntry.class, fileEntry);
308    
309                    return fileEntry;
310            }
311    
312            @Override
313            public FileEntry copyFileEntry(
314                            long userId, long groupId, long fileEntryId, long destFolderId,
315                            ServiceContext serviceContext)
316                    throws PortalException {
317    
318                    Repository repository = getRepository();
319    
320                    FileEntry fileEntry = repository.copyFileEntry(
321                            userId, groupId, fileEntryId, destFolderId, serviceContext);
322    
323                    _repositoryEventTrigger.trigger(
324                            RepositoryEventType.Add.class, FileEntry.class, fileEntry);
325    
326                    return fileEntry;
327            }
328    
329            /**
330             * @deprecated As of 7.0.0, replaced by {@link #copyFileEntry(long, long,
331             *             long, long, ServiceContext)}
332             */
333            @Deprecated
334            @Override
335            public FileEntry copyFileEntry(
336                            long groupId, long fileEntryId, long destFolderId,
337                            ServiceContext serviceContext)
338                    throws PortalException {
339    
340                    return copyFileEntry(
341                            com.liferay.portal.kernel.repository.util.RepositoryUserUtil.
342                                    getUserId(),
343                            groupId, fileEntryId, destFolderId, serviceContext);
344            }
345    
346            @Override
347            public void deleteAll() throws PortalException {
348                    Repository repository = getRepository();
349    
350                    _repositoryEventTrigger.trigger(
351                            RepositoryEventType.Delete.class, Repository.class, repository);
352    
353                    repository.deleteAll();
354            }
355    
356            @Override
357            public void deleteFileEntry(long fileEntryId) throws PortalException {
358                    Repository repository = getRepository();
359    
360                    FileEntry fileEntry = repository.getFileEntry(fileEntryId);
361    
362                    _repositoryEventTrigger.trigger(
363                            RepositoryEventType.Delete.class, FileEntry.class, fileEntry);
364    
365                    repository.deleteFileEntry(fileEntryId);
366            }
367    
368            @Override
369            public void deleteFileEntry(long folderId, String title)
370                    throws PortalException {
371    
372                    Repository repository = getRepository();
373    
374                    FileEntry fileEntry = repository.getFileEntry(folderId, title);
375    
376                    _repositoryEventTrigger.trigger(
377                            RepositoryEventType.Delete.class, FileEntry.class, fileEntry);
378    
379                    repository.deleteFileEntry(folderId, title);
380            }
381    
382            @Override
383            public void deleteFileShortcut(long fileShortcutId) throws PortalException {
384                    Repository repository = getRepository();
385    
386                    FileShortcut fileShortcut = repository.getFileShortcut(fileShortcutId);
387    
388                    _repositoryEventTrigger.trigger(
389                            RepositoryEventType.Delete.class, FileShortcut.class, fileShortcut);
390    
391                    repository.deleteFileShortcut(fileShortcutId);
392            }
393    
394            @Override
395            public void deleteFileShortcuts(long toFileEntryId) throws PortalException {
396                    Repository repository = getRepository();
397    
398                    FileEntry fileEntry = repository.getFileEntry(toFileEntryId);
399    
400                    List<FileShortcut> fileShortcuts = fileEntry.getFileShortcuts();
401    
402                    for (FileShortcut fileShortcut : fileShortcuts) {
403                            _repositoryEventTrigger.trigger(
404                                    RepositoryEventType.Delete.class, FileShortcut.class,
405                                    fileShortcut);
406                    }
407    
408                    repository.deleteFileShortcuts(toFileEntryId);
409            }
410    
411            @Override
412            public void deleteFileVersion(long fileEntryId, String version)
413                    throws PortalException {
414    
415                    Repository repository = getRepository();
416    
417                    FileEntry fileEntry = repository.getFileEntry(fileEntryId);
418    
419                    _repositoryEventTrigger.trigger(
420                            RepositoryEventType.Update.class, FileEntry.class, fileEntry);
421    
422                    repository.deleteFileVersion(fileEntryId, version);
423            }
424    
425            @Override
426            public void deleteFolder(long folderId) throws PortalException {
427                    Repository repository = getRepository();
428    
429                    Folder folder = repository.getFolder(folderId);
430    
431                    _repositoryEventTrigger.trigger(
432                            RepositoryEventType.Delete.class, Folder.class, folder);
433    
434                    repository.deleteFolder(folderId);
435            }
436    
437            @Override
438            public void deleteFolder(long parentFolderId, String name)
439                    throws PortalException {
440    
441                    Repository repository = getRepository();
442    
443                    Folder folder = repository.getFolder(parentFolderId, name);
444    
445                    _repositoryEventTrigger.trigger(
446                            RepositoryEventType.Delete.class, Folder.class, folder);
447    
448                    repository.deleteFolder(parentFolderId, name);
449            }
450    
451            @Override
452            public List<FileEntry> getFileEntries(
453                            long folderId, int status, int start, int end,
454                            OrderByComparator<FileEntry> obc)
455                    throws PortalException {
456    
457                    return getRepository().getFileEntries(
458                            folderId, status, start, end, obc);
459            }
460    
461            @Override
462            public List<FileEntry> getFileEntries(
463                            long folderId, int start, int end, OrderByComparator<FileEntry> obc)
464                    throws PortalException {
465    
466                    return getRepository().getFileEntries(folderId, start, end, obc);
467            }
468    
469            @Override
470            public List<FileEntry> getFileEntries(
471                            long folderId, long fileEntryTypeId, int start, int end,
472                            OrderByComparator<FileEntry> obc)
473                    throws PortalException {
474    
475                    return getRepository().getFileEntries(
476                            folderId, fileEntryTypeId, start, end, obc);
477            }
478    
479            @Override
480            public List<FileEntry> getFileEntries(
481                            long folderId, String[] mimeTypes, int start, int end,
482                            OrderByComparator<FileEntry> obc)
483                    throws PortalException {
484    
485                    return getRepository().getFileEntries(
486                            folderId, mimeTypes, start, end, obc);
487            }
488    
489            @Override
490            public List<RepositoryEntry> getFileEntriesAndFileShortcuts(
491                            long folderId, int status, int start, int end)
492                    throws PortalException {
493    
494                    return getRepository().getFileEntriesAndFileShortcuts(
495                            folderId, status, start, end);
496            }
497    
498            @Override
499            public int getFileEntriesAndFileShortcutsCount(long folderId, int status)
500                    throws PortalException {
501    
502                    return getRepository().getFileEntriesAndFileShortcutsCount(
503                            folderId, status);
504            }
505    
506            @Override
507            public int getFileEntriesAndFileShortcutsCount(
508                            long folderId, int status, String[] mimeTypes)
509                    throws PortalException {
510    
511                    return getRepository().getFileEntriesAndFileShortcutsCount(
512                            folderId, status, mimeTypes);
513            }
514    
515            @Override
516            public int getFileEntriesCount(long folderId) throws PortalException {
517                    return getRepository().getFileEntriesCount(folderId);
518            }
519    
520            @Override
521            public int getFileEntriesCount(long folderId, int status)
522                    throws PortalException {
523    
524                    return getRepository().getFileEntriesCount(folderId, status);
525            }
526    
527            @Override
528            public int getFileEntriesCount(long folderId, long fileEntryTypeId)
529                    throws PortalException {
530    
531                    return getRepository().getFileEntriesCount(folderId, fileEntryTypeId);
532            }
533    
534            @Override
535            public int getFileEntriesCount(long folderId, String[] mimeTypes)
536                    throws PortalException {
537    
538                    return getRepository().getFileEntriesCount(folderId, mimeTypes);
539            }
540    
541            @Override
542            public FileEntry getFileEntry(long fileEntryId) throws PortalException {
543                    return getRepository().getFileEntry(fileEntryId);
544            }
545    
546            @Override
547            public FileEntry getFileEntry(long folderId, String title)
548                    throws PortalException {
549    
550                    return getRepository().getFileEntry(folderId, title);
551            }
552    
553            @Override
554            public FileEntry getFileEntryByUuid(String uuid) throws PortalException {
555                    return getRepository().getFileEntryByUuid(uuid);
556            }
557    
558            @Override
559            public FileShortcut getFileShortcut(long fileShortcutId)
560                    throws PortalException {
561    
562                    return getRepository().getFileShortcut(fileShortcutId);
563            }
564    
565            @Override
566            public FileVersion getFileVersion(long fileVersionId)
567                    throws PortalException {
568    
569                    return getRepository().getFileVersion(fileVersionId);
570            }
571    
572            @Override
573            public Folder getFolder(long folderId) throws PortalException {
574                    return getRepository().getFolder(folderId);
575            }
576    
577            @Override
578            public Folder getFolder(long parentFolderId, String name)
579                    throws PortalException {
580    
581                    return getRepository().getFolder(parentFolderId, name);
582            }
583    
584            @Override
585            public List<Folder> getFolders(
586                            long parentFolderId, boolean includeMountFolders, int start,
587                            int end, OrderByComparator<Folder> obc)
588                    throws PortalException {
589    
590                    return getRepository().getFolders(
591                            parentFolderId, includeMountFolders, start, end, obc);
592            }
593    
594            @Override
595            public List<Folder> getFolders(
596                            long parentFolderId, int status, boolean includeMountFolders,
597                            int start, int end, OrderByComparator<Folder> obc)
598                    throws PortalException {
599    
600                    return getRepository().getFolders(
601                            parentFolderId, status, includeMountFolders, start, end, obc);
602            }
603    
604            @Override
605            public List<RepositoryEntry> getFoldersAndFileEntriesAndFileShortcuts(
606                            long folderId, int status, boolean includeMountFolders, int start,
607                            int end, OrderByComparator<?> obc)
608                    throws PortalException {
609    
610                    return getRepository().getFoldersAndFileEntriesAndFileShortcuts(
611                            folderId, status, includeMountFolders, start, end, obc);
612            }
613    
614            @Override
615            public List<RepositoryEntry> getFoldersAndFileEntriesAndFileShortcuts(
616                            long folderId, int status, String[] mimetypes,
617                            boolean includeMountFolders, int start, int end,
618                            OrderByComparator<?> obc)
619                    throws PortalException {
620    
621                    return getRepository().getFoldersAndFileEntriesAndFileShortcuts(
622                            folderId, status, mimetypes, includeMountFolders, start, end, obc);
623            }
624    
625            @Override
626            public int getFoldersAndFileEntriesAndFileShortcutsCount(
627                            long folderId, int status, boolean includeMountFolders)
628                    throws PortalException {
629    
630                    return getRepository().getFoldersAndFileEntriesAndFileShortcutsCount(
631                            folderId, status, includeMountFolders);
632            }
633    
634            @Override
635            public int getFoldersAndFileEntriesAndFileShortcutsCount(
636                            long folderId, int status, String[] mimetypes,
637                            boolean includeMountFolders)
638                    throws PortalException {
639    
640                    return getRepository().getFoldersAndFileEntriesAndFileShortcutsCount(
641                            folderId, status, mimetypes, includeMountFolders);
642            }
643    
644            @Override
645            public int getFoldersCount(long parentFolderId, boolean includeMountfolders)
646                    throws PortalException {
647    
648                    return getRepository().getFoldersCount(
649                            parentFolderId, includeMountfolders);
650            }
651    
652            @Override
653            public int getFoldersCount(
654                            long parentFolderId, int status, boolean includeMountfolders)
655                    throws PortalException {
656    
657                    return getRepository().getFoldersCount(
658                            parentFolderId, status, includeMountfolders);
659            }
660    
661            @Override
662            public int getFoldersFileEntriesCount(List<Long> folderIds, int status)
663                    throws PortalException {
664    
665                    return getRepository().getFoldersFileEntriesCount(folderIds, status);
666            }
667    
668            @Override
669            public List<Folder> getMountFolders(
670                            long parentFolderId, int start, int end,
671                            OrderByComparator<Folder> obc)
672                    throws PortalException {
673    
674                    return getRepository().getMountFolders(parentFolderId, start, end, obc);
675            }
676    
677            @Override
678            public int getMountFoldersCount(long parentFolderId)
679                    throws PortalException {
680    
681                    return getRepository().getMountFoldersCount(parentFolderId);
682            }
683    
684            @Override
685            public List<FileEntry> getRepositoryFileEntries(
686                            long userId, long rootFolderId, int start, int end,
687                            OrderByComparator<FileEntry> obc)
688                    throws PortalException {
689    
690                    return getRepository().getRepositoryFileEntries(
691                            userId, rootFolderId, start, end, obc);
692            }
693    
694            @Override
695            public List<FileEntry> getRepositoryFileEntries(
696                            long userId, long rootFolderId, String[] mimeTypes, int status,
697                            int start, int end, OrderByComparator<FileEntry> obc)
698                    throws PortalException {
699    
700                    return getRepository().getRepositoryFileEntries(
701                            userId, rootFolderId, mimeTypes, status, start, end, obc);
702            }
703    
704            @Override
705            public int getRepositoryFileEntriesCount(long userId, long rootFolderId)
706                    throws PortalException {
707    
708                    return getRepository().getRepositoryFileEntriesCount(
709                            userId, rootFolderId);
710            }
711    
712            @Override
713            public int getRepositoryFileEntriesCount(
714                            long userId, long rootFolderId, String[] mimeTypes, int status)
715                    throws PortalException {
716    
717                    return getRepository().getRepositoryFileEntriesCount(
718                            userId, rootFolderId, mimeTypes, status);
719            }
720    
721            @Override
722            public long getRepositoryId() {
723                    return getRepository().getRepositoryId();
724            }
725    
726            @Override
727            public void getSubfolderIds(List<Long> folderIds, long folderId)
728                    throws PortalException {
729    
730                    getRepository().getSubfolderIds(folderIds, folderId);
731            }
732    
733            @Override
734            public List<Long> getSubfolderIds(long folderId, boolean recurse)
735                    throws PortalException {
736    
737                    return getRepository().getSubfolderIds(folderId, recurse);
738            }
739    
740            @Override
741            public Lock lockFolder(long folderId) throws PortalException {
742                    return getRepository().lockFolder(folderId);
743            }
744    
745            @Override
746            public Lock lockFolder(
747                            long folderId, String owner, boolean inheritable,
748                            long expirationTime)
749                    throws PortalException {
750    
751                    return getRepository().lockFolder(
752                            folderId, owner, inheritable, expirationTime);
753            }
754    
755            @Override
756            public FileEntry moveFileEntry(
757                            long userId, long fileEntryId, long newFolderId,
758                            ServiceContext serviceContext)
759                    throws PortalException {
760    
761                    Repository repository = getRepository();
762    
763                    FileEntry fileEntry = repository.moveFileEntry(
764                            userId, fileEntryId, newFolderId, serviceContext);
765    
766                    _repositoryEventTrigger.trigger(
767                            RepositoryEventType.Move.class, FileEntry.class, fileEntry);
768    
769                    return fileEntry;
770            }
771    
772            /**
773             * @deprecated As of 7.0.0, replaced by {@link #moveFileEntry(long, long,
774             *             long, ServiceContext)}
775             */
776            @Deprecated
777            @Override
778            public FileEntry moveFileEntry(
779                            long fileEntryId, long newFolderId, ServiceContext serviceContext)
780                    throws PortalException {
781    
782                    return moveFileEntry(
783                            com.liferay.portal.kernel.repository.util.RepositoryUserUtil.
784                                    getUserId(),
785                            fileEntryId, newFolderId, serviceContext);
786            }
787    
788            @Override
789            public Folder moveFolder(
790                            long userId, long folderId, long parentFolderId,
791                            ServiceContext serviceContext)
792                    throws PortalException {
793    
794                    Repository repository = getRepository();
795    
796                    Folder folder = repository.moveFolder(
797                            userId, folderId, parentFolderId, serviceContext);
798    
799                    _repositoryEventTrigger.trigger(
800                            RepositoryEventType.Move.class, Folder.class, folder);
801    
802                    return folder;
803            }
804    
805            /**
806             * @deprecated As of 7.0.0, replaced by {@link #moveFolder(long, long, long,
807             *             ServiceContext)}
808             */
809            @Deprecated
810            @Override
811            public Folder moveFolder(
812                            long folderId, long newParentFolderId,
813                            ServiceContext serviceContext)
814                    throws PortalException {
815    
816                    return moveFolder(
817                            com.liferay.portal.kernel.repository.util.RepositoryUserUtil.
818                                    getUserId(),
819                            folderId, newParentFolderId, serviceContext);
820            }
821    
822            @Override
823            public Lock refreshFileEntryLock(
824                            String lockUuid, long companyId, long expirationTime)
825                    throws PortalException {
826    
827                    return getRepository().refreshFileEntryLock(
828                            lockUuid, companyId, expirationTime);
829            }
830    
831            @Override
832            public Lock refreshFolderLock(
833                            String lockUuid, long companyId, long expirationTime)
834                    throws PortalException {
835    
836                    return getRepository().refreshFolderLock(
837                            lockUuid, companyId, expirationTime);
838            }
839    
840            @Override
841            public void revertFileEntry(
842                            long userId, long fileEntryId, String version,
843                            ServiceContext serviceContext)
844                    throws PortalException {
845    
846                    Repository repository = getRepository();
847    
848                    repository.revertFileEntry(
849                            userId, fileEntryId, version, serviceContext);
850    
851                    FileEntry fileEntry = getFileEntry(fileEntryId);
852    
853                    _repositoryEventTrigger.trigger(
854                            RepositoryEventType.Update.class, FileEntry.class, fileEntry);
855            }
856    
857            /**
858             * @deprecated As of 7.0.0, replaced by {@link #revertFileEntry(long, long,
859             *             String, ServiceContext)}
860             */
861            @Deprecated
862            @Override
863            public void revertFileEntry(
864                            long fileEntryId, String version, ServiceContext serviceContext)
865                    throws PortalException {
866    
867                    Repository repository = getRepository();
868    
869                    repository.revertFileEntry(fileEntryId, version, serviceContext);
870    
871                    FileEntry fileEntry = getFileEntry(fileEntryId);
872    
873                    _repositoryEventTrigger.trigger(
874                            RepositoryEventType.Update.class, FileEntry.class, fileEntry);
875            }
876    
877            @Override
878            public Hits search(long creatorUserId, int status, int start, int end)
879                    throws PortalException {
880    
881                    return getRepository().search(creatorUserId, status, start, end);
882            }
883    
884            @Override
885            public Hits search(
886                            long creatorUserId, long folderId, String[] mimeTypes, int status,
887                            int start, int end)
888                    throws PortalException {
889    
890                    return getRepository().search(
891                            creatorUserId, folderId, mimeTypes, status, start, end);
892            }
893    
894            @Override
895            public Hits search(SearchContext searchContext) throws SearchException {
896                    return getRepository().search(searchContext);
897            }
898    
899            @Override
900            public Hits search(SearchContext searchContext, Query query)
901                    throws SearchException {
902    
903                    return getRepository().search(searchContext, query);
904            }
905    
906            @Override
907            public void unlockFolder(long folderId, String lockUuid)
908                    throws PortalException {
909    
910                    getRepository().unlockFolder(folderId, lockUuid);
911            }
912    
913            @Override
914            public void unlockFolder(long parentFolderId, String name, String lockUuid)
915                    throws PortalException {
916    
917                    getRepository().unlockFolder(parentFolderId, name, lockUuid);
918            }
919    
920            @Override
921            public FileEntry updateFileEntry(
922                            long userId, long fileEntryId, String sourceFileName,
923                            String mimeType, String title, String description, String changeLog,
924                            boolean majorVersion, File file, ServiceContext serviceContext)
925                    throws PortalException {
926    
927                    Repository repository = getRepository();
928    
929                    FileEntry fileEntry = repository.updateFileEntry(
930                            userId, fileEntryId, sourceFileName, mimeType, title, description,
931                            changeLog, majorVersion, file, serviceContext);
932    
933                    _repositoryEventTrigger.trigger(
934                            RepositoryEventType.Update.class, FileEntry.class, fileEntry);
935    
936                    return fileEntry;
937            }
938    
939            @Override
940            public FileEntry updateFileEntry(
941                            long userId, long fileEntryId, String sourceFileName,
942                            String mimeType, String title, String description, String changeLog,
943                            boolean majorVersion, InputStream is, long size,
944                            ServiceContext serviceContext)
945                    throws PortalException {
946    
947                    Repository repository = getRepository();
948    
949                    FileEntry fileEntry = repository.updateFileEntry(
950                            userId, fileEntryId, sourceFileName, mimeType, title, description,
951                            changeLog, majorVersion, is, size, serviceContext);
952    
953                    _repositoryEventTrigger.trigger(
954                            RepositoryEventType.Update.class, FileEntry.class, fileEntry);
955    
956                    return fileEntry;
957            }
958    
959            /**
960             * @deprecated As of 7.0.0, replaced by {@link #updateFileEntry(long, long,
961             *             String, String, String, String, String, boolean, File,
962             *             ServiceContext)}
963             */
964            @Deprecated
965            @Override
966            public FileEntry updateFileEntry(
967                            long fileEntryId, String sourceFileName, String mimeType,
968                            String title, String description, String changeLog,
969                            boolean majorVersion, File file, ServiceContext serviceContext)
970                    throws PortalException {
971    
972                    Repository repository = getRepository();
973    
974                    FileEntry fileEntry = repository.updateFileEntry(
975                            fileEntryId, sourceFileName, mimeType, title, description,
976                            changeLog, majorVersion, file, serviceContext);
977    
978                    _repositoryEventTrigger.trigger(
979                            RepositoryEventType.Update.class, FileEntry.class, fileEntry);
980    
981                    return fileEntry;
982            }
983    
984            /**
985             * @deprecated As of 7.0.0, replaced by {@link #updateFileEntry(long, long,
986             *             String, String, String, String, String, boolean, InputStream,
987             *             long, ServiceContext)}
988             */
989            @Deprecated
990            @Override
991            public FileEntry updateFileEntry(
992                            long fileEntryId, String sourceFileName, String mimeType,
993                            String title, String description, String changeLog,
994                            boolean majorVersion, InputStream is, long size,
995                            ServiceContext serviceContext)
996                    throws PortalException {
997    
998                    Repository repository = getRepository();
999    
1000                    FileEntry fileEntry = repository.updateFileEntry(
1001                            fileEntryId, sourceFileName, mimeType, title, description,
1002                            changeLog, majorVersion, is, size, serviceContext);
1003    
1004                    _repositoryEventTrigger.trigger(
1005                            RepositoryEventType.Update.class, FileEntry.class, fileEntry);
1006    
1007                    return fileEntry;
1008            }
1009    
1010            @Override
1011            public FileShortcut updateFileShortcut(
1012                            long userId, long fileShortcutId, long folderId, long toFileEntryId,
1013                            ServiceContext serviceContext)
1014                    throws PortalException {
1015    
1016                    Repository repository = getRepository();
1017    
1018                    FileShortcut fileShortcut = repository.updateFileShortcut(
1019                            userId, fileShortcutId, folderId, toFileEntryId, serviceContext);
1020    
1021                    _repositoryEventTrigger.trigger(
1022                            RepositoryEventType.Update.class, FileShortcut.class, fileShortcut);
1023    
1024                    return fileShortcut;
1025            }
1026    
1027            @Override
1028            public void updateFileShortcuts(
1029                            long oldToFileEntryId, long newToFileEntryId)
1030                    throws PortalException {
1031    
1032                    Repository repository = getRepository();
1033    
1034                    FileEntry oldToFileEntry = repository.getFileEntry(oldToFileEntryId);
1035    
1036                    List<FileShortcut> fileShortcuts = oldToFileEntry.getFileShortcuts();
1037    
1038                    for (FileShortcut fileShortcut : fileShortcuts) {
1039                            _repositoryEventTrigger.trigger(
1040                                    RepositoryEventType.Update.class, FileShortcut.class,
1041                                    fileShortcut);
1042                    }
1043    
1044                    repository.updateFileShortcuts(oldToFileEntryId, newToFileEntryId);
1045            }
1046    
1047            @Override
1048            public Folder updateFolder(
1049                            long folderId, long parentFolderId, String name, String description,
1050                            ServiceContext serviceContext)
1051                    throws PortalException {
1052    
1053                    Repository repository = getRepository();
1054    
1055                    Folder folder = repository.updateFolder(
1056                            folderId, parentFolderId, name, description, serviceContext);
1057    
1058                    _repositoryEventTrigger.trigger(
1059                            RepositoryEventType.Update.class, Folder.class, folder);
1060    
1061                    return folder;
1062            }
1063    
1064            @Override
1065            public Folder updateFolder(
1066                            long folderId, String name, String description,
1067                            ServiceContext serviceContext)
1068                    throws PortalException {
1069    
1070                    Repository repository = getRepository();
1071    
1072                    Folder folder = repository.updateFolder(
1073                            folderId, name, description, serviceContext);
1074    
1075                    if (folderId != DLFolderConstants.DEFAULT_PARENT_FOLDER_ID) {
1076                            _repositoryEventTrigger.trigger(
1077                                    RepositoryEventType.Update.class, Folder.class, folder);
1078                    }
1079    
1080                    return folder;
1081            }
1082    
1083            @Override
1084            public boolean verifyFileEntryCheckOut(long fileEntryId, String lockUuid)
1085                    throws PortalException {
1086    
1087                    return getRepository().verifyFileEntryCheckOut(fileEntryId, lockUuid);
1088            }
1089    
1090            @Override
1091            public boolean verifyFileEntryLock(long fileEntryId, String lockUuid)
1092                    throws PortalException {
1093    
1094                    return getRepository().verifyFileEntryLock(fileEntryId, lockUuid);
1095            }
1096    
1097            @Override
1098            public boolean verifyInheritableLock(long folderId, String lockUuid)
1099                    throws PortalException {
1100    
1101                    return getRepository().verifyInheritableLock(folderId, lockUuid);
1102            }
1103    
1104            private final RepositoryEventTrigger _repositoryEventTrigger;
1105    
1106    }