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