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.proxy;
016    
017    import com.liferay.portal.kernel.exception.PortalException;
018    import com.liferay.portal.kernel.repository.LocalRepository;
019    import com.liferay.portal.kernel.repository.capabilities.Capability;
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 {
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 {
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 name, String description,
076                            ServiceContext serviceContext)
077                    throws PortalException {
078    
079                    Folder folder = _localRepository.addFolder(
080                            userId, parentFolderId, name, description, serviceContext);
081    
082                    return newFolderProxyBean(folder);
083            }
084    
085            @Override
086            public void deleteAll() throws PortalException {
087                    _localRepository.deleteAll();
088            }
089    
090            @Override
091            public void deleteFileEntry(long fileEntryId) throws PortalException {
092                    _localRepository.deleteFileEntry(fileEntryId);
093            }
094    
095            @Override
096            public void deleteFolder(long folderId) throws PortalException {
097                    _localRepository.deleteFolder(folderId);
098            }
099    
100            @Override
101            public <T extends Capability> T getCapability(Class<T> capabilityClass) {
102                    return _localRepository.getCapability(capabilityClass);
103            }
104    
105            @Override
106            public FileEntry getFileEntry(long fileEntryId) throws PortalException {
107                    FileEntry fileEntry = _localRepository.getFileEntry(fileEntryId);
108    
109                    return newFileEntryProxyBean(fileEntry);
110            }
111    
112            @Override
113            public FileEntry getFileEntry(long folderId, String title)
114                    throws PortalException {
115    
116                    FileEntry fileEntry = _localRepository.getFileEntry(folderId, title);
117    
118                    return newFileEntryProxyBean(fileEntry);
119            }
120    
121            @Override
122            public FileEntry getFileEntryByUuid(String uuid) throws PortalException {
123                    FileEntry fileEntry = _localRepository.getFileEntryByUuid(uuid);
124    
125                    return newFileEntryProxyBean(fileEntry);
126            }
127    
128            @Override
129            public FileVersion getFileVersion(long fileVersionId)
130                    throws PortalException {
131    
132                    FileVersion fileVersion = _localRepository.getFileVersion(
133                            fileVersionId);
134    
135                    return newFileVersionProxyBean(fileVersion);
136            }
137    
138            @Override
139            public Folder getFolder(long folderId) throws PortalException {
140                    Folder folder = _localRepository.getFolder(folderId);
141    
142                    return newFolderProxyBean(folder);
143            }
144    
145            @Override
146            public Folder getFolder(long parentFolderId, String name)
147                    throws PortalException {
148    
149                    return _localRepository.getFolder(parentFolderId, name);
150            }
151    
152            @Override
153            public List<FileEntry> getRepositoryFileEntries(
154                            long rootFolderId, int start, int end,
155                            OrderByComparator<FileEntry> obc)
156                    throws PortalException {
157    
158                    return _localRepository.getRepositoryFileEntries(
159                            rootFolderId, start, end, obc);
160            }
161    
162            @Override
163            public long getRepositoryId() {
164                    return _localRepository.getRepositoryId();
165            }
166    
167            @Override
168            public <T extends Capability> boolean isCapabilityProvided(
169                    Class<T> capabilityClass) {
170    
171                    return _localRepository.isCapabilityProvided(capabilityClass);
172            }
173    
174            @Override
175            public FileEntry moveFileEntry(
176                            long userId, long fileEntryId, long newFolderId,
177                            ServiceContext serviceContext)
178                    throws PortalException {
179    
180                    FileEntry fileEntry = _localRepository.moveFileEntry(
181                            userId, fileEntryId, newFolderId, serviceContext);
182    
183                    return newFileEntryProxyBean(fileEntry);
184            }
185    
186            @Override
187            public Folder moveFolder(
188                            long userId, long folderId, long parentFolderId,
189                            ServiceContext serviceContext)
190                    throws PortalException {
191    
192                    Folder folder = _localRepository.moveFolder(
193                            userId, folderId, parentFolderId, serviceContext);
194    
195                    return newFolderProxyBean(folder);
196            }
197    
198            @Override
199            public void updateAsset(
200                            long userId, FileEntry fileEntry, FileVersion fileVersion,
201                            long[] assetCategoryIds, String[] assetTagNames,
202                            long[] assetLinkEntryIds)
203                    throws PortalException {
204    
205                    _localRepository.updateAsset(
206                            userId, fileEntry, fileVersion, assetCategoryIds, assetTagNames,
207                            assetLinkEntryIds);
208            }
209    
210            @Override
211            public FileEntry updateFileEntry(
212                            long userId, long fileEntryId, String sourceFileName,
213                            String mimeType, String title, String description, String changeLog,
214                            boolean majorVersion, File file, ServiceContext serviceContext)
215                    throws PortalException {
216    
217                    FileEntry fileEntry = _localRepository.updateFileEntry(
218                            userId, fileEntryId, sourceFileName, mimeType, title, description,
219                            changeLog, majorVersion, file, serviceContext);
220    
221                    return newFileEntryProxyBean(fileEntry);
222            }
223    
224            @Override
225            public FileEntry updateFileEntry(
226                            long userId, long fileEntryId, String sourceFileName,
227                            String mimeType, String title, String description, String changeLog,
228                            boolean majorVersion, InputStream is, long size,
229                            ServiceContext serviceContext)
230                    throws PortalException {
231    
232                    FileEntry fileEntry = _localRepository.updateFileEntry(
233                            userId, fileEntryId, sourceFileName, mimeType, title, description,
234                            changeLog, majorVersion, is, size, serviceContext);
235    
236                    return newFileEntryProxyBean(fileEntry);
237            }
238    
239            @Override
240            public Folder updateFolder(
241                            long folderId, long parentFolderId, String name, String description,
242                            ServiceContext serviceContext)
243                    throws PortalException {
244    
245                    return _localRepository.updateFolder(
246                            folderId, parentFolderId, name, description, serviceContext);
247            }
248    
249            private final LocalRepository _localRepository;
250    
251    }