001
014
015 package com.liferay.portal.repository.liferayrepository;
016
017 import com.liferay.portal.kernel.exception.PortalException;
018 import com.liferay.portal.kernel.repository.Repository;
019 import com.liferay.portal.kernel.repository.model.FileEntry;
020 import com.liferay.portal.kernel.repository.model.FileVersion;
021 import com.liferay.portal.kernel.repository.model.Folder;
022 import com.liferay.portal.kernel.search.Hits;
023 import com.liferay.portal.kernel.search.Indexer;
024 import com.liferay.portal.kernel.search.IndexerRegistryUtil;
025 import com.liferay.portal.kernel.search.Query;
026 import com.liferay.portal.kernel.search.SearchContext;
027 import com.liferay.portal.kernel.search.SearchEngineUtil;
028 import com.liferay.portal.kernel.search.SearchException;
029 import com.liferay.portal.kernel.util.OrderByComparator;
030 import com.liferay.portal.kernel.util.ParamUtil;
031 import com.liferay.portal.kernel.util.SortedArrayList;
032 import com.liferay.portal.kernel.workflow.WorkflowConstants;
033 import com.liferay.portal.model.Lock;
034 import com.liferay.portal.repository.liferayrepository.model.LiferayFileEntry;
035 import com.liferay.portal.repository.liferayrepository.model.LiferayFileVersion;
036 import com.liferay.portal.repository.liferayrepository.model.LiferayFolder;
037 import com.liferay.portal.service.RepositoryLocalService;
038 import com.liferay.portal.service.RepositoryService;
039 import com.liferay.portal.service.ResourceLocalService;
040 import com.liferay.portal.service.ServiceContext;
041 import com.liferay.portlet.documentlibrary.model.DLFileEntry;
042 import com.liferay.portlet.documentlibrary.model.DLFileVersion;
043 import com.liferay.portlet.documentlibrary.model.DLFolder;
044 import com.liferay.portlet.documentlibrary.service.DLAppHelperLocalService;
045 import com.liferay.portlet.documentlibrary.service.DLFileEntryLocalService;
046 import com.liferay.portlet.documentlibrary.service.DLFileEntryService;
047 import com.liferay.portlet.documentlibrary.service.DLFileEntryTypeLocalService;
048 import com.liferay.portlet.documentlibrary.service.DLFileVersionLocalService;
049 import com.liferay.portlet.documentlibrary.service.DLFileVersionService;
050 import com.liferay.portlet.documentlibrary.service.DLFolderLocalService;
051 import com.liferay.portlet.documentlibrary.service.DLFolderService;
052 import com.liferay.portlet.documentlibrary.util.DLSearcher;
053 import com.liferay.portlet.documentlibrary.util.RepositoryModelUtil;
054 import com.liferay.portlet.documentlibrary.util.comparator.DLFileEntryOrderByComparator;
055 import com.liferay.portlet.documentlibrary.util.comparator.DLFolderOrderByComparator;
056 import com.liferay.portlet.dynamicdatamapping.storage.Fields;
057
058 import java.io.File;
059 import java.io.InputStream;
060
061 import java.util.List;
062 import java.util.Map;
063
064
067 public class LiferayRepository
068 extends LiferayRepositoryBase implements Repository {
069
070 public LiferayRepository(
071 RepositoryLocalService repositoryLocalService,
072 RepositoryService repositoryService,
073 DLAppHelperLocalService dlAppHelperLocalService,
074 DLFileEntryLocalService dlFileEntryLocalService,
075 DLFileEntryService dlFileEntryService,
076 DLFileEntryTypeLocalService dlFileEntryTypeLocalService,
077 DLFileVersionLocalService dlFileVersionLocalService,
078 DLFileVersionService dlFileVersionService,
079 DLFolderLocalService dlFolderLocalService,
080 DLFolderService dlFolderService,
081 ResourceLocalService resourceLocalService, long groupId,
082 long repositoryId, long dlFolderId) {
083
084 super(
085 repositoryLocalService, repositoryService, dlAppHelperLocalService,
086 dlFileEntryLocalService, dlFileEntryService,
087 dlFileEntryTypeLocalService, dlFileVersionLocalService,
088 dlFileVersionService, dlFolderLocalService, dlFolderService,
089 resourceLocalService, groupId, repositoryId, dlFolderId);
090 }
091
092 @Override
093 public FileEntry addFileEntry(
094 long userId, long folderId, String sourceFileName, String mimeType,
095 String title, String description, String changeLog, File file,
096 ServiceContext serviceContext)
097 throws PortalException {
098
099 long fileEntryTypeId = ParamUtil.getLong(
100 serviceContext, "fileEntryTypeId",
101 getDefaultFileEntryTypeId(serviceContext, folderId));
102
103 Map<String, Fields> fieldsMap = getFieldsMap(
104 serviceContext, fileEntryTypeId);
105
106 long size = 0;
107
108 if (file != null) {
109 size = file.length();
110 }
111
112 DLFileEntry dlFileEntry = dlFileEntryService.addFileEntry(
113 getGroupId(), getRepositoryId(), toFolderId(folderId),
114 sourceFileName, mimeType, title, description, changeLog,
115 fileEntryTypeId, fieldsMap, file, null, size, serviceContext);
116
117 addFileEntryResources(dlFileEntry, serviceContext);
118
119 return new LiferayFileEntry(dlFileEntry);
120 }
121
122 @Override
123 public FileEntry addFileEntry(
124 long userId, long folderId, String sourceFileName, String mimeType,
125 String title, String description, String changeLog, InputStream is,
126 long size, ServiceContext serviceContext)
127 throws PortalException {
128
129 long fileEntryTypeId = ParamUtil.getLong(
130 serviceContext, "fileEntryTypeId",
131 getDefaultFileEntryTypeId(serviceContext, folderId));
132
133 Map<String, Fields> fieldsMap = getFieldsMap(
134 serviceContext, fileEntryTypeId);
135
136 DLFileEntry dlFileEntry = dlFileEntryService.addFileEntry(
137 getGroupId(), getRepositoryId(), toFolderId(folderId),
138 sourceFileName, mimeType, title, description, changeLog,
139 fileEntryTypeId, fieldsMap, null, is, size, serviceContext);
140
141 addFileEntryResources(dlFileEntry, serviceContext);
142
143 return new LiferayFileEntry(dlFileEntry);
144 }
145
146
150 @Deprecated
151 @Override
152 public FileEntry addFileEntry(
153 long folderId, String sourceFileName, String mimeType, String title,
154 String description, String changeLog, File file,
155 ServiceContext serviceContext)
156 throws PortalException {
157
158 return addFileEntry(
159 com.liferay.portal.kernel.repository.util.RepositoryUserUtil.
160 getUserId(),
161 folderId, sourceFileName, mimeType, title, description, changeLog,
162 file, serviceContext);
163 }
164
165
170 @Deprecated
171 @Override
172 public FileEntry addFileEntry(
173 long folderId, String sourceFileName, String mimeType, String title,
174 String description, String changeLog, InputStream is, long size,
175 ServiceContext serviceContext)
176 throws PortalException {
177
178 return addFileEntry(
179 com.liferay.portal.kernel.repository.util.RepositoryUserUtil.
180 getUserId(),
181 folderId, sourceFileName, mimeType, title, description, changeLog,
182 is, size, serviceContext);
183 }
184
185 @Override
186 public Folder addFolder(
187 long userId, long parentFolderId, String name, String description,
188 ServiceContext serviceContext)
189 throws PortalException {
190
191 boolean mountPoint = ParamUtil.getBoolean(serviceContext, "mountPoint");
192
193 DLFolder dlFolder = dlFolderService.addFolder(
194 getGroupId(), getRepositoryId(), mountPoint,
195 toFolderId(parentFolderId), name, description, serviceContext);
196
197 return new LiferayFolder(dlFolder);
198 }
199
200
204 @Deprecated
205 @Override
206 public Folder addFolder(
207 long parentFolderId, String name, String description,
208 ServiceContext serviceContext)
209 throws PortalException {
210
211 return addFolder(
212 com.liferay.portal.kernel.repository.util.RepositoryUserUtil.
213 getUserId(),
214 parentFolderId, name, description, serviceContext);
215 }
216
217 @Override
218 public FileVersion cancelCheckOut(long fileEntryId) throws PortalException {
219 DLFileVersion dlFileVersion = dlFileEntryService.cancelCheckOut(
220 fileEntryId);
221
222 if (dlFileVersion != null) {
223 return new LiferayFileVersion(dlFileVersion);
224 }
225
226 return null;
227 }
228
229
233 @Deprecated
234 @Override
235 public void checkInFileEntry(
236 long fileEntryId, boolean major, String changeLog,
237 ServiceContext serviceContext)
238 throws PortalException {
239
240 checkInFileEntry(
241 com.liferay.portal.kernel.repository.util.RepositoryUserUtil.
242 getUserId(),
243 fileEntryId, major, changeLog, serviceContext);
244 }
245
246 @Override
247 public void checkInFileEntry(
248 long userId, long fileEntryId, boolean major, String changeLog,
249 ServiceContext serviceContext)
250 throws PortalException {
251
252 dlFileEntryService.checkInFileEntry(
253 fileEntryId, major, changeLog, serviceContext);
254 }
255
256 @Override
257 public void checkInFileEntry(
258 long userId, long fileEntryId, String lockUuid,
259 ServiceContext serviceContext)
260 throws PortalException {
261
262 dlFileEntryService.checkInFileEntry(
263 fileEntryId, lockUuid, serviceContext);
264 }
265
266
270 @Deprecated
271 @Override
272 public void checkInFileEntry(long fileEntryId, String lockUuid)
273 throws PortalException {
274
275 checkInFileEntry(fileEntryId, lockUuid, new ServiceContext());
276 }
277
278
282 @Deprecated
283 @Override
284 public void checkInFileEntry(
285 long fileEntryId, String lockUuid, ServiceContext serviceContext)
286 throws PortalException {
287
288 checkInFileEntry(
289 com.liferay.portal.kernel.repository.util.RepositoryUserUtil.
290 getUserId(),
291 fileEntryId, lockUuid, serviceContext);
292 }
293
294 @Override
295 public FileEntry checkOutFileEntry(
296 long fileEntryId, ServiceContext serviceContext)
297 throws PortalException {
298
299 DLFileEntry dlFileEntry = dlFileEntryService.checkOutFileEntry(
300 fileEntryId, serviceContext);
301
302 return new LiferayFileEntry(dlFileEntry);
303 }
304
305 @Override
306 public FileEntry checkOutFileEntry(
307 long fileEntryId, String owner, long expirationTime,
308 ServiceContext serviceContext)
309 throws PortalException {
310
311 DLFileEntry dlFileEntry = dlFileEntryService.checkOutFileEntry(
312 fileEntryId, owner, expirationTime, serviceContext);
313
314 return new LiferayFileEntry(dlFileEntry);
315 }
316
317 @Override
318 public FileEntry copyFileEntry(
319 long userId, long groupId, long fileEntryId, long destFolderId,
320 ServiceContext serviceContext)
321 throws PortalException {
322
323 DLFileEntry dlFileEntry = dlFileEntryService.copyFileEntry(
324 groupId, getRepositoryId(), fileEntryId, destFolderId,
325 serviceContext);
326
327 return new LiferayFileEntry(dlFileEntry);
328 }
329
330
334 @Deprecated
335 @Override
336 public FileEntry copyFileEntry(
337 long groupId, long fileEntryId, long destFolderId,
338 ServiceContext serviceContext)
339 throws PortalException {
340
341 return copyFileEntry(
342 com.liferay.portal.kernel.repository.util.RepositoryUserUtil.
343 getUserId(),
344 groupId, fileEntryId, destFolderId, serviceContext);
345 }
346
347 @Override
348 public void deleteAll() {
349 throw new UnsupportedOperationException();
350 }
351
352 @Override
353 public void deleteFileEntry(long fileEntryId) throws PortalException {
354 dlFileEntryService.deleteFileEntry(fileEntryId);
355 }
356
357 @Override
358 public void deleteFileEntry(long folderId, String title)
359 throws PortalException {
360
361 dlFileEntryService.deleteFileEntry(
362 getGroupId(), toFolderId(folderId), title);
363 }
364
365 @Override
366 public void deleteFileVersion(long fileEntryId, String version)
367 throws PortalException {
368
369 dlFileEntryService.deleteFileVersion(fileEntryId, version);
370 }
371
372 @Override
373 public void deleteFolder(long folderId) throws PortalException {
374 dlFolderService.deleteFolder(folderId);
375 }
376
377 @Override
378 public void deleteFolder(long parentFolderId, String name)
379 throws PortalException {
380
381 dlFolderService.deleteFolder(
382 getGroupId(), toFolderId(parentFolderId), name);
383 }
384
385 @Override
386 public List<FileEntry> getFileEntries(
387 long folderId, int start, int end, OrderByComparator<FileEntry> obc)
388 throws PortalException {
389
390 List<DLFileEntry> dlFileEntries = dlFileEntryService.getFileEntries(
391 getGroupId(), toFolderId(folderId), start, end,
392 DLFileEntryOrderByComparator.getOrderByComparator(obc));
393
394 return RepositoryModelUtil.toFileEntries(dlFileEntries);
395 }
396
397 @Override
398 public List<FileEntry> getFileEntries(
399 long folderId, long fileEntryTypeId, int start, int end,
400 OrderByComparator<FileEntry> obc)
401 throws PortalException {
402
403 List<DLFileEntry> dlFileEntries = dlFileEntryService.getFileEntries(
404 getGroupId(), toFolderId(folderId), fileEntryTypeId, start, end,
405 DLFileEntryOrderByComparator.getOrderByComparator(obc));
406
407 return RepositoryModelUtil.toFileEntries(dlFileEntries);
408 }
409
410 @Override
411 public List<FileEntry> getFileEntries(
412 long folderId, String[] mimeTypes, int start, int end,
413 OrderByComparator<FileEntry> obc)
414 throws PortalException {
415
416 List<DLFileEntry> dlFileEntries = dlFileEntryService.getFileEntries(
417 getGroupId(), toFolderId(folderId), mimeTypes, start, end,
418 DLFileEntryOrderByComparator.getOrderByComparator(obc));
419
420 return RepositoryModelUtil.toFileEntries(dlFileEntries);
421 }
422
423 @Override
424 public List<Object> getFileEntriesAndFileShortcuts(
425 long folderId, int status, int start, int end)
426 throws PortalException {
427
428 List<Object> dlFileEntriesAndFileShortcuts =
429 dlFolderService.getFileEntriesAndFileShortcuts(
430 getGroupId(), toFolderId(folderId), status, start, end);
431
432 return RepositoryModelUtil.toFileEntriesAndFolders(
433 dlFileEntriesAndFileShortcuts);
434 }
435
436 @Override
437 public int getFileEntriesAndFileShortcutsCount(long folderId, int status)
438 throws PortalException {
439
440 return dlFolderService.getFileEntriesAndFileShortcutsCount(
441 getGroupId(), toFolderId(folderId), status);
442 }
443
444 @Override
445 public int getFileEntriesAndFileShortcutsCount(
446 long folderId, int status, String[] mimeTypes)
447 throws PortalException {
448
449 return dlFolderService.getFileEntriesAndFileShortcutsCount(
450 getGroupId(), toFolderId(folderId), status, mimeTypes);
451 }
452
453 @Override
454 public int getFileEntriesCount(long folderId) {
455 return dlFileEntryService.getFileEntriesCount(
456 getGroupId(), toFolderId(folderId));
457 }
458
459 @Override
460 public int getFileEntriesCount(long folderId, long fileEntryTypeId) {
461 return dlFileEntryService.getFileEntriesCount(
462 getGroupId(), toFolderId(folderId), fileEntryTypeId);
463 }
464
465 @Override
466 public int getFileEntriesCount(long folderId, String[] mimeTypes) {
467 return dlFileEntryService.getFileEntriesCount(
468 getGroupId(), folderId, mimeTypes);
469 }
470
471 @Override
472 public FileEntry getFileEntry(long fileEntryId) throws PortalException {
473 DLFileEntry dlFileEntry = dlFileEntryService.getFileEntry(fileEntryId);
474
475 return new LiferayFileEntry(dlFileEntry);
476 }
477
478 @Override
479 public FileEntry getFileEntry(long folderId, String title)
480 throws PortalException {
481
482 DLFileEntry dlFileEntry = dlFileEntryService.getFileEntry(
483 getGroupId(), toFolderId(folderId), title);
484
485 return new LiferayFileEntry(dlFileEntry);
486 }
487
488 @Override
489 public FileEntry getFileEntryByUuid(String uuid) throws PortalException {
490 DLFileEntry dlFileEntry =
491 dlFileEntryService.getFileEntryByUuidAndGroupId(uuid, getGroupId());
492
493 return new LiferayFileEntry(dlFileEntry);
494 }
495
496 public Lock getFileEntryLock(long fileEntryId) {
497 return dlFileEntryService.getFileEntryLock(fileEntryId);
498 }
499
500 @Override
501 public FileVersion getFileVersion(long fileVersionId)
502 throws PortalException {
503
504 DLFileVersion dlFileVersion = dlFileVersionService.getFileVersion(
505 fileVersionId);
506
507 return new LiferayFileVersion(dlFileVersion);
508 }
509
510 @Override
511 public Folder getFolder(long folderId) throws PortalException {
512 DLFolder dlFolder = dlFolderService.getFolder(toFolderId(folderId));
513
514 return new LiferayFolder(dlFolder);
515 }
516
517 @Override
518 public Folder getFolder(long parentFolderId, String name)
519 throws PortalException {
520
521 DLFolder dlFolder = dlFolderService.getFolder(
522 getGroupId(), toFolderId(parentFolderId), name);
523
524 return new LiferayFolder(dlFolder);
525 }
526
527 @Override
528 public List<Folder> getFolders(
529 long parentFolderId, boolean includeMountfolders, int start,
530 int end, OrderByComparator<Folder> obc)
531 throws PortalException {
532
533 return getFolders(
534 parentFolderId, WorkflowConstants.STATUS_APPROVED,
535 includeMountfolders, start, end, obc);
536 }
537
538 @Override
539 public List<Folder> getFolders(
540 long parentFolderId, int status, boolean includeMountfolders,
541 int start, int end, OrderByComparator<Folder> obc)
542 throws PortalException {
543
544 List<DLFolder> dlFolders = dlFolderService.getFolders(
545 getGroupId(), toFolderId(parentFolderId), status,
546 includeMountfolders, start, end,
547 DLFolderOrderByComparator.getOrderByComparator(obc));
548
549 return RepositoryModelUtil.toFolders(dlFolders);
550 }
551
552 @Override
553 public List<Object> getFoldersAndFileEntriesAndFileShortcuts(
554 long folderId, int status, boolean includeMountFolders, int start,
555 int end, OrderByComparator<?> obc)
556 throws PortalException {
557
558 List<Object> dlFoldersAndFileEntriesAndFileShortcuts =
559 dlFolderService.getFoldersAndFileEntriesAndFileShortcuts(
560 getGroupId(), toFolderId(folderId), status, includeMountFolders,
561 start, end, obc);
562
563 return RepositoryModelUtil.toFileEntriesAndFolders(
564 dlFoldersAndFileEntriesAndFileShortcuts);
565 }
566
567 @Override
568 public List<Object> getFoldersAndFileEntriesAndFileShortcuts(
569 long folderId, int status, String[] mimeTypes,
570 boolean includeMountFolders, int start, int end,
571 OrderByComparator<?> obc)
572 throws PortalException {
573
574 List<Object> dlFoldersAndFileEntriesAndFileShortcuts =
575 dlFolderService.getFoldersAndFileEntriesAndFileShortcuts(
576 getGroupId(), toFolderId(folderId), status, mimeTypes,
577 includeMountFolders, start, end, obc);
578
579 return RepositoryModelUtil.toFileEntriesAndFolders(
580 dlFoldersAndFileEntriesAndFileShortcuts);
581 }
582
583 @Override
584 public int getFoldersAndFileEntriesAndFileShortcutsCount(
585 long folderId, int status, boolean includeMountFolders)
586 throws PortalException {
587
588 return dlFolderService.getFoldersAndFileEntriesAndFileShortcutsCount(
589 getGroupId(), toFolderId(folderId), status, includeMountFolders);
590 }
591
592 @Override
593 public int getFoldersAndFileEntriesAndFileShortcutsCount(
594 long folderId, int status, String[] mimeTypes,
595 boolean includeMountFolders)
596 throws PortalException {
597
598 return dlFolderService.getFoldersAndFileEntriesAndFileShortcutsCount(
599 getGroupId(), toFolderId(folderId), status, mimeTypes,
600 includeMountFolders);
601 }
602
603 @Override
604 public int getFoldersCount(long parentFolderId, boolean includeMountfolders)
605 throws PortalException {
606
607 return getFoldersCount(
608 parentFolderId, WorkflowConstants.STATUS_APPROVED,
609 includeMountfolders);
610 }
611
612 @Override
613 public int getFoldersCount(
614 long parentFolderId, int status, boolean includeMountfolders)
615 throws PortalException {
616
617 return dlFolderService.getFoldersCount(
618 getGroupId(), toFolderId(parentFolderId), status,
619 includeMountfolders);
620 }
621
622 @Override
623 public int getFoldersFileEntriesCount(List<Long> folderIds, int status) {
624 return dlFileEntryService.getFoldersFileEntriesCount(
625 getGroupId(), toFolderIds(folderIds), status);
626 }
627
628 @Override
629 public List<Folder> getMountFolders(
630 long parentFolderId, int start, int end,
631 OrderByComparator<Folder> obc)
632 throws PortalException {
633
634 List<DLFolder> dlFolders = dlFolderService.getMountFolders(
635 getGroupId(), toFolderId(parentFolderId), start, end,
636 DLFolderOrderByComparator.getOrderByComparator(obc));
637
638 return RepositoryModelUtil.toFolders(dlFolders);
639 }
640
641 @Override
642 public int getMountFoldersCount(long parentFolderId)
643 throws PortalException {
644
645 return dlFolderService.getMountFoldersCount(
646 getGroupId(), toFolderId(parentFolderId));
647 }
648
649 @Override
650 public List<FileEntry> getRepositoryFileEntries(
651 long userId, long rootFolderId, int start, int end,
652 OrderByComparator<FileEntry> obc)
653 throws PortalException {
654
655 List<DLFileEntry> dlFileEntries =
656 dlFileEntryService.getGroupFileEntries(
657 getGroupId(), userId, toFolderId(rootFolderId), start, end,
658 DLFileEntryOrderByComparator.getOrderByComparator(obc));
659
660 return RepositoryModelUtil.toFileEntries(dlFileEntries);
661 }
662
663 @Override
664 public List<FileEntry> getRepositoryFileEntries(
665 long userId, long rootFolderId, String[] mimeTypes, int status,
666 int start, int end, OrderByComparator<FileEntry> obc)
667 throws PortalException {
668
669 List<DLFileEntry> dlFileEntries =
670 dlFileEntryService.getGroupFileEntries(
671 getGroupId(), userId, getRepositoryId(),
672 toFolderId(rootFolderId), mimeTypes, status, start, end,
673 DLFileEntryOrderByComparator.getOrderByComparator(obc));
674
675 return RepositoryModelUtil.toFileEntries(dlFileEntries);
676 }
677
678 @Override
679 public int getRepositoryFileEntriesCount(long userId, long rootFolderId)
680 throws PortalException {
681
682 return dlFileEntryService.getGroupFileEntriesCount(
683 getGroupId(), userId, toFolderId(rootFolderId));
684 }
685
686 @Override
687 public int getRepositoryFileEntriesCount(
688 long userId, long rootFolderId, String[] mimeTypes, int status)
689 throws PortalException {
690
691 return dlFileEntryService.getGroupFileEntriesCount(
692 getGroupId(), userId, getRepositoryId(), toFolderId(rootFolderId),
693 mimeTypes, status);
694 }
695
696 @Override
697 public void getSubfolderIds(List<Long> folderIds, long folderId)
698 throws PortalException {
699
700 dlFolderService.getSubfolderIds(
701 folderIds, getGroupId(), toFolderId(folderId), true);
702 }
703
704 @Override
705 public List<Long> getSubfolderIds(long folderId, boolean recurse)
706 throws PortalException {
707
708 return dlFolderService.getSubfolderIds(
709 getGroupId(), toFolderId(folderId), recurse);
710 }
711
712
716 @Deprecated
717 @Override
718 public Lock lockFileEntry(long fileEntryId) throws PortalException {
719 FileEntry fileEntry = checkOutFileEntry(
720 fileEntryId, new ServiceContext());
721
722 return fileEntry.getLock();
723 }
724
725
729 @Deprecated
730 @Override
731 public Lock lockFileEntry(
732 long fileEntryId, String owner, long expirationTime)
733 throws PortalException {
734
735 FileEntry fileEntry = checkOutFileEntry(
736 fileEntryId, owner, expirationTime, new ServiceContext());
737
738 return fileEntry.getLock();
739 }
740
741 @Override
742 public Lock lockFolder(long folderId) throws PortalException {
743 return dlFolderService.lockFolder(toFolderId(folderId));
744 }
745
746 @Override
747 public Lock lockFolder(
748 long folderId, String owner, boolean inheritable,
749 long expirationTime)
750 throws PortalException {
751
752 return dlFolderService.lockFolder(
753 toFolderId(folderId), owner, inheritable, expirationTime);
754 }
755
756 @Override
757 public FileEntry moveFileEntry(
758 long userId, long fileEntryId, long newFolderId,
759 ServiceContext serviceContext)
760 throws PortalException {
761
762 DLFileEntry dlFileEntry = dlFileEntryService.moveFileEntry(
763 fileEntryId, toFolderId(newFolderId), serviceContext);
764
765 return new LiferayFileEntry(dlFileEntry);
766 }
767
768
772 @Deprecated
773 @Override
774 public FileEntry moveFileEntry(
775 long fileEntryId, long newFolderId, ServiceContext serviceContext)
776 throws PortalException {
777
778 return moveFileEntry(
779 com.liferay.portal.kernel.repository.util.RepositoryUserUtil.
780 getUserId(),
781 fileEntryId, newFolderId, serviceContext);
782 }
783
784 @Override
785 public Folder moveFolder(
786 long userId, long folderId, long parentFolderId,
787 ServiceContext serviceContext)
788 throws PortalException {
789
790 DLFolder dlFolder = dlFolderService.moveFolder(
791 toFolderId(folderId), toFolderId(parentFolderId), serviceContext);
792
793 return new LiferayFolder(dlFolder);
794 }
795
796
800 @Deprecated
801 @Override
802 public Folder moveFolder(
803 long folderId, long newParentFolderId,
804 ServiceContext serviceContext)
805 throws PortalException {
806
807 return moveFolder(
808 com.liferay.portal.kernel.repository.util.RepositoryUserUtil.
809 getUserId(),
810 folderId, newParentFolderId, serviceContext);
811 }
812
813 @Override
814 public Lock refreshFileEntryLock(
815 String lockUuid, long companyId, long expirationTime)
816 throws PortalException {
817
818 return dlFileEntryService.refreshFileEntryLock(
819 lockUuid, companyId, expirationTime);
820 }
821
822 @Override
823 public Lock refreshFolderLock(
824 String lockUuid, long companyId, long expirationTime)
825 throws PortalException {
826
827 return dlFolderService.refreshFolderLock(
828 lockUuid, companyId, expirationTime);
829 }
830
831 @Override
832 public void revertFileEntry(
833 long userId, long fileEntryId, String version,
834 ServiceContext serviceContext)
835 throws PortalException {
836
837 dlFileEntryService.revertFileEntry(
838 fileEntryId, version, serviceContext);
839 }
840
841
845 @Deprecated
846 @Override
847 public void revertFileEntry(
848 long fileEntryId, String version, ServiceContext serviceContext)
849 throws PortalException {
850
851 dlFileEntryService.revertFileEntry(
852 fileEntryId, version, serviceContext);
853 }
854
855 @Override
856 public Hits search(long creatorUserId, int status, int start, int end)
857 throws PortalException {
858
859 return dlFileEntryService.search(
860 getGroupId(), creatorUserId, status, start, end);
861 }
862
863 @Override
864 public Hits search(
865 long creatorUserId, long folderId, String[] mimeTypes, int status,
866 int start, int end)
867 throws PortalException {
868
869 return dlFileEntryService.search(
870 getGroupId(), creatorUserId, toFolderId(folderId), mimeTypes,
871 status, start, end);
872 }
873
874 @Override
875 public Hits search(SearchContext searchContext) throws SearchException {
876 Indexer indexer = null;
877
878 if (searchContext.isIncludeFolders()) {
879 indexer = DLSearcher.getInstance();
880 }
881 else {
882 indexer = IndexerRegistryUtil.getIndexer(DLFileEntry.class);
883 }
884
885 searchContext.setSearchEngineId(indexer.getSearchEngineId());
886
887 return indexer.search(searchContext);
888 }
889
890 @Override
891 public Hits search(SearchContext searchContext, Query query)
892 throws SearchException {
893
894 return SearchEngineUtil.search(searchContext, query);
895 }
896
897 @Override
898 public void unlockFolder(long folderId, String lockUuid)
899 throws PortalException {
900
901 dlFolderService.unlockFolder(toFolderId(folderId), lockUuid);
902 }
903
904 @Override
905 public void unlockFolder(long parentFolderId, String name, String lockUuid)
906 throws PortalException {
907
908 dlFolderService.unlockFolder(
909 getGroupId(), toFolderId(parentFolderId), name, lockUuid);
910 }
911
912 @Override
913 public FileEntry updateFileEntry(
914 long userId, long fileEntryId, String sourceFileName,
915 String mimeType, String title, String description, String changeLog,
916 boolean majorVersion, File file, ServiceContext serviceContext)
917 throws PortalException {
918
919 long fileEntryTypeId = ParamUtil.getLong(
920 serviceContext, "fileEntryTypeId", -1L);
921
922 Map<String, Fields> fieldsMap = getFieldsMap(
923 serviceContext, fileEntryTypeId);
924
925 long size = 0;
926
927 if (file != null) {
928 size = file.length();
929 }
930
931 DLFileEntry dlFileEntry = dlFileEntryService.updateFileEntry(
932 fileEntryId, sourceFileName, mimeType, title, description,
933 changeLog, majorVersion, fileEntryTypeId, fieldsMap, file, null,
934 size, serviceContext);
935
936 return new LiferayFileEntry(dlFileEntry);
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 long fileEntryTypeId = ParamUtil.getLong(
948 serviceContext, "fileEntryTypeId", -1L);
949
950 Map<String, Fields> fieldsMap = getFieldsMap(
951 serviceContext, fileEntryTypeId);
952
953 DLFileEntry dlFileEntry = dlFileEntryService.updateFileEntry(
954 fileEntryId, sourceFileName, mimeType, title, description,
955 changeLog, majorVersion, fileEntryTypeId, fieldsMap, null, is, size,
956 serviceContext);
957
958 return new LiferayFileEntry(dlFileEntry);
959 }
960
961
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 return updateFileEntry(
975 com.liferay.portal.kernel.repository.util.RepositoryUserUtil.
976 getUserId(),
977 fileEntryId, sourceFileName, mimeType, title, description,
978 changeLog, majorVersion, file, serviceContext);
979 }
980
981
986 @Deprecated
987 @Override
988 public FileEntry updateFileEntry(
989 long fileEntryId, String sourceFileName, String mimeType,
990 String title, String description, String changeLog,
991 boolean majorVersion, InputStream is, long size,
992 ServiceContext serviceContext)
993 throws PortalException {
994
995 return updateFileEntry(
996 com.liferay.portal.kernel.repository.util.RepositoryUserUtil.
997 getUserId(),
998 fileEntryId, sourceFileName, mimeType, title, description,
999 changeLog, majorVersion, is, size, serviceContext);
1000 }
1001
1002 @Override
1003 public Folder updateFolder(
1004 long folderId, long parentFolderId, String name, String description,
1005 ServiceContext serviceContext) {
1006
1007 throw new UnsupportedOperationException();
1008 }
1009
1010 @Override
1011 public Folder updateFolder(
1012 long folderId, String name, String description,
1013 ServiceContext serviceContext)
1014 throws PortalException {
1015
1016 long defaultFileEntryTypeId = ParamUtil.getLong(
1017 serviceContext, "defaultFileEntryTypeId");
1018 SortedArrayList<Long> fileEntryTypeIds = getLongList(
1019 serviceContext, "dlFileEntryTypesSearchContainerPrimaryKeys");
1020 int restrictionType = ParamUtil.getInteger(
1021 serviceContext, "restrictionType");
1022
1023 DLFolder dlFolder = dlFolderService.updateFolder(
1024 toFolderId(folderId), name, description, defaultFileEntryTypeId,
1025 fileEntryTypeIds, restrictionType, serviceContext);
1026
1027 return new LiferayFolder(dlFolder);
1028 }
1029
1030 @Override
1031 public boolean verifyFileEntryCheckOut(long fileEntryId, String lockUuid)
1032 throws PortalException {
1033
1034 return dlFileEntryService.verifyFileEntryCheckOut(
1035 fileEntryId, lockUuid);
1036 }
1037
1038 @Override
1039 public boolean verifyFileEntryLock(long fileEntryId, String lockUuid)
1040 throws PortalException {
1041
1042 return dlFileEntryService.verifyFileEntryLock(fileEntryId, lockUuid);
1043 }
1044
1045 @Override
1046 public boolean verifyInheritableLock(long folderId, String lockUuid)
1047 throws PortalException {
1048
1049 return dlFolderService.verifyInheritableLock(
1050 toFolderId(folderId), lockUuid);
1051 }
1052
1053 }