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            public FileEntry addFileEntry(
043                            long userId, long folderId, String sourceFileName, String mimeType,
044                            String title, String description, String changeLog, File file,
045                            ServiceContext serviceContext)
046                    throws PortalException, SystemException {
047    
048                    FileEntry fileEntry = _localRepository.addFileEntry(
049                            userId, folderId, sourceFileName, mimeType, title, description,
050                            changeLog, file, serviceContext);
051    
052                    return newFileEntryProxyBean(fileEntry);
053            }
054    
055            public FileEntry addFileEntry(
056                            long userId, long folderId, String sourceFileName, String mimeType,
057                            String title, String description, String changeLog, InputStream is,
058                            long size, ServiceContext serviceContext)
059                    throws PortalException, SystemException {
060    
061                    FileEntry fileEntry = _localRepository.addFileEntry(
062                            userId, folderId, sourceFileName, mimeType, title, description,
063                            changeLog, is, size, serviceContext);
064    
065                    return newFileEntryProxyBean(fileEntry);
066            }
067    
068            public Folder addFolder(
069                            long userId, long parentFolderId, String title, String description,
070                            ServiceContext serviceContext)
071                    throws PortalException, SystemException {
072    
073                    Folder folder = _localRepository.addFolder(
074                            userId, parentFolderId, title, description, serviceContext);
075    
076                    return newFolderProxyBean(folder);
077            }
078    
079            public void deleteAll() throws PortalException, SystemException {
080                    _localRepository.deleteAll();
081            }
082    
083            public void deleteFileEntry(long fileEntryId)
084                    throws PortalException, SystemException {
085    
086                    _localRepository.deleteFileEntry(fileEntryId);
087            }
088    
089            public void deleteFolder(long folderId)
090                    throws PortalException, SystemException {
091    
092                    _localRepository.deleteFolder(folderId);
093            }
094    
095            public FileEntry getFileEntry(long fileEntryId)
096                    throws PortalException, SystemException {
097    
098                    FileEntry fileEntry = _localRepository.getFileEntry(fileEntryId);
099    
100                    return newFileEntryProxyBean(fileEntry);
101            }
102    
103            public FileEntry getFileEntry(long folderId, String title)
104                    throws PortalException, SystemException {
105    
106                    FileEntry fileEntry = _localRepository.getFileEntry(folderId, title);
107    
108                    return newFileEntryProxyBean(fileEntry);
109            }
110    
111            public FileEntry getFileEntryByUuid(String uuid)
112                    throws PortalException, SystemException {
113    
114                    FileEntry fileEntry = _localRepository.getFileEntryByUuid(uuid);
115    
116                    return newFileEntryProxyBean(fileEntry);
117            }
118    
119            public FileVersion getFileVersion(long fileVersionId)
120                    throws PortalException, SystemException {
121    
122                    FileVersion fileVersion = _localRepository.getFileVersion(
123                            fileVersionId);
124    
125                    return newFileVersionProxyBean(fileVersion);
126            }
127    
128            public Folder getFolder(long folderId)
129                    throws PortalException, SystemException {
130    
131                    Folder folder = _localRepository.getFolder(folderId);
132    
133                    return newFolderProxyBean(folder);
134            }
135    
136            public Folder getFolder(long parentFolderId, String title)
137                    throws PortalException, SystemException {
138    
139                    return _localRepository.getFolder(parentFolderId, title);
140            }
141    
142            public long getRepositoryId() {
143                    return _localRepository.getRepositoryId();
144            }
145    
146            public FileEntry moveFileEntry(
147                            long userId, long fileEntryId, long newFolderId,
148                            ServiceContext serviceContext)
149                    throws PortalException, SystemException {
150    
151                    FileEntry fileEntry = _localRepository.moveFileEntry(
152                            userId, fileEntryId, newFolderId, serviceContext);
153    
154                    return newFileEntryProxyBean(fileEntry);
155            }
156    
157            public void updateAsset(
158                            long userId, FileEntry fileEntry, FileVersion fileVersion,
159                            long[] assetCategoryIds, String[] assetTagNames,
160                            long[] assetLinkEntryIds)
161                    throws PortalException, SystemException {
162    
163                    _localRepository.updateAsset(
164                            userId, fileEntry, fileVersion, assetCategoryIds, assetTagNames,
165                            assetLinkEntryIds);
166            }
167    
168            public FileEntry updateFileEntry(
169                            long userId, long fileEntryId, String sourceFileName,
170                            String mimeType, String title, String description, String changeLog,
171                            boolean majorVersion, File file, ServiceContext serviceContext)
172                    throws PortalException, SystemException {
173    
174                    FileEntry fileEntry = _localRepository.updateFileEntry(
175                            userId, fileEntryId, sourceFileName, mimeType, title, description,
176                            changeLog, majorVersion, file, serviceContext);
177    
178                    return newFileEntryProxyBean(fileEntry);
179            }
180    
181            public FileEntry updateFileEntry(
182                            long userId, long fileEntryId, String sourceFileName,
183                            String mimeType, String title, String description, String changeLog,
184                            boolean majorVersion, InputStream is, long size,
185                            ServiceContext serviceContext)
186                    throws PortalException, SystemException {
187    
188                    FileEntry fileEntry = _localRepository.updateFileEntry(
189                            userId, fileEntryId, sourceFileName, mimeType, title, description,
190                            changeLog, majorVersion, is, size, serviceContext);
191    
192                    return newFileEntryProxyBean(fileEntry);
193            }
194    
195            public Folder updateFolder(
196                            long folderId, long parentFolderId, String title,
197                            String description, ServiceContext serviceContext)
198                    throws PortalException, SystemException {
199    
200                    return _localRepository.updateFolder(
201                            folderId, parentFolderId, title, description, serviceContext);
202            }
203    
204            private LocalRepository _localRepository;
205    
206    }