public void updateStatus( long userId, FileEntry fileEntry, FileVersion latestFileVersion, int oldStatus, int newStatus, Map<String, Serializable> workflowContext) throws PortalException, SystemException { if (newStatus == WorkflowConstants.STATUS_APPROVED) { // Asset String latestFileVersionVersion = latestFileVersion.getVersion(); if (latestFileVersionVersion.equals(fileEntry.getVersion())) { if (!latestFileVersionVersion.equals(DLFileEntryConstants.VERSION_DEFAULT)) { AssetEntry draftAssetEntry = null; try { long fileEntryTypeId = getFileEntryTypeId(fileEntry); draftAssetEntry = assetEntryLocalService.getEntry( DLFileEntryConstants.getClassName(), latestFileVersion.getPrimaryKey()); long[] assetCategoryIds = draftAssetEntry.getCategoryIds(); String[] assetTagNames = draftAssetEntry.getTagNames(); List<AssetLink> assetLinks = assetLinkLocalService.getDirectLinks( draftAssetEntry.getEntryId(), AssetLinkConstants.TYPE_RELATED); long[] assetLinkEntryIds = StringUtil.split(ListUtil.toString(assetLinks, AssetLink.ENTRY_ID2_ACCESSOR), 0L); AssetEntry assetEntry = assetEntryLocalService.updateEntry( userId, fileEntry.getGroupId(), DLFileEntryConstants.getClassName(), fileEntry.getFileEntryId(), fileEntry.getUuid(), fileEntryTypeId, assetCategoryIds, assetTagNames, true, null, null, null, draftAssetEntry.getMimeType(), fileEntry.getTitle(), fileEntry.getDescription(), null, null, null, 0, 0, null, false); assetLinkLocalService.updateLinks( userId, assetEntry.getEntryId(), assetLinkEntryIds, AssetLinkConstants.TYPE_RELATED); assetEntryLocalService.deleteEntry(draftAssetEntry.getEntryId()); } catch (NoSuchEntryException nsee) { } } assetEntryLocalService.updateVisible( DLFileEntryConstants.getClassName(), fileEntry.getFileEntryId(), true); } // Sync String event = (String) workflowContext.get("event"); if (!isStagingGroup(fileEntry.getGroupId()) && Validator.isNotNull(event)) { if (event.equals(DLSyncConstants.EVENT_ADD)) { dlSyncLocalService.addSync( fileEntry.getFileEntryId(), fileEntry.getUuid(), fileEntry.getCompanyId(), fileEntry.getRepositoryId(), fileEntry.getFolderId(), fileEntry.getTitle(), fileEntry.getDescription(), DLSyncConstants.TYPE_FILE, fileEntry.getVersion()); } else if (event.equals(DLSyncConstants.EVENT_UPDATE)) { dlSyncLocalService.updateSync( fileEntry.getFileEntryId(), fileEntry.getFolderId(), fileEntry.getTitle(), fileEntry.getDescription(), DLSyncConstants.EVENT_UPDATE, fileEntry.getVersion()); } } // Social int activityType = DLActivityKeys.UPDATE_FILE_ENTRY; if (latestFileVersionVersion.equals(DLFileEntryConstants.VERSION_DEFAULT)) { activityType = DLActivityKeys.ADD_FILE_ENTRY; } if (oldStatus != WorkflowConstants.STATUS_IN_TRASH) { socialActivityLocalService.addUniqueActivity( latestFileVersion.getStatusByUserId(), fileEntry.getGroupId(), latestFileVersion.getCreateDate(), DLFileEntryConstants.getClassName(), fileEntry.getFileEntryId(), activityType, StringPool.BLANK, 0); } } else { // Asset if (newStatus == WorkflowConstants.STATUS_IN_TRASH) { assetEntryLocalService.moveEntryToTrash( DLFileEntryConstants.getClassName(), fileEntry.getFileEntryId()); } else { boolean visible = false; if (Validator.isNotNull(fileEntry.getVersion())) { visible = true; } assetEntryLocalService.updateVisible( DLFileEntryConstants.getClassName(), fileEntry.getFileEntryId(), visible); } } }