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