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                    if (fileVersion != null) {
191                            _repositoryEventTrigger.trigger(
192                                    RepositoryEventType.Update.class, FileEntry.class,
193                                    fileVersion.getFileEntry());
194                    }
195    
196                    return fileVersion;
197            }
198    
199            /**
200             * @deprecated As of 7.0.0, replaced by {@link #checkInFileEntry(long, long,
201             *             boolean, String, ServiceContext)}
202             */
203            @Deprecated
204            @Override
205            public void checkInFileEntry(
206                            long fileEntryId, boolean major, String changeLog,
207                            ServiceContext serviceContext)
208                    throws PortalException {
209    
210                    checkInFileEntry(
211                            com.liferay.portal.kernel.repository.util.RepositoryUserUtil.
212                                    getUserId(),
213                            fileEntryId, major, changeLog, serviceContext);
214            }
215    
216            @Override
217            public void checkInFileEntry(
218                            long userId, long fileEntryId, boolean major, String changeLog,
219                            ServiceContext serviceContext)
220                    throws PortalException {
221    
222                    Repository repository = getRepository();
223    
224                    repository.checkInFileEntry(
225                            userId, fileEntryId, major, changeLog, serviceContext);
226    
227                    FileEntry fileEntry = repository.getFileEntry(fileEntryId);
228    
229                    _repositoryEventTrigger.trigger(
230                            RepositoryEventType.Update.class, FileEntry.class, fileEntry);
231            }
232    
233            @Override
234            public void checkInFileEntry(
235                            long userId, long fileEntryId, String lockUuid,
236                            ServiceContext serviceContext)
237                    throws PortalException {
238    
239                    Repository repository = getRepository();
240    
241                    repository.checkInFileEntry(
242                            userId, fileEntryId, lockUuid, serviceContext);
243    
244                    FileEntry fileEntry = repository.getFileEntry(fileEntryId);
245    
246                    _repositoryEventTrigger.trigger(
247                            RepositoryEventType.Update.class, FileEntry.class, fileEntry);
248            }
249    
250            @Deprecated
251            @Override
252            public void checkInFileEntry(long fileEntryId, String lockUuid)
253                    throws PortalException {
254    
255                    Repository repository = getRepository();
256    
257                    repository.checkInFileEntry(fileEntryId, lockUuid);
258    
259                    FileEntry fileEntry = repository.getFileEntry(fileEntryId);
260    
261                    _repositoryEventTrigger.trigger(
262                            RepositoryEventType.Update.class, FileEntry.class, fileEntry);
263            }
264    
265            /**
266             * @deprecated As of 7.0.0, replaced by {@link #checkInFileEntry(long, long,
267             *             String, ServiceContext)}
268             */
269            @Deprecated
270            @Override
271            public void checkInFileEntry(
272                            long fileEntryId, String lockUuid, ServiceContext serviceContext)
273                    throws PortalException {
274    
275                    checkInFileEntry(
276                            com.liferay.portal.kernel.repository.util.RepositoryUserUtil.
277                                    getUserId(),
278                            fileEntryId, lockUuid, serviceContext);
279            }
280    
281            @Override
282            public FileEntry checkOutFileEntry(
283                            long fileEntryId, ServiceContext serviceContext)
284                    throws PortalException {
285    
286                    Repository repository = getRepository();
287    
288                    FileEntry fileEntry = repository.checkOutFileEntry(
289                            fileEntryId, serviceContext);
290    
291                    _repositoryEventTrigger.trigger(
292                            RepositoryEventType.Update.class, FileEntry.class, fileEntry);
293    
294                    return fileEntry;
295            }
296    
297            @Override
298            public FileEntry checkOutFileEntry(
299                            long fileEntryId, String owner, long expirationTime,
300                            ServiceContext serviceContext)
301                    throws PortalException {
302    
303                    Repository repository = getRepository();
304    
305                    FileEntry fileEntry = repository.checkOutFileEntry(
306                            fileEntryId, owner, expirationTime, serviceContext);
307    
308                    _repositoryEventTrigger.trigger(
309                            RepositoryEventType.Update.class, FileEntry.class, fileEntry);
310    
311                    return fileEntry;
312            }
313    
314            @Override
315            public FileEntry copyFileEntry(
316                            long userId, long groupId, long fileEntryId, long destFolderId,
317                            ServiceContext serviceContext)
318                    throws PortalException {
319    
320                    Repository repository = getRepository();
321    
322                    FileEntry fileEntry = repository.copyFileEntry(
323                            userId, groupId, fileEntryId, destFolderId, serviceContext);
324    
325                    _repositoryEventTrigger.trigger(
326                            RepositoryEventType.Add.class, FileEntry.class, fileEntry);
327    
328                    return fileEntry;
329            }
330    
331            /**
332             * @deprecated As of 7.0.0, replaced by {@link #copyFileEntry(long, long,
333             *             long, long, ServiceContext)}
334             */
335            @Deprecated
336            @Override
337            public FileEntry copyFileEntry(
338                            long groupId, long fileEntryId, long destFolderId,
339                            ServiceContext serviceContext)
340                    throws PortalException {
341    
342                    return copyFileEntry(
343                            com.liferay.portal.kernel.repository.util.RepositoryUserUtil.
344                                    getUserId(),
345                            groupId, fileEntryId, destFolderId, serviceContext);
346            }
347    
348            @Override
349            public void deleteAll() throws PortalException {
350                    Repository repository = getRepository();
351    
352                    _repositoryEventTrigger.trigger(
353                            RepositoryEventType.Delete.class, Repository.class, repository);
354    
355                    repository.deleteAll();
356            }
357    
358            @Override
359            public void deleteFileEntry(long fileEntryId) throws PortalException {
360                    Repository repository = getRepository();
361    
362                    FileEntry fileEntry = repository.getFileEntry(fileEntryId);
363    
364                    _repositoryEventTrigger.trigger(
365                            RepositoryEventType.Delete.class, FileEntry.class, fileEntry);
366    
367                    repository.deleteFileEntry(fileEntryId);
368            }
369    
370            @Override
371            public void deleteFileEntry(long folderId, String title)
372                    throws PortalException {
373    
374                    Repository repository = getRepository();
375    
376                    FileEntry fileEntry = repository.getFileEntry(folderId, title);
377    
378                    _repositoryEventTrigger.trigger(
379                            RepositoryEventType.Delete.class, FileEntry.class, fileEntry);
380    
381                    repository.deleteFileEntry(folderId, title);
382            }
383    
384            @Override
385            public void deleteFileShortcut(long fileShortcutId) throws PortalException {
386                    Repository repository = getRepository();
387    
388                    FileShortcut fileShortcut = repository.getFileShortcut(fileShortcutId);
389    
390                    _repositoryEventTrigger.trigger(
391                            RepositoryEventType.Delete.class, FileShortcut.class, fileShortcut);
392    
393                    repository.deleteFileShortcut(fileShortcutId);
394            }
395    
396            @Override
397            public void deleteFileShortcuts(long toFileEntryId) throws PortalException {
398                    Repository repository = getRepository();
399    
400                    FileEntry fileEntry = repository.getFileEntry(toFileEntryId);
401    
402                    List<FileShortcut> fileShortcuts = fileEntry.getFileShortcuts();
403    
404                    for (FileShortcut fileShortcut : fileShortcuts) {
405                            _repositoryEventTrigger.trigger(
406                                    RepositoryEventType.Delete.class, FileShortcut.class,
407                                    fileShortcut);
408                    }
409    
410                    repository.deleteFileShortcuts(toFileEntryId);
411            }
412    
413            @Override
414            public void deleteFileVersion(long fileEntryId, String version)
415                    throws PortalException {
416    
417                    Repository repository = getRepository();
418    
419                    FileEntry fileEntry = repository.getFileEntry(fileEntryId);
420    
421                    _repositoryEventTrigger.trigger(
422                            RepositoryEventType.Update.class, FileEntry.class, fileEntry);
423    
424                    repository.deleteFileVersion(fileEntryId, version);
425            }
426    
427            @Override
428            public void deleteFolder(long folderId) throws PortalException {
429                    Repository repository = getRepository();
430    
431                    Folder folder = repository.getFolder(folderId);
432    
433                    _repositoryEventTrigger.trigger(
434                            RepositoryEventType.Delete.class, Folder.class, folder);
435    
436                    repository.deleteFolder(folderId);
437            }
438    
439            @Override
440            public void deleteFolder(long parentFolderId, String name)
441                    throws PortalException {
442    
443                    Repository repository = getRepository();
444    
445                    Folder folder = repository.getFolder(parentFolderId, name);
446    
447                    _repositoryEventTrigger.trigger(
448                            RepositoryEventType.Delete.class, Folder.class, folder);
449    
450                    repository.deleteFolder(parentFolderId, name);
451            }
452    
453            @Override
454            public List<FileEntry> getFileEntries(
455                            long folderId, int status, int start, int end,
456                            OrderByComparator<FileEntry> obc)
457                    throws PortalException {
458    
459                    return getRepository().getFileEntries(
460                            folderId, status, start, end, obc);
461            }
462    
463            @Override
464            public List<FileEntry> getFileEntries(
465                            long folderId, int start, int end, OrderByComparator<FileEntry> obc)
466                    throws PortalException {
467    
468                    return getRepository().getFileEntries(folderId, start, end, obc);
469            }
470    
471            @Override
472            public List<FileEntry> getFileEntries(
473                            long folderId, long fileEntryTypeId, int start, int end,
474                            OrderByComparator<FileEntry> obc)
475                    throws PortalException {
476    
477                    return getRepository().getFileEntries(
478                            folderId, fileEntryTypeId, start, end, obc);
479            }
480    
481            @Override
482            public List<FileEntry> getFileEntries(
483                            long folderId, String[] mimeTypes, int start, int end,
484                            OrderByComparator<FileEntry> obc)
485                    throws PortalException {
486    
487                    return getRepository().getFileEntries(
488                            folderId, mimeTypes, start, end, obc);
489            }
490    
491            @Override
492            public List<RepositoryEntry> getFileEntriesAndFileShortcuts(
493                            long folderId, int status, int start, int end)
494                    throws PortalException {
495    
496                    return getRepository().getFileEntriesAndFileShortcuts(
497                            folderId, status, start, end);
498            }
499    
500            @Override
501            public int getFileEntriesAndFileShortcutsCount(long folderId, int status)
502                    throws PortalException {
503    
504                    return getRepository().getFileEntriesAndFileShortcutsCount(
505                            folderId, status);
506            }
507    
508            @Override
509            public int getFileEntriesAndFileShortcutsCount(
510                            long folderId, int status, String[] mimeTypes)
511                    throws PortalException {
512    
513                    return getRepository().getFileEntriesAndFileShortcutsCount(
514                            folderId, status, mimeTypes);
515            }
516    
517            @Override
518            public int getFileEntriesCount(long folderId) throws PortalException {
519                    return getRepository().getFileEntriesCount(folderId);
520            }
521    
522            @Override
523            public int getFileEntriesCount(long folderId, int status)
524                    throws PortalException {
525    
526                    return getRepository().getFileEntriesCount(folderId, status);
527            }
528    
529            @Override
530            public int getFileEntriesCount(long folderId, long fileEntryTypeId)
531                    throws PortalException {
532    
533                    return getRepository().getFileEntriesCount(folderId, fileEntryTypeId);
534            }
535    
536            @Override
537            public int getFileEntriesCount(long folderId, String[] mimeTypes)
538                    throws PortalException {
539    
540                    return getRepository().getFileEntriesCount(folderId, mimeTypes);
541            }
542    
543            @Override
544            public FileEntry getFileEntry(long fileEntryId) throws PortalException {
545                    return getRepository().getFileEntry(fileEntryId);
546            }
547    
548            @Override
549            public FileEntry getFileEntry(long folderId, String title)
550                    throws PortalException {
551    
552                    return getRepository().getFileEntry(folderId, title);
553            }
554    
555            @Override
556            public FileEntry getFileEntryByUuid(String uuid) throws PortalException {
557                    return getRepository().getFileEntryByUuid(uuid);
558            }
559    
560            @Override
561            public FileShortcut getFileShortcut(long fileShortcutId)
562                    throws PortalException {
563    
564                    return getRepository().getFileShortcut(fileShortcutId);
565            }
566    
567            @Override
568            public FileVersion getFileVersion(long fileVersionId)
569                    throws PortalException {
570    
571                    return getRepository().getFileVersion(fileVersionId);
572            }
573    
574            @Override
575            public Folder getFolder(long folderId) throws PortalException {
576                    return getRepository().getFolder(folderId);
577            }
578    
579            @Override
580            public Folder getFolder(long parentFolderId, String name)
581                    throws PortalException {
582    
583                    return getRepository().getFolder(parentFolderId, name);
584            }
585    
586            @Override
587            public List<Folder> getFolders(
588                            long parentFolderId, boolean includeMountFolders, int start,
589                            int end, OrderByComparator<Folder> obc)
590                    throws PortalException {
591    
592                    return getRepository().getFolders(
593                            parentFolderId, includeMountFolders, start, end, obc);
594            }
595    
596            @Override
597            public List<Folder> getFolders(
598                            long parentFolderId, int status, boolean includeMountFolders,
599                            int start, int end, OrderByComparator<Folder> obc)
600                    throws PortalException {
601    
602                    return getRepository().getFolders(
603                            parentFolderId, status, includeMountFolders, start, end, obc);
604            }
605    
606            @Override
607            public List<RepositoryEntry> getFoldersAndFileEntriesAndFileShortcuts(
608                            long folderId, int status, boolean includeMountFolders, int start,
609                            int end, OrderByComparator<?> obc)
610                    throws PortalException {
611    
612                    return getRepository().getFoldersAndFileEntriesAndFileShortcuts(
613                            folderId, status, includeMountFolders, start, end, obc);
614            }
615    
616            @Override
617            public List<RepositoryEntry> getFoldersAndFileEntriesAndFileShortcuts(
618                            long folderId, int status, String[] mimetypes,
619                            boolean includeMountFolders, int start, int end,
620                            OrderByComparator<?> obc)
621                    throws PortalException {
622    
623                    return getRepository().getFoldersAndFileEntriesAndFileShortcuts(
624                            folderId, status, mimetypes, includeMountFolders, start, end, obc);
625            }
626    
627            @Override
628            public int getFoldersAndFileEntriesAndFileShortcutsCount(
629                            long folderId, int status, boolean includeMountFolders)
630                    throws PortalException {
631    
632                    return getRepository().getFoldersAndFileEntriesAndFileShortcutsCount(
633                            folderId, status, includeMountFolders);
634            }
635    
636            @Override
637            public int getFoldersAndFileEntriesAndFileShortcutsCount(
638                            long folderId, int status, String[] mimetypes,
639                            boolean includeMountFolders)
640                    throws PortalException {
641    
642                    return getRepository().getFoldersAndFileEntriesAndFileShortcutsCount(
643                            folderId, status, mimetypes, includeMountFolders);
644            }
645    
646            @Override
647            public int getFoldersCount(long parentFolderId, boolean includeMountfolders)
648                    throws PortalException {
649    
650                    return getRepository().getFoldersCount(
651                            parentFolderId, includeMountfolders);
652            }
653    
654            @Override
655            public int getFoldersCount(
656                            long parentFolderId, int status, boolean includeMountfolders)
657                    throws PortalException {
658    
659                    return getRepository().getFoldersCount(
660                            parentFolderId, status, includeMountfolders);
661            }
662    
663            @Override
664            public int getFoldersFileEntriesCount(List<Long> folderIds, int status)
665                    throws PortalException {
666    
667                    return getRepository().getFoldersFileEntriesCount(folderIds, status);
668            }
669    
670            @Override
671            public List<Folder> getMountFolders(
672                            long parentFolderId, int start, int end,
673                            OrderByComparator<Folder> obc)
674                    throws PortalException {
675    
676                    return getRepository().getMountFolders(parentFolderId, start, end, obc);
677            }
678    
679            @Override
680            public int getMountFoldersCount(long parentFolderId)
681                    throws PortalException {
682    
683                    return getRepository().getMountFoldersCount(parentFolderId);
684            }
685    
686            @Override
687            public List<FileEntry> getRepositoryFileEntries(
688                            long userId, long rootFolderId, int start, int end,
689                            OrderByComparator<FileEntry> obc)
690                    throws PortalException {
691    
692                    return getRepository().getRepositoryFileEntries(
693                            userId, rootFolderId, start, end, obc);
694            }
695    
696            @Override
697            public List<FileEntry> getRepositoryFileEntries(
698                            long userId, long rootFolderId, String[] mimeTypes, int status,
699                            int start, int end, OrderByComparator<FileEntry> obc)
700                    throws PortalException {
701    
702                    return getRepository().getRepositoryFileEntries(
703                            userId, rootFolderId, mimeTypes, status, start, end, obc);
704            }
705    
706            @Override
707            public int getRepositoryFileEntriesCount(long userId, long rootFolderId)
708                    throws PortalException {
709    
710                    return getRepository().getRepositoryFileEntriesCount(
711                            userId, rootFolderId);
712            }
713    
714            @Override
715            public int getRepositoryFileEntriesCount(
716                            long userId, long rootFolderId, String[] mimeTypes, int status)
717                    throws PortalException {
718    
719                    return getRepository().getRepositoryFileEntriesCount(
720                            userId, rootFolderId, mimeTypes, status);
721            }
722    
723            @Override
724            public long getRepositoryId() {
725                    return getRepository().getRepositoryId();
726            }
727    
728            @Override
729            public void getSubfolderIds(List<Long> folderIds, long folderId)
730                    throws PortalException {
731    
732                    getRepository().getSubfolderIds(folderIds, folderId);
733            }
734    
735            @Override
736            public List<Long> getSubfolderIds(long folderId, boolean recurse)
737                    throws PortalException {
738    
739                    return getRepository().getSubfolderIds(folderId, recurse);
740            }
741    
742            @Override
743            public Lock lockFolder(long folderId) throws PortalException {
744                    return getRepository().lockFolder(folderId);
745            }
746    
747            @Override
748            public Lock lockFolder(
749                            long folderId, String owner, boolean inheritable,
750                            long expirationTime)
751                    throws PortalException {
752    
753                    return getRepository().lockFolder(
754                            folderId, owner, inheritable, expirationTime);
755            }
756    
757            @Override
758            public FileEntry moveFileEntry(
759                            long userId, long fileEntryId, long newFolderId,
760                            ServiceContext serviceContext)
761                    throws PortalException {
762    
763                    Repository repository = getRepository();
764    
765                    FileEntry fileEntry = repository.moveFileEntry(
766                            userId, fileEntryId, newFolderId, serviceContext);
767    
768                    _repositoryEventTrigger.trigger(
769                            RepositoryEventType.Move.class, FileEntry.class, fileEntry);
770    
771                    return fileEntry;
772            }
773    
774            /**
775             * @deprecated As of 7.0.0, replaced by {@link #moveFileEntry(long, long,
776             *             long, ServiceContext)}
777             */
778            @Deprecated
779            @Override
780            public FileEntry moveFileEntry(
781                            long fileEntryId, long newFolderId, ServiceContext serviceContext)
782                    throws PortalException {
783    
784                    return moveFileEntry(
785                            com.liferay.portal.kernel.repository.util.RepositoryUserUtil.
786                                    getUserId(),
787                            fileEntryId, newFolderId, serviceContext);
788            }
789    
790            @Override
791            public Folder moveFolder(
792                            long userId, long folderId, long parentFolderId,
793                            ServiceContext serviceContext)
794                    throws PortalException {
795    
796                    Repository repository = getRepository();
797    
798                    Folder folder = repository.moveFolder(
799                            userId, folderId, parentFolderId, serviceContext);
800    
801                    _repositoryEventTrigger.trigger(
802                            RepositoryEventType.Move.class, Folder.class, folder);
803    
804                    return folder;
805            }
806    
807            /**
808             * @deprecated As of 7.0.0, replaced by {@link #moveFolder(long, long, long,
809             *             ServiceContext)}
810             */
811            @Deprecated
812            @Override
813            public Folder moveFolder(
814                            long folderId, long newParentFolderId,
815                            ServiceContext serviceContext)
816                    throws PortalException {
817    
818                    return moveFolder(
819                            com.liferay.portal.kernel.repository.util.RepositoryUserUtil.
820                                    getUserId(),
821                            folderId, newParentFolderId, serviceContext);
822            }
823    
824            @Override
825            public Lock refreshFileEntryLock(
826                            String lockUuid, long companyId, long expirationTime)
827                    throws PortalException {
828    
829                    return getRepository().refreshFileEntryLock(
830                            lockUuid, companyId, expirationTime);
831            }
832    
833            @Override
834            public Lock refreshFolderLock(
835                            String lockUuid, long companyId, long expirationTime)
836                    throws PortalException {
837    
838                    return getRepository().refreshFolderLock(
839                            lockUuid, companyId, expirationTime);
840            }
841    
842            @Override
843            public void revertFileEntry(
844                            long userId, long fileEntryId, String version,
845                            ServiceContext serviceContext)
846                    throws PortalException {
847    
848                    Repository repository = getRepository();
849    
850                    repository.revertFileEntry(
851                            userId, fileEntryId, version, serviceContext);
852    
853                    FileEntry fileEntry = getFileEntry(fileEntryId);
854    
855                    _repositoryEventTrigger.trigger(
856                            RepositoryEventType.Update.class, FileEntry.class, fileEntry);
857            }
858    
859            /**
860             * @deprecated As of 7.0.0, replaced by {@link #revertFileEntry(long, long,
861             *             String, ServiceContext)}
862             */
863            @Deprecated
864            @Override
865            public void revertFileEntry(
866                            long fileEntryId, String version, ServiceContext serviceContext)
867                    throws PortalException {
868    
869                    Repository repository = getRepository();
870    
871                    repository.revertFileEntry(fileEntryId, version, serviceContext);
872    
873                    FileEntry fileEntry = getFileEntry(fileEntryId);
874    
875                    _repositoryEventTrigger.trigger(
876                            RepositoryEventType.Update.class, FileEntry.class, fileEntry);
877            }
878    
879            @Override
880            public Hits search(long creatorUserId, int status, int start, int end)
881                    throws PortalException {
882    
883                    return getRepository().search(creatorUserId, status, start, end);
884            }
885    
886            @Override
887            public Hits search(
888                            long creatorUserId, long folderId, String[] mimeTypes, int status,
889                            int start, int end)
890                    throws PortalException {
891    
892                    return getRepository().search(
893                            creatorUserId, folderId, mimeTypes, status, start, end);
894            }
895    
896            @Override
897            public Hits search(SearchContext searchContext) throws SearchException {
898                    return getRepository().search(searchContext);
899            }
900    
901            @Override
902            public Hits search(SearchContext searchContext, Query query)
903                    throws SearchException {
904    
905                    return getRepository().search(searchContext, query);
906            }
907    
908            @Override
909            public void unlockFolder(long folderId, String lockUuid)
910                    throws PortalException {
911    
912                    getRepository().unlockFolder(folderId, lockUuid);
913            }
914    
915            @Override
916            public void unlockFolder(long parentFolderId, String name, String lockUuid)
917                    throws PortalException {
918    
919                    getRepository().unlockFolder(parentFolderId, name, lockUuid);
920            }
921    
922            @Override
923            public FileEntry updateFileEntry(
924                            long userId, long fileEntryId, String sourceFileName,
925                            String mimeType, String title, String description, String changeLog,
926                            boolean majorVersion, File file, ServiceContext serviceContext)
927                    throws PortalException {
928    
929                    Repository repository = getRepository();
930    
931                    FileEntry fileEntry = repository.updateFileEntry(
932                            userId, fileEntryId, sourceFileName, mimeType, title, description,
933                            changeLog, majorVersion, file, serviceContext);
934    
935                    _repositoryEventTrigger.trigger(
936                            RepositoryEventType.Update.class, FileEntry.class, fileEntry);
937    
938                    return fileEntry;
939            }
940    
941            @Override
942            public FileEntry updateFileEntry(
943                            long userId, long fileEntryId, String sourceFileName,
944                            String mimeType, String title, String description, String changeLog,
945                            boolean majorVersion, InputStream is, long size,
946                            ServiceContext serviceContext)
947                    throws PortalException {
948    
949                    Repository repository = getRepository();
950    
951                    FileEntry fileEntry = repository.updateFileEntry(
952                            userId, fileEntryId, sourceFileName, mimeType, title, description,
953                            changeLog, majorVersion, is, size, serviceContext);
954    
955                    _repositoryEventTrigger.trigger(
956                            RepositoryEventType.Update.class, FileEntry.class, fileEntry);
957    
958                    return fileEntry;
959            }
960    
961            /**
962             * @deprecated As of 7.0.0, replaced by {@link #updateFileEntry(long, long,
963             *             String, String, String, String, String, boolean, File,
964             *             ServiceContext)}
965             */
966            @Deprecated
967            @Override
968            public FileEntry updateFileEntry(
969                            long fileEntryId, String sourceFileName, String mimeType,
970                            String title, String description, String changeLog,
971                            boolean majorVersion, File file, ServiceContext serviceContext)
972                    throws PortalException {
973    
974                    Repository repository = getRepository();
975    
976                    FileEntry fileEntry = repository.updateFileEntry(
977                            fileEntryId, sourceFileName, mimeType, title, description,
978                            changeLog, majorVersion, file, serviceContext);
979    
980                    _repositoryEventTrigger.trigger(
981                            RepositoryEventType.Update.class, FileEntry.class, fileEntry);
982    
983                    return fileEntry;
984            }
985    
986            /**
987             * @deprecated As of 7.0.0, replaced by {@link #updateFileEntry(long, long,
988             *             String, String, String, String, String, boolean, InputStream,
989             *             long, ServiceContext)}
990             */
991            @Deprecated
992            @Override
993            public FileEntry updateFileEntry(
994                            long fileEntryId, String sourceFileName, String mimeType,
995                            String title, String description, String changeLog,
996                            boolean majorVersion, InputStream is, long size,
997                            ServiceContext serviceContext)
998                    throws PortalException {
999    
1000                    Repository repository = getRepository();
1001    
1002                    FileEntry fileEntry = repository.updateFileEntry(
1003                            fileEntryId, sourceFileName, mimeType, title, description,
1004                            changeLog, majorVersion, is, size, serviceContext);
1005    
1006                    _repositoryEventTrigger.trigger(
1007                            RepositoryEventType.Update.class, FileEntry.class, fileEntry);
1008    
1009                    return fileEntry;
1010            }
1011    
1012            @Override
1013            public FileShortcut updateFileShortcut(
1014                            long userId, long fileShortcutId, long folderId, long toFileEntryId,
1015                            ServiceContext serviceContext)
1016                    throws PortalException {
1017    
1018                    Repository repository = getRepository();
1019    
1020                    FileShortcut fileShortcut = repository.updateFileShortcut(
1021                            userId, fileShortcutId, folderId, toFileEntryId, serviceContext);
1022    
1023                    _repositoryEventTrigger.trigger(
1024                            RepositoryEventType.Update.class, FileShortcut.class, fileShortcut);
1025    
1026                    return fileShortcut;
1027            }
1028    
1029            @Override
1030            public void updateFileShortcuts(
1031                            long oldToFileEntryId, long newToFileEntryId)
1032                    throws PortalException {
1033    
1034                    Repository repository = getRepository();
1035    
1036                    FileEntry oldToFileEntry = repository.getFileEntry(oldToFileEntryId);
1037    
1038                    List<FileShortcut> fileShortcuts = oldToFileEntry.getFileShortcuts();
1039    
1040                    for (FileShortcut fileShortcut : fileShortcuts) {
1041                            _repositoryEventTrigger.trigger(
1042                                    RepositoryEventType.Update.class, FileShortcut.class,
1043                                    fileShortcut);
1044                    }
1045    
1046                    repository.updateFileShortcuts(oldToFileEntryId, newToFileEntryId);
1047            }
1048    
1049            @Override
1050            public Folder updateFolder(
1051                            long folderId, long parentFolderId, String name, String description,
1052                            ServiceContext serviceContext)
1053                    throws PortalException {
1054    
1055                    Repository repository = getRepository();
1056    
1057                    Folder folder = repository.updateFolder(
1058                            folderId, parentFolderId, name, description, serviceContext);
1059    
1060                    _repositoryEventTrigger.trigger(
1061                            RepositoryEventType.Update.class, Folder.class, folder);
1062    
1063                    return folder;
1064            }
1065    
1066            @Override
1067            public Folder updateFolder(
1068                            long folderId, String name, String description,
1069                            ServiceContext serviceContext)
1070                    throws PortalException {
1071    
1072                    Repository repository = getRepository();
1073    
1074                    Folder folder = repository.updateFolder(
1075                            folderId, name, description, serviceContext);
1076    
1077                    if (folderId != DLFolderConstants.DEFAULT_PARENT_FOLDER_ID) {
1078                            _repositoryEventTrigger.trigger(
1079                                    RepositoryEventType.Update.class, Folder.class, folder);
1080                    }
1081    
1082                    return folder;
1083            }
1084    
1085            @Override
1086            public boolean verifyFileEntryCheckOut(long fileEntryId, String lockUuid)
1087                    throws PortalException {
1088    
1089                    return getRepository().verifyFileEntryCheckOut(fileEntryId, lockUuid);
1090            }
1091    
1092            @Override
1093            public boolean verifyFileEntryLock(long fileEntryId, String lockUuid)
1094                    throws PortalException {
1095    
1096                    return getRepository().verifyFileEntryLock(fileEntryId, lockUuid);
1097            }
1098    
1099            @Override
1100            public boolean verifyInheritableLock(long folderId, String lockUuid)
1101                    throws PortalException {
1102    
1103                    return getRepository().verifyInheritableLock(folderId, lockUuid);
1104            }
1105    
1106            private final RepositoryEventTrigger _repositoryEventTrigger;
1107    
1108    }