001    /**
002     * Copyright (c) 2000-2013 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.proxy;
016    
017    import com.liferay.portal.kernel.exception.PortalException;
018    import com.liferay.portal.kernel.exception.SystemException;
019    import com.liferay.portal.kernel.repository.LocalRepository;
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.util.OrderByComparator;
024    import com.liferay.portal.service.ServiceContext;
025    
026    import java.io.File;
027    import java.io.InputStream;
028    
029    import java.util.List;
030    
031    /**
032     * @author Mika Koivisto
033     */
034    public class LocalRepositoryProxyBean
035            extends RepositoryModelProxyBean implements LocalRepository {
036    
037            public LocalRepositoryProxyBean(
038                    LocalRepository localRepository, ClassLoader classLoader) {
039    
040                    super(classLoader);
041    
042                    _localRepository = localRepository;
043            }
044    
045            @Override
046            public FileEntry addFileEntry(
047                            long userId, long folderId, String sourceFileName, String mimeType,
048                            String title, String description, String changeLog, File file,
049                            ServiceContext serviceContext)
050                    throws PortalException, SystemException {
051    
052                    FileEntry fileEntry = _localRepository.addFileEntry(
053                            userId, folderId, sourceFileName, mimeType, title, description,
054                            changeLog, file, serviceContext);
055    
056                    return newFileEntryProxyBean(fileEntry);
057            }
058    
059            @Override
060            public FileEntry addFileEntry(
061                            long userId, long folderId, String sourceFileName, String mimeType,
062                            String title, String description, String changeLog, InputStream is,
063                            long size, ServiceContext serviceContext)
064                    throws PortalException, SystemException {
065    
066                    FileEntry fileEntry = _localRepository.addFileEntry(
067                            userId, folderId, sourceFileName, mimeType, title, description,
068                            changeLog, is, size, serviceContext);
069    
070                    return newFileEntryProxyBean(fileEntry);
071            }
072    
073            @Override
074            public Folder addFolder(
075                            long userId, long parentFolderId, String title, String description,
076                            ServiceContext serviceContext)
077                    throws PortalException, SystemException {
078    
079                    Folder folder = _localRepository.addFolder(
080                            userId, parentFolderId, title, description, serviceContext);
081    
082                    return newFolderProxyBean(folder);
083            }
084    
085            @Override
086            public void deleteAll() throws PortalException, SystemException {
087                    _localRepository.deleteAll();
088            }
089    
090            @Override
091            public void deleteFileEntry(long fileEntryId)
092                    throws PortalException, SystemException {
093    
094                    _localRepository.deleteFileEntry(fileEntryId);
095            }
096    
097            @Override
098            public void deleteFolder(long folderId)
099                    throws PortalException, SystemException {
100    
101                    _localRepository.deleteFolder(folderId);
102            }
103    
104            @Override
105            public List<FileEntry> getFileEntries(
106                            long folderId, int start, int end, OrderByComparator obc)
107                    throws SystemException {
108    
109                    List<FileEntry> fileEntries = _localRepository.getFileEntries(
110                            folderId, start, end, obc);
111    
112                    return toFileEntryProxyBeans(fileEntries);
113            }
114    
115            @Override
116            public List<Object> getFileEntriesAndFileShortcuts(
117                            long folderId, int status, int start, int end)
118                    throws SystemException {
119    
120                    List<Object> objects = _localRepository.getFileEntriesAndFileShortcuts(
121                            folderId, status, start, end);
122    
123                    return toObjectProxyBeans(objects);
124            }
125    
126            @Override
127            public int getFileEntriesAndFileShortcutsCount(long folderId, int status)
128                    throws SystemException {
129    
130                    return _localRepository.getFileEntriesAndFileShortcutsCount(
131                            folderId, status);
132            }
133    
134            @Override
135            public int getFileEntriesCount(long folderId) throws SystemException {
136                    return _localRepository.getFileEntriesCount(folderId);
137            }
138    
139            @Override
140            public FileEntry getFileEntry(long fileEntryId)
141                    throws PortalException, SystemException {
142    
143                    FileEntry fileEntry = _localRepository.getFileEntry(fileEntryId);
144    
145                    return newFileEntryProxyBean(fileEntry);
146            }
147    
148            @Override
149            public FileEntry getFileEntry(long folderId, String title)
150                    throws PortalException, SystemException {
151    
152                    FileEntry fileEntry = _localRepository.getFileEntry(folderId, title);
153    
154                    return newFileEntryProxyBean(fileEntry);
155            }
156    
157            @Override
158            public FileEntry getFileEntryByUuid(String uuid)
159                    throws PortalException, SystemException {
160    
161                    FileEntry fileEntry = _localRepository.getFileEntryByUuid(uuid);
162    
163                    return newFileEntryProxyBean(fileEntry);
164            }
165    
166            @Override
167            public FileVersion getFileVersion(long fileVersionId)
168                    throws PortalException, SystemException {
169    
170                    FileVersion fileVersion = _localRepository.getFileVersion(
171                            fileVersionId);
172    
173                    return newFileVersionProxyBean(fileVersion);
174            }
175    
176            @Override
177            public Folder getFolder(long folderId)
178                    throws PortalException, SystemException {
179    
180                    Folder folder = _localRepository.getFolder(folderId);
181    
182                    return newFolderProxyBean(folder);
183            }
184    
185            @Override
186            public Folder getFolder(long parentFolderId, String title)
187                    throws PortalException, SystemException {
188    
189                    return _localRepository.getFolder(parentFolderId, title);
190            }
191    
192            @Override
193            public List<Folder> getFolders(
194                            long parentFolderId, boolean includeMountfolders, int start,
195                            int end, OrderByComparator obc)
196                    throws PortalException, SystemException {
197    
198                    List<Folder> folderList = _localRepository.getFolders(
199                            parentFolderId, includeMountfolders, start, end, obc);
200    
201                    return toFolderProxyBeans(folderList);
202            }
203    
204            @Override
205            public List<Object> getFoldersAndFileEntriesAndFileShortcuts(
206                            long folderId, int status, boolean includeMountFolders, int start,
207                            int end, OrderByComparator obc)
208                    throws SystemException {
209    
210                    List<Object> objects =
211                            _localRepository.getFoldersAndFileEntriesAndFileShortcuts(
212                                    folderId, status, includeMountFolders, start, end, obc);
213    
214                    return toObjectProxyBeans(objects);
215            }
216    
217            @Override
218            public List<Object> getFoldersAndFileEntriesAndFileShortcuts(
219                            long folderId, int status, String[] mimeTypes,
220                            boolean includeMountFolders, int start, int end,
221                            OrderByComparator obc)
222                    throws PortalException, SystemException {
223    
224                    List<Object> objects =
225                            _localRepository.getFoldersAndFileEntriesAndFileShortcuts(
226                                    folderId, status, mimeTypes, includeMountFolders, start, end,
227                                    obc);
228    
229                    return toObjectProxyBeans(objects);
230            }
231    
232            @Override
233            public int getFoldersAndFileEntriesAndFileShortcutsCount(
234                            long folderId, int status, boolean includeMountFolders)
235                    throws SystemException {
236    
237                    return _localRepository.getFoldersAndFileEntriesAndFileShortcutsCount(
238                            folderId, status, includeMountFolders);
239            }
240    
241            @Override
242            public int getFoldersAndFileEntriesAndFileShortcutsCount(
243                            long folderId, int status, String[] mimeTypes,
244                            boolean includeMountFolders)
245                    throws PortalException, SystemException {
246    
247                    return _localRepository.getFoldersAndFileEntriesAndFileShortcutsCount(
248                            folderId, status, mimeTypes, includeMountFolders);
249            }
250    
251            @Override
252            public int getFoldersCount(long parentFolderId, boolean includeMountFolders)
253                    throws PortalException, SystemException {
254    
255                    return _localRepository.getFoldersCount(
256                            parentFolderId, includeMountFolders);
257            }
258    
259            @Override
260            public int getFoldersFileEntriesCount(List<Long> folderIds, int status)
261                    throws SystemException {
262    
263                    return _localRepository.getFoldersFileEntriesCount(folderIds, status);
264            }
265    
266            @Override
267            public List<Folder> getMountFolders(
268                            long parentFolderId, int start, int end, OrderByComparator obc)
269                    throws SystemException {
270    
271                    List<Folder> folderList = _localRepository.getMountFolders(
272                            parentFolderId, start, end, obc);
273    
274                    return toFolderProxyBeans(folderList);
275            }
276    
277            @Override
278            public int getMountFoldersCount(long parentFolderId)
279                    throws SystemException {
280    
281                    return _localRepository.getMountFoldersCount(parentFolderId);
282            }
283    
284            @Override
285            public long getRepositoryId() {
286                    return _localRepository.getRepositoryId();
287            }
288    
289            @Override
290            public FileEntry moveFileEntry(
291                            long userId, long fileEntryId, long newFolderId,
292                            ServiceContext serviceContext)
293                    throws PortalException, SystemException {
294    
295                    FileEntry fileEntry = _localRepository.moveFileEntry(
296                            userId, fileEntryId, newFolderId, serviceContext);
297    
298                    return newFileEntryProxyBean(fileEntry);
299            }
300    
301            @Override
302            public void updateAsset(
303                            long userId, FileEntry fileEntry, FileVersion fileVersion,
304                            long[] assetCategoryIds, String[] assetTagNames,
305                            long[] assetLinkEntryIds)
306                    throws PortalException, SystemException {
307    
308                    _localRepository.updateAsset(
309                            userId, fileEntry, fileVersion, assetCategoryIds, assetTagNames,
310                            assetLinkEntryIds);
311            }
312    
313            @Override
314            public FileEntry updateFileEntry(
315                            long userId, long fileEntryId, String sourceFileName,
316                            String mimeType, String title, String description, String changeLog,
317                            boolean majorVersion, File file, ServiceContext serviceContext)
318                    throws PortalException, SystemException {
319    
320                    FileEntry fileEntry = _localRepository.updateFileEntry(
321                            userId, fileEntryId, sourceFileName, mimeType, title, description,
322                            changeLog, majorVersion, file, serviceContext);
323    
324                    return newFileEntryProxyBean(fileEntry);
325            }
326    
327            @Override
328            public FileEntry updateFileEntry(
329                            long userId, long fileEntryId, String sourceFileName,
330                            String mimeType, String title, String description, String changeLog,
331                            boolean majorVersion, InputStream is, long size,
332                            ServiceContext serviceContext)
333                    throws PortalException, SystemException {
334    
335                    FileEntry fileEntry = _localRepository.updateFileEntry(
336                            userId, fileEntryId, sourceFileName, mimeType, title, description,
337                            changeLog, majorVersion, is, size, serviceContext);
338    
339                    return newFileEntryProxyBean(fileEntry);
340            }
341    
342            @Override
343            public Folder updateFolder(
344                            long folderId, long parentFolderId, String title,
345                            String description, ServiceContext serviceContext)
346                    throws PortalException, SystemException {
347    
348                    return _localRepository.updateFolder(
349                            folderId, parentFolderId, title, description, serviceContext);
350            }
351    
352            private LocalRepository _localRepository;
353    
354    }