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            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            public List<FileShortcut> getFileShortcuts();
092    
093            /**
094             * Returns the current file version. The workflow state of the latest file
095             * version may affect the file version that is returned. In a Liferay
096             * repository, the latest approved version is returned; the latest version
097             * regardless of workflow state can be retrieved by {@link
098             * #getLatestFileVersion()}. In third-party repositories, these two methods
099             * may function identically.
100             *
101             * @return the current file version
102             * @throws PortalException if a portal exception occurred
103             */
104            public FileVersion getFileVersion() throws PortalException;
105    
106            public FileVersion getFileVersion(String version) throws PortalException;
107    
108            public List<FileVersion> getFileVersions(int status);
109    
110            public Folder getFolder();
111    
112            public long getFolderId();
113    
114            @Override
115            public long getGroupId();
116    
117            public String getIcon();
118    
119            public String getIconCssClass();
120    
121            /**
122             * Returns the latest file version. In a Liferay repository, the latest
123             * version is returned, regardless of workflow state. In third-party
124             * repositories, the functionality of this method and {@link
125             * #getFileVersion()} may be identical.
126             *
127             * @return the latest file version
128             * @throws PortalException if a portal exception occurred
129             */
130            public FileVersion getLatestFileVersion() throws PortalException;
131    
132            /**
133             * Returns the latest file version, optionally bypassing security checks. In
134             * a Liferay repository, the latest version is returned, regardless of
135             * workflow state. In third-party repositories, the functionality of this
136             * method and {@link #getFileVersion()} may be identical.
137             *
138             * @param  trusted whether to bypass permission checks. In third-party
139             *         repositories, this parameter may be ignored.
140             * @return the latest file version
141             * @throws PortalException if a portal exception occurred
142             */
143            public FileVersion getLatestFileVersion(boolean trusted)
144                    throws PortalException;
145    
146            public Lock getLock();
147    
148            public String getMimeType();
149    
150            public String getMimeType(String version);
151    
152            @Override
153            public Date getModifiedDate();
154    
155            public int getReadCount();
156    
157            public <T extends Capability> T getRepositoryCapability(
158                    Class<T> capabilityClass);
159    
160            public long getRepositoryId();
161    
162            public long getSize();
163    
164            public String getTitle();
165    
166            @Override
167            public long getUserId();
168    
169            @Override
170            public String getUserName();
171    
172            @Override
173            public String getUserUuid();
174    
175            @Override
176            public String getUuid();
177    
178            public String getVersion();
179    
180            public long getVersionUserId();
181    
182            public String getVersionUserName();
183    
184            public String getVersionUserUuid();
185    
186            public boolean hasLock();
187    
188            public boolean isCheckedOut();
189    
190            public boolean isDefaultRepository();
191    
192            public boolean isInTrash();
193    
194            public boolean isInTrashContainer();
195    
196            public boolean isManualCheckInRequired();
197    
198            public <T extends Capability> boolean isRepositoryCapabilityProvided(
199                    Class<T> capabilityClass);
200    
201            public boolean isSupportsLocking();
202    
203            public boolean isSupportsMetadata();
204    
205            public boolean isSupportsSocial();
206    
207    }