001    /**
002     * Copyright (c) 2000-2011 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
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    /**
066     * @author Alexander Chow
067     */
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<Object> getFileEntriesAndFileShortcuts(
271                            long folderId, int status, int start, int end)
272                    throws SystemException {
273    
274                    List<Object> dlFileEntriesAndFileShortcuts =
275                            dlFolderService.getFileEntriesAndFileShortcuts(
276                                    getGroupId(), toFolderId(folderId), status, start, end);
277    
278                    return toFileEntriesAndFolders(dlFileEntriesAndFileShortcuts);
279            }
280    
281            public int getFileEntriesAndFileShortcutsCount(long folderId, int status)
282                    throws SystemException {
283    
284                    return dlFolderService.getFileEntriesAndFileShortcutsCount(
285                            getGroupId(), toFolderId(folderId), status);
286            }
287    
288            public int getFileEntriesCount(long folderId) throws SystemException {
289                    return dlFileEntryService.getFileEntriesCount(
290                            getGroupId(), toFolderId(folderId));
291            }
292    
293            public int getFileEntriesCount(long folderId, long fileEntryTypeId)
294                    throws SystemException {
295    
296                    return dlFileEntryService.getFileEntriesCount(
297                            getGroupId(), toFolderId(folderId), fileEntryTypeId);
298            }
299    
300            public FileEntry getFileEntry(long fileEntryId)
301                    throws PortalException, SystemException {
302    
303                    DLFileEntry dlFileEntry = dlFileEntryService.getFileEntry(fileEntryId);
304    
305                    return new LiferayFileEntry(dlFileEntry);
306            }
307    
308            public FileEntry getFileEntry(long folderId, String title)
309                    throws PortalException, SystemException {
310    
311                    DLFileEntry dlFileEntry = dlFileEntryService.getFileEntry(
312                            getGroupId(), toFolderId(folderId), title);
313    
314                    return new LiferayFileEntry(dlFileEntry);
315            }
316    
317            public FileEntry getFileEntryByUuid(String uuid)
318                    throws PortalException, SystemException {
319    
320                    DLFileEntry dlFileEntry =
321                            dlFileEntryService.getFileEntryByUuidAndGroupId(uuid, getGroupId());
322    
323                    return new LiferayFileEntry(dlFileEntry);
324            }
325    
326            public Lock getFileEntryLock(long fileEntryId) {
327                    return dlFileEntryService.getFileEntryLock(fileEntryId);
328            }
329    
330            public FileVersion getFileVersion(long fileVersionId)
331                    throws PortalException, SystemException {
332    
333                    DLFileVersion dlFileVersion = dlFileVersionService.getFileVersion(
334                            fileVersionId);
335    
336                    return new LiferayFileVersion(dlFileVersion);
337            }
338    
339            public Folder getFolder(long folderId)
340                    throws PortalException, SystemException {
341    
342                    DLFolder dlFolder = dlFolderService.getFolder(toFolderId(folderId));
343    
344                    return new LiferayFolder(dlFolder);
345            }
346    
347            public Folder getFolder(long parentFolderId, String title)
348                    throws PortalException, SystemException {
349    
350                    DLFolder dlFolder = dlFolderService.getFolder(
351                            getGroupId(), toFolderId(parentFolderId), title);
352    
353                    return new LiferayFolder(dlFolder);
354            }
355    
356            public List<Folder> getFolders(
357                            long parentFolderId, boolean includeMountfolders, int start,
358                            int end, OrderByComparator obc)
359                    throws SystemException {
360    
361                    List<DLFolder> dlFolders = dlFolderService.getFolders(
362                            getGroupId(), toFolderId(parentFolderId), includeMountfolders,
363                            start, end, obc);
364    
365                    return toFolders(dlFolders);
366            }
367    
368            public List<Object> getFoldersAndFileEntriesAndFileShortcuts(
369                            long folderId, int status, boolean includeMountFolders, int start,
370                            int end, OrderByComparator obc)
371                    throws SystemException {
372    
373                    List<Object> dlFoldersAndFileEntriesAndFileShortcuts =
374                            dlFolderService.getFoldersAndFileEntriesAndFileShortcuts(
375                                    getGroupId(), toFolderId(folderId), status, includeMountFolders,
376                                    start, end, obc);
377    
378                    return toFileEntriesAndFolders(dlFoldersAndFileEntriesAndFileShortcuts);
379            }
380    
381            public List<Object> getFoldersAndFileEntriesAndFileShortcuts(
382                            long folderId, int status, String[] mimeTypes,
383                            boolean includeMountFolders, int start, int end,
384                            OrderByComparator obc)
385                    throws SystemException {
386    
387                    List<Object> dlFoldersAndFileEntriesAndFileShortcuts =
388                            dlFolderService.getFoldersAndFileEntriesAndFileShortcuts(
389                                    getGroupId(), toFolderId(folderId), status, mimeTypes,
390                                    includeMountFolders, start, end, obc);
391    
392                    return toFileEntriesAndFolders(dlFoldersAndFileEntriesAndFileShortcuts);
393            }
394    
395            public int getFoldersAndFileEntriesAndFileShortcutsCount(
396                            long folderId, int status, boolean includeMountFolders)
397                    throws SystemException {
398    
399                    return dlFolderService.getFoldersAndFileEntriesAndFileShortcutsCount(
400                            getGroupId(), toFolderId(folderId), status, includeMountFolders);
401            }
402    
403            public int getFoldersAndFileEntriesAndFileShortcutsCount(
404                            long folderId, int status, String[] mimeTypes,
405                            boolean includeMountFolders)
406                    throws SystemException {
407    
408                    return dlFolderService.getFoldersAndFileEntriesAndFileShortcutsCount(
409                            getGroupId(), toFolderId(folderId), status, mimeTypes,
410                            includeMountFolders);
411            }
412    
413            public int getFoldersCount(long parentFolderId) throws SystemException {
414                    return getFoldersCount(parentFolderId, true);
415            }
416    
417            public int getFoldersCount(long parentFolderId, boolean includeMountfolders)
418                    throws SystemException {
419    
420                    return dlFolderService.getFoldersCount(
421                            getGroupId(), toFolderId(parentFolderId), includeMountfolders);
422            }
423    
424            public int getFoldersFileEntriesCount(List<Long> folderIds, int status)
425                    throws SystemException {
426    
427                    return dlFileEntryService.getFoldersFileEntriesCount(
428                            getGroupId(), toFolderIds(folderIds), status);
429            }
430    
431            public List<Folder> getMountFolders(
432                            long parentFolderId, int start, int end, OrderByComparator obc)
433                    throws SystemException {
434    
435                    List<DLFolder> dlFolders = dlFolderService.getMountFolders(
436                            getGroupId(), toFolderId(parentFolderId), start, end, obc);
437    
438                    return toFolders(dlFolders);
439            }
440    
441            public int getMountFoldersCount(long parentFolderId)
442                    throws SystemException {
443    
444                    return dlFolderService.getMountFoldersCount(
445                            getGroupId(), toFolderId(parentFolderId));
446            }
447    
448            public List<FileEntry> getRepositoryFileEntries(
449                            long userId, long rootFolderId, int start, int end,
450                            OrderByComparator obc)
451                    throws SystemException {
452    
453                    List<DLFileEntry> dlFileEntries =
454                            dlFileEntryService.getGroupFileEntries(
455                                    getGroupId(), userId, toFolderId(rootFolderId), start, end,
456                                    obc);
457    
458                    return toFileEntries(dlFileEntries);
459            }
460    
461            public int getRepositoryFileEntriesCount(long userId, long rootFolderId)
462                    throws SystemException {
463    
464                    return dlFileEntryService.getGroupFileEntriesCount(
465                            getGroupId(), userId, toFolderId(rootFolderId));
466            }
467    
468            public void getSubfolderIds(List<Long> folderIds, long folderId)
469                    throws SystemException {
470    
471                    dlFolderService.getSubfolderIds(
472                            folderIds, getGroupId(), toFolderId(folderId));
473            }
474    
475            public List<Long> getSubfolderIds(long folderId, boolean recurse)
476                    throws SystemException {
477    
478                    return dlFolderService.getSubfolderIds(
479                            getGroupId(), toFolderId(folderId), recurse);
480            }
481    
482            public Lock lockFolder(long folderId)
483                    throws PortalException, SystemException {
484    
485                    return dlFolderService.lockFolder(toFolderId(folderId));
486            }
487    
488            public Lock lockFolder(
489                            long folderId, String owner, boolean inheritable,
490                            long expirationTime)
491                    throws PortalException, SystemException {
492    
493                    return dlFolderService.lockFolder(
494                            toFolderId(folderId), owner, inheritable, expirationTime);
495            }
496    
497            public FileEntry moveFileEntry(
498                            long fileEntryId, long newFolderId, ServiceContext serviceContext)
499                    throws PortalException, SystemException {
500    
501                    DLFileEntry dlFileEntry = dlFileEntryService.moveFileEntry(
502                            fileEntryId, toFolderId(newFolderId), serviceContext);
503    
504                    return new LiferayFileEntry(dlFileEntry);
505            }
506    
507            public Folder moveFolder(
508                            long folderId, long parentFolderId, ServiceContext serviceContext)
509                    throws PortalException, SystemException {
510    
511                    DLFolder dlFolder = dlFolderService.moveFolder(
512                            toFolderId(folderId), toFolderId(parentFolderId), serviceContext);
513    
514                    return new LiferayFolder(dlFolder);
515            }
516    
517            public Lock refreshFileEntryLock(String lockUuid, long expirationTime)
518                    throws PortalException, SystemException {
519    
520                    return dlFileEntryService.refreshFileEntryLock(
521                            lockUuid, expirationTime);
522            }
523    
524            public Lock refreshFolderLock(String lockUuid, long expirationTime)
525                    throws PortalException, SystemException {
526    
527                    return dlFolderService.refreshFolderLock(lockUuid, expirationTime);
528            }
529    
530            public void revertFileEntry(
531                            long fileEntryId, String version, ServiceContext serviceContext)
532                    throws PortalException, SystemException {
533    
534                    dlFileEntryService.revertFileEntry(
535                            fileEntryId, version, serviceContext);
536            }
537    
538            public Hits search(SearchContext searchContext) throws SearchException {
539                    Indexer indexer = IndexerRegistryUtil.getIndexer(
540                            DLFileEntryConstants.getClassName());
541    
542                    BooleanQuery fullQuery = indexer.getFullQuery(searchContext);
543    
544                    return SearchEngineUtil.search(searchContext, fullQuery);
545            }
546    
547            public Hits search(SearchContext searchContext, Query query)
548                    throws SearchException {
549    
550                    return SearchEngineUtil.search(searchContext, query);
551            }
552    
553            public void unlockFolder(long folderId, String lockUuid)
554                    throws PortalException, SystemException {
555    
556                    dlFolderService.unlockFolder(
557                            getGroupId(), toFolderId(folderId), lockUuid);
558            }
559    
560            public void unlockFolder(long parentFolderId, String title, String lockUuid)
561                    throws PortalException, SystemException {
562    
563                    dlFolderService.unlockFolder(
564                            getGroupId(), toFolderId(parentFolderId), title, lockUuid);
565            }
566    
567            public FileEntry updateFileEntry(
568                            long fileEntryId, String sourceFileName, String mimeType,
569                            String title, String description, String changeLog,
570                            boolean majorVersion, File file, ServiceContext serviceContext)
571                    throws PortalException, SystemException {
572    
573                    long fileEntryTypeId = ParamUtil.getLong(
574                            serviceContext, "fileEntryTypeId", -1L);
575                    Map<String, Fields> fieldsMap = getFieldsMap(
576                            serviceContext, fileEntryTypeId);
577                    long size = 0;
578    
579                    if (file != null) {
580                            size = file.length();
581                    }
582    
583                    DLFileEntry dlFileEntry = dlFileEntryService.updateFileEntry(
584                            fileEntryId, sourceFileName, mimeType, title, description,
585                            changeLog, majorVersion, fileEntryTypeId, fieldsMap, file, null,
586                            size, serviceContext);
587    
588                    return new LiferayFileEntry(dlFileEntry);
589            }
590    
591            public FileEntry updateFileEntry(
592                            long fileEntryId, String sourceFileName, String mimeType,
593                            String title, String description, String changeLog,
594                            boolean majorVersion, InputStream is, long size,
595                            ServiceContext serviceContext)
596                    throws PortalException, SystemException {
597    
598                    long fileEntryTypeId = ParamUtil.getLong(
599                            serviceContext, "fileEntryTypeId", -1L);
600                    Map<String, Fields> fieldsMap = getFieldsMap(
601                            serviceContext, fileEntryTypeId);
602    
603                    DLFileEntry dlFileEntry = dlFileEntryService.updateFileEntry(
604                            fileEntryId, sourceFileName, mimeType, title, description,
605                            changeLog, majorVersion, fileEntryTypeId, fieldsMap, null, is, size,
606                            serviceContext);
607    
608                    return new LiferayFileEntry(dlFileEntry);
609            }
610    
611            public Folder updateFolder(
612                            long folderId, String title, String description,
613                            ServiceContext serviceContext)
614                    throws PortalException, SystemException {
615    
616                    long defaultFileEntryTypeId = ParamUtil.getLong(
617                            serviceContext, "defaultFileEntryTypeId");
618                    SortedArrayList<Long> fileEntryTypeIds = getLongList(
619                            serviceContext, "fileEntryTypeSearchContainerPrimaryKeys");
620                    boolean overrideFileEntryTypes = ParamUtil.getBoolean(
621                            serviceContext, "overrideFileEntryTypes");
622    
623                    DLFolder dlFolder = dlFolderService.updateFolder(
624                            toFolderId(folderId), title, description, defaultFileEntryTypeId,
625                            fileEntryTypeIds, overrideFileEntryTypes, serviceContext);
626    
627                    return new LiferayFolder(dlFolder);
628            }
629    
630            public boolean verifyFileEntryCheckOut(long fileEntryId, String lockUuid)
631                    throws PortalException, SystemException {
632    
633                    return dlFileEntryService.verifyFileEntryCheckOut(
634                            fileEntryId, lockUuid);
635            }
636    
637            public boolean verifyInheritableLock(long folderId, String lockUuid)
638                    throws PortalException, SystemException {
639    
640                    return dlFolderService.verifyInheritableLock(
641                            toFolderId(folderId), lockUuid);
642            }
643    
644            @Override
645            protected void initByFileEntryId(long fileEntryId) {
646                    try {
647                            DLFileEntry dlFileEntry = dlFileEntryService.getFileEntry(
648                                    fileEntryId);
649    
650                            initByRepositoryId(dlFileEntry.getRepositoryId());
651                    }
652                    catch (Exception e) {
653                            if (_log.isTraceEnabled()) {
654                                    if (e instanceof NoSuchFileEntryException) {
655                                            _log.trace(e.getMessage());
656                                    }
657                                    else {
658                                            _log.trace(e, e);
659                                    }
660                            }
661                    }
662            }
663    
664            @Override
665            protected void initByFileVersionId(long fileVersionId) {
666                    try {
667                            DLFileVersion dlFileVersion =
668                                    dlFileVersionService.getFileVersion(fileVersionId);
669    
670                            initByRepositoryId(dlFileVersion.getRepositoryId());
671                    }
672                    catch (Exception e) {
673                            if (_log.isTraceEnabled()) {
674                                    if (e instanceof NoSuchFileVersionException) {
675                                            _log.trace(e.getMessage());
676                                    }
677                                    else {
678                                            _log.trace(e, e);
679                                    }
680                            }
681                    }
682            }
683    
684            @Override
685            protected void initByFolderId(long folderId) {
686                    try {
687                            DLFolder dlFolder = dlFolderService.getFolder(folderId);
688    
689                            initByRepositoryId(dlFolder.getRepositoryId());
690                    }
691                    catch (Exception e) {
692                            if (_log.isTraceEnabled()) {
693                                    if (e instanceof NoSuchFolderException) {
694                                            _log.trace(e.getMessage());
695                                    }
696                                    else {
697                                            _log.trace(e, e);
698                                    }
699                            }
700                    }
701            }
702    
703            @Override
704            protected void initByRepositoryId(long repositoryId) {
705                    setGroupId(repositoryId);
706                    setRepositoryId(repositoryId);
707    
708                    try {
709                            com.liferay.portal.model.Repository repository =
710                                    repositoryService.getRepository(repositoryId);
711    
712                            setDlFolderId(repository.getDlFolderId());
713                            setGroupId(repository.getGroupId());
714                            setRepositoryId(repository.getRepositoryId());
715                    }
716                    catch (Exception e) {
717                    }
718            }
719    
720            private static Log _log = LogFactoryUtil.getLog(LiferayRepository.class);
721    
722    }