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