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