List of usage examples for com.liferay.portal.kernel.workflow WorkflowConstants STATUS_APPROVED
int STATUS_APPROVED
To view the source code for com.liferay.portal.kernel.workflow WorkflowConstants STATUS_APPROVED.
Click Source Link
From source file:com.liferay.journal.service.test.JournalArticleServiceTest.java
License:Open Source License
@Test public void testFetchLatestArticleByApprovedStatusWhenFirstArticleExpired() throws Exception { JournalTestUtil.updateArticle(_article, "Version 2"); _article = JournalTestUtil.expireArticle(_group.getGroupId(), _article, 1.0); _latestArticle = fetchLatestArticle(WorkflowConstants.STATUS_APPROVED); Assert.assertEquals("Version 2", _latestArticle.getTitle(LocaleUtil.getDefault())); Assert.assertTrue(_latestArticle.isApproved()); Assert.assertTrue(_latestArticle.getVersion() == 1.1); }
From source file:com.liferay.journal.service.test.JournalArticleServiceTest.java
License:Open Source License
@Test public void testFetchLatestArticleExpiredWithStatusApproved() throws Exception { updateAndExpireLatestArticle("Version 2"); _latestArticle = fetchLatestArticle(WorkflowConstants.STATUS_APPROVED, false); Assert.assertTrue(_latestArticle.isApproved()); Assert.assertEquals("Version 1", _latestArticle.getTitle(LocaleUtil.getDefault())); Assert.assertEquals(1.0, _latestArticle.getVersion(), 0); }
From source file:com.liferay.journal.service.test.JournalArticleServiceTest.java
License:Open Source License
@Test public void testFetchLatestArticleNotExpiredWithStatusApproved() throws Exception { _article = JournalTestUtil.updateArticle(_article, "Version 2"); _latestArticle = fetchLatestArticle(WorkflowConstants.STATUS_APPROVED, false); Assert.assertTrue(_latestArticle.isApproved()); Assert.assertEquals("Version 2", _latestArticle.getTitle(LocaleUtil.getDefault())); Assert.assertEquals(1.1, _latestArticle.getVersion(), 0); }
From source file:com.liferay.journal.service.test.JournalArticleServiceTest.java
License:Open Source License
@Test public void testGetGroupArticlesWhenUserNotNullAndStatusApproved() throws Exception { List<JournalArticle> expectedArticles = addArticles(2, RandomTestUtil.randomString()); expectedArticles.add(0, _article);//from www. j av a 2s . c o m _article = updateArticleStatus(_article, WorkflowConstants.STATUS_DRAFT); int count = JournalArticleServiceUtil.getGroupArticlesCount(_group.getGroupId(), _article.getUserId(), JournalFolderConstants.DEFAULT_PARENT_FOLDER_ID, WorkflowConstants.STATUS_APPROVED); Assert.assertEquals(3, count); List<JournalArticle> articles = JournalArticleServiceUtil.getGroupArticles(_group.getGroupId(), _article.getUserId(), JournalFolderConstants.DEFAULT_PARENT_FOLDER_ID, WorkflowConstants.STATUS_APPROVED, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); Assert.assertEquals(expectedArticles, articles); }
From source file:com.liferay.journal.service.test.JournalArticleServiceTest.java
License:Open Source License
@Test public void testGetGroupArticlesWhenUserNullAndStatusApproved() throws Exception { List<JournalArticle> expectedArticles = addArticles(2, RandomTestUtil.randomString()); expectedArticles.add(0, _article);/*from w w w.j a v a 2 s . com*/ _article = updateArticleStatus(_article, WorkflowConstants.STATUS_DRAFT); int count = JournalArticleServiceUtil.getGroupArticlesCount(_group.getGroupId(), 0, JournalFolderConstants.DEFAULT_PARENT_FOLDER_ID, WorkflowConstants.STATUS_APPROVED); Assert.assertEquals(3, count); List<JournalArticle> articles = JournalArticleServiceUtil.getGroupArticles(_group.getGroupId(), 0, JournalFolderConstants.DEFAULT_PARENT_FOLDER_ID, WorkflowConstants.STATUS_APPROVED, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); Assert.assertEquals(expectedArticles, articles); }
From source file:com.liferay.journal.service.test.JournalArticleServiceTest.java
License:Open Source License
@Test public void testSearchArticlesByKeywordAndStatus() throws Exception { List<JournalArticle> initialArticles = createArticlesWithKeyword(2); updateArticleStatus(initialArticles.get(0), WorkflowConstants.STATUS_DRAFT); int count = countArticlesByKeyword(_keyword, WorkflowConstants.STATUS_APPROVED); Assert.assertEquals(2, count);/* w ww . jav a 2 s. c om*/ List<JournalArticle> articles = searchArticlesByKeyword(_keyword, WorkflowConstants.STATUS_APPROVED); Assert.assertEquals(initialArticles, articles); }
From source file:com.liferay.journal.taglib.servlet.taglib.JournalArticleTag.java
License:Open Source License
@Override public int doStartTag() throws JspException { ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); PortletRequest portletRequest = (PortletRequest) request.getAttribute(JavaConstants.JAVAX_PORTLET_REQUEST); PortletResponse portletResponse = (PortletResponse) request .getAttribute(JavaConstants.JAVAX_PORTLET_RESPONSE); PortletRequestModel portletRequestModel = new PortletRequestModel(portletRequest, portletResponse); _article = JournalArticleLocalServiceUtil.fetchLatestArticle(_groupId, _articleId, WorkflowConstants.STATUS_APPROVED); try {/*w w w .ja va 2 s. c o m*/ _articleDisplay = JournalArticleLocalServiceUtil.getArticleDisplay(_article.getGroupId(), _article.getArticleId(), _article.getVersion(), _ddmTemplateKey, Constants.VIEW, getLanguageId(), 1, portletRequestModel, themeDisplay); } catch (PortalException pe) { if (_log.isDebugEnabled()) { _log.debug("Unable to get journal article display", pe); } return SKIP_BODY; } return super.doStartTag(); }
From source file:com.liferay.journal.trash.test.JournalArticleTrashHandlerTest.java
License:Open Source License
@Test public void testArticleImages() throws Exception { ServiceContext serviceContext = ServiceContextTestUtil.getServiceContext(group.getGroupId()); Class<?> clazz = getClass(); ClassLoader classLoader = clazz.getClassLoader(); String definition = StringUtil.read(classLoader, "com/liferay/journal/dependencies" + "/test-ddm-structure-image-field.xml"); DDMForm ddmForm = _ddmFormXSDDeserializer.deserialize(definition); DDMStructure ddmStructure = DDMStructureTestUtil.addStructure(serviceContext.getScopeGroupId(), JournalArticle.class.getName(), ddmForm); DDMTemplate ddmTemplate = DDMTemplateTestUtil.addTemplate(serviceContext.getScopeGroupId(), ddmStructure.getStructureId(), PortalUtil.getClassNameId(JournalArticle.class)); InputStream inputStream = classLoader.getResourceAsStream("/com/liferay/journal/dependencies/liferay.png"); FileEntry tempFileEntry = TempFileEntryUtil.addTempFileEntry(group.getGroupId(), TestPropsValues.getUserId(), JournalArticle.class.getName(), "liferay.png", inputStream, ContentTypes.IMAGE_PNG);// w ww. java2 s . c o m String content = StringUtil.read(classLoader, "com/liferay/journal/dependencies/test-journal-content-image-" + "field.xml"); Document document = SAXReaderUtil.read(content); Element dynamicContent = (Element) document.selectSingleNode("//dynamic-content"); JSONObject jsonObject = JSONFactoryUtil.createJSONObject(); jsonObject.put("groupId", group.getGroupId()); jsonObject.put("name", "liferay.png"); jsonObject.put("tempFile", Boolean.TRUE.toString()); jsonObject.put("title", "liferay.png"); jsonObject.put("type", "journal"); jsonObject.put("uuid", tempFileEntry.getUuid()); dynamicContent.setText(jsonObject.toString()); baseModel = JournalTestUtil.addArticleWithXMLContent(JournalFolderConstants.DEFAULT_PARENT_FOLDER_ID, document.asXML(), ddmStructure.getStructureKey(), ddmTemplate.getTemplateKey(), serviceContext); JournalArticle article = (JournalArticle) baseModel; long folderId = article.getImagesFolderId(); Assert.assertEquals(1, PortletFileRepositoryUtil.getPortletFileEntriesCount(group.getGroupId(), folderId)); moveBaseModelToTrash((Long) baseModel.getPrimaryKeyObj()); Assert.assertEquals(0, PortletFileRepositoryUtil.getPortletFileEntriesCount(group.getGroupId(), folderId, WorkflowConstants.STATUS_APPROVED)); Assert.assertEquals(1, PortletFileRepositoryUtil.getPortletFileEntriesCount(group.getGroupId(), folderId, WorkflowConstants.STATUS_IN_TRASH)); TrashHandler trashHandler = TrashHandlerRegistryUtil.getTrashHandler(getBaseModelClassName()); trashHandler.deleteTrashEntry(getTrashEntryClassPK(baseModel)); Assert.assertEquals(0, PortletFileRepositoryUtil.getPortletFileEntriesCount(group.getGroupId(), folderId)); }
From source file:com.liferay.journal.util.impl.JournalArticleSitemapURLProvider.java
License:Open Source License
protected void visitArticles(Element element, LayoutSet layoutSet, ThemeDisplay themeDisplay, List<JournalArticle> journalArticles) throws PortalException { if (journalArticles.isEmpty()) { return;/*from w w w . j a va 2 s. co m*/ } Set<String> processedArticleIds = new HashSet<>(); String portalURL = _portal.getPortalURL(layoutSet, themeDisplay); for (JournalArticle journalArticle : journalArticles) { if (processedArticleIds.contains(journalArticle.getArticleId()) || (journalArticle.getStatus() != WorkflowConstants.STATUS_APPROVED) || !JournalUtil.isHead(journalArticle)) { continue; } String groupFriendlyURL = _portal.getGroupFriendlyURL( _layoutSetLocalService.getLayoutSet(journalArticle.getGroupId(), false), themeDisplay); StringBundler sb = new StringBundler(4); if (!groupFriendlyURL.startsWith(portalURL)) { sb.append(portalURL); } sb.append(groupFriendlyURL); sb.append(JournalArticleConstants.CANONICAL_URL_SEPARATOR); sb.append(journalArticle.getUrlTitle()); Layout layout = _layoutLocalService.getLayoutByUuidAndGroupId(journalArticle.getLayoutUuid(), layoutSet.getGroupId(), layoutSet.getPrivateLayout()); String articleURL = _portal.getCanonicalURL(sb.toString(), themeDisplay, layout); Map<Locale, String> alternateURLs = SitemapUtil.getAlternateURLs(articleURL, themeDisplay, layout); for (String alternateURL : alternateURLs.values()) { SitemapUtil.addURLElement(element, alternateURL, null, journalArticle.getModifiedDate(), articleURL, alternateURLs); } processedArticleIds.add(journalArticle.getArticleId()); } }
From source file:com.liferay.journal.util.impl.JournalContentImpl.java
License:Open Source License
protected JournalArticleDisplay getArticleDisplay(JournalArticle article, String ddmTemplateKey, String viewMode, String languageId, int page, PortletRequestModel portletRequestModel, ThemeDisplay themeDisplay) {/* w w w .ja v a 2s . c o m*/ if (article.getStatus() != WorkflowConstants.STATUS_APPROVED) { return null; } Date now = new Date(); Date displayDate = article.getDisplayDate(); Date expirationDate = article.getExpirationDate(); if (((displayDate != null) && displayDate.after(now)) || ((expirationDate != null) && expirationDate.before(now))) { return null; } try { return _journalArticleLocalService.getArticleDisplay(article, ddmTemplateKey, viewMode, languageId, page, portletRequestModel, themeDisplay); } catch (Exception e) { if (_log.isWarnEnabled()) { _log.warn("Unable to get display for " + article + " " + languageId, e); } return null; } }