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 aQute.bnd.annotation.ProviderType;
018    
019    import com.liferay.portal.kernel.exception.PortalException;
020    import com.liferay.portal.kernel.lock.Lock;
021    import com.liferay.portal.kernel.log.Log;
022    import com.liferay.portal.kernel.log.LogFactoryUtil;
023    import com.liferay.portal.kernel.repository.capabilities.Capability;
024    import com.liferay.portal.kernel.repository.model.FileEntry;
025    import com.liferay.portal.kernel.repository.model.FileShortcut;
026    import com.liferay.portal.kernel.repository.model.FileVersion;
027    import com.liferay.portal.kernel.repository.model.Folder;
028    import com.liferay.portal.kernel.repository.model.RepositoryModelOperation;
029    import com.liferay.portal.kernel.util.StringPool;
030    import com.liferay.portal.security.permission.PermissionChecker;
031    import com.liferay.portlet.expando.model.ExpandoBridge;
032    import com.liferay.portlet.exportimport.lar.StagedModelType;
033    
034    import java.io.InputStream;
035    import java.io.Serializable;
036    
037    import java.util.Date;
038    import java.util.List;
039    import java.util.Map;
040    
041    /**
042     * @author Mika Koivisto
043     */
044    @ProviderType
045    public class FileEntryProxyBean
046            extends RepositoryModelProxyBean implements FileEntry {
047    
048            public FileEntryProxyBean(FileEntry fileEntry, ClassLoader classLoader) {
049                    super(classLoader);
050    
051                    _fileEntry = fileEntry;
052            }
053    
054            @Override
055            public Object clone() {
056                    return newFileEntryProxyBean(_fileEntry);
057            }
058    
059            @Override
060            public boolean containsPermission(
061                            PermissionChecker permissionChecker, String actionId)
062                    throws PortalException {
063    
064                    return _fileEntry.containsPermission(permissionChecker, actionId);
065            }
066    
067            @Override
068            public void execute(RepositoryModelOperation repositoryModelOperation)
069                    throws PortalException {
070    
071                    repositoryModelOperation.execute(this);
072            }
073    
074            @Override
075            public Map<String, Serializable> getAttributes() {
076                    return _fileEntry.getAttributes();
077            }
078    
079            @Override
080            public long getCompanyId() {
081                    return _fileEntry.getCompanyId();
082            }
083    
084            @Override
085            public InputStream getContentStream() throws PortalException {
086                    return _fileEntry.getContentStream();
087            }
088    
089            @Override
090            public InputStream getContentStream(String version) throws PortalException {
091                    return _fileEntry.getContentStream(version);
092            }
093    
094            @Override
095            public Date getCreateDate() {
096                    return _fileEntry.getCreateDate();
097            }
098    
099            @Override
100            public String getDescription() {
101                    return _fileEntry.getDescription();
102            }
103    
104            @Override
105            public ExpandoBridge getExpandoBridge() {
106                    ExpandoBridge expandoBridge = _fileEntry.getExpandoBridge();
107    
108                    return (ExpandoBridge)newProxyInstance(
109                            expandoBridge, ExpandoBridge.class);
110            }
111    
112            @Override
113            public String getExtension() {
114                    return _fileEntry.getExtension();
115            }
116    
117            @Override
118            public long getFileEntryId() {
119                    return _fileEntry.getFileEntryId();
120            }
121    
122            @Override
123            public String getFileName() {
124                    return _fileEntry.getFileName();
125            }
126    
127            @Override
128            public List<FileShortcut> getFileShortcuts() {
129                    return _fileEntry.getFileShortcuts();
130            }
131    
132            @Override
133            public FileVersion getFileVersion() throws PortalException {
134                    FileVersion fileVersion = _fileEntry.getFileVersion();
135    
136                    return newFileVersionProxyBean(fileVersion);
137            }
138    
139            @Override
140            public FileVersion getFileVersion(String version) throws PortalException {
141                    FileVersion fileVersion = _fileEntry.getFileVersion(version);
142    
143                    return newFileVersionProxyBean(fileVersion);
144            }
145    
146            @Override
147            public List<FileVersion> getFileVersions(int status) {
148                    List<FileVersion> fileVersions = _fileEntry.getFileVersions(status);
149    
150                    return toFileVersionProxyBeans(fileVersions);
151            }
152    
153            @Override
154            public Folder getFolder() {
155                    Folder folder = _fileEntry.getFolder();
156    
157                    return newFolderProxyBean(folder);
158            }
159    
160            @Override
161            public long getFolderId() {
162                    return _fileEntry.getFolderId();
163            }
164    
165            @Override
166            public long getGroupId() {
167                    return _fileEntry.getGroupId();
168            }
169    
170            @Override
171            public String getIcon() {
172                    return _fileEntry.getIcon();
173            }
174    
175            @Override
176            public String getIconCssClass() {
177                    return _fileEntry.getIconCssClass();
178            }
179    
180            @Override
181            public FileVersion getLatestFileVersion() throws PortalException {
182                    FileVersion fileVersion = _fileEntry.getLatestFileVersion();
183    
184                    return newFileVersionProxyBean(fileVersion);
185            }
186    
187            @Override
188            public FileVersion getLatestFileVersion(boolean trusted)
189                    throws PortalException {
190    
191                    FileVersion fileVersion = _fileEntry.getLatestFileVersion(trusted);
192    
193                    return newFileVersionProxyBean(fileVersion);
194            }
195    
196            @Override
197            public Lock getLock() {
198                    Lock lock = _fileEntry.getLock();
199    
200                    return (Lock)newProxyInstance(lock, Lock.class);
201            }
202    
203            @Override
204            public String getMimeType() {
205                    return _fileEntry.getMimeType();
206            }
207    
208            @Override
209            public String getMimeType(String version) {
210                    return _fileEntry.getMimeType(version);
211            }
212    
213            @Override
214            public Object getModel() {
215                    return _fileEntry.getModel();
216            }
217    
218            @Override
219            public Class<?> getModelClass() {
220                    return _fileEntry.getModelClass();
221            }
222    
223            @Override
224            public String getModelClassName() {
225                    return _fileEntry.getModelClassName();
226            }
227    
228            @Override
229            public Date getModifiedDate() {
230                    return _fileEntry.getModifiedDate();
231            }
232    
233            @Override
234            public long getPrimaryKey() {
235                    return _fileEntry.getPrimaryKey();
236            }
237    
238            @Override
239            public Serializable getPrimaryKeyObj() {
240                    return _fileEntry.getPrimaryKeyObj();
241            }
242    
243            @Override
244            public int getReadCount() {
245                    return _fileEntry.getReadCount();
246            }
247    
248            @Override
249            public <T extends Capability> T getRepositoryCapability(
250                    Class<T> capabilityClass) {
251    
252                    return _fileEntry.getRepositoryCapability(capabilityClass);
253            }
254    
255            @Override
256            public long getRepositoryId() {
257                    return _fileEntry.getRepositoryId();
258            }
259    
260            @Override
261            public long getSize() {
262                    return _fileEntry.getSize();
263            }
264    
265            @Override
266            public StagedModelType getStagedModelType() {
267                    return _fileEntry.getStagedModelType();
268            }
269    
270            @Override
271            public String getTitle() {
272                    return _fileEntry.getTitle();
273            }
274    
275            @Override
276            public long getUserId() {
277                    return _fileEntry.getUserId();
278            }
279    
280            @Override
281            public String getUserName() {
282                    return _fileEntry.getUserName();
283            }
284    
285            @Override
286            public String getUserUuid() {
287                    return _fileEntry.getUserUuid();
288            }
289    
290            @Override
291            public String getUuid() {
292                    return _fileEntry.getUuid();
293            }
294    
295            @Override
296            public String getVersion() {
297                    return _fileEntry.getVersion();
298            }
299    
300            /**
301             * @deprecated As of 6.2.0, replaced by {@link
302             *             FileVersionProxyBean#getUserId()}
303             */
304            @Deprecated
305            @Override
306            public long getVersionUserId() {
307                    long versionUserId = 0;
308    
309                    try {
310                            FileVersion fileVersion = _fileEntry.getFileVersion();
311    
312                            versionUserId = fileVersion.getUserId();
313                    }
314                    catch (Exception e) {
315                            _log.error(e, e);
316                    }
317    
318                    return versionUserId;
319            }
320    
321            /**
322             * @deprecated As of 6.2.0, replaced by {@link
323             *             FileVersionProxyBean#getUserName()}
324             */
325            @Deprecated
326            @Override
327            public String getVersionUserName() {
328                    String versionUserName = StringPool.BLANK;
329    
330                    try {
331                            FileVersion fileVersion = _fileEntry.getFileVersion();
332    
333                            versionUserName = fileVersion.getUserName();
334                    }
335                    catch (Exception e) {
336                            _log.error(e, e);
337                    }
338    
339                    return versionUserName;
340            }
341    
342            /**
343             * @deprecated As of 6.2.0, replaced by {@link
344             *             FileVersionProxyBean#getUserUuid()}
345             */
346            @Deprecated
347            @Override
348            public String getVersionUserUuid() {
349                    String versionUserUuid = StringPool.BLANK;
350    
351                    try {
352                            FileVersion fileVersion = _fileEntry.getFileVersion();
353    
354                            versionUserUuid = fileVersion.getUserUuid();
355                    }
356                    catch (Exception e) {
357                            _log.error(e, e);
358                    }
359    
360                    return versionUserUuid;
361            }
362    
363            @Override
364            public boolean hasLock() {
365                    return _fileEntry.hasLock();
366            }
367    
368            @Override
369            public boolean isCheckedOut() {
370                    return _fileEntry.isCheckedOut();
371            }
372    
373            @Override
374            public boolean isDefaultRepository() {
375                    return _fileEntry.isDefaultRepository();
376            }
377    
378            @Override
379            public boolean isEscapedModel() {
380                    return _fileEntry.isEscapedModel();
381            }
382    
383            @Override
384            public boolean isInTrash() {
385                    return _fileEntry.isInTrash();
386            }
387    
388            @Override
389            public boolean isInTrashContainer() {
390                    return _fileEntry.isInTrashContainer();
391            }
392    
393            @Override
394            public boolean isManualCheckInRequired() {
395                    return _fileEntry.isManualCheckInRequired();
396            }
397    
398            @Override
399            public <T extends Capability> boolean isRepositoryCapabilityProvided(
400                    Class<T> capabilityClass) {
401    
402                    return _fileEntry.isRepositoryCapabilityProvided(capabilityClass);
403            }
404    
405            @Override
406            public boolean isSupportsLocking() {
407                    return _fileEntry.isSupportsLocking();
408            }
409    
410            @Override
411            public boolean isSupportsMetadata() {
412                    return _fileEntry.isSupportsMetadata();
413            }
414    
415            @Override
416            public boolean isSupportsSocial() {
417                    return _fileEntry.isSupportsSocial();
418            }
419    
420            @Override
421            public void setCompanyId(long companyId) {
422                    _fileEntry.setCompanyId(companyId);
423            }
424    
425            @Override
426            public void setCreateDate(Date date) {
427                    _fileEntry.setCreateDate(date);
428            }
429    
430            @Override
431            public void setGroupId(long groupId) {
432                    _fileEntry.setGroupId(groupId);
433            }
434    
435            @Override
436            public void setModifiedDate(Date date) {
437                    _fileEntry.setModifiedDate(date);
438            }
439    
440            @Override
441            public void setPrimaryKeyObj(Serializable primaryKeyObj) {
442                    _fileEntry.setPrimaryKeyObj(primaryKeyObj);
443            }
444    
445            @Override
446            public void setUserId(long userId) {
447                    _fileEntry.setUserId(userId);
448            }
449    
450            @Override
451            public void setUserName(String userName) {
452                    _fileEntry.setUserName(userName);
453            }
454    
455            @Override
456            public void setUserUuid(String userUuid) {
457                    _fileEntry.setUserUuid(userUuid);
458            }
459    
460            @Override
461            public void setUuid(String uuid) {
462                    _fileEntry.setUuid(uuid);
463            }
464    
465            @Override
466            public FileEntry toEscapedModel() {
467                    FileEntry fileEntry = _fileEntry.toEscapedModel();
468    
469                    return newFileEntryProxyBean(fileEntry);
470            }
471    
472            @Override
473            public FileEntry toUnescapedModel() {
474                    FileEntry fileEntry = _fileEntry.toUnescapedModel();
475    
476                    return newFileEntryProxyBean(fileEntry);
477            }
478    
479            private static final Log _log = LogFactoryUtil.getLog(
480                    FileEntryProxyBean.class);
481    
482            private final FileEntry _fileEntry;
483    
484    }