List of usage examples for com.liferay.portal.kernel.repository.model FileVersion getStatusByUserId
public long getStatusByUserId();
From source file:com.liferay.portlet.documentlibrary.service.impl.DLAppHelperLocalServiceImpl.java
License:Open Source License
public void updateStatus(long userId, FileEntry fileEntry, FileVersion latestFileVersion, int status, Map<String, Serializable> workflowContext) throws PortalException, SystemException { if (status == WorkflowConstants.STATUS_APPROVED) { // Asset//from www . j a v a 2 s . com 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, 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(), DLSyncConstants.TYPE_FILE, fileEntry.getVersion()); } else if (event.equals(DLSyncConstants.EVENT_UPDATE)) { dlSyncLocalService.updateSync(fileEntry.getFileEntryId(), fileEntry.getFolderId(), fileEntry.getTitle(), DLSyncConstants.EVENT_UPDATE, fileEntry.getVersion()); } } // Social int activityType = DLActivityKeys.UPDATE_FILE_ENTRY; if (latestFileVersionVersion.equals(DLFileEntryConstants.VERSION_DEFAULT)) { activityType = DLActivityKeys.ADD_FILE_ENTRY; } socialActivityLocalService.addUniqueActivity(latestFileVersion.getStatusByUserId(), fileEntry.getGroupId(), latestFileVersion.getCreateDate(), DLFileEntryConstants.getClassName(), fileEntry.getFileEntryId(), activityType, StringPool.BLANK, 0); } else { // Asset if (Validator.isNull(fileEntry.getVersion())) { assetEntryLocalService.updateVisible(DLFileEntryConstants.getClassName(), fileEntry.getFileEntryId(), false); } } }