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.security.permission.PermissionChecker;
024    import com.liferay.portal.kernel.util.Accessor;
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 int getFileVersionsCount(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             */
129            public FileVersion getLatestFileVersion() throws PortalException;
130    
131            /**
132             * Returns the latest file version, optionally bypassing security checks. In
133             * a Liferay repository, the latest version is returned, regardless of
134             * workflow state. In third-party repositories, the functionality of this
135             * method and {@link #getFileVersion()} may be identical.
136             *
137             * @param  trusted whether to bypass permission checks. In third-party
138             *         repositories, this parameter may be ignored.
139             * @return the latest file version
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 <T extends Capability> T getRepositoryCapability(
156                    Class<T> capabilityClass);
157    
158            public long getRepositoryId();
159    
160            public long getSize();
161    
162            public String getTitle();
163    
164            @Override
165            public long getUserId();
166    
167            @Override
168            public String getUserName();
169    
170            @Override
171            public String getUserUuid();
172    
173            @Override
174            public String getUuid();
175    
176            public String getVersion();
177    
178            public long getVersionUserId();
179    
180            public String getVersionUserName();
181    
182            public String getVersionUserUuid();
183    
184            public boolean hasLock();
185    
186            public boolean isCheckedOut();
187    
188            public boolean isDefaultRepository();
189    
190            public boolean isInTrash();
191    
192            public boolean isInTrashContainer();
193    
194            public boolean isManualCheckInRequired();
195    
196            public <T extends Capability> boolean isRepositoryCapabilityProvided(
197                    Class<T> capabilityClass);
198    
199            public boolean isSupportsLocking();
200    
201            public boolean isSupportsMetadata();
202    
203            public boolean isSupportsSocial();
204    
205    }