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