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