001
014
015 package com.liferay.portal.kernel.repository.cmis;
016
017 import com.liferay.portal.kernel.exception.PortalException;
018 import com.liferay.portal.kernel.repository.BaseRepository;
019 import com.liferay.portal.kernel.repository.BaseRepositoryImpl;
020 import com.liferay.portal.kernel.repository.RepositoryException;
021 import com.liferay.portal.kernel.repository.capabilities.Capability;
022 import com.liferay.portal.kernel.repository.model.FileEntry;
023 import com.liferay.portal.kernel.repository.model.FileVersion;
024 import com.liferay.portal.kernel.repository.model.Folder;
025 import com.liferay.portal.kernel.search.Hits;
026 import com.liferay.portal.kernel.search.Query;
027 import com.liferay.portal.kernel.search.SearchContext;
028 import com.liferay.portal.kernel.search.SearchException;
029 import com.liferay.portal.kernel.util.GetterUtil;
030 import com.liferay.portal.kernel.util.OrderByComparator;
031 import com.liferay.portal.kernel.util.StringUtil;
032 import com.liferay.portal.kernel.util.Validator;
033 import com.liferay.portal.model.Company;
034 import com.liferay.portal.model.CompanyConstants;
035 import com.liferay.portal.model.Lock;
036 import com.liferay.portal.model.User;
037 import com.liferay.portal.security.auth.PrincipalThreadLocal;
038 import com.liferay.portal.service.ServiceContext;
039
040 import java.io.InputStream;
041
042 import java.util.List;
043 import java.util.Map;
044
045
048 public abstract class CMISRepositoryHandler
049 extends BaseRepositoryImpl implements Capability {
050
051 @Override
052 public FileEntry addFileEntry(
053 long userId, long folderId, String sourceFileName, String mimeType,
054 String title, String description, String changeLog, InputStream is,
055 long size, ServiceContext serviceContext)
056 throws PortalException {
057
058 return _baseCmisRepository.addFileEntry(
059 userId, folderId, sourceFileName, mimeType, title, description,
060 changeLog, is, size, serviceContext);
061 }
062
063 @Override
064 public Folder addFolder(
065 long userId, long parentFolderId, String name, String description,
066 ServiceContext serviceContext)
067 throws PortalException {
068
069 return _baseCmisRepository.addFolder(
070 userId, parentFolderId, name, description, serviceContext);
071 }
072
073 @Override
074 public FileVersion cancelCheckOut(long fileEntryId) throws PortalException {
075 return _baseCmisRepository.cancelCheckOut(fileEntryId);
076 }
077
078 @Override
079 public void checkInFileEntry(
080 long userId, long fileEntryId, boolean major, String changeLog,
081 ServiceContext serviceContext)
082 throws PortalException {
083
084 _baseCmisRepository.checkInFileEntry(
085 userId, fileEntryId, major, changeLog, serviceContext);
086 }
087
088 @Override
089 public void checkInFileEntry(
090 long userId, long fileEntryId, String lockUuid,
091 ServiceContext serviceContext)
092 throws PortalException {
093
094 _baseCmisRepository.checkInFileEntry(
095 userId, fileEntryId, lockUuid, serviceContext);
096 }
097
098 @Override
099 public FileEntry checkOutFileEntry(
100 long fileEntryId, ServiceContext serviceContext)
101 throws PortalException {
102
103 return _baseCmisRepository.checkOutFileEntry(
104 fileEntryId, serviceContext);
105 }
106
107 @Override
108 public FileEntry checkOutFileEntry(
109 long fileEntryId, String owner, long expirationTime,
110 ServiceContext serviceContext)
111 throws PortalException {
112
113 return _baseCmisRepository.checkOutFileEntry(
114 fileEntryId, owner, expirationTime, serviceContext);
115 }
116
117 @Override
118 public FileEntry copyFileEntry(
119 long userId, long groupId, long fileEntryId, long destFolderId,
120 ServiceContext serviceContext)
121 throws PortalException {
122
123 return _baseCmisRepository.copyFileEntry(
124 userId, groupId, fileEntryId, destFolderId, serviceContext);
125 }
126
127 @Override
128 public void deleteFileEntry(long fileEntryId) throws PortalException {
129 _baseCmisRepository.deleteFileEntry(fileEntryId);
130 }
131
132 @Override
133 public void deleteFolder(long folderId) throws PortalException {
134 _baseCmisRepository.deleteFolder(folderId);
135 }
136
137 public BaseRepository getCmisRepository() {
138 return _baseCmisRepository;
139 }
140
141 @Override
142 public List<FileEntry> getFileEntries(
143 long folderId, int start, int end, OrderByComparator<FileEntry> obc)
144 throws PortalException {
145
146 return _baseCmisRepository.getFileEntries(folderId, start, end, obc);
147 }
148
149 @Override
150 public List<FileEntry> getFileEntries(
151 long folderId, long fileEntryTypeId, int start, int end,
152 OrderByComparator<FileEntry> obc)
153 throws PortalException {
154
155 return _baseCmisRepository.getFileEntries(
156 folderId, fileEntryTypeId, start, end, obc);
157 }
158
159 @Override
160 public List<FileEntry> getFileEntries(
161 long folderId, String[] mimeTypes, int start, int end,
162 OrderByComparator<FileEntry> obc)
163 throws PortalException {
164
165 return _baseCmisRepository.getFileEntries(
166 folderId, mimeTypes, start, end, obc);
167 }
168
169 @Override
170 public int getFileEntriesCount(long folderId) throws PortalException {
171 return _baseCmisRepository.getFileEntriesCount(folderId);
172 }
173
174 @Override
175 public int getFileEntriesCount(long folderId, long fileEntryTypeId)
176 throws PortalException {
177
178 return _baseCmisRepository.getFileEntriesCount(
179 folderId, fileEntryTypeId);
180 }
181
182 @Override
183 public int getFileEntriesCount(long folderId, String[] mimeTypes)
184 throws PortalException {
185
186 return _baseCmisRepository.getFileEntriesCount(folderId, mimeTypes);
187 }
188
189 @Override
190 public FileEntry getFileEntry(long fileEntryId) throws PortalException {
191 return _baseCmisRepository.getFileEntry(fileEntryId);
192 }
193
194 @Override
195 public FileEntry getFileEntry(long folderId, String title)
196 throws PortalException {
197
198 return _baseCmisRepository.getFileEntry(folderId, title);
199 }
200
201 @Override
202 public FileEntry getFileEntryByUuid(String uuid) throws PortalException {
203 return _baseCmisRepository.getFileEntryByUuid(uuid);
204 }
205
206 @Override
207 public FileVersion getFileVersion(long fileVersionId)
208 throws PortalException {
209
210 return _baseCmisRepository.getFileVersion(fileVersionId);
211 }
212
213 @Override
214 public Folder getFolder(long folderId) throws PortalException {
215 return _baseCmisRepository.getFolder(folderId);
216 }
217
218 @Override
219 public Folder getFolder(long parentFolderId, String name)
220 throws PortalException {
221
222 return _baseCmisRepository.getFolder(parentFolderId, name);
223 }
224
225 @Override
226 public List<Folder> getFolders(
227 long parentFolderId, boolean includeMountfolders, int start,
228 int end, OrderByComparator<Folder> obc)
229 throws PortalException {
230
231 return _baseCmisRepository.getFolders(
232 parentFolderId, includeMountfolders, start, end, obc);
233 }
234
235 @Override
236 public List<Object> getFoldersAndFileEntries(
237 long folderId, int start, int end, OrderByComparator<?> obc) {
238
239 return _baseCmisRepository.getFoldersAndFileEntries(
240 folderId, start, end, obc);
241 }
242
243 @Override
244 public List<Object> getFoldersAndFileEntries(
245 long folderId, String[] mimeTypes, int start, int end,
246 OrderByComparator<?> obc)
247 throws PortalException {
248
249 return _baseCmisRepository.getFoldersAndFileEntries(
250 folderId, mimeTypes, start, end, obc);
251 }
252
253 @Override
254 public int getFoldersAndFileEntriesCount(long folderId) {
255 return _baseCmisRepository.getFoldersAndFileEntriesCount(folderId);
256 }
257
258 @Override
259 public int getFoldersAndFileEntriesCount(long folderId, String[] mimeTypes)
260 throws PortalException {
261
262 return _baseCmisRepository.getFoldersAndFileEntriesCount(
263 folderId, mimeTypes);
264 }
265
266 @Override
267 public int getFoldersCount(long parentFolderId, boolean includeMountfolders)
268 throws PortalException {
269
270 return _baseCmisRepository.getFoldersCount(
271 parentFolderId, includeMountfolders);
272 }
273
274 @Override
275 public int getFoldersFileEntriesCount(List<Long> folderIds, int status)
276 throws PortalException {
277
278 return _baseCmisRepository.getFoldersFileEntriesCount(
279 folderIds, status);
280 }
281
282 public String getLatestVersionId(String objectId) {
283 return _baseCmisRepository.getLatestVersionId(objectId);
284 }
285
286 public String getLogin() {
287 String login = PrincipalThreadLocal.getName();
288
289 if (Validator.isNull(login)) {
290 return login;
291 }
292
293 try {
294 Company company = companyLocalService.getCompany(getCompanyId());
295
296 String authType = company.getAuthType();
297
298 if (!authType.equals(CompanyConstants.AUTH_TYPE_ID)) {
299 User user = userLocalService.getUser(GetterUtil.getLong(login));
300
301 if (authType.equals(CompanyConstants.AUTH_TYPE_EA)) {
302 login = user.getEmailAddress();
303 }
304 else if (authType.equals(CompanyConstants.AUTH_TYPE_SN)) {
305 login = user.getScreenName();
306 }
307 }
308 }
309 catch (Exception e) {
310 throw new RepositoryException(e);
311 }
312
313 return login;
314 }
315
316 @Override
317 public List<Folder> getMountFolders(
318 long parentFolderId, int start, int end,
319 OrderByComparator<Folder> obc)
320 throws PortalException {
321
322 return _baseCmisRepository.getMountFolders(
323 parentFolderId, start, end, obc);
324 }
325
326 @Override
327 public int getMountFoldersCount(long parentFolderId)
328 throws PortalException {
329
330 return _baseCmisRepository.getMountFoldersCount(parentFolderId);
331 }
332
333 public String getObjectName(String objectId) throws PortalException {
334 return _baseCmisRepository.getObjectName(objectId);
335 }
336
337 public List<String> getObjectPaths(String objectId) throws PortalException {
338 return _baseCmisRepository.getObjectPaths(objectId);
339 }
340
341 public abstract Session getSession() throws PortalException;
342
343 @Override
344 public void getSubfolderIds(List<Long> folderIds, long folderId)
345 throws PortalException {
346
347 _baseCmisRepository.getSubfolderIds(folderIds, folderId);
348 }
349
350 @Override
351 public List<Long> getSubfolderIds(long folderId, boolean recurse)
352 throws PortalException {
353
354 return _baseCmisRepository.getSubfolderIds(folderId, recurse);
355 }
356
357 @Override
358 public void initRepository() throws PortalException {
359 _baseCmisRepository.initRepository();
360 }
361
362 public boolean isCancelCheckOutAllowable(String objectId)
363 throws PortalException {
364
365 return _baseCmisRepository.isCancelCheckOutAllowable(objectId);
366 }
367
368 public boolean isCheckInAllowable(String objectId) throws PortalException {
369 return _baseCmisRepository.isCheckInAllowable(objectId);
370 }
371
372 public boolean isCheckOutAllowable(String objectId) throws PortalException {
373 return _baseCmisRepository.isCheckOutAllowable(objectId);
374 }
375
376 public boolean isDocumentRetrievableByVersionSeriesId() {
377 return true;
378 }
379
380 public boolean isRefreshBeforePermissionCheck() {
381 return false;
382 }
383
384 public boolean isSupportsMinorVersions(String productName) {
385
386
387
388 productName = StringUtil.toLowerCase(productName);
389
390 if (productName.contains("filenet") && productName.contains("p8")) {
391 return false;
392 }
393 else {
394 return true;
395 }
396 }
397
398 @Override
399 public Lock lockFolder(long folderId) throws PortalException {
400 return _baseCmisRepository.lockFolder(folderId);
401 }
402
403 @Override
404 public Lock lockFolder(
405 long folderId, String owner, boolean inheritable,
406 long expirationTime)
407 throws PortalException {
408
409 return _baseCmisRepository.lockFolder(
410 folderId, owner, inheritable, expirationTime);
411 }
412
413 @Override
414 public FileEntry moveFileEntry(
415 long userId, long fileEntryId, long newFolderId,
416 ServiceContext serviceContext)
417 throws PortalException {
418
419 return _baseCmisRepository.moveFileEntry(
420 userId, fileEntryId, newFolderId, serviceContext);
421 }
422
423 @Override
424 public Folder moveFolder(
425 long userId, long folderId, long newParentFolderId,
426 ServiceContext serviceContext)
427 throws PortalException {
428
429 return _baseCmisRepository.moveFolder(
430 userId, folderId, newParentFolderId, serviceContext);
431 }
432
433 @Override
434 public Lock refreshFileEntryLock(
435 String lockUuid, long companyId, long expirationTime)
436 throws PortalException {
437
438 return _baseCmisRepository.refreshFileEntryLock(
439 lockUuid, companyId, expirationTime);
440 }
441
442 @Override
443 public Lock refreshFolderLock(
444 String lockUuid, long companyId, long expirationTime)
445 throws PortalException {
446
447 return _baseCmisRepository.refreshFolderLock(
448 lockUuid, companyId, expirationTime);
449 }
450
451 @Override
452 public void revertFileEntry(
453 long userId, long fileEntryId, String version,
454 ServiceContext serviceContext)
455 throws PortalException {
456
457 _baseCmisRepository.revertFileEntry(
458 userId, fileEntryId, version, serviceContext);
459 }
460
461 @Override
462 public Hits search(long creatorUserId, int status, int start, int end)
463 throws PortalException {
464
465 return _baseCmisRepository.search(creatorUserId, status, start, end);
466 }
467
468 @Override
469 public Hits search(
470 long creatorUserId, long folderId, String[] mimeTypes, int status,
471 int start, int end)
472 throws PortalException {
473
474 return _baseCmisRepository.search(
475 creatorUserId, folderId, mimeTypes, status, start, end);
476 }
477
478 @Override
479 public Hits search(SearchContext searchContext) throws SearchException {
480 return _baseCmisRepository.search(searchContext);
481 }
482
483 @Override
484 public Hits search(SearchContext searchContext, Query query)
485 throws SearchException {
486
487 return _baseCmisRepository.search(searchContext, query);
488 }
489
490 public void setCmisRepository(BaseCmisRepository baseCmisRepository) {
491 _baseCmisRepository = baseCmisRepository;
492 }
493
494 public FileEntry toFileEntry(String objectId) throws PortalException {
495 return _baseCmisRepository.toFileEntry(objectId);
496 }
497
498 public Folder toFolder(String objectId) throws PortalException {
499 return _baseCmisRepository.toFolder(objectId);
500 }
501
502 @Override
503 public void unlockFolder(long folderId, String lockUuid)
504 throws PortalException {
505
506 _baseCmisRepository.unlockFolder(folderId, lockUuid);
507 }
508
509 @Override
510 public FileEntry updateFileEntry(
511 long userId, long fileEntryId, String sourceFileName,
512 String mimeType, String title, String description, String changeLog,
513 boolean majorVersion, InputStream is, long size,
514 ServiceContext serviceContext)
515 throws PortalException {
516
517 return _baseCmisRepository.updateFileEntry(
518 userId, fileEntryId, sourceFileName, mimeType, title, description,
519 changeLog, majorVersion, is, size, serviceContext);
520 }
521
522 public FileEntry updateFileEntry(
523 String objectId, String mimeType, Map<String, Object> properties,
524 InputStream is, String sourceFileName, long size,
525 ServiceContext serviceContext)
526 throws PortalException {
527
528 return _baseCmisRepository.updateFileEntry(
529 objectId, mimeType, properties, is, sourceFileName, size,
530 serviceContext);
531 }
532
533 @Override
534 public Folder updateFolder(
535 long folderId, String name, String description,
536 ServiceContext serviceContext)
537 throws PortalException {
538
539 return _baseCmisRepository.updateFolder(
540 folderId, name, description, serviceContext);
541 }
542
543 @Override
544 public boolean verifyFileEntryCheckOut(long fileEntryId, String lockUuid)
545 throws PortalException {
546
547 return _baseCmisRepository.verifyFileEntryCheckOut(
548 fileEntryId, lockUuid);
549 }
550
551 @Override
552 public boolean verifyInheritableLock(long folderId, String lockUuid)
553 throws PortalException {
554
555 return _baseCmisRepository.verifyInheritableLock(folderId, lockUuid);
556 }
557
558 private BaseCmisRepository _baseCmisRepository;
559
560 }