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.service.ServiceContext;
024    
025    import java.io.File;
026    import java.io.InputStream;
027    
028    /**
029     * @author Mika Koivisto
030     */
031    public class LocalRepositoryProxyBean
032            extends RepositoryModelProxyBean implements LocalRepository {
033    
034            public LocalRepositoryProxyBean(
035                    LocalRepository localRepository, ClassLoader classLoader) {
036    
037                    super(classLoader);
038    
039                    _localRepository = localRepository;
040            }
041    
042            @Override
043            public FileEntry addFileEntry(
044                            long userId, long folderId, String sourceFileName, String mimeType,
045                            String title, String description, String changeLog, File file,
046                            ServiceContext serviceContext)
047                    throws PortalException, SystemException {
048    
049                    FileEntry fileEntry = _localRepository.addFileEntry(
050                            userId, folderId, sourceFileName, mimeType, title, description,
051                            changeLog, file, serviceContext);
052    
053                    return newFileEntryProxyBean(fileEntry);
054            }
055    
056            @Override
057            public FileEntry addFileEntry(
058                            long userId, long folderId, String sourceFileName, String mimeType,
059                            String title, String description, String changeLog, InputStream is,
060                            long size, ServiceContext serviceContext)
061                    throws PortalException, SystemException {
062    
063                    FileEntry fileEntry = _localRepository.addFileEntry(
064                            userId, folderId, sourceFileName, mimeType, title, description,
065                            changeLog, is, size, serviceContext);
066    
067                    return newFileEntryProxyBean(fileEntry);
068            }
069    
070            @Override
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            @Override
083            public void deleteAll() throws PortalException, SystemException {
084                    _localRepository.deleteAll();
085            }
086    
087            @Override
088            public void deleteFileEntry(long fileEntryId)
089                    throws PortalException, SystemException {
090    
091                    _localRepository.deleteFileEntry(fileEntryId);
092            }
093    
094            @Override
095            public void deleteFolder(long folderId)
096                    throws PortalException, SystemException {
097    
098                    _localRepository.deleteFolder(folderId);
099            }
100    
101            @Override
102            public FileEntry getFileEntry(long fileEntryId)
103                    throws PortalException, SystemException {
104    
105                    FileEntry fileEntry = _localRepository.getFileEntry(fileEntryId);
106    
107                    return newFileEntryProxyBean(fileEntry);
108            }
109    
110            @Override
111            public FileEntry getFileEntry(long folderId, String title)
112                    throws PortalException, SystemException {
113    
114                    FileEntry fileEntry = _localRepository.getFileEntry(folderId, title);
115    
116                    return newFileEntryProxyBean(fileEntry);
117            }
118    
119            @Override
120            public FileEntry getFileEntryByUuid(String uuid)
121                    throws PortalException, SystemException {
122    
123                    FileEntry fileEntry = _localRepository.getFileEntryByUuid(uuid);
124    
125                    return newFileEntryProxyBean(fileEntry);
126            }
127    
128            @Override
129            public FileVersion getFileVersion(long fileVersionId)
130                    throws PortalException, SystemException {
131    
132                    FileVersion fileVersion = _localRepository.getFileVersion(
133                            fileVersionId);
134    
135                    return newFileVersionProxyBean(fileVersion);
136            }
137    
138            @Override
139            public Folder getFolder(long folderId)
140                    throws PortalException, SystemException {
141    
142                    Folder folder = _localRepository.getFolder(folderId);
143    
144                    return newFolderProxyBean(folder);
145            }
146    
147            @Override
148            public Folder getFolder(long parentFolderId, String title)
149                    throws PortalException, SystemException {
150    
151                    return _localRepository.getFolder(parentFolderId, title);
152            }
153    
154            @Override
155            public long getRepositoryId() {
156                    return _localRepository.getRepositoryId();
157            }
158    
159            @Override
160            public FileEntry moveFileEntry(
161                            long userId, long fileEntryId, long newFolderId,
162                            ServiceContext serviceContext)
163                    throws PortalException, SystemException {
164    
165                    FileEntry fileEntry = _localRepository.moveFileEntry(
166                            userId, fileEntryId, newFolderId, serviceContext);
167    
168                    return newFileEntryProxyBean(fileEntry);
169            }
170    
171            @Override
172            public Folder moveFolder(
173                            long userId, long folderId, long parentFolderId,
174                            ServiceContext serviceContext)
175                    throws PortalException, SystemException {
176    
177                    Folder folder = _localRepository.moveFolder(
178                            userId, folderId, parentFolderId, serviceContext);
179    
180                    return newFolderProxyBean(folder);
181            }
182    
183            @Override
184            public void updateAsset(
185                            long userId, FileEntry fileEntry, FileVersion fileVersion,
186                            long[] assetCategoryIds, String[] assetTagNames,
187                            long[] assetLinkEntryIds)
188                    throws PortalException, SystemException {
189    
190                    _localRepository.updateAsset(
191                            userId, fileEntry, fileVersion, assetCategoryIds, assetTagNames,
192                            assetLinkEntryIds);
193            }
194    
195            @Override
196            public FileEntry updateFileEntry(
197                            long userId, long fileEntryId, String sourceFileName,
198                            String mimeType, String title, String description, String changeLog,
199                            boolean majorVersion, File file, ServiceContext serviceContext)
200                    throws PortalException, SystemException {
201    
202                    FileEntry fileEntry = _localRepository.updateFileEntry(
203                            userId, fileEntryId, sourceFileName, mimeType, title, description,
204                            changeLog, majorVersion, file, serviceContext);
205    
206                    return newFileEntryProxyBean(fileEntry);
207            }
208    
209            @Override
210            public FileEntry updateFileEntry(
211                            long userId, long fileEntryId, String sourceFileName,
212                            String mimeType, String title, String description, String changeLog,
213                            boolean majorVersion, InputStream is, long size,
214                            ServiceContext serviceContext)
215                    throws PortalException, SystemException {
216    
217                    FileEntry fileEntry = _localRepository.updateFileEntry(
218                            userId, fileEntryId, sourceFileName, mimeType, title, description,
219                            changeLog, majorVersion, is, size, serviceContext);
220    
221                    return newFileEntryProxyBean(fileEntry);
222            }
223    
224            @Override
225            public Folder updateFolder(
226                            long folderId, long parentFolderId, String title,
227                            String description, ServiceContext serviceContext)
228                    throws PortalException, SystemException {
229    
230                    return _localRepository.updateFolder(
231                            folderId, parentFolderId, title, description, serviceContext);
232            }
233    
234            private LocalRepository _localRepository;
235    
236    }