001
014
015 package com.liferay.portal.repository.liferayrepository.model;
016
017 import com.liferay.portal.kernel.exception.PortalException;
018 import com.liferay.portal.kernel.exception.SystemException;
019 import com.liferay.portal.kernel.repository.model.FileEntry;
020 import com.liferay.portal.kernel.repository.model.FileVersion;
021 import com.liferay.portal.kernel.repository.model.Folder;
022 import com.liferay.portal.kernel.util.ContentTypes;
023 import com.liferay.portal.model.Lock;
024 import com.liferay.portal.security.permission.PermissionChecker;
025 import com.liferay.portlet.documentlibrary.model.DLFileEntry;
026 import com.liferay.portlet.documentlibrary.model.DLFileVersion;
027 import com.liferay.portlet.documentlibrary.service.DLFileVersionLocalServiceUtil;
028 import com.liferay.portlet.documentlibrary.service.permission.DLFileEntryPermission;
029 import com.liferay.portlet.expando.model.ExpandoBridge;
030
031 import java.io.InputStream;
032 import java.io.Serializable;
033
034 import java.util.Date;
035 import java.util.List;
036 import java.util.Map;
037
038
041 public class LiferayFileEntry extends LiferayModel implements FileEntry {
042
043 public LiferayFileEntry(DLFileEntry dlFileEntry) {
044 _dlFileEntry = dlFileEntry;
045 }
046
047 public LiferayFileEntry(DLFileEntry fileEntry, boolean escapedModel) {
048 _dlFileEntry = fileEntry;
049 _escapedModel = escapedModel;
050 }
051
052 public boolean containsPermission(
053 PermissionChecker permissionChecker, String actionId)
054 throws PortalException, SystemException {
055
056 return DLFileEntryPermission.contains(
057 permissionChecker, _dlFileEntry, actionId);
058 }
059
060 public Map<String, Serializable> getAttributes() {
061 ExpandoBridge expandoBridge = getExpandoBridge();
062
063 return expandoBridge.getAttributes();
064 }
065
066 @Override
067 public long getCompanyId() {
068 return _dlFileEntry.getCompanyId();
069 }
070
071 public InputStream getContentStream()
072 throws PortalException, SystemException {
073
074 return _dlFileEntry.getContentStream();
075 }
076
077 public InputStream getContentStream(String version)
078 throws PortalException, SystemException {
079
080 return _dlFileEntry.getContentStream(version);
081 }
082
083 public Date getCreateDate() {
084 return _dlFileEntry.getCreateDate();
085 }
086
087 public String getDescription() {
088 return _dlFileEntry.getDescription();
089 }
090
091 public DLFileEntry getDLFileEntry() {
092 return _dlFileEntry;
093 }
094
095 @Override
096 public ExpandoBridge getExpandoBridge() {
097 return _dlFileEntry.getExpandoBridge();
098 }
099
100 public String getExtension() {
101 return _dlFileEntry.getExtension();
102 }
103
104 public long getFileEntryId() {
105 return _dlFileEntry.getFileEntryId();
106 }
107
108 public FileVersion getFileVersion()
109 throws PortalException, SystemException {
110
111 return new LiferayFileVersion(_dlFileEntry.getFileVersion());
112 }
113
114 public FileVersion getFileVersion(String version)
115 throws PortalException, SystemException {
116
117 return new LiferayFileVersion(_dlFileEntry.getFileVersion(version));
118 }
119
120 public List<FileVersion> getFileVersions(int status)
121 throws SystemException {
122
123 return toFileVersions(_dlFileEntry.getFileVersions(status));
124 }
125
126 public Folder getFolder() {
127 return new LiferayFolder(_dlFileEntry.getFolder());
128 }
129
130 public long getFolderId() {
131 return _dlFileEntry.getFolderId();
132 }
133
134 public long getGroupId() {
135 return _dlFileEntry.getGroupId();
136 }
137
138 public String getIcon() {
139 return _dlFileEntry.getIcon();
140 }
141
142 public FileVersion getLatestFileVersion()
143 throws PortalException, SystemException {
144
145 return new LiferayFileVersion(_dlFileEntry.getLatestFileVersion(false));
146 }
147
148 public Lock getLock() {
149 return _dlFileEntry.getLock();
150 }
151
152 public String getMimeType() {
153 return _dlFileEntry.getMimeType();
154 }
155
156 public String getMimeType(String version) {
157 try {
158 DLFileVersion dlFileVersion =
159 DLFileVersionLocalServiceUtil.getFileVersion(
160 _dlFileEntry.getFileEntryId(), version);
161
162 return dlFileVersion.getMimeType();
163 }
164 catch (Exception e) {
165 }
166
167 return ContentTypes.APPLICATION_OCTET_STREAM;
168 }
169
170 public Object getModel() {
171 return _dlFileEntry;
172 }
173
174 public Class<?> getModelClass() {
175 return DLFileEntry.class;
176 }
177
178 @Override
179 public String getModelClassName() {
180 return DLFileEntry.class.getName();
181 }
182
183 public Date getModifiedDate() {
184 return _dlFileEntry.getModifiedDate();
185 }
186
187 @Override
188 public long getPrimaryKey() {
189 return _dlFileEntry.getPrimaryKey();
190 }
191
192 public Serializable getPrimaryKeyObj() {
193 return getPrimaryKey();
194 }
195
196 public int getReadCount() {
197 return _dlFileEntry.getReadCount();
198 }
199
200 public long getRepositoryId() {
201 return _dlFileEntry.getRepositoryId();
202 }
203
204 public long getSize() {
205 return _dlFileEntry.getSize();
206 }
207
208 public String getTitle() {
209 return _dlFileEntry.getTitle();
210 }
211
212 public long getUserId() {
213 return _dlFileEntry.getUserId();
214 }
215
216 public String getUserName() {
217 return _dlFileEntry.getVersionUserName();
218 }
219
220 public String getUserUuid() throws SystemException {
221 return _dlFileEntry.getUserUuid();
222 }
223
224 public String getUuid() {
225 return _dlFileEntry.getUuid();
226 }
227
228 public String getVersion() {
229 return _dlFileEntry.getVersion();
230 }
231
232 public long getVersionUserId() {
233 return _dlFileEntry.getVersionUserId();
234 }
235
236 public String getVersionUserName() {
237 return _dlFileEntry.getVersionUserName();
238 }
239
240 public String getVersionUserUuid() throws SystemException {
241 return _dlFileEntry.getVersionUserUuid();
242 }
243
244 public boolean hasLock() {
245 return _dlFileEntry.hasLock();
246 }
247
248 public boolean isCheckedOut() {
249 return _dlFileEntry.isCheckedOut();
250 }
251
252 public boolean isDefaultRepository() {
253 if (_dlFileEntry.getGroupId() == _dlFileEntry.getRepositoryId()) {
254 return true;
255 }
256 else {
257 return false;
258 }
259 }
260
261 public boolean isEscapedModel() {
262 return _escapedModel;
263 }
264
265 public boolean isSupportsLocking() {
266 return true;
267 }
268
269 public boolean isSupportsMetadata() {
270 return true;
271 }
272
273 public boolean isSupportsSocial() {
274 return true;
275 }
276
277 public void setCompanyId(long companyId) {
278 _dlFileEntry.setCompanyId(companyId);
279 }
280
281 public void setCreateDate(Date date) {
282 _dlFileEntry.setCreateDate(date);
283 }
284
285 public void setGroupId(long groupId) {
286 _dlFileEntry.setGroupId(groupId);
287 }
288
289 public void setModifiedDate(Date date) {
290 _dlFileEntry.setModifiedDate(date);
291 }
292
293 public void setPrimaryKey(long primaryKey) {
294 _dlFileEntry.setPrimaryKey(primaryKey);
295 }
296
297 public void setPrimaryKeyObj(Serializable primaryKeyObj) {
298 setPrimaryKey(((Long)primaryKeyObj).longValue());
299 }
300
301 public void setUserId(long userId) {
302 _dlFileEntry.setUserId(userId);
303 }
304
305 public void setUserName(String userName) {
306 _dlFileEntry.setUserName(userName);
307 }
308
309 public void setUserUuid(String userUuid) {
310 _dlFileEntry.setUserUuid(userUuid);
311 }
312
313 public FileEntry toEscapedModel() {
314 if (isEscapedModel()) {
315 return this;
316 }
317 else {
318 return new LiferayFileEntry(_dlFileEntry.toEscapedModel(), true);
319 }
320 }
321
322 private DLFileEntry _dlFileEntry;
323 private boolean _escapedModel;
324
325 }