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.util.Accessor;
022    import com.liferay.portal.model.Lock;
023    import com.liferay.portal.security.permission.PermissionChecker;
024    
025    import java.io.InputStream;
026    
027    import java.util.Date;
028    import java.util.List;
029    
030    /**
031     * @author Alexander Chow
032     */
033    @JSON
034    @ProviderType
035    public interface FileEntry extends RepositoryModel<FileEntry> {
036    
037            public static final Accessor<FileEntry, Long> FILE_ENTRY_ID_ACCESSOR =
038    
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             * @throws PortalException if a portal exception occurred
073             * @see    #getFileVersion()
074             */
075            @JSON(include = false)
076            public InputStream getContentStream() throws PortalException;
077    
078            public InputStream getContentStream(String version) throws PortalException;
079    
080            @Override
081            public Date getCreateDate();
082    
083            public String getDescription();
084    
085            public String getExtension();
086    
087            public long getFileEntryId();
088    
089            public String getFileName();
090    
091            /**
092             * Returns the current file version. The workflow state of the latest file
093             * version may affect the file version that is returned. In a Liferay
094             * repository, the latest approved version is returned; the latest version
095             * regardless of workflow state can be retrieved by {@link
096             * #getLatestFileVersion()}. In third-party repositories, these two methods
097             * may function identically.
098             *
099             * @return the current file version
100             * @throws PortalException if a portal exception occurred
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             * @throws PortalException if a portal exception occurred
127             */
128            public FileVersion getLatestFileVersion() throws PortalException;
129    
130            /**
131             * Returns the latest file version, optionally bypassing security checks. In
132             * a Liferay repository, the latest version is returned, regardless of
133             * workflow state. In third-party repositories, the functionality of this
134             * method and {@link #getFileVersion()} may be identical.
135             *
136             * @param  trusted whether to bypass permission checks. In third-party
137             *         repositories, this parameter may be ignored.
138             * @return the latest file version
139             * @throws PortalException if a portal exception occurred
140             */
141            public FileVersion getLatestFileVersion(boolean trusted)
142                    throws PortalException;
143    
144            public Lock getLock();
145    
146            public String getMimeType();
147    
148            public String getMimeType(String version);
149    
150            @Override
151            public Date getModifiedDate();
152    
153            public int getReadCount();
154    
155            public long getRepositoryId();
156    
157            public long getSize();
158    
159            public String getTitle();
160    
161            @Override
162            public long getUserId();
163    
164            @Override
165            public String getUserName();
166    
167            @Override
168            public String getUserUuid();
169    
170            @Override
171            public String getUuid();
172    
173            public String getVersion();
174    
175            public long getVersionUserId();
176    
177            public String getVersionUserName();
178    
179            public String getVersionUserUuid();
180    
181            public boolean hasLock();
182    
183            public boolean isCheckedOut();
184    
185            public boolean isDefaultRepository();
186    
187            public boolean isInTrash();
188    
189            public boolean isInTrashContainer();
190    
191            public boolean isManualCheckInRequired();
192    
193            public boolean isSupportsLocking();
194    
195            public boolean isSupportsMetadata();
196    
197            public boolean isSupportsSocial();
198    
199    }