List of usage examples for com.liferay.portal.kernel.service ServiceContext getCommand
public String getCommand()
From source file:com.liferay.document.library.internal.service.SubscriptionDLAppHelperLocalServiceWrapper.java
License:Open Source License
protected void notifySubscribers(long userId, FileVersion fileVersion, String entryURL, ServiceContext serviceContext) throws PortalException { if (!fileVersion.isApproved() || Validator.isNull(entryURL)) { return;/*from w w w . j a va2s .com*/ } DLGroupServiceSettings dlGroupServiceSettings = DLGroupServiceSettings .getInstance(fileVersion.getGroupId()); boolean commandUpdate = false; if (serviceContext.isCommandUpdate() || Constants.CHECKIN.equals(serviceContext.getCommand())) { commandUpdate = true; } if (serviceContext.isCommandAdd() && dlGroupServiceSettings.isEmailFileEntryAddedEnabled()) { } else if (commandUpdate && dlGroupServiceSettings.isEmailFileEntryUpdatedEnabled()) { } else { return; } String entryTitle = fileVersion.getTitle(); String fromName = dlGroupServiceSettings.getEmailFromName(); String fromAddress = dlGroupServiceSettings.getEmailFromAddress(); LocalizedValuesMap subjectLocalizedValuesMap = null; LocalizedValuesMap bodyLocalizedValuesMap = null; if (commandUpdate) { subjectLocalizedValuesMap = dlGroupServiceSettings.getEmailFileEntryUpdatedSubject(); bodyLocalizedValuesMap = dlGroupServiceSettings.getEmailFileEntryUpdatedBody(); } else { subjectLocalizedValuesMap = dlGroupServiceSettings.getEmailFileEntryAddedSubject(); bodyLocalizedValuesMap = dlGroupServiceSettings.getEmailFileEntryAddedBody(); } FileEntry fileEntry = fileVersion.getFileEntry(); Folder folder = null; long folderId = fileEntry.getFolderId(); if (folderId != DLFolderConstants.DEFAULT_PARENT_FOLDER_ID) { folder = _dlAppLocalService.getFolder(folderId); } SubscriptionSender subscriptionSender = new GroupSubscriptionCheckSubscriptionSender( DLPermission.RESOURCE_NAME); DLFileEntry dlFileEntry = (DLFileEntry) fileEntry.getModel(); DLFileEntryType dlFileEntryType = _dlFileEntryTypeLocalService .getDLFileEntryType(dlFileEntry.getFileEntryTypeId()); subscriptionSender.setClassPK(fileVersion.getFileEntryId()); subscriptionSender.setClassName(DLFileEntryConstants.getClassName()); subscriptionSender.setCompanyId(fileVersion.getCompanyId()); if (folder != null) { subscriptionSender.setContextAttribute("[$FOLDER_NAME$]", folder.getName(), true); } else { subscriptionSender.setLocalizedContextAttribute("[$FOLDER_NAME$]", new EscapableLocalizableFunction(locale -> LanguageUtil.get(locale, "home"))); } subscriptionSender.setContextAttributes("[$DOCUMENT_STATUS_BY_USER_NAME$]", fileVersion.getStatusByUserName(), "[$DOCUMENT_TITLE$]", entryTitle, "[$DOCUMENT_URL$]", entryURL); subscriptionSender.setContextCreatorUserPrefix("DOCUMENT"); subscriptionSender.setCreatorUserId(fileVersion.getUserId()); subscriptionSender.setCurrentUserId(userId); subscriptionSender.setEntryTitle(entryTitle); subscriptionSender.setEntryURL(entryURL); subscriptionSender.setFrom(fromAddress, fromName); subscriptionSender.setHtmlFormat(true); subscriptionSender.setLocalizedBodyMap(LocalizationUtil.getMap(bodyLocalizedValuesMap)); subscriptionSender.setLocalizedContextAttribute("[$DOCUMENT_TYPE$]", new EscapableLocalizableFunction(locale -> dlFileEntryType.getName(locale))); subscriptionSender.setLocalizedSubjectMap(LocalizationUtil.getMap(subjectLocalizedValuesMap)); subscriptionSender.setMailId("file_entry", fileVersion.getFileEntryId()); int notificationType = UserNotificationDefinition.NOTIFICATION_TYPE_ADD_ENTRY; if (commandUpdate) { notificationType = UserNotificationDefinition.NOTIFICATION_TYPE_UPDATE_ENTRY; } subscriptionSender.setNotificationType(notificationType); String portletId = PortletProviderUtil.getPortletId(FileEntry.class.getName(), PortletProvider.Action.VIEW); subscriptionSender.setPortletId(portletId); subscriptionSender.setReplyToAddress(fromAddress); subscriptionSender.setScopeGroupId(fileVersion.getGroupId()); subscriptionSender.setServiceContext(serviceContext); subscriptionSender.addPersistedSubscribers(DLFolder.class.getName(), fileVersion.getGroupId()); if (folder != null) { subscriptionSender.addPersistedSubscribers(DLFolder.class.getName(), folder.getFolderId()); for (Long ancestorFolderId : folder.getAncestorFolderIds()) { subscriptionSender.addPersistedSubscribers(DLFolder.class.getName(), ancestorFolderId); } } if (dlFileEntryType.getFileEntryTypeId() == DLFileEntryTypeConstants.FILE_ENTRY_TYPE_ID_BASIC_DOCUMENT) { subscriptionSender.addPersistedSubscribers(DLFileEntryType.class.getName(), fileVersion.getGroupId()); } else { subscriptionSender.addPersistedSubscribers(DLFileEntryType.class.getName(), dlFileEntryType.getFileEntryTypeId()); } subscriptionSender.addPersistedSubscribers(DLFileEntry.class.getName(), fileEntry.getFileEntryId()); subscriptionSender.flushNotificationsAsync(); }
From source file:com.liferay.dynamic.data.lists.service.impl.DDLRecordLocalServiceImpl.java
License:Open Source License
/** * See <code>DLFileVersionPolicyImpl#isKeepFileVersionLabel</code> in the * <code>com.liferay.document.library.service</code> module. *///from ww w. ja va 2s . c o m protected boolean isKeepRecordVersionLabel(DDLRecordVersion lastRecordVersion, DDLRecordVersion latestRecordVersion, ServiceContext serviceContext) throws PortalException { if (Objects.equals(serviceContext.getCommand(), Constants.REVERT)) { return false; } if (serviceContext.getWorkflowAction() == WorkflowConstants.ACTION_SAVE_DRAFT) { return false; } if (Objects.equals(lastRecordVersion.getVersion(), latestRecordVersion.getVersion())) { return false; } DDMFormValues lastDDMFormValues = storageEngine.getDDMFormValues(lastRecordVersion.getDDMStorageId()); DDMFormValues latestDDMFormValues = storageEngine.getDDMFormValues(latestRecordVersion.getDDMStorageId()); if (!lastDDMFormValues.equals(latestDDMFormValues)) { return false; } ExpandoBridge lastExpandoBridge = lastRecordVersion.getExpandoBridge(); ExpandoBridge latestExpandoBridge = latestRecordVersion.getExpandoBridge(); Map<String, Serializable> lastAttributes = lastExpandoBridge.getAttributes(); Map<String, Serializable> latestAttributes = latestExpandoBridge.getAttributes(); if (!lastAttributes.equals(latestAttributes)) { return false; } return true; }
From source file:com.liferay.dynamic.data.mapping.service.impl.DDMFormInstanceRecordLocalServiceImpl.java
License:Open Source License
protected boolean isKeepFormInstanceRecordVersionLabel( DDMFormInstanceRecordVersion lastDDMFormInstanceRecordVersion, DDMFormInstanceRecordVersion latestDDMFormInstanceRecordVersion, ServiceContext serviceContext) throws PortalException { if (Objects.equals(serviceContext.getCommand(), Constants.REVERT)) { return false; }//from ww w .jav a 2 s .co m if (serviceContext.getWorkflowAction() == WorkflowConstants.ACTION_SAVE_DRAFT) { return false; } if (Objects.equals(lastDDMFormInstanceRecordVersion.getVersion(), latestDDMFormInstanceRecordVersion.getVersion())) { return false; } StorageEngine storageEngine = storageEngineAccessor.getStorageEngine(); DDMFormValues lastDDMFormValues = storageEngine .getDDMFormValues(lastDDMFormInstanceRecordVersion.getStorageId()); DDMFormValues latestDDMFormValues = storageEngine .getDDMFormValues(latestDDMFormInstanceRecordVersion.getStorageId()); if (!lastDDMFormValues.equals(latestDDMFormValues)) { return false; } ExpandoBridge lastExpandoBridge = lastDDMFormInstanceRecordVersion.getExpandoBridge(); ExpandoBridge latestExpandoBridge = latestDDMFormInstanceRecordVersion.getExpandoBridge(); Map<String, Serializable> lastAttributes = lastExpandoBridge.getAttributes(); Map<String, Serializable> latestAttributes = latestExpandoBridge.getAttributes(); if (!lastAttributes.equals(latestAttributes)) { return false; } return true; }
From source file:com.liferay.wiki.service.impl.WikiPageLocalServiceImpl.java
License:Open Source License
protected WikiPage startWorkflowInstance(long userId, WikiPage page, ServiceContext serviceContext) throws PortalException { Map<String, Serializable> workflowContext = new HashMap<>(); workflowContext.put(WorkflowConstants.CONTEXT_COMMAND, serviceContext.getCommand()); workflowContext.put(WorkflowConstants.CONTEXT_URL, getPageURL(page, serviceContext)); return WorkflowHandlerRegistryUtil.startWorkflowInstance(page.getCompanyId(), page.getGroupId(), userId, WikiPage.class.getName(), page.getPageId(), page, serviceContext, workflowContext); }
From source file:de.hofuniversity.iisys.liferay.workflows.LoggingTaskManager.java
License:Open Source License
private void logServiceContext(ServiceContext serviceContext, String indent) { if (serviceContext != null) { fLogger.println(indent + "command: " + serviceContext.getCommand()); try {//from w w w . j ava 2 s.co m fLogger.println(indent + "guestOrUserId: " + serviceContext.getGuestOrUserId()); } catch (PortalException e) { // TODO Auto-generated catch block e.printStackTrace(); } fLogger.println(indent + "workflowAction: " + serviceContext.getWorkflowAction()); fLogger.println(indent + "attributes:"); logMap(serviceContext.getAttributes(), indent + "\t"); } }