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