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.model;
016    
017    import aQute.bnd.annotation.ProviderType;
018    
019    import com.liferay.portal.kernel.exception.PortalException;
020    import com.liferay.portal.kernel.json.JSON;
021    import com.liferay.portal.kernel.lock.Lock;
022    import com.liferay.portal.kernel.repository.capabilities.Capability;
023    import com.liferay.portal.kernel.util.Accessor;
024    import com.liferay.portal.security.permission.PermissionChecker;
025    
026    import java.io.InputStream;
027    
028    import java.util.Date;
029    import java.util.List;
030    
031    /**
032     * @author Alexander Chow
033     */
034    @JSON
035    @ProviderType
036    public interface FileEntry extends RepositoryEntry, RepositoryModel<FileEntry> {
037    
038            public static final Accessor<FileEntry, Long> FILE_ENTRY_ID_ACCESSOR =
039                    new Accessor<FileEntry, Long>() {
040    
041                            @Override
042                            public Long get(FileEntry fileEntry) {
043                                    return fileEntry.getFileEntryId();
044                            }
045    
046                            @Override
047                            public Class<Long> getAttributeClass() {
048                                    return Long.class;
049                            }
050    
051                            @Override
052                            public Class<FileEntry> getTypeClass() {
053                                    return FileEntry.class;
054                            }
055    
056                    };
057    
058            public boolean containsPermission(
059                            PermissionChecker permissionChecker, String actionId)
060                    throws PortalException;
061    
062            @Override
063            public long getCompanyId();
064    
065            /**
066             * Returns the content stream of the current file version. In a Liferay
067             * repository, this is the latest approved version. In third-party
068             * repositories, the latest content stream may be returned, regardless of
069             * workflow state.
070             *
071             * @return the content stream of the current file version
072             * @see    #getFileVersion()
073             */
074            @JSON(include = false)
075            public InputStream getContentStream() throws PortalException;
076    
077            public InputStream getContentStream(String version) throws PortalException;
078    
079            @Override
080            public Date getCreateDate();
081    
082            public String getDescription();
083    
084            public String getExtension();
085    
086            public long getFileEntryId();
087    
088            public String getFileName();
089    
090            public List<FileShortcut> getFileShortcuts();
091    
092            /**
093             * Returns the current file version. The workflow state of the latest file
094             * version may affect the file version that is returned. In a Liferay
095             * repository, the latest approved version is returned; the latest version
096             * regardless of workflow state can be retrieved by {@link
097             * #getLatestFileVersion()}. In third-party repositories, these two methods
098             * may function identically.
099             *
100             * @return the current file version
101             */
102            public FileVersion getFileVersion() throws PortalException;
103    
104            public FileVersion getFileVersion(String version) throws PortalException;
105    
106            public List<FileVersion> getFileVersions(int status);
107    
108            public Folder getFolder();
109    
110            public long getFolderId();
111    
112            @Override
113            public long getGroupId();
114    
115            public String getIcon();
116    
117            public String getIconCssClass();
118    
119            /**
120             * Returns the latest file version. In a Liferay repository, the latest
121             * version is returned, regardless of workflow state. In third-party
122             * repositories, the functionality of this method and {@link
123             * #getFileVersion()} may be identical.
124             *
125             * @return the latest file version
126             */
127            public FileVersion getLatestFileVersion() throws PortalException;
128    
129            /**
130             * Returns the latest file version, optionally bypassing security checks. In
131             * a Liferay repository, the latest version is returned, regardless of
132             * workflow state. In third-party repositories, the functionality of this
133             * method and {@link #getFileVersion()} may be identical.
134             *
135             * @param  trusted whether to bypass permission checks. In third-party
136             *         repositories, this parameter may be ignored.
137             * @return the latest file version
138             */
139            public FileVersion getLatestFileVersion(boolean trusted)
140                    throws PortalException;
141    
142            public Lock getLock();
143    
144            public String getMimeType();
145    
146            public String getMimeType(String version);
147    
148            @Override
149            public Date getModifiedDate();
150    
151            public int getReadCount();
152    
153            public <T extends Capability> T getRepositoryCapability(
154                    Class<T> capabilityClass);
155    
156            public long getRepositoryId();
157    
158            public long getSize();
159    
160            public String getTitle();
161    
162            @Override
163            public long getUserId();
164    
165            @Override
166            public String getUserName();
167    
168            @Override
169            public String getUserUuid();
170    
171            @Override
172            public String getUuid();
173    
174            public String getVersion();
175    
176            public long getVersionUserId();
177    
178            public String getVersionUserName();
179    
180            public String getVersionUserUuid();
181    
182            public boolean hasLock();
183    
184            public boolean isCheckedOut();
185    
186            public boolean isDefaultRepository();
187    
188            public boolean isInTrash();
189    
190            public boolean isInTrashContainer();
191    
192            public boolean isManualCheckInRequired();
193    
194            public <T extends Capability> boolean isRepositoryCapabilityProvided(
195                    Class<T> capabilityClass);
196    
197            public boolean isSupportsLocking();
198    
199            public boolean isSupportsMetadata();
200    
201            public boolean isSupportsSocial();
202    
203    }