PageRenderTime 46ms CodeModel.GetById 17ms RepoModel.GetById 1ms app.codeStats 0ms

/portal-service/src/com/liferay/portal/kernel/repository/cmis/CMISRepositoryHandler.java

https://github.com/lululiferay/liferay-portal
Java | 521 lines | 372 code | 132 blank | 17 comment | 8 complexity | c52d124db3ee6514e275e84d9e684c6b MD5 | raw file
  1. /**
  2. * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
  3. *
  4. * This library is free software; you can redistribute it and/or modify it under
  5. * the terms of the GNU Lesser General Public License as published by the Free
  6. * Software Foundation; either version 2.1 of the License, or (at your option)
  7. * any later version.
  8. *
  9. * This library is distributed in the hope that it will be useful, but WITHOUT
  10. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  11. * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
  12. * details.
  13. */
  14. package com.liferay.portal.kernel.repository.cmis;
  15. import com.liferay.portal.kernel.exception.PortalException;
  16. import com.liferay.portal.kernel.exception.SystemException;
  17. import com.liferay.portal.kernel.repository.BaseRepository;
  18. import com.liferay.portal.kernel.repository.BaseRepositoryImpl;
  19. import com.liferay.portal.kernel.repository.RepositoryException;
  20. import com.liferay.portal.kernel.repository.model.FileEntry;
  21. import com.liferay.portal.kernel.repository.model.FileVersion;
  22. import com.liferay.portal.kernel.repository.model.Folder;
  23. import com.liferay.portal.kernel.search.Hits;
  24. import com.liferay.portal.kernel.search.Query;
  25. import com.liferay.portal.kernel.search.SearchContext;
  26. import com.liferay.portal.kernel.search.SearchException;
  27. import com.liferay.portal.kernel.util.GetterUtil;
  28. import com.liferay.portal.kernel.util.OrderByComparator;
  29. import com.liferay.portal.kernel.util.Validator;
  30. import com.liferay.portal.model.CompanyConstants;
  31. import com.liferay.portal.model.Lock;
  32. import com.liferay.portal.model.User;
  33. import com.liferay.portal.security.auth.PrincipalThreadLocal;
  34. import com.liferay.portal.service.ServiceContext;
  35. import java.io.InputStream;
  36. import java.util.List;
  37. import java.util.Map;
  38. /**
  39. * @author Alexander Chow
  40. */
  41. public abstract class CMISRepositoryHandler extends BaseRepositoryImpl {
  42. public FileEntry addFileEntry(
  43. long folderId, String sourceFileName, String mimeType, String title,
  44. String description, String changeLog, InputStream is, long size,
  45. ServiceContext serviceContext)
  46. throws PortalException, SystemException {
  47. return _baseCmisRepository.addFileEntry(
  48. folderId, sourceFileName, mimeType, title, description, changeLog,
  49. is, size, serviceContext);
  50. }
  51. public Folder addFolder(
  52. long parentFolderId, String title, String description,
  53. ServiceContext serviceContext)
  54. throws PortalException, SystemException {
  55. return _baseCmisRepository.addFolder(
  56. parentFolderId, title, description, serviceContext);
  57. }
  58. public FileVersion cancelCheckOut(long fileEntryId)
  59. throws PortalException, SystemException {
  60. return _baseCmisRepository.cancelCheckOut(fileEntryId);
  61. }
  62. public void checkInFileEntry(
  63. long fileEntryId, boolean major, String changeLog,
  64. ServiceContext serviceContext)
  65. throws PortalException, SystemException {
  66. _baseCmisRepository.checkInFileEntry(
  67. fileEntryId, major, changeLog, serviceContext);
  68. }
  69. public void checkInFileEntry(long fileEntryId, String lockUuid)
  70. throws PortalException, SystemException {
  71. _baseCmisRepository.checkInFileEntry(fileEntryId, lockUuid);
  72. }
  73. public FileEntry checkOutFileEntry(
  74. long fileEntryId, ServiceContext serviceContext)
  75. throws PortalException, SystemException {
  76. return _baseCmisRepository.checkOutFileEntry(
  77. fileEntryId, serviceContext);
  78. }
  79. public FileEntry checkOutFileEntry(
  80. long fileEntryId, String owner, long expirationTime,
  81. ServiceContext serviceContext)
  82. throws PortalException, SystemException {
  83. return _baseCmisRepository.checkOutFileEntry(
  84. fileEntryId, owner, expirationTime, serviceContext);
  85. }
  86. public FileEntry copyFileEntry(
  87. long groupId, long fileEntryId, long destFolderId,
  88. ServiceContext serviceContext)
  89. throws PortalException, SystemException {
  90. return _baseCmisRepository.copyFileEntry(
  91. groupId, fileEntryId, destFolderId, serviceContext);
  92. }
  93. public void deleteFileEntry(long fileEntryId)
  94. throws PortalException, SystemException {
  95. _baseCmisRepository.deleteFileEntry(fileEntryId);
  96. }
  97. public void deleteFolder(long folderId)
  98. throws PortalException, SystemException {
  99. _baseCmisRepository.deleteFolder(folderId);
  100. }
  101. public BaseRepository getCmisRepository() {
  102. return _baseCmisRepository;
  103. }
  104. public List<FileEntry> getFileEntries(
  105. long folderId, int start, int end, OrderByComparator obc)
  106. throws SystemException {
  107. return _baseCmisRepository.getFileEntries(folderId, start, end, obc);
  108. }
  109. public List<FileEntry> getFileEntries(
  110. long folderId, long fileEntryTypeId, int start, int end,
  111. OrderByComparator obc)
  112. throws SystemException {
  113. return _baseCmisRepository.getFileEntries(
  114. folderId, fileEntryTypeId, start, end, obc);
  115. }
  116. public List<FileEntry> getFileEntries(
  117. long folderId, String[] mimeTypes, int start, int end,
  118. OrderByComparator obc)
  119. throws PortalException, SystemException {
  120. return _baseCmisRepository.getFileEntries(
  121. folderId, mimeTypes, start, end, obc);
  122. }
  123. public int getFileEntriesCount(long folderId) throws SystemException {
  124. return _baseCmisRepository.getFileEntriesCount(folderId);
  125. }
  126. public int getFileEntriesCount(long folderId, long fileEntryTypeId)
  127. throws SystemException {
  128. return _baseCmisRepository.getFileEntriesCount(
  129. folderId, fileEntryTypeId);
  130. }
  131. public int getFileEntriesCount(long folderId, String[] mimeTypes)
  132. throws PortalException, SystemException {
  133. return _baseCmisRepository.getFileEntriesCount(folderId, mimeTypes);
  134. }
  135. public FileEntry getFileEntry(long fileEntryId)
  136. throws PortalException, SystemException {
  137. return _baseCmisRepository.getFileEntry(fileEntryId);
  138. }
  139. public FileEntry getFileEntry(long folderId, String title)
  140. throws PortalException, SystemException {
  141. return _baseCmisRepository.getFileEntry(folderId, title);
  142. }
  143. public FileEntry getFileEntryByUuid(String uuid)
  144. throws PortalException, SystemException {
  145. return _baseCmisRepository.getFileEntryByUuid(uuid);
  146. }
  147. public FileVersion getFileVersion(long fileVersionId)
  148. throws PortalException, SystemException {
  149. return _baseCmisRepository.getFileVersion(fileVersionId);
  150. }
  151. public Folder getFolder(long folderId)
  152. throws PortalException, SystemException {
  153. return _baseCmisRepository.getFolder(folderId);
  154. }
  155. public Folder getFolder(long parentFolderId, String title)
  156. throws PortalException, SystemException {
  157. return _baseCmisRepository.getFolder(parentFolderId, title);
  158. }
  159. public List<Folder> getFolders(
  160. long parentFolderId, boolean includeMountfolders, int start,
  161. int end, OrderByComparator obc)
  162. throws PortalException, SystemException {
  163. return _baseCmisRepository.getFolders(
  164. parentFolderId, includeMountfolders, start, end, obc);
  165. }
  166. @Override
  167. public List<Object> getFoldersAndFileEntries(
  168. long folderId, int start, int end, OrderByComparator obc)
  169. throws SystemException {
  170. return _baseCmisRepository.getFoldersAndFileEntries(
  171. folderId, start, end, obc);
  172. }
  173. @Override
  174. public List<Object> getFoldersAndFileEntries(
  175. long folderId, String[] mimeTypes, int start, int end,
  176. OrderByComparator obc)
  177. throws PortalException, SystemException {
  178. return _baseCmisRepository.getFoldersAndFileEntries(
  179. folderId, mimeTypes, start, end, obc);
  180. }
  181. @Override
  182. public int getFoldersAndFileEntriesCount(long folderId)
  183. throws SystemException {
  184. return _baseCmisRepository.getFoldersAndFileEntriesCount(folderId);
  185. }
  186. @Override
  187. public int getFoldersAndFileEntriesCount(long folderId, String[] mimeTypes)
  188. throws PortalException, SystemException {
  189. return _baseCmisRepository.getFoldersAndFileEntriesCount(
  190. folderId, mimeTypes);
  191. }
  192. public int getFoldersCount(long parentFolderId, boolean includeMountfolders)
  193. throws PortalException, SystemException {
  194. return _baseCmisRepository.getFoldersCount(
  195. parentFolderId, includeMountfolders);
  196. }
  197. public int getFoldersFileEntriesCount(List<Long> folderIds, int status)
  198. throws SystemException {
  199. return _baseCmisRepository.getFoldersFileEntriesCount(
  200. folderIds, status);
  201. }
  202. public String getLatestVersionId(String objectId) throws SystemException {
  203. return _baseCmisRepository.getLatestVersionId(objectId);
  204. }
  205. public String getLogin() throws SystemException {
  206. String login = PrincipalThreadLocal.getName();
  207. if (Validator.isNull(login)) {
  208. return login;
  209. }
  210. try {
  211. String authType = companyLocalService.getCompany(
  212. getCompanyId()).getAuthType();
  213. if (!authType.equals(CompanyConstants.AUTH_TYPE_ID)) {
  214. User user = userLocalService.getUser(GetterUtil.getLong(login));
  215. if (authType.equals(CompanyConstants.AUTH_TYPE_EA)) {
  216. login = user.getEmailAddress();
  217. }
  218. else if (authType.equals(CompanyConstants.AUTH_TYPE_SN)) {
  219. login = user.getScreenName();
  220. }
  221. }
  222. }
  223. catch (Exception e) {
  224. throw new RepositoryException(e);
  225. }
  226. return login;
  227. }
  228. public List<Folder> getMountFolders(
  229. long parentFolderId, int start, int end, OrderByComparator obc)
  230. throws SystemException {
  231. return _baseCmisRepository.getMountFolders(
  232. parentFolderId, start, end, obc);
  233. }
  234. public int getMountFoldersCount(long parentFolderId)
  235. throws SystemException {
  236. return _baseCmisRepository.getMountFoldersCount(parentFolderId);
  237. }
  238. public String getObjectName(String objectId)
  239. throws PortalException, SystemException {
  240. return _baseCmisRepository.getObjectName(objectId);
  241. }
  242. public List<String> getObjectPaths(String objectId)
  243. throws PortalException, SystemException {
  244. return _baseCmisRepository.getObjectPaths(objectId);
  245. }
  246. public abstract Session getSession()
  247. throws PortalException, SystemException;
  248. public void getSubfolderIds(List<Long> folderIds, long folderId)
  249. throws SystemException {
  250. _baseCmisRepository.getSubfolderIds(folderIds, folderId);
  251. }
  252. public List<Long> getSubfolderIds(long folderId, boolean recurse)
  253. throws SystemException {
  254. return _baseCmisRepository.getSubfolderIds(folderId, recurse);
  255. }
  256. @Override
  257. public void initRepository() throws PortalException, SystemException {
  258. _baseCmisRepository.initRepository();
  259. }
  260. public boolean isCancelCheckOutAllowable(String objectId)
  261. throws PortalException, SystemException {
  262. return _baseCmisRepository.isCancelCheckOutAllowable(objectId);
  263. }
  264. public boolean isCheckInAllowable(String objectId)
  265. throws PortalException, SystemException {
  266. return _baseCmisRepository.isCheckInAllowable(objectId);
  267. }
  268. public boolean isCheckOutAllowable(String objectId)
  269. throws PortalException, SystemException {
  270. return _baseCmisRepository.isCheckOutAllowable(objectId);
  271. }
  272. public boolean isDocumentRetrievableByVersionSeriesId() {
  273. return true;
  274. }
  275. public boolean isRefreshBeforePermissionCheck() {
  276. return false;
  277. }
  278. public boolean isSupportsMinorVersions(String productName) {
  279. // LPS-20509
  280. productName = productName.toLowerCase();
  281. if (productName.contains("filenet") && productName.contains("p8")) {
  282. return false;
  283. }
  284. else {
  285. return true;
  286. }
  287. }
  288. public Lock lockFolder(long folderId)
  289. throws PortalException, SystemException {
  290. return _baseCmisRepository.lockFolder(folderId);
  291. }
  292. public Lock lockFolder(
  293. long folderId, String owner, boolean inheritable,
  294. long expirationTime)
  295. throws PortalException, SystemException {
  296. return _baseCmisRepository.lockFolder(
  297. folderId, owner, inheritable, expirationTime);
  298. }
  299. public FileEntry moveFileEntry(
  300. long fileEntryId, long newFolderId, ServiceContext serviceContext)
  301. throws PortalException, SystemException {
  302. return _baseCmisRepository.moveFileEntry(
  303. fileEntryId, newFolderId, serviceContext);
  304. }
  305. public Folder moveFolder(
  306. long folderId, long newParentFolderId,
  307. ServiceContext serviceContext)
  308. throws PortalException, SystemException {
  309. return _baseCmisRepository.moveFolder(
  310. folderId, newParentFolderId, serviceContext);
  311. }
  312. public Lock refreshFileEntryLock(
  313. String lockUuid, long companyId, long expirationTime)
  314. throws PortalException, SystemException {
  315. return _baseCmisRepository.refreshFileEntryLock(
  316. lockUuid, companyId, expirationTime);
  317. }
  318. public Lock refreshFolderLock(
  319. String lockUuid, long companyId, long expirationTime)
  320. throws PortalException, SystemException {
  321. return _baseCmisRepository.refreshFolderLock(
  322. lockUuid, companyId, expirationTime);
  323. }
  324. public void revertFileEntry(
  325. long fileEntryId, String version, ServiceContext serviceContext)
  326. throws PortalException, SystemException {
  327. _baseCmisRepository.revertFileEntry(
  328. fileEntryId, version, serviceContext);
  329. }
  330. @Override
  331. public Hits search(SearchContext searchContext) throws SearchException {
  332. return _baseCmisRepository.search(searchContext);
  333. }
  334. public Hits search(SearchContext searchContext, Query query)
  335. throws SearchException {
  336. return _baseCmisRepository.search(searchContext, query);
  337. }
  338. public void setCmisRepository(BaseCmisRepository baseCmisRepository) {
  339. _baseCmisRepository = baseCmisRepository;
  340. }
  341. public FileEntry toFileEntry(String objectId)
  342. throws PortalException, SystemException {
  343. return _baseCmisRepository.toFileEntry(objectId);
  344. }
  345. public Folder toFolder(String objectId)
  346. throws PortalException, SystemException {
  347. return _baseCmisRepository.toFolder(objectId);
  348. }
  349. public void unlockFolder(long folderId, String lockUuid)
  350. throws PortalException, SystemException {
  351. _baseCmisRepository.unlockFolder(folderId, lockUuid);
  352. }
  353. public FileEntry updateFileEntry(
  354. long fileEntryId, String sourceFileName, String mimeType,
  355. String title, String description, String changeLog,
  356. boolean majorVersion, InputStream is, long size,
  357. ServiceContext serviceContext)
  358. throws PortalException, SystemException {
  359. return _baseCmisRepository.updateFileEntry(
  360. fileEntryId, sourceFileName, mimeType, title, description,
  361. changeLog, majorVersion, is, size, serviceContext);
  362. }
  363. public FileEntry updateFileEntry(
  364. String objectId, String mimeType, Map<String, Object> properties,
  365. InputStream is, String sourceFileName, long size,
  366. ServiceContext serviceContext)
  367. throws PortalException, SystemException {
  368. return _baseCmisRepository.updateFileEntry(
  369. objectId, mimeType, properties, is, sourceFileName, size,
  370. serviceContext);
  371. }
  372. public Folder updateFolder(
  373. long folderId, String title, String description,
  374. ServiceContext serviceContext)
  375. throws PortalException, SystemException {
  376. return _baseCmisRepository.updateFolder(
  377. folderId, title, description, serviceContext);
  378. }
  379. public boolean verifyFileEntryCheckOut(long fileEntryId, String lockUuid)
  380. throws PortalException, SystemException {
  381. return _baseCmisRepository.verifyFileEntryCheckOut(
  382. fileEntryId, lockUuid);
  383. }
  384. public boolean verifyInheritableLock(long folderId, String lockUuid)
  385. throws PortalException, SystemException {
  386. return _baseCmisRepository.verifyInheritableLock(folderId, lockUuid);
  387. }
  388. private BaseCmisRepository _baseCmisRepository;
  389. }