001    /**
002     * Copyright (c) 2000-present 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;
016    
017    import com.liferay.portal.kernel.exception.PortalException;
018    import com.liferay.portal.kernel.lock.Lock;
019    import com.liferay.portal.kernel.repository.Repository;
020    import com.liferay.portal.kernel.repository.model.FileEntry;
021    import com.liferay.portal.kernel.repository.model.FileVersion;
022    import com.liferay.portal.kernel.repository.model.Folder;
023    import com.liferay.portal.kernel.repository.model.RepositoryEntry;
024    import com.liferay.portal.kernel.search.Hits;
025    import com.liferay.portal.kernel.search.Query;
026    import com.liferay.portal.kernel.search.SearchContext;
027    import com.liferay.portal.kernel.search.SearchException;
028    import com.liferay.portal.kernel.service.ServiceContext;
029    import com.liferay.portal.kernel.util.OrderByComparator;
030    
031    import java.io.File;
032    import java.io.InputStream;
033    
034    import java.util.List;
035    
036    /**
037     * @author Iv??n Zaera
038     */
039    public class InitializedRepository
040            extends InitializedDocumentRepository<Repository> implements Repository {
041    
042            @Deprecated
043            @Override
044            public FileEntry addFileEntry(
045                            long folderId, String sourceFileName, String mimeType, String title,
046                            String description, String changeLog, File file,
047                            ServiceContext serviceContext)
048                    throws PortalException {
049    
050                    checkDocumentRepository();
051    
052                    return documentRepository.addFileEntry(
053                            folderId, sourceFileName, mimeType, title, description, changeLog,
054                            file, serviceContext);
055            }
056    
057            @Deprecated
058            @Override
059            public FileEntry addFileEntry(
060                            long folderId, String sourceFileName, String mimeType, String title,
061                            String description, String changeLog, InputStream is, long size,
062                            ServiceContext serviceContext)
063                    throws PortalException {
064    
065                    checkDocumentRepository();
066    
067                    return documentRepository.addFileEntry(
068                            folderId, sourceFileName, mimeType, title, description, changeLog,
069                            is, size, serviceContext);
070            }
071    
072            @Deprecated
073            @Override
074            public Folder addFolder(
075                            long parentFolderId, String name, String description,
076                            ServiceContext serviceContext)
077                    throws PortalException {
078    
079                    checkDocumentRepository();
080    
081                    return documentRepository.addFolder(
082                            parentFolderId, name, description, serviceContext);
083            }
084    
085            @Override
086            public FileVersion cancelCheckOut(long fileEntryId) throws PortalException {
087                    checkDocumentRepository();
088    
089                    return documentRepository.cancelCheckOut(fileEntryId);
090            }
091    
092            @Deprecated
093            @Override
094            public void checkInFileEntry(
095                            long fileEntryId, boolean major, String changeLog,
096                            ServiceContext serviceContext)
097                    throws PortalException {
098    
099                    checkDocumentRepository();
100    
101                    documentRepository.checkInFileEntry(
102                            fileEntryId, major, changeLog, serviceContext);
103            }
104    
105            @Deprecated
106            @Override
107            public void checkInFileEntry(
108                            long fileEntryId, String lockUuid, ServiceContext serviceContext)
109                    throws PortalException {
110    
111                    checkDocumentRepository();
112    
113                    documentRepository.checkInFileEntry(
114                            fileEntryId, lockUuid, serviceContext);
115            }
116    
117            @Override
118            public FileEntry checkOutFileEntry(
119                            long fileEntryId, ServiceContext serviceContext)
120                    throws PortalException {
121    
122                    checkDocumentRepository();
123    
124                    return documentRepository.checkOutFileEntry(
125                            fileEntryId, serviceContext);
126            }
127    
128            @Override
129            public FileEntry checkOutFileEntry(
130                            long fileEntryId, String owner, long expirationTime,
131                            ServiceContext serviceContext)
132                    throws PortalException {
133    
134                    checkDocumentRepository();
135    
136                    return documentRepository.checkOutFileEntry(
137                            fileEntryId, owner, expirationTime, serviceContext);
138            }
139    
140            @Deprecated
141            @Override
142            public FileEntry copyFileEntry(
143                            long groupId, long fileEntryId, long destFolderId,
144                            ServiceContext serviceContext)
145                    throws PortalException {
146    
147                    checkDocumentRepository();
148    
149                    return documentRepository.copyFileEntry(
150                            groupId, fileEntryId, destFolderId, serviceContext);
151            }
152    
153            @Override
154            public void deleteFileEntry(long folderId, String title)
155                    throws PortalException {
156    
157                    checkDocumentRepository();
158    
159                    documentRepository.deleteFileEntry(folderId, title);
160            }
161    
162            @Override
163            public void deleteFileVersion(long fileEntryId, String version)
164                    throws PortalException {
165    
166                    checkDocumentRepository();
167    
168                    documentRepository.deleteFileVersion(fileEntryId, version);
169            }
170    
171            @Override
172            public void deleteFolder(long parentFolderId, String name)
173                    throws PortalException {
174    
175                    checkDocumentRepository();
176    
177                    documentRepository.deleteFolder(parentFolderId, name);
178            }
179    
180            @Override
181            public List<FileEntry> getFileEntries(
182                            long folderId, long fileEntryTypeId, int start, int end,
183                            OrderByComparator<FileEntry> obc)
184                    throws PortalException {
185    
186                    checkDocumentRepository();
187    
188                    return documentRepository.getFileEntries(
189                            folderId, fileEntryTypeId, start, end, obc);
190            }
191    
192            @Override
193            public List<FileEntry> getFileEntries(
194                            long folderId, String[] mimeTypes, int start, int end,
195                            OrderByComparator<FileEntry> obc)
196                    throws PortalException {
197    
198                    checkDocumentRepository();
199    
200                    return documentRepository.getFileEntries(
201                            folderId, mimeTypes, start, end, obc);
202            }
203    
204            @Override
205            public List<RepositoryEntry> getFileEntriesAndFileShortcuts(
206                            long folderId, int status, int start, int end)
207                    throws PortalException {
208    
209                    checkDocumentRepository();
210    
211                    return documentRepository.getFileEntriesAndFileShortcuts(
212                            folderId, status, start, end);
213            }
214    
215            @Override
216            public int getFileEntriesAndFileShortcutsCount(long folderId, int status)
217                    throws PortalException {
218    
219                    checkDocumentRepository();
220    
221                    return documentRepository.getFileEntriesAndFileShortcutsCount(
222                            folderId, status);
223            }
224    
225            @Override
226            public int getFileEntriesAndFileShortcutsCount(
227                            long folderId, int status, String[] mimeTypes)
228                    throws PortalException {
229    
230                    checkDocumentRepository();
231    
232                    return documentRepository.getFileEntriesAndFileShortcutsCount(
233                            folderId, status, mimeTypes);
234            }
235    
236            @Override
237            public int getFileEntriesCount(long folderId, long fileEntryTypeId)
238                    throws PortalException {
239    
240                    checkDocumentRepository();
241    
242                    return documentRepository.getFileEntriesCount(
243                            folderId, fileEntryTypeId);
244            }
245    
246            @Override
247            public int getFileEntriesCount(long folderId, String[] mimeTypes)
248                    throws PortalException {
249    
250                    checkDocumentRepository();
251    
252                    return documentRepository.getFileEntriesCount(folderId, mimeTypes);
253            }
254    
255            @Override
256            public List<Folder> getFolders(
257                            long parentFolderId, boolean includeMountFolders, int start,
258                            int end, OrderByComparator<Folder> obc)
259                    throws PortalException {
260    
261                    checkDocumentRepository();
262    
263                    return documentRepository.getFolders(
264                            parentFolderId, includeMountFolders, start, end, obc);
265            }
266    
267            @Override
268            public List<Folder> getFolders(
269                            long parentFolderId, int status, boolean includeMountFolders,
270                            int start, int end, OrderByComparator<Folder> obc)
271                    throws PortalException {
272    
273                    checkDocumentRepository();
274    
275                    return documentRepository.getFolders(
276                            parentFolderId, status, includeMountFolders, start, end, obc);
277            }
278    
279            @Override
280            public List<RepositoryEntry> getFoldersAndFileEntriesAndFileShortcuts(
281                            long folderId, int status, boolean includeMountFolders, int start,
282                            int end, OrderByComparator<?> obc)
283                    throws PortalException {
284    
285                    checkDocumentRepository();
286    
287                    return documentRepository.getFoldersAndFileEntriesAndFileShortcuts(
288                            folderId, status, includeMountFolders, start, end, obc);
289            }
290    
291            @Override
292            public List<RepositoryEntry> getFoldersAndFileEntriesAndFileShortcuts(
293                            long folderId, int status, String[] mimetypes,
294                            boolean includeMountFolders, int start, int end,
295                            OrderByComparator<?> obc)
296                    throws PortalException {
297    
298                    checkDocumentRepository();
299    
300                    return documentRepository.getFoldersAndFileEntriesAndFileShortcuts(
301                            folderId, status, mimetypes, includeMountFolders, start, end, obc);
302            }
303    
304            @Override
305            public int getFoldersAndFileEntriesAndFileShortcutsCount(
306                            long folderId, int status, boolean includeMountFolders)
307                    throws PortalException {
308    
309                    checkDocumentRepository();
310    
311                    return documentRepository.getFoldersAndFileEntriesAndFileShortcutsCount(
312                            folderId, status, includeMountFolders);
313            }
314    
315            @Override
316            public int getFoldersAndFileEntriesAndFileShortcutsCount(
317                            long folderId, int status, String[] mimetypes,
318                            boolean includeMountFolders)
319                    throws PortalException {
320    
321                    checkDocumentRepository();
322    
323                    return documentRepository.getFoldersAndFileEntriesAndFileShortcutsCount(
324                            folderId, status, mimetypes, includeMountFolders);
325            }
326    
327            @Override
328            public int getFoldersCount(long parentFolderId, boolean includeMountfolders)
329                    throws PortalException {
330    
331                    checkDocumentRepository();
332    
333                    return documentRepository.getFoldersCount(
334                            parentFolderId, includeMountfolders);
335            }
336    
337            @Override
338            public int getFoldersCount(
339                            long parentFolderId, int status, boolean includeMountfolders)
340                    throws PortalException {
341    
342                    checkDocumentRepository();
343    
344                    return documentRepository.getFoldersCount(
345                            parentFolderId, status, includeMountfolders);
346            }
347    
348            @Override
349            public int getFoldersFileEntriesCount(List<Long> folderIds, int status)
350                    throws PortalException {
351    
352                    checkDocumentRepository();
353    
354                    return documentRepository.getFoldersFileEntriesCount(folderIds, status);
355            }
356    
357            @Override
358            public List<Folder> getMountFolders(
359                            long parentFolderId, int start, int end,
360                            OrderByComparator<Folder> obc)
361                    throws PortalException {
362    
363                    checkDocumentRepository();
364    
365                    return documentRepository.getMountFolders(
366                            parentFolderId, start, end, obc);
367            }
368    
369            @Override
370            public int getMountFoldersCount(long parentFolderId)
371                    throws PortalException {
372    
373                    checkDocumentRepository();
374    
375                    return documentRepository.getMountFoldersCount(parentFolderId);
376            }
377    
378            @Override
379            public List<FileEntry> getRepositoryFileEntries(
380                            long userId, long rootFolderId, String[] mimeTypes, int status,
381                            int start, int end, OrderByComparator<FileEntry> obc)
382                    throws PortalException {
383    
384                    checkDocumentRepository();
385    
386                    return documentRepository.getRepositoryFileEntries(
387                            userId, rootFolderId, mimeTypes, status, start, end, obc);
388            }
389    
390            @Override
391            public int getRepositoryFileEntriesCount(long userId, long rootFolderId)
392                    throws PortalException {
393    
394                    checkDocumentRepository();
395    
396                    return documentRepository.getRepositoryFileEntriesCount(
397                            userId, rootFolderId);
398            }
399    
400            @Override
401            public int getRepositoryFileEntriesCount(
402                            long userId, long rootFolderId, String[] mimeTypes, int status)
403                    throws PortalException {
404    
405                    checkDocumentRepository();
406    
407                    return documentRepository.getRepositoryFileEntriesCount(
408                            userId, rootFolderId, mimeTypes, status);
409            }
410    
411            @Override
412            public void getSubfolderIds(List<Long> folderIds, long folderId)
413                    throws PortalException {
414    
415                    checkDocumentRepository();
416    
417                    documentRepository.getSubfolderIds(folderIds, folderId);
418            }
419    
420            @Override
421            public List<Long> getSubfolderIds(long folderId, boolean recurse)
422                    throws PortalException {
423    
424                    checkDocumentRepository();
425    
426                    return documentRepository.getSubfolderIds(folderId, recurse);
427            }
428    
429            @Override
430            public Lock lockFolder(long folderId) throws PortalException {
431                    checkDocumentRepository();
432    
433                    return documentRepository.lockFolder(folderId);
434            }
435    
436            @Override
437            public Lock lockFolder(
438                            long folderId, String owner, boolean inheritable,
439                            long expirationTime)
440                    throws PortalException {
441    
442                    checkDocumentRepository();
443    
444                    return documentRepository.lockFolder(
445                            folderId, owner, inheritable, expirationTime);
446            }
447    
448            @Deprecated
449            @Override
450            public FileEntry moveFileEntry(
451                            long fileEntryId, long newFolderId, ServiceContext serviceContext)
452                    throws PortalException {
453    
454                    checkDocumentRepository();
455    
456                    return documentRepository.moveFileEntry(
457                            fileEntryId, newFolderId, serviceContext);
458            }
459    
460            @Deprecated
461            @Override
462            public Folder moveFolder(
463                            long folderId, long newParentFolderId,
464                            ServiceContext serviceContext)
465                    throws PortalException {
466    
467                    checkDocumentRepository();
468    
469                    return documentRepository.moveFolder(
470                            folderId, newParentFolderId, serviceContext);
471            }
472    
473            @Override
474            public Lock refreshFileEntryLock(
475                            String lockUuid, long companyId, long expirationTime)
476                    throws PortalException {
477    
478                    checkDocumentRepository();
479    
480                    return documentRepository.refreshFileEntryLock(
481                            lockUuid, companyId, expirationTime);
482            }
483    
484            @Override
485            public Lock refreshFolderLock(
486                            String lockUuid, long companyId, long expirationTime)
487                    throws PortalException {
488    
489                    checkDocumentRepository();
490    
491                    return documentRepository.refreshFolderLock(
492                            lockUuid, companyId, expirationTime);
493            }
494    
495            @Deprecated
496            @Override
497            public void revertFileEntry(
498                            long fileEntryId, String version, ServiceContext serviceContext)
499                    throws PortalException {
500    
501                    checkDocumentRepository();
502    
503                    documentRepository.revertFileEntry(
504                            fileEntryId, version, serviceContext);
505            }
506    
507            @Override
508            public Hits search(long creatorUserId, int status, int start, int end)
509                    throws PortalException {
510    
511                    checkDocumentRepository();
512    
513                    return documentRepository.search(creatorUserId, status, start, end);
514            }
515    
516            @Override
517            public Hits search(
518                            long creatorUserId, long folderId, String[] mimeTypes, int status,
519                            int start, int end)
520                    throws PortalException {
521    
522                    checkDocumentRepository();
523    
524                    return documentRepository.search(
525                            creatorUserId, folderId, mimeTypes, status, start, end);
526            }
527    
528            @Override
529            public Hits search(SearchContext searchContext) throws SearchException {
530                    checkDocumentRepository();
531    
532                    return documentRepository.search(searchContext);
533            }
534    
535            @Override
536            public Hits search(SearchContext searchContext, Query query)
537                    throws SearchException {
538    
539                    checkDocumentRepository();
540    
541                    return documentRepository.search(searchContext, query);
542            }
543    
544            @Override
545            public void unlockFolder(long folderId, String lockUuid)
546                    throws PortalException {
547    
548                    checkDocumentRepository();
549    
550                    documentRepository.unlockFolder(folderId, lockUuid);
551            }
552    
553            @Override
554            public void unlockFolder(long parentFolderId, String name, String lockUuid)
555                    throws PortalException {
556    
557                    checkDocumentRepository();
558    
559                    documentRepository.unlockFolder(parentFolderId, name, lockUuid);
560            }
561    
562            @Deprecated
563            @Override
564            public FileEntry updateFileEntry(
565                            long fileEntryId, String sourceFileName, String mimeType,
566                            String title, String description, String changeLog,
567                            boolean majorVersion, File file, ServiceContext serviceContext)
568                    throws PortalException {
569    
570                    checkDocumentRepository();
571    
572                    return documentRepository.updateFileEntry(
573                            fileEntryId, sourceFileName, mimeType, title, description,
574                            changeLog, majorVersion, file, serviceContext);
575            }
576    
577            @Deprecated
578            @Override
579            public FileEntry updateFileEntry(
580                            long fileEntryId, String sourceFileName, String mimeType,
581                            String title, String description, String changeLog,
582                            boolean majorVersion, InputStream is, long size,
583                            ServiceContext serviceContext)
584                    throws PortalException {
585    
586                    checkDocumentRepository();
587    
588                    return documentRepository.updateFileEntry(
589                            fileEntryId, sourceFileName, mimeType, title, description,
590                            changeLog, majorVersion, is, size, serviceContext);
591            }
592    
593            @Override
594            public Folder updateFolder(
595                            long folderId, String name, String description,
596                            ServiceContext serviceContext)
597                    throws PortalException {
598    
599                    checkDocumentRepository();
600    
601                    return documentRepository.updateFolder(
602                            folderId, name, description, serviceContext);
603            }
604    
605            @Override
606            public boolean verifyFileEntryCheckOut(long fileEntryId, String lockUuid)
607                    throws PortalException {
608    
609                    checkDocumentRepository();
610    
611                    return documentRepository.verifyFileEntryCheckOut(
612                            fileEntryId, lockUuid);
613            }
614    
615            @Override
616            public boolean verifyFileEntryLock(long fileEntryId, String lockUuid)
617                    throws PortalException {
618    
619                    checkDocumentRepository();
620    
621                    return documentRepository.verifyFileEntryLock(fileEntryId, lockUuid);
622            }
623    
624            @Override
625            public boolean verifyInheritableLock(long folderId, String lockUuid)
626                    throws PortalException {
627    
628                    checkDocumentRepository();
629    
630                    return documentRepository.verifyInheritableLock(folderId, lockUuid);
631            }
632    
633    }