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