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.kernel.repository;
016    
017    import com.liferay.portal.kernel.exception.PortalException;
018    import com.liferay.portal.kernel.exception.SystemException;
019    import com.liferay.portal.kernel.repository.model.FileEntry;
020    import com.liferay.portal.kernel.repository.model.FileVersion;
021    import com.liferay.portal.kernel.repository.model.Folder;
022    import com.liferay.portal.kernel.util.OrderByComparator;
023    import com.liferay.portal.service.ServiceContext;
024    
025    import java.io.File;
026    import java.io.InputStream;
027    
028    import java.util.List;
029    
030    /**
031     * This class is designed for third party repository implementations. Since the
032     * paradigm of remote and local services exists only within Liferay, the
033     * assumption is that all permission checking will be delegated to the specific
034     * repository.
035     *
036     * There are also many calls within this class that pass in a user ID as a
037     * parameter. These methods should only be called for administration of Liferay
038     * repositories and are hence not supported in all third party repositories.
039     * This includes moving between document library hooks and LAR import/export.
040     * Calling these methods will throw an
041     * <code>UnsupportedOperationException</code>.
042     *
043     * @author Alexander Chow
044     */
045    public class DefaultLocalRepositoryImpl implements LocalRepository {
046    
047            public DefaultLocalRepositoryImpl(Repository repository) {
048                    _repository = repository;
049            }
050    
051            public FileEntry addFileEntry(
052                    long userId, long folderId, String sourceFileName, String mimeType,
053                    String title, String description, String changeLog, File file,
054                    ServiceContext serviceContext) {
055    
056                    throw new UnsupportedOperationException();
057            }
058    
059            public FileEntry addFileEntry(
060                    long userId, long folderId, String sourceFileName, String mimeType,
061                    String title, String description, String changeLog, InputStream is,
062                    long size, ServiceContext serviceContext) {
063    
064                    throw new UnsupportedOperationException();
065            }
066    
067            public Folder addFolder(
068                    long userId, long parentFolderId, String title, String description,
069                    ServiceContext serviceContext) {
070    
071                    throw new UnsupportedOperationException();
072            }
073    
074            public void deleteAll() {
075                    throw new UnsupportedOperationException();
076            }
077    
078            public void deleteFileEntry(long fileEntryId)
079                    throws PortalException, SystemException {
080    
081                    _repository.deleteFileEntry(fileEntryId);
082            }
083    
084            public void deleteFolder(long folderId)
085                    throws PortalException, SystemException {
086    
087                    _repository.deleteFolder(folderId);
088            }
089    
090            public List<FileEntry> getFileEntries(
091                            long folderId, int start, int end, OrderByComparator obc)
092                    throws SystemException {
093    
094                    return _repository.getFileEntries(folderId, start, end, obc);
095            }
096    
097            public List<Object> getFileEntriesAndFileShortcuts(
098                            long folderId, int status, int start, int end)
099                    throws SystemException {
100    
101                    return _repository.getFileEntriesAndFileShortcuts(
102                            folderId, status, start, end);
103            }
104    
105            public int getFileEntriesAndFileShortcutsCount(long folderId, int status)
106                    throws SystemException {
107    
108                    return _repository.getFileEntriesAndFileShortcutsCount(
109                            folderId, status);
110            }
111    
112            public int getFileEntriesCount(long folderId) throws SystemException {
113                    return _repository.getFileEntriesCount(folderId);
114            }
115    
116            public FileEntry getFileEntry(long fileEntryId)
117                    throws PortalException, SystemException {
118    
119                    return _repository.getFileEntry(fileEntryId);
120            }
121    
122            public FileEntry getFileEntry(long folderId, String title)
123                            throws PortalException, SystemException {
124    
125                    return _repository.getFileEntry(folderId, title);
126            }
127    
128            public FileEntry getFileEntryByUuid(String uuid)
129                    throws PortalException, SystemException {
130    
131                    return _repository.getFileEntryByUuid(uuid);
132            }
133    
134            public FileVersion getFileVersion(long fileVersionId)
135                    throws PortalException, SystemException {
136    
137                    return _repository.getFileVersion(fileVersionId);
138            }
139    
140            public Folder getFolder(long folderId)
141                    throws PortalException, SystemException {
142    
143                    return _repository.getFolder(folderId);
144            }
145    
146            public Folder getFolder(long parentFolderId, String title)
147                    throws PortalException, SystemException {
148    
149                    return _repository.getFolder(parentFolderId, title);
150            }
151    
152            public List<Folder> getFolders(
153                            long parentFolderId, boolean includeMountfolders, int start,
154                            int end, OrderByComparator obc)
155                    throws PortalException, SystemException {
156    
157                    return _repository.getFolders(
158                            parentFolderId, includeMountfolders, start, end, obc);
159            }
160    
161            public List<Object> getFoldersAndFileEntriesAndFileShortcuts(
162                            long folderId, int status, boolean includeMountFolders, int start,
163                            int end, OrderByComparator obc)
164                    throws SystemException {
165    
166                    return _repository.getFoldersAndFileEntriesAndFileShortcuts(
167                            folderId, status, includeMountFolders, start, end, obc);
168            }
169    
170            public List<Object> getFoldersAndFileEntriesAndFileShortcuts(
171                            long folderId, int status, int start, int end,
172                            OrderByComparator obc)
173                    throws SystemException {
174    
175                    return getFoldersAndFileEntriesAndFileShortcuts(
176                            folderId, status, true, start, end, obc);
177            }
178    
179            public List<Object> getFoldersAndFileEntriesAndFileShortcuts(
180                            long folderId, int status, String[] mimeTypes,
181                            boolean includeMountFolders, int start, int end,
182                            OrderByComparator obc)
183                    throws PortalException, SystemException {
184    
185                    return _repository.getFoldersAndFileEntriesAndFileShortcuts(
186                            folderId, status, mimeTypes, includeMountFolders, start, end, obc);
187            }
188    
189            public int getFoldersAndFileEntriesAndFileShortcutsCount(
190                            long folderId, int status)
191                    throws SystemException {
192    
193                    return getFoldersAndFileEntriesAndFileShortcutsCount(
194                            folderId, status, true);
195            }
196    
197            public int getFoldersAndFileEntriesAndFileShortcutsCount(
198                            long folderId, int status, boolean includeMountFolders)
199                    throws SystemException {
200    
201                    return _repository.getFoldersAndFileEntriesAndFileShortcutsCount(
202                            folderId, status, includeMountFolders);
203            }
204    
205            public int getFoldersAndFileEntriesAndFileShortcutsCount(
206                            long folderId, int status, String[] mimeTypes,
207                            boolean includeMountFolders)
208                    throws PortalException, SystemException {
209    
210                    return _repository.getFoldersAndFileEntriesAndFileShortcutsCount(
211                            folderId, status, mimeTypes, includeMountFolders);
212            }
213    
214            public int getFoldersCount(long parentFolderId, boolean includeMountfolders)
215                    throws PortalException, SystemException {
216    
217                    return _repository.getFoldersCount(parentFolderId, includeMountfolders);
218            }
219    
220            public int getFoldersFileEntriesCount(List<Long> folderIds, int status)
221                    throws SystemException {
222    
223                    return _repository.getFoldersFileEntriesCount(folderIds, status);
224            }
225    
226            public List<Folder> getMountFolders(
227                            long parentFolderId, int start, int end, OrderByComparator obc)
228                    throws SystemException {
229    
230                    return _repository.getMountFolders(parentFolderId, start, end, obc);
231            }
232    
233            public int getMountFoldersCount(long parentFolderId)
234                    throws SystemException {
235    
236                    return _repository.getMountFoldersCount(parentFolderId);
237            }
238    
239            public long getRepositoryId() {
240                    return _repository.getRepositoryId();
241            }
242    
243            public FileEntry moveFileEntry(
244                    long userId, long fileEntryId, long newFolderId,
245                    ServiceContext serviceContext) {
246    
247                    throw new UnsupportedOperationException();
248            }
249    
250            public void updateAsset(
251                    long userId, FileEntry fileEntry, FileVersion fileVersion,
252                    long[] assetCategoryIds, String[] assetTagNames,
253                    long[] assetLinkEntryIds) {
254    
255                    throw new UnsupportedOperationException();
256            }
257    
258            public FileEntry updateFileEntry(
259                    long userId, long fileEntryId, String sourceFileName, String mimeType,
260                    String title, String description, String changeLog,
261                    boolean majorVersion, File file, ServiceContext serviceContext) {
262    
263                    throw new UnsupportedOperationException();
264            }
265    
266            public FileEntry updateFileEntry(
267                    long userId, long fileEntryId, String sourceFileName, String mimeType,
268                    String title, String description, String changeLog,
269                    boolean majorVersion, InputStream is, long size,
270                    ServiceContext serviceContext) {
271    
272                    throw new UnsupportedOperationException();
273            }
274    
275            public Folder updateFolder(
276                    long folderId, long parentFolderId, String title, String description,
277                    ServiceContext serviceContext) {
278    
279                    throw new UnsupportedOperationException();
280            }
281    
282            private Repository _repository;
283    
284    }