--- /dev/null
+/**\r
+ * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.\r
+ *\r
+ * This library is free software; you can redistribute it and/or modify it under\r
+ * the terms of the GNU Lesser General Public License as published by the Free\r
+ * Software Foundation; either version 2.1 of the License, or (at your option)\r
+ * any later version.\r
+ *\r
+ * This library is distributed in the hope that it will be useful, but WITHOUT\r
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\r
+ * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more\r
+ * details.\r
+ */\r
+\r
+package com.liferay.portlet.documentlibrary.service.impl;\r
+\r
+import com.liferay.portal.kernel.exception.PortalException;\r
+import com.liferay.portal.kernel.exception.SystemException;\r
+import com.liferay.portal.kernel.json.JSONFactoryUtil;\r
+import com.liferay.portal.kernel.json.JSONObject;\r
+import com.liferay.portal.kernel.repository.model.FileEntry;\r
+import com.liferay.portal.kernel.repository.model.FileVersion;\r
+import com.liferay.portal.kernel.repository.model.Folder;\r
+import com.liferay.portal.kernel.util.ListUtil;\r
+import com.liferay.portal.kernel.util.StringUtil;\r
+import com.liferay.portal.kernel.util.Validator;\r
+import com.liferay.portal.kernel.workflow.WorkflowConstants;\r
+import com.liferay.portal.kernel.workflow.WorkflowHandlerRegistryUtil;\r
+import com.liferay.portal.model.Group;\r
+import com.liferay.portal.repository.liferayrepository.model.LiferayFileEntry;\r
+import com.liferay.portal.repository.liferayrepository.model.LiferayFileVersion;\r
+import com.liferay.portal.service.ServiceContext;\r
+import com.liferay.portal.spring.transaction.TransactionCommitCallbackUtil;\r
+import com.liferay.portal.util.PropsValues;\r
+import com.liferay.portlet.asset.NoSuchEntryException;\r
+import com.liferay.portlet.asset.model.AssetEntry;\r
+import com.liferay.portlet.asset.model.AssetLink;\r
+import com.liferay.portlet.asset.model.AssetLinkConstants;\r
+import com.liferay.portlet.documentlibrary.model.DLFileEntry;\r
+import com.liferay.portlet.documentlibrary.model.DLFileEntryConstants;\r
+import com.liferay.portlet.documentlibrary.model.DLFileShortcut;\r
+import com.liferay.portlet.documentlibrary.model.DLFileVersion;\r
+import com.liferay.portlet.documentlibrary.model.DLSyncConstants;\r
+import com.liferay.portlet.documentlibrary.service.base.DLAppHelperLocalServiceBaseImpl;\r
+import com.liferay.portlet.documentlibrary.social.DLActivityKeys;\r
+import com.liferay.portlet.documentlibrary.util.DLProcessorRegistryUtil;\r
+\r
+import java.io.Serializable;\r
+\r
+import java.util.HashMap;\r
+import java.util.List;\r
+import java.util.Map;\r
+import java.util.concurrent.Callable;\r
+\r
+/**\r
+ * @author Alexander Chow\r
+ */\r
+public class DLAppHelperLocalServiceImpl\r
+ extends DLAppHelperLocalServiceBaseImpl {\r
+\r
+ public void addFileEntry(\r
+ long userId, FileEntry fileEntry, FileVersion fileVersion,\r
+ ServiceContext serviceContext)\r
+ throws PortalException, SystemException {\r
+\r
+ updateAsset(\r
+ userId, fileEntry, fileVersion,\r
+ serviceContext.getAssetCategoryIds(),\r
+ serviceContext.getAssetTagNames(),\r
+ serviceContext.getAssetLinkEntryIds());\r
+\r
+ if (PropsValues.DL_FILE_ENTRY_COMMENTS_ENABLED) {\r
+ mbMessageLocalService.addDiscussionMessage(\r
+ fileEntry.getUserId(), fileEntry.getUserName(),\r
+ fileEntry.getGroupId(), DLFileEntryConstants.getClassName(),\r
+ fileEntry.getFileEntryId(), WorkflowConstants.ACTION_PUBLISH);\r
+ }\r
+\r
+ if (fileVersion instanceof LiferayFileVersion) {\r
+ DLFileVersion dlFileVersion = (DLFileVersion)fileVersion.getModel();\r
+\r
+ Map<String, Serializable> workflowContext =\r
+ new HashMap<String, Serializable>();\r
+\r
+ workflowContext.put("event", DLSyncConstants.EVENT_ADD);\r
+\r
+ WorkflowHandlerRegistryUtil.startWorkflowInstance(\r
+ dlFileVersion.getCompanyId(), dlFileVersion.getGroupId(),\r
+ userId, DLFileEntryConstants.getClassName(),\r
+ dlFileVersion.getFileVersionId(), dlFileVersion, serviceContext,\r
+ workflowContext);\r
+ }\r
+\r
+ registerDLProcessorCallback(fileEntry);\r
+ }\r
+\r
+ public void addFolder(Folder folder, ServiceContext serviceContext)\r
+ throws PortalException, SystemException {\r
+\r
+ if (!isStagingGroup(folder.getGroupId())) {\r
+ dlSyncLocalService.addSync(\r
+ folder.getFolderId(), folder.getUuid(), folder.getCompanyId(),\r
+ folder.getRepositoryId(), folder.getParentFolderId(),\r
+ folder.getName(), folder.getDescription(),\r
+ DLSyncConstants.TYPE_FOLDER, "-1");\r
+ }\r
+ }\r
+\r
+ public void cancelCheckOut(\r
+ long userId, FileEntry fileEntry,\r
+ FileVersion destinationFileVersion, FileVersion draftFileVersion,\r
+ ServiceContext serviceContext)\r
+ throws PortalException, SystemException {\r
+\r
+ updateFileEntry(\r
+ userId, fileEntry, destinationFileVersion, serviceContext);\r
+\r
+ if (draftFileVersion == null) {\r
+ return;\r
+ }\r
+\r
+ AssetEntry draftAssetEntry = null;\r
+\r
+ try {\r
+ draftAssetEntry = assetEntryLocalService.getEntry(\r
+ DLFileEntryConstants.getClassName(),\r
+ draftFileVersion.getPrimaryKey());\r
+\r
+ assetEntryLocalService.deleteEntry(draftAssetEntry.getEntryId());\r
+ }\r
+ catch (NoSuchEntryException nsee) {\r
+ }\r
+ }\r
+\r
+ public void checkAssetEntry(\r
+ long userId, FileEntry fileEntry, FileVersion fileVersion)\r
+ throws PortalException, SystemException {\r
+\r
+ AssetEntry fileEntryAssetEntry = assetEntryLocalService.fetchEntry(\r
+ DLFileEntryConstants.getClassName(), fileEntry.getFileEntryId());\r
+\r
+ long[] assetCategoryIds = new long[0];\r
+ String[] assetTagNames = new String[0];\r
+\r
+ long fileEntryTypeId = getFileEntryTypeId(fileEntry);\r
+\r
+ if (fileEntryAssetEntry == null) {\r
+ fileEntryAssetEntry = assetEntryLocalService.updateEntry(\r
+ userId, fileEntry.getGroupId(),\r
+ DLFileEntryConstants.getClassName(), fileEntry.getFileEntryId(),\r
+ fileEntry.getUuid(), fileEntryTypeId, assetCategoryIds,\r
+ assetTagNames, false, null, null, null, null,\r
+ fileEntry.getMimeType(), fileEntry.getTitle(),\r
+ fileEntry.getDescription(), null, null, null, 0, 0, null,\r
+ false);\r
+ }\r
+\r
+ AssetEntry fileVersionAssetEntry = assetEntryLocalService.fetchEntry(\r
+ DLFileEntryConstants.getClassName(),\r
+ fileVersion.getFileVersionId());\r
+\r
+ if ((fileVersionAssetEntry == null) && !fileVersion.isApproved() &&\r
+ !fileVersion.getVersion().equals(\r
+ DLFileEntryConstants.VERSION_DEFAULT)) {\r
+\r
+ assetCategoryIds = assetCategoryLocalService.getCategoryIds(\r
+ DLFileEntryConstants.getClassName(),\r
+ fileEntry.getFileEntryId());\r
+ assetTagNames = assetTagLocalService.getTagNames(\r
+ DLFileEntryConstants.getClassName(),\r
+ fileEntry.getFileEntryId());\r
+\r
+ fileVersionAssetEntry = assetEntryLocalService.updateEntry(\r
+ userId, fileEntry.getGroupId(),\r
+ DLFileEntryConstants.getClassName(),\r
+ fileVersion.getFileVersionId(), fileEntry.getUuid(),\r
+ fileEntryTypeId, assetCategoryIds, assetTagNames, false, null,\r
+ null, null, null, fileEntry.getMimeType(), fileEntry.getTitle(),\r
+ fileEntry.getDescription(), null, null, null, 0, 0, null,\r
+ false);\r
+\r
+ List<AssetLink> assetLinks = assetLinkLocalService.getDirectLinks(\r
+ fileEntryAssetEntry.getEntryId());\r
+\r
+ long[] assetLinkIds = StringUtil.split(\r
+ ListUtil.toString(assetLinks, AssetLink.ENTRY_ID2_ACCESSOR),\r
+ 0L);\r
+\r
+ assetLinkLocalService.updateLinks(\r
+ userId, fileVersionAssetEntry.getEntryId(), assetLinkIds,\r
+ AssetLinkConstants.TYPE_RELATED);\r
+ }\r
+ }\r
+\r
+ public void deleteFileEntry(FileEntry fileEntry)\r
+ throws PortalException, SystemException {\r
+\r
+ // Subscriptions\r
+\r
+ subscriptionLocalService.deleteSubscriptions(\r
+ fileEntry.getCompanyId(), DLFileEntryConstants.getClassName(),\r
+ fileEntry.getFileEntryId());\r
+\r
+ // File previews\r
+\r
+ DLProcessorRegistryUtil.cleanUp(fileEntry);\r
+\r
+ // File ranks\r
+\r
+ dlFileRankLocalService.deleteFileRanksByFileEntryId(\r
+ fileEntry.getFileEntryId());\r
+\r
+ // File shortcuts\r
+\r
+ dlFileShortcutLocalService.deleteFileShortcuts(\r
+ fileEntry.getFileEntryId());\r
+\r
+ // Sync\r
+\r
+ if (!isStagingGroup(fileEntry.getGroupId())) {\r
+ dlSyncLocalService.updateSync(\r
+ fileEntry.getFileEntryId(), fileEntry.getFolderId(),\r
+ fileEntry.getTitle(), fileEntry.getDescription(),\r
+ DLSyncConstants.EVENT_DELETE, fileEntry.getVersion());\r
+ }\r
+\r
+ /* Slow the folder delete function. We clean this unused data thanks cron job\r
+ // Asset\r
+\r
+ assetEntryLocalService.deleteEntry(\r
+ DLFileEntryConstants.getClassName(), fileEntry.getFileEntryId());\r
+\r
+ // Message boards\r
+\r
+ mbMessageLocalService.deleteDiscussionMessages(\r
+ DLFileEntryConstants.getClassName(), fileEntry.getFileEntryId());\r
+ */\r
+ // Ratings\r
+\r
+ ratingsStatsLocalService.deleteStats(\r
+ DLFileEntryConstants.getClassName(), fileEntry.getFileEntryId());\r
+ }\r
+\r
+ public void deleteFolder(Folder folder)\r
+ throws PortalException, SystemException {\r
+\r
+ if (!isStagingGroup(folder.getGroupId())) {\r
+ dlSyncLocalService.updateSync(\r
+ folder.getFolderId(), folder.getParentFolderId(),\r
+ folder.getName(), folder.getDescription(),\r
+ DLSyncConstants.EVENT_DELETE, "-1");\r
+ }\r
+ }\r
+\r
+ public void getFileAsStream(\r
+ long userId, FileEntry fileEntry, boolean incrementCounter)\r
+ throws SystemException {\r
+\r
+ if (!incrementCounter) {\r
+ return;\r
+ }\r
+\r
+ // File rank\r
+\r
+ if (userId > 0) {\r
+ dlFileRankLocalService.updateFileRank(\r
+ fileEntry.getGroupId(), fileEntry.getCompanyId(), userId,\r
+ fileEntry.getFileEntryId(), new ServiceContext());\r
+ }\r
+\r
+ // File read count\r
+\r
+ assetEntryLocalService.incrementViewCounter(\r
+ userId, DLFileEntryConstants.getClassName(),\r
+ fileEntry.getFileEntryId(), 1);\r
+\r
+ List<DLFileShortcut> fileShortcuts =\r
+ dlFileShortcutPersistence.findByToFileEntryId(\r
+ fileEntry.getFileEntryId());\r
+\r
+ for (DLFileShortcut fileShortcut : fileShortcuts) {\r
+ assetEntryLocalService.incrementViewCounter(\r
+ userId, DLFileShortcut.class.getName(),\r
+ fileShortcut.getFileShortcutId(), 1);\r
+ }\r
+ }\r
+\r
+ public List<DLFileShortcut> getFileShortcuts(\r
+ long groupId, long folderId, int status)\r
+ throws SystemException {\r
+\r
+ return dlFileShortcutPersistence.findByG_F_S(groupId, folderId, status);\r
+ }\r
+\r
+ public int getFileShortcutsCount(long groupId, long folderId, int status)\r
+ throws SystemException {\r
+\r
+ return dlFileShortcutPersistence.countByG_F_S(\r
+ groupId, folderId, status);\r
+ }\r
+\r
+ public List<FileEntry> getNoAssetFileEntries() {\r
+ return null;\r
+ }\r
+\r
+ public void moveFileEntry(FileEntry fileEntry)\r
+ throws PortalException, SystemException {\r
+\r
+ if (!isStagingGroup(fileEntry.getGroupId())) {\r
+ dlSyncLocalService.updateSync(\r
+ fileEntry.getFileEntryId(), fileEntry.getFolderId(),\r
+ fileEntry.getTitle(), fileEntry.getDescription(),\r
+ DLSyncConstants.EVENT_UPDATE, fileEntry.getVersion());\r
+ }\r
+ }\r
+\r
+ public void moveFolder(Folder folder)\r
+ throws PortalException, SystemException {\r
+\r
+ if (!isStagingGroup(folder.getGroupId())) {\r
+ dlSyncLocalService.updateSync(\r
+ folder.getFolderId(), folder.getParentFolderId(), folder.getName(),\r
+ folder.getDescription(), DLSyncConstants.EVENT_UPDATE, "-1");\r
+ }\r
+ }\r
+\r
+ public AssetEntry updateAsset(\r
+ long userId, FileEntry fileEntry, FileVersion fileVersion,\r
+ long assetClassPk)\r
+ throws PortalException, SystemException {\r
+\r
+ long[] assetCategoryIds = new long[0];\r
+ try {\r
+ assetCategoryIds = assetCategoryLocalService.getCategoryIds(\r
+ DLFileEntryConstants.getClassName(), assetClassPk);\r
+ } catch (Exception e){\r
+ // No Such Asset Categories\r
+ }\r
+ \r
+ String[] assetTagNames = new String[0];\r
+ try {\r
+ assetTagNames = assetTagLocalService.getTagNames(\r
+ DLFileEntryConstants.getClassName(), assetClassPk);\r
+ } catch (Exception e){\r
+ // No Such Asset Tag Names\r
+ }\r
+\r
+ AssetEntry assetEntry = assetEntryLocalService.getEntry(\r
+ DLFileEntryConstants.getClassName(), assetClassPk);\r
+\r
+ List<AssetLink> assetLinks = assetLinkLocalService.getDirectLinks(\r
+ assetEntry.getEntryId());\r
+\r
+ long[] assetLinkIds = StringUtil.split(\r
+ ListUtil.toString(assetLinks, AssetLink.ENTRY_ID2_ACCESSOR), 0L);\r
+\r
+ return updateAsset(\r
+ userId, fileEntry, fileVersion, assetCategoryIds, assetTagNames,\r
+ assetLinkIds);\r
+ }\r
+\r
+ public AssetEntry updateAsset(\r
+ long userId, FileEntry fileEntry, FileVersion fileVersion,\r
+ long[] assetCategoryIds, String[] assetTagNames,\r
+ long[] assetLinkEntryIds)\r
+ throws PortalException, SystemException {\r
+\r
+ AssetEntry assetEntry = null;\r
+\r
+ boolean visible = false;\r
+\r
+ boolean addDraftAssetEntry = false;\r
+\r
+ if (fileEntry instanceof LiferayFileEntry) {\r
+ DLFileVersion dlFileVersion = (DLFileVersion)fileVersion.getModel();\r
+\r
+ if (dlFileVersion.isApproved()) {\r
+ visible = true;\r
+ }\r
+ else {\r
+ String version = dlFileVersion.getVersion();\r
+\r
+ if (!version.equals(DLFileEntryConstants.VERSION_DEFAULT)) {\r
+ addDraftAssetEntry = true;\r
+ }\r
+ }\r
+ }\r
+ else {\r
+ visible = true;\r
+ }\r
+\r
+ long fileEntryTypeId = getFileEntryTypeId(fileEntry);\r
+\r
+ if (addDraftAssetEntry) {\r
+ assetEntry = assetEntryLocalService.updateEntry(\r
+ userId, fileEntry.getGroupId(),\r
+ DLFileEntryConstants.getClassName(),\r
+ fileVersion.getFileVersionId(), fileEntry.getUuid(),\r
+ fileEntryTypeId, assetCategoryIds, assetTagNames, false, null,\r
+ null, null, null, fileEntry.getMimeType(), fileEntry.getTitle(),\r
+ fileEntry.getDescription(), null, null, null, 0, 0, null,\r
+ false);\r
+ }\r
+ else {\r
+ assetEntry = assetEntryLocalService.updateEntry(\r
+ userId, fileEntry.getGroupId(),\r
+ DLFileEntryConstants.getClassName(), fileEntry.getFileEntryId(),\r
+ fileEntry.getUuid(), fileEntryTypeId, assetCategoryIds,\r
+ assetTagNames, visible, null, null, null, null,\r
+ fileEntry.getMimeType(), fileEntry.getTitle(),\r
+ fileEntry.getDescription(), null, null, null, 0, 0, null,\r
+ false);\r
+\r
+ List<DLFileShortcut> dlFileShortcuts =\r
+ dlFileShortcutPersistence.findByToFileEntryId(\r
+ fileEntry.getFileEntryId());\r
+\r
+ for (DLFileShortcut dlFileShortcut : dlFileShortcuts) {\r
+ assetEntryLocalService.updateEntry(\r
+ userId, dlFileShortcut.getGroupId(),\r
+ DLFileShortcut.class.getName(),\r
+ dlFileShortcut.getFileShortcutId(),\r
+ dlFileShortcut.getUuid(), fileEntryTypeId, assetCategoryIds,\r
+ assetTagNames, true, null, null, null, null,\r
+ fileEntry.getMimeType(), fileEntry.getTitle(),\r
+ fileEntry.getDescription(), null, null, null, 0, 0, null,\r
+ false);\r
+ }\r
+ }\r
+\r
+ assetLinkLocalService.updateLinks(\r
+ userId, assetEntry.getEntryId(), assetLinkEntryIds,\r
+ AssetLinkConstants.TYPE_RELATED);\r
+\r
+ return assetEntry;\r
+ }\r
+\r
+ public void updateFileEntry(\r
+ long userId, FileEntry fileEntry, FileVersion fileVersion,\r
+ long assetClassPk)\r
+ throws PortalException, SystemException {\r
+\r
+ boolean updateAsset = true;\r
+\r
+ if (fileEntry instanceof LiferayFileEntry &&\r
+ fileEntry.getVersion().equals(fileVersion.getVersion())) {\r
+\r
+ updateAsset = false;\r
+ }\r
+\r
+ if (updateAsset) {\r
+ updateAsset(userId, fileEntry, fileVersion, assetClassPk);\r
+ }\r
+\r
+ registerDLProcessorCallback(fileEntry);\r
+ }\r
+\r
+ public void updateFileEntry(\r
+ long userId, FileEntry fileEntry, FileVersion fileVersion,\r
+ ServiceContext serviceContext)\r
+ throws PortalException, SystemException {\r
+\r
+ updateAsset(\r
+ userId, fileEntry, fileVersion,\r
+ serviceContext.getAssetCategoryIds(),\r
+ serviceContext.getAssetTagNames(),\r
+ serviceContext.getAssetLinkEntryIds());\r
+\r
+ registerDLProcessorCallback(fileEntry);\r
+ }\r
+\r
+ public void updateFolder(Folder folder, ServiceContext serviceContext)\r
+ throws PortalException, SystemException {\r
+\r
+ if (!isStagingGroup(folder.getGroupId())) {\r
+ dlSyncLocalService.updateSync(\r
+ folder.getFolderId(), folder.getParentFolderId(),\r
+ folder.getName(), folder.getDescription(),\r
+ DLSyncConstants.EVENT_UPDATE, "-1");\r
+ }\r
+ }\r
+\r
+ public void updateStatus(\r
+ long userId, FileEntry fileEntry, FileVersion latestFileVersion,\r
+ int status, Map<String, Serializable> workflowContext)\r
+ throws PortalException, SystemException {\r
+\r
+ if (status == WorkflowConstants.STATUS_APPROVED) {\r
+\r
+ // Asset\r
+\r
+ String latestFileVersionVersion = latestFileVersion.getVersion();\r
+\r
+ if (latestFileVersionVersion.equals(fileEntry.getVersion())) {\r
+ if (!latestFileVersionVersion.equals(\r
+ DLFileEntryConstants.VERSION_DEFAULT)) {\r
+\r
+ AssetEntry draftAssetEntry = null;\r
+\r
+ try {\r
+ long fileEntryTypeId = getFileEntryTypeId(fileEntry);\r
+\r
+ draftAssetEntry = assetEntryLocalService.getEntry(\r
+ DLFileEntryConstants.getClassName(),\r
+ latestFileVersion.getPrimaryKey());\r
+\r
+ long[] assetCategoryIds =\r
+ draftAssetEntry.getCategoryIds();\r
+ String[] assetTagNames = draftAssetEntry.getTagNames();\r
+\r
+ List<AssetLink> assetLinks =\r
+ assetLinkLocalService.getDirectLinks(\r
+ draftAssetEntry.getEntryId(),\r
+ AssetLinkConstants.TYPE_RELATED);\r
+\r
+ long[] assetLinkEntryIds = StringUtil.split(\r
+ ListUtil.toString(\r
+ assetLinks, AssetLink.ENTRY_ID2_ACCESSOR), 0L);\r
+\r
+ AssetEntry assetEntry =\r
+ assetEntryLocalService.updateEntry(\r
+ userId, fileEntry.getGroupId(),\r
+ DLFileEntryConstants.getClassName(),\r
+ fileEntry.getFileEntryId(), fileEntry.getUuid(),\r
+ fileEntryTypeId, assetCategoryIds,\r
+ assetTagNames, true, null, null, null, null,\r
+ draftAssetEntry.getMimeType(),\r
+ fileEntry.getTitle(),\r
+ fileEntry.getDescription(), null, null, null, 0,\r
+ 0, null, false);\r
+\r
+ assetLinkLocalService.updateLinks(\r
+ userId, assetEntry.getEntryId(), assetLinkEntryIds,\r
+ AssetLinkConstants.TYPE_RELATED);\r
+\r
+ assetEntryLocalService.deleteEntry(\r
+ draftAssetEntry.getEntryId());\r
+ }\r
+ // MIGRATION MODIFICATION --> NoSuchEntryException\r
+ catch (Exception e) {\r
+ }\r
+ }\r
+\r
+ assetEntryLocalService.updateVisible(\r
+ DLFileEntryConstants.getClassName(),\r
+ fileEntry.getFileEntryId(), true);\r
+ }\r
+\r
+ // Sync\r
+\r
+ String event = (String)workflowContext.get("event");\r
+\r
+ if (!isStagingGroup(fileEntry.getGroupId()) &&\r
+ Validator.isNotNull(event)) {\r
+\r
+ if (event.equals(DLSyncConstants.EVENT_ADD)) {\r
+ dlSyncLocalService.addSync(\r
+ fileEntry.getFileEntryId(), fileEntry.getUuid(),\r
+ fileEntry.getCompanyId(), fileEntry.getRepositoryId(),\r
+ fileEntry.getFolderId(), fileEntry.getTitle(),\r
+ fileEntry.getDescription(), DLSyncConstants.TYPE_FILE,\r
+ fileEntry.getVersion());\r
+ }\r
+ else if (event.equals(DLSyncConstants.EVENT_UPDATE)) {\r
+ dlSyncLocalService.updateSync(\r
+ fileEntry.getFileEntryId(), fileEntry.getFolderId(),\r
+ fileEntry.getTitle(), fileEntry.getDescription(),\r
+ DLSyncConstants.EVENT_UPDATE, fileEntry.getVersion());\r
+ }\r
+ }\r
+\r
+ // Social\r
+\r
+ int activityType = DLActivityKeys.UPDATE_FILE_ENTRY;\r
+\r
+ if (latestFileVersionVersion.equals(\r
+ DLFileEntryConstants.VERSION_DEFAULT)) {\r
+\r
+ activityType = DLActivityKeys.ADD_FILE_ENTRY;\r
+ }\r
+\r
+ JSONObject extraDataJSONObject = JSONFactoryUtil.createJSONObject();\r
+\r
+ extraDataJSONObject.put("title", fileEntry.getTitle());\r
+\r
+ socialActivityLocalService.addUniqueActivity(\r
+ latestFileVersion.getStatusByUserId(), fileEntry.getGroupId(),\r
+ latestFileVersion.getCreateDate(),\r
+ DLFileEntryConstants.getClassName(), fileEntry.getFileEntryId(),\r
+ activityType, extraDataJSONObject.toString(), 0);\r
+ }\r
+ else {\r
+\r
+ // Asset\r
+\r
+ if (Validator.isNull(fileEntry.getVersion())) {\r
+ assetEntryLocalService.updateVisible(\r
+ DLFileEntryConstants.getClassName(),\r
+ fileEntry.getFileEntryId(), false);\r
+ }\r
+ }\r
+ }\r
+\r
+ protected long getFileEntryTypeId(FileEntry fileEntry) {\r
+ if (fileEntry instanceof LiferayFileEntry) {\r
+ DLFileEntry dlFileEntry = (DLFileEntry)fileEntry.getModel();\r
+\r
+ return dlFileEntry.getFileEntryTypeId();\r
+ }\r
+ else {\r
+ return 0;\r
+ }\r
+ }\r
+\r
+ protected boolean isStagingGroup(long groupId) {\r
+ try {\r
+ Group group = groupLocalService.getGroup(groupId);\r
+\r
+ return group.isStagingGroup();\r
+ }\r
+ catch (Exception e) {\r
+ return false;\r
+ }\r
+ }\r
+\r
+ protected void registerDLProcessorCallback(final FileEntry fileEntry) {\r
+ TransactionCommitCallbackUtil.registerCallback(\r
+ new Callable<Void>() {\r
+\r
+ public Void call() throws Exception {\r
+ DLProcessorRegistryUtil.trigger(fileEntry);\r
+\r
+ return null;\r
+ }\r
+\r
+ });\r
+ }\r
+\r
+}
\ No newline at end of file