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.kernel.repository;
016    
017    import com.liferay.portal.kernel.exception.PortalException;
018    import com.liferay.portal.kernel.repository.capabilities.Capability;
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            @Override
052            public FileEntry addFileEntry(
053                    long userId, long folderId, String sourceFileName, String mimeType,
054                    String title, String description, String changeLog, File file,
055                    ServiceContext serviceContext) {
056    
057                    throw new UnsupportedOperationException();
058            }
059    
060            @Override
061            public FileEntry addFileEntry(
062                    long userId, long folderId, String sourceFileName, String mimeType,
063                    String title, String description, String changeLog, InputStream is,
064                    long size, ServiceContext serviceContext) {
065    
066                    throw new UnsupportedOperationException();
067            }
068    
069            @Override
070            public Folder addFolder(
071                    long userId, long parentFolderId, String name, String description,
072                    ServiceContext serviceContext) {
073    
074                    throw new UnsupportedOperationException();
075            }
076    
077            @Override
078            public void deleteAll() {
079                    throw new UnsupportedOperationException();
080            }
081    
082            @Override
083            public void deleteFileEntry(long fileEntryId) throws PortalException {
084                    _repository.deleteFileEntry(fileEntryId);
085            }
086    
087            @Override
088            public void deleteFolder(long folderId) throws PortalException {
089                    _repository.deleteFolder(folderId);
090            }
091    
092            @Override
093            public <T extends Capability> T getCapability(Class<T> capabilityClass) {
094                    return _repository.getCapability(capabilityClass);
095            }
096    
097            @Override
098            public FileEntry getFileEntry(long fileEntryId) throws PortalException {
099                    return _repository.getFileEntry(fileEntryId);
100            }
101    
102            @Override
103            public FileEntry getFileEntry(long folderId, String title)
104                    throws PortalException {
105    
106                    return _repository.getFileEntry(folderId, title);
107            }
108    
109            @Override
110            public FileEntry getFileEntryByUuid(String uuid) throws PortalException {
111                    return _repository.getFileEntryByUuid(uuid);
112            }
113    
114            @Override
115            public FileVersion getFileVersion(long fileVersionId)
116                    throws PortalException {
117    
118                    return _repository.getFileVersion(fileVersionId);
119            }
120    
121            @Override
122            public Folder getFolder(long folderId) throws PortalException {
123                    return _repository.getFolder(folderId);
124            }
125    
126            @Override
127            public Folder getFolder(long parentFolderId, String name)
128                    throws PortalException {
129    
130                    return _repository.getFolder(parentFolderId, name);
131            }
132    
133            @Override
134            public List<FileEntry> getRepositoryFileEntries(
135                            long rootFolderId, int start, int end,
136                            OrderByComparator<FileEntry> obc)
137                    throws PortalException {
138    
139                    return _repository.getRepositoryFileEntries(
140                            0, rootFolderId, start, end, obc);
141            }
142    
143            @Override
144            public long getRepositoryId() {
145                    return _repository.getRepositoryId();
146            }
147    
148            @Override
149            public <T extends Capability> boolean isCapabilityProvided(
150                    Class<T> capabilityClass) {
151    
152                    return _repository.isCapabilityProvided(capabilityClass);
153            }
154    
155            @Override
156            public FileEntry moveFileEntry(
157                    long userId, long fileEntryId, long newFolderId,
158                    ServiceContext serviceContext) {
159    
160                    throw new UnsupportedOperationException();
161            }
162    
163            @Override
164            public Folder moveFolder(
165                    long userId, long folderId, long parentFolderId,
166                    ServiceContext serviceContext) {
167    
168                    throw new UnsupportedOperationException();
169            }
170    
171            @Override
172            public void updateAsset(
173                    long userId, FileEntry fileEntry, FileVersion fileVersion,
174                    long[] assetCategoryIds, String[] assetTagNames,
175                    long[] assetLinkEntryIds) {
176    
177                    throw new UnsupportedOperationException();
178            }
179    
180            @Override
181            public FileEntry updateFileEntry(
182                    long userId, long fileEntryId, String sourceFileName, String mimeType,
183                    String title, String description, String changeLog,
184                    boolean majorVersion, File file, ServiceContext serviceContext) {
185    
186                    throw new UnsupportedOperationException();
187            }
188    
189            @Override
190            public FileEntry updateFileEntry(
191                    long userId, long fileEntryId, String sourceFileName, String mimeType,
192                    String title, String description, String changeLog,
193                    boolean majorVersion, InputStream is, long size,
194                    ServiceContext serviceContext) {
195    
196                    throw new UnsupportedOperationException();
197            }
198    
199            @Override
200            public Folder updateFolder(
201                    long folderId, long parentFolderId, String name, String description,
202                    ServiceContext serviceContext) {
203    
204                    throw new UnsupportedOperationException();
205            }
206    
207            private final Repository _repository;
208    
209    }