List of usage examples for com.liferay.portal.kernel.workflow WorkflowConstants STATUS_DRAFT
int STATUS_DRAFT
To view the source code for com.liferay.portal.kernel.workflow WorkflowConstants STATUS_DRAFT.
Click Source Link
From source file:com.liferay.lms.model.impl.CompetenceModelImpl.java
License:Open Source License
public boolean isDraft() { if ((getStatus() == WorkflowConstants.STATUS_DRAFT) || (getStatus() == WorkflowConstants.STATUS_DRAFT_FROM_APPROVED)) { return true; } else {//from w w w. ja v a 2s . c om return false; } }
From source file:com.liferay.message.boards.internal.verify.MessageBoardsServiceVerifyProcess.java
License:Open Source License
protected void verifyAssetsForMessages() throws Exception { try (LoggingTimer loggingTimer = new LoggingTimer()) { List<MBMessage> messages = _mbMessageLocalService.getNoAssetMessages(); if (_log.isDebugEnabled()) { _log.debug("Processing " + messages.size() + " messages with no asset"); }//from w w w . ja v a2 s .co m for (MBMessage message : messages) { try { _mbMessageLocalService.updateAsset(message.getUserId(), message, null, null, null); if (message.getStatus() == WorkflowConstants.STATUS_DRAFT) { boolean visible = false; if (message.isApproved() && ((message.getClassNameId() == 0) || (message.getParentMessageId() != 0))) { visible = true; } _assetEntryLocalService.updateEntry(message.getWorkflowClassName(), message.getMessageId(), null, null, true, visible); } } catch (Exception e) { if (_log.isWarnEnabled()) { _log.warn(StringBundler.concat("Unable to update asset for message ", String.valueOf(message.getMessageId()), ": ", e.getMessage())); } } } if (_log.isDebugEnabled()) { _log.debug("Assets verified for messages"); } } }
From source file:com.liferay.message.boards.service.test.MBCategoryLocalServiceTest.java
License:Open Source License
@Test public void testGetCategoriesCountWithStatusApprovedAndExcludedCategories() throws Exception { addCategory();/*from w w w . j av a2 s . com*/ MBCategory excludedCategory1 = addCategory(); MBCategory excludedCategory2 = addCategory(); MBCategory draftCategory = addCategory(); MBCategoryLocalServiceUtil.updateStatus(draftCategory.getUserId(), draftCategory.getCategoryId(), WorkflowConstants.STATUS_DRAFT); Assert.assertEquals(3, MBCategoryLocalServiceUtil.getCategoriesCount(_group.getGroupId(), MBCategoryConstants.DEFAULT_PARENT_CATEGORY_ID, WorkflowConstants.STATUS_APPROVED)); Assert.assertEquals(1, MBCategoryLocalServiceUtil.getCategoriesCount(_group.getGroupId(), new long[] { excludedCategory1.getCategoryId(), excludedCategory2.getCategoryId() }, new long[] { MBCategoryConstants.DEFAULT_PARENT_CATEGORY_ID }, WorkflowConstants.STATUS_APPROVED)); }
From source file:com.liferay.message.boards.service.test.MBCategoryLocalServiceTest.java
License:Open Source License
@Test public void testGetCategoriesCountWithStatusApprovedAndExcludedCategory() throws Exception { addCategory();/*from w w w.j a v a2s .c om*/ MBCategory excludedCategory = addCategory(); MBCategory draftCategory = addCategory(); MBCategoryLocalServiceUtil.updateStatus(draftCategory.getUserId(), draftCategory.getCategoryId(), WorkflowConstants.STATUS_DRAFT); Assert.assertEquals(2, MBCategoryLocalServiceUtil.getCategoriesCount(_group.getGroupId(), MBCategoryConstants.DEFAULT_PARENT_CATEGORY_ID, WorkflowConstants.STATUS_APPROVED)); Assert.assertEquals(1, MBCategoryLocalServiceUtil.getCategoriesCount(_group.getGroupId(), excludedCategory.getCategoryId(), MBCategoryConstants.DEFAULT_PARENT_CATEGORY_ID, WorkflowConstants.STATUS_APPROVED)); }
From source file:com.liferay.message.boards.service.test.MBCategoryLocalServiceTest.java
License:Open Source License
@Test public void testGetCategoriesWithStatusApprovedAndExcludedCategories() throws Exception { List<MBCategory> expectedCategories = new ArrayList<>(); expectedCategories.add(addCategory()); MBCategory excludedCategory1 = addCategory(); expectedCategories.add(excludedCategory1); MBCategory excludedCategory2 = addCategory(); expectedCategories.add(excludedCategory2); MBCategory draftCategory = addCategory(); MBCategoryLocalServiceUtil.updateStatus(draftCategory.getUserId(), draftCategory.getCategoryId(), WorkflowConstants.STATUS_DRAFT); List<MBCategory> categories = MBCategoryLocalServiceUtil.getCategories(_group.getGroupId(), WorkflowConstants.STATUS_APPROVED); AssertUtils.assertEquals(expectedCategories, categories); expectedCategories.remove(excludedCategory1); expectedCategories.remove(excludedCategory2); categories = MBCategoryLocalServiceUtil.getCategories(_group.getGroupId(), new long[] { excludedCategory1.getCategoryId(), excludedCategory2.getCategoryId() }, new long[] { MBCategoryConstants.DEFAULT_PARENT_CATEGORY_ID }, WorkflowConstants.STATUS_APPROVED, QueryUtil.ALL_POS, QueryUtil.ALL_POS); AssertUtils.assertEquals(expectedCategories, categories); }
From source file:com.liferay.message.boards.service.test.MBCategoryLocalServiceTest.java
License:Open Source License
@Test public void testGetCategoriesWithStatusApprovedAndExcludedCategory() throws Exception { List<MBCategory> expectedCategories = new ArrayList<>(); expectedCategories.add(addCategory()); MBCategory excludedCategory = addCategory(); expectedCategories.add(excludedCategory); MBCategory draftCategory = addCategory(); MBCategoryLocalServiceUtil.updateStatus(draftCategory.getUserId(), draftCategory.getCategoryId(), WorkflowConstants.STATUS_DRAFT); List<MBCategory> categories = MBCategoryLocalServiceUtil.getCategories(_group.getGroupId(), WorkflowConstants.STATUS_APPROVED); AssertUtils.assertEquals(expectedCategories, categories); expectedCategories.remove(excludedCategory); categories = MBCategoryLocalServiceUtil.getCategories(_group.getGroupId(), excludedCategory.getCategoryId(), MBCategoryConstants.DEFAULT_PARENT_CATEGORY_ID, WorkflowConstants.STATUS_APPROVED, QueryUtil.ALL_POS, QueryUtil.ALL_POS); AssertUtils.assertEquals(expectedCategories, categories); }
From source file:com.liferay.message.boards.trash.test.MBCategoryTrashHandlerTest.java
License:Open Source License
@Override public BaseModel<?> updateBaseModel(long primaryKey, ServiceContext serviceContext) throws Exception { MBCategory category = MBCategoryLocalServiceUtil.getCategory(primaryKey); if (serviceContext.getWorkflowAction() == WorkflowConstants.ACTION_SAVE_DRAFT) { category = MBCategoryLocalServiceUtil.updateStatus(TestPropsValues.getUserId(), primaryKey, WorkflowConstants.STATUS_DRAFT); }//from w ww .ja v a 2s. c om return category; }
From source file:com.liferay.message.boards.trash.test.MBThreadTrashHandlerTest.java
License:Open Source License
@Override public BaseModel<?> updateBaseModel(long primaryKey, ServiceContext serviceContext) throws Exception { MBThread thread = MBThreadLocalServiceUtil.getThread(primaryKey); if (serviceContext.getWorkflowAction() == WorkflowConstants.ACTION_SAVE_DRAFT) { thread = MBThreadLocalServiceUtil.updateStatus(TestPropsValues.getUserId(), primaryKey, WorkflowConstants.STATUS_DRAFT); }/*from www. j av a 2 s . c o m*/ return thread; }
From source file:com.liferay.portlet.blogs.service.impl.BlogsEntryLocalServiceImpl.java
License:Open Source License
public BlogsEntry addEntry(long userId, String title, String description, String content, int displayDateMonth, int displayDateDay, int displayDateYear, int displayDateHour, int displayDateMinute, boolean allowPingbacks, boolean allowTrackbacks, String[] trackbacks, boolean smallImage, String smallImageURL, String smallImageFileName, InputStream smallImageInputStream, ServiceContext serviceContext) throws PortalException, SystemException { // Entry/*from w w w .ja v a 2 s. co m*/ User user = userPersistence.findByPrimaryKey(userId); long groupId = serviceContext.getScopeGroupId(); Date displayDate = PortalUtil.getDate(displayDateMonth, displayDateDay, displayDateYear, displayDateHour, displayDateMinute, user.getTimeZone(), new EntryDisplayDateException()); byte[] smallImageBytes = null; try { if ((smallImageInputStream != null) && smallImage) { smallImageBytes = FileUtil.getBytes(smallImageInputStream); } } catch (IOException ioe) { } Date now = new Date(); validate(title, content, smallImage, smallImageURL, smallImageFileName, smallImageBytes); long entryId = counterLocalService.increment(); BlogsEntry entry = blogsEntryPersistence.create(entryId); entry.setUuid(serviceContext.getUuid()); entry.setGroupId(groupId); entry.setCompanyId(user.getCompanyId()); entry.setUserId(user.getUserId()); entry.setUserName(user.getFullName()); entry.setCreateDate(serviceContext.getCreateDate(now)); entry.setModifiedDate(serviceContext.getModifiedDate(now)); entry.setTitle(title); entry.setUrlTitle(getUniqueUrlTitle(entryId, groupId, title)); entry.setDescription(description); entry.setContent(content); entry.setDisplayDate(displayDate); entry.setAllowPingbacks(allowPingbacks); entry.setAllowTrackbacks(allowTrackbacks); entry.setSmallImage(smallImage); entry.setSmallImageId(counterLocalService.increment()); entry.setSmallImageURL(smallImageURL); entry.setStatus(WorkflowConstants.STATUS_DRAFT); entry.setStatusDate(serviceContext.getModifiedDate(now)); entry.setExpandoBridgeAttributes(serviceContext); blogsEntryPersistence.update(entry, false); // Resources if (serviceContext.isAddGroupPermissions() || serviceContext.isAddGuestPermissions()) { addEntryResources(entry, serviceContext.isAddGroupPermissions(), serviceContext.isAddGuestPermissions()); } else { addEntryResources(entry, serviceContext.getGroupPermissions(), serviceContext.getGuestPermissions()); } // Small image saveImages(smallImage, entry.getSmallImageId(), smallImageBytes); // Asset updateAsset(userId, entry, serviceContext.getAssetCategoryIds(), serviceContext.getAssetTagNames(), serviceContext.getAssetLinkEntryIds()); // Message boards if (PropsValues.BLOGS_ENTRY_COMMENTS_ENABLED) { mbMessageLocalService.addDiscussionMessage(userId, entry.getUserName(), groupId, BlogsEntry.class.getName(), entryId, WorkflowConstants.ACTION_PUBLISH); } // Workflow if ((trackbacks != null) && (trackbacks.length > 0)) { serviceContext.setAttribute("trackbacks", trackbacks); } else { serviceContext.setAttribute("trackbacks", null); } WorkflowHandlerRegistryUtil.startWorkflowInstance(user.getCompanyId(), groupId, userId, BlogsEntry.class.getName(), entry.getEntryId(), entry, serviceContext); return entry; }
From source file:com.liferay.portlet.blogs.service.impl.BlogsEntryLocalServiceImpl.java
License:Open Source License
public BlogsEntry updateEntry(long userId, long entryId, String title, String description, String content, int displayDateMonth, int displayDateDay, int displayDateYear, int displayDateHour, int displayDateMinute, boolean allowPingbacks, boolean allowTrackbacks, String[] trackbacks, boolean smallImage, String smallImageURL, String smallImageFileName, InputStream smallImageInputStream, ServiceContext serviceContext) throws PortalException, SystemException { // Entry/*from w ww.jav a 2 s . com*/ User user = userPersistence.findByPrimaryKey(userId); Date displayDate = PortalUtil.getDate(displayDateMonth, displayDateDay, displayDateYear, displayDateHour, displayDateMinute, user.getTimeZone(), new EntryDisplayDateException()); byte[] smallImageBytes = null; try { if ((smallImageInputStream != null) && smallImage) { smallImageBytes = FileUtil.getBytes(smallImageInputStream); } } catch (IOException ioe) { } validate(title, content, smallImage, smallImageURL, smallImageFileName, smallImageBytes); BlogsEntry entry = blogsEntryPersistence.findByPrimaryKey(entryId); String oldUrlTitle = entry.getUrlTitle(); entry.setModifiedDate(serviceContext.getModifiedDate(null)); entry.setTitle(title); entry.setUrlTitle(getUniqueUrlTitle(entryId, entry.getGroupId(), title)); entry.setDescription(description); entry.setContent(content); entry.setDisplayDate(displayDate); entry.setAllowPingbacks(allowPingbacks); entry.setAllowTrackbacks(allowTrackbacks); entry.setSmallImage(smallImage); if (entry.getSmallImageId() == 0) { entry.setSmallImageId(counterLocalService.increment()); } entry.setSmallImageURL(smallImageURL); if (!entry.isPending()) { entry.setStatus(WorkflowConstants.STATUS_DRAFT); } entry.setExpandoBridgeAttributes(serviceContext); blogsEntryPersistence.update(entry, false); // Resources if ((serviceContext.getGroupPermissions() != null) || (serviceContext.getGuestPermissions() != null)) { updateEntryResources(entry, serviceContext.getGroupPermissions(), serviceContext.getGuestPermissions()); } // Small image saveImages(smallImage, entry.getSmallImageId(), smallImageBytes); // Asset updateAsset(userId, entry, serviceContext.getAssetCategoryIds(), serviceContext.getAssetTagNames(), serviceContext.getAssetLinkEntryIds()); // Workflow boolean pingOldTrackbacks = false; if (!oldUrlTitle.equals(entry.getUrlTitle())) { pingOldTrackbacks = true; } serviceContext.setAttribute("pingOldTrackbacks", String.valueOf(pingOldTrackbacks)); if (Validator.isNotNull(trackbacks)) { serviceContext.setAttribute("trackbacks", trackbacks); } else { serviceContext.setAttribute("trackbacks", null); } WorkflowHandlerRegistryUtil.startWorkflowInstance(user.getCompanyId(), entry.getGroupId(), userId, BlogsEntry.class.getName(), entry.getEntryId(), entry, serviceContext); return entry; }