/portal-impl/src/com/liferay/portlet/journal/service/impl/JournalArticleLocalServiceImpl.java
Java | 1655 lines | 1224 code | 379 blank | 52 comment | 116 complexity | 2626eb759b535eec2204fc03161cb48b MD5 | raw file
- /**
- * Copyright (c) 2000-2011 Liferay, Inc. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or modify it under
- * the terms of the GNU Lesser General Public License as published by the Free
- * Software Foundation; either version 2.1 of the License, or (at your option)
- * any later version.
- *
- * This library is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
- * details.
- */
- package com.liferay.portlet.journal.service.impl;
- import com.liferay.portal.NoSuchImageException;
- import com.liferay.portal.kernel.dao.orm.QueryUtil;
- import com.liferay.portal.kernel.exception.PortalException;
- import com.liferay.portal.kernel.exception.SystemException;
- import com.liferay.portal.kernel.log.Log;
- import com.liferay.portal.kernel.log.LogFactoryUtil;
- import com.liferay.portal.kernel.mail.MailMessage;
- import com.liferay.portal.kernel.search.Indexer;
- import com.liferay.portal.kernel.search.IndexerRegistryUtil;
- import com.liferay.portal.kernel.servlet.ImageServletTokenUtil;
- import com.liferay.portal.kernel.util.CalendarFactoryUtil;
- import com.liferay.portal.kernel.util.CharPool;
- import com.liferay.portal.kernel.util.ContentTypes;
- import com.liferay.portal.kernel.util.FileUtil;
- import com.liferay.portal.kernel.util.GetterUtil;
- import com.liferay.portal.kernel.util.HtmlUtil;
- import com.liferay.portal.kernel.util.HttpUtil;
- import com.liferay.portal.kernel.util.LocaleUtil;
- import com.liferay.portal.kernel.util.LocalizationUtil;
- import com.liferay.portal.kernel.util.MathUtil;
- import com.liferay.portal.kernel.util.OrderByComparator;
- import com.liferay.portal.kernel.util.PropsKeys;
- import com.liferay.portal.kernel.util.StringPool;
- import com.liferay.portal.kernel.util.StringUtil;
- import com.liferay.portal.kernel.util.Time;
- import com.liferay.portal.kernel.util.Validator;
- import com.liferay.portal.kernel.workflow.WorkflowConstants;
- import com.liferay.portal.kernel.workflow.WorkflowHandlerRegistryUtil;
- import com.liferay.portal.kernel.xml.Document;
- import com.liferay.portal.kernel.xml.DocumentException;
- import com.liferay.portal.kernel.xml.Element;
- import com.liferay.portal.kernel.xml.Node;
- import com.liferay.portal.kernel.xml.SAXReaderUtil;
- import com.liferay.portal.kernel.xml.XPath;
- import com.liferay.portal.model.Company;
- import com.liferay.portal.model.Group;
- import com.liferay.portal.model.Image;
- import com.liferay.portal.model.ResourceConstants;
- import com.liferay.portal.model.User;
- import com.liferay.portal.security.permission.ActionKeys;
- import com.liferay.portal.service.ServiceContext;
- import com.liferay.portal.service.ServiceContextUtil;
- import com.liferay.portal.servlet.filters.cache.CacheUtil;
- import com.liferay.portal.theme.ThemeDisplay;
- import com.liferay.portal.util.PortalUtil;
- import com.liferay.portal.util.PortletKeys;
- import com.liferay.portal.util.PrefsPropsUtil;
- import com.liferay.portal.util.PropsValues;
- import com.liferay.portal.util.SubscriptionSender;
- import com.liferay.portlet.asset.NoSuchEntryException;
- import com.liferay.portlet.asset.model.AssetEntry;
- import com.liferay.portlet.dynamicdatamapping.util.DDMXMLUtil;
- import com.liferay.portlet.expando.model.ExpandoBridge;
- import com.liferay.portlet.journal.ArticleContentException;
- import com.liferay.portlet.journal.ArticleDisplayDateException;
- import com.liferay.portlet.journal.ArticleExpirationDateException;
- import com.liferay.portlet.journal.ArticleIdException;
- import com.liferay.portlet.journal.ArticleReviewDateException;
- import com.liferay.portlet.journal.ArticleSmallImageNameException;
- import com.liferay.portlet.journal.ArticleSmallImageSizeException;
- import com.liferay.portlet.journal.ArticleTitleException;
- import com.liferay.portlet.journal.ArticleTypeException;
- import com.liferay.portlet.journal.ArticleVersionException;
- import com.liferay.portlet.journal.DuplicateArticleIdException;
- import com.liferay.portlet.journal.NoSuchArticleException;
- import com.liferay.portlet.journal.NoSuchArticleResourceException;
- import com.liferay.portlet.journal.NoSuchStructureException;
- import com.liferay.portlet.journal.NoSuchTemplateException;
- import com.liferay.portlet.journal.StructureXsdException;
- import com.liferay.portlet.journal.model.JournalArticle;
- import com.liferay.portlet.journal.model.JournalArticleConstants;
- import com.liferay.portlet.journal.model.JournalArticleDisplay;
- import com.liferay.portlet.journal.model.JournalStructure;
- import com.liferay.portlet.journal.model.JournalTemplate;
- import com.liferay.portlet.journal.model.impl.JournalArticleDisplayImpl;
- import com.liferay.portlet.journal.service.base.JournalArticleLocalServiceBaseImpl;
- import com.liferay.portlet.journal.util.JournalUtil;
- import com.liferay.portlet.journal.util.comparator.ArticleIDComparator;
- import com.liferay.portlet.journal.util.comparator.ArticleVersionComparator;
- import com.liferay.portlet.journalcontent.util.JournalContentUtil;
- import java.io.File;
- import java.io.IOException;
- import java.util.Calendar;
- import java.util.Date;
- import java.util.HashSet;
- import java.util.List;
- import java.util.Locale;
- import java.util.Map;
- import java.util.Set;
- import javax.mail.internet.InternetAddress;
- import javax.portlet.PortletPreferences;
- /**
- * @author Brian Wing Shun Chan
- * @author Raymond Augé
- * @author Bruno Farache
- * @author Juan Fernández
- */
- public class JournalArticleLocalServiceImpl
- extends JournalArticleLocalServiceBaseImpl {
- public JournalArticle addArticle(
- long userId, long groupId, String articleId, boolean autoArticleId,
- double version, Map<Locale, String> titleMap,
- Map<Locale, String> descriptionMap, String content, String type,
- String structureId, String templateId, String layoutUuid,
- int displayDateMonth, int displayDateDay, int displayDateYear,
- int displayDateHour, int displayDateMinute, int expirationDateMonth,
- int expirationDateDay, int expirationDateYear,
- int expirationDateHour, int expirationDateMinute,
- boolean neverExpire, int reviewDateMonth, int reviewDateDay,
- int reviewDateYear, int reviewDateHour, int reviewDateMinute,
- boolean neverReview, boolean indexable, boolean smallImage,
- String smallImageURL, File smallFile, Map<String, byte[]> images,
- String articleURL, ServiceContext serviceContext)
- throws PortalException, SystemException {
- // Article
- User user = userPersistence.findByPrimaryKey(userId);
- articleId = articleId.trim().toUpperCase();
- Date displayDate = PortalUtil.getDate(
- displayDateMonth, displayDateDay, displayDateYear,
- displayDateHour, displayDateMinute, user.getTimeZone(),
- new ArticleDisplayDateException());
- Date expirationDate = null;
- if (!neverExpire) {
- expirationDate = PortalUtil.getDate(
- expirationDateMonth, expirationDateDay, expirationDateYear,
- expirationDateHour, expirationDateMinute, user.getTimeZone(),
- new ArticleExpirationDateException());
- }
- Date reviewDate = null;
- if (!neverReview) {
- reviewDate = PortalUtil.getDate(
- reviewDateMonth, reviewDateDay, reviewDateYear, reviewDateHour,
- reviewDateMinute, user.getTimeZone(),
- new ArticleReviewDateException());
- }
- byte[] smallBytes = null;
- try {
- smallBytes = FileUtil.getBytes(smallFile);
- }
- catch (IOException ioe) {
- }
- Date now = new Date();
- validate(
- user.getCompanyId(), groupId, articleId, autoArticleId, version,
- titleMap, content, type, structureId, templateId,smallImage,
- smallImageURL, smallFile, smallBytes);
- if (autoArticleId) {
- articleId = String.valueOf(counterLocalService.increment());
- }
- long id = counterLocalService.increment();
- long resourcePrimKey =
- journalArticleResourceLocalService.getArticleResourcePrimKey(
- serviceContext.getUuid(), groupId, articleId);
- JournalArticle article = journalArticlePersistence.create(id);
- Locale locale = LocaleUtil.getDefault();
- String defaultLanguageId = GetterUtil.getString(
- serviceContext.getAttribute("defaultLanguageId"));
- if (Validator.isNotNull(defaultLanguageId)) {
- locale = LocaleUtil.fromLanguageId(defaultLanguageId);
- }
- String title = titleMap.get(locale);
- content = format(
- groupId, articleId, version, false, content, structureId, images);
- article.setResourcePrimKey(resourcePrimKey);
- article.setGroupId(groupId);
- article.setCompanyId(user.getCompanyId());
- article.setUserId(user.getUserId());
- article.setUserName(user.getFullName());
- article.setCreateDate(serviceContext.getCreateDate(now));
- article.setModifiedDate(serviceContext.getModifiedDate(now));
- article.setArticleId(articleId);
- article.setVersion(version);
- article.setTitleMap(titleMap, locale);
- article.setUrlTitle(getUniqueUrlTitle(id, groupId, articleId, title));
- article.setDescriptionMap(descriptionMap, locale);
- article.setContent(content);
- article.setType(type);
- article.setStructureId(structureId);
- article.setTemplateId(templateId);
- article.setLayoutUuid(layoutUuid);
- article.setDisplayDate(displayDate);
- article.setExpirationDate(expirationDate);
- article.setReviewDate(reviewDate);
- article.setIndexable(indexable);
- article.setSmallImage(smallImage);
- article.setSmallImageId(counterLocalService.increment());
- article.setSmallImageURL(smallImageURL);
- if ((expirationDate == null) || expirationDate.after(now)) {
- article.setStatus(WorkflowConstants.STATUS_DRAFT);
- }
- else {
- article.setStatus(WorkflowConstants.STATUS_EXPIRED);
- }
- journalArticlePersistence.update(article, false);
- // Resources
- if (serviceContext.getAddCommunityPermissions() ||
- serviceContext.getAddGuestPermissions()) {
- addArticleResources(
- article, serviceContext.getAddCommunityPermissions(),
- serviceContext.getAddGuestPermissions());
- }
- else {
- addArticleResources(
- article, serviceContext.getCommunityPermissions(),
- serviceContext.getGuestPermissions());
- }
- // Expando
- ExpandoBridge expandoBridge = article.getExpandoBridge();
- expandoBridge.setAttributes(serviceContext);
- // Small image
- saveImages(
- smallImage, article.getSmallImageId(), smallFile, smallBytes);
- // Asset
- updateAsset(
- userId, article, serviceContext.getAssetCategoryIds(),
- serviceContext.getAssetTagNames());
- // Message boards
- if (PropsValues.JOURNAL_ARTICLE_COMMENTS_ENABLED) {
- mbMessageLocalService.addDiscussionMessage(
- userId, article.getUserName(), groupId,
- JournalArticle.class.getName(), resourcePrimKey,
- WorkflowConstants.ACTION_PUBLISH);
- }
- // Email
- PortletPreferences preferences =
- ServiceContextUtil.getPortletPreferences(serviceContext);
- try {
- sendEmail(article, articleURL, preferences, "requested");
- }
- catch (IOException ioe) {
- throw new SystemException(ioe);
- }
- // Workflow
- WorkflowHandlerRegistryUtil.startWorkflowInstance(
- user.getCompanyId(), groupId, userId,
- JournalArticle.class.getName(), article.getResourcePrimKey(),
- article, serviceContext);
- return article;
- }
- public void addArticleResources(
- JournalArticle article, boolean addCommunityPermissions,
- boolean addGuestPermissions)
- throws PortalException, SystemException {
- resourceLocalService.addResources(
- article.getCompanyId(), article.getGroupId(),
- article.getUserId(), JournalArticle.class.getName(),
- article.getResourcePrimKey(), false, addCommunityPermissions,
- addGuestPermissions);
- }
- public void addArticleResources(
- JournalArticle article, String[] communityPermissions,
- String[] guestPermissions)
- throws PortalException, SystemException {
- resourceLocalService.addModelResources(
- article.getCompanyId(), article.getGroupId(),
- article.getUserId(), JournalArticle.class.getName(),
- article.getResourcePrimKey(), communityPermissions,
- guestPermissions);
- }
- public void addArticleResources(
- long groupId, String articleId, boolean addCommunityPermissions,
- boolean addGuestPermissions)
- throws PortalException, SystemException {
- JournalArticle article = getLatestArticle(groupId, articleId);
- addArticleResources(
- article, addCommunityPermissions, addGuestPermissions);
- }
- public void addArticleResources(
- long groupId, String articleId, String[] communityPermissions,
- String[] guestPermissions)
- throws PortalException, SystemException {
- JournalArticle article = getLatestArticle(groupId, articleId);
- addArticleResources(article, communityPermissions, guestPermissions);
- }
- public JournalArticle checkArticleResourcePrimKey(
- long groupId, String articleId, double version)
- throws PortalException, SystemException {
- JournalArticle article = journalArticlePersistence.findByG_A_V(
- groupId, articleId, version);
- if (article.getResourcePrimKey() > 0) {
- return article;
- }
- long resourcePrimKey =
- journalArticleResourceLocalService.getArticleResourcePrimKey(
- groupId, articleId);
- article.setResourcePrimKey(resourcePrimKey);
- journalArticlePersistence.update(article, false);
- return article;
- }
- public void checkArticles() throws PortalException, SystemException {
- Date now = new Date();
- List<JournalArticle> articles =
- journalArticleFinder.findByExpirationDate(
- WorkflowConstants.STATUS_APPROVED, now,
- new Date(now.getTime() - _JOURNAL_ARTICLE_CHECK_INTERVAL));
- if (_log.isDebugEnabled()) {
- _log.debug("Expiring " + articles.size() + " articles");
- }
- Set<Long> companyIds = new HashSet<Long>();
- for (JournalArticle article : articles) {
- article.setStatus(WorkflowConstants.STATUS_EXPIRED);
- journalArticlePersistence.update(article, false);
- if (article.isIndexable()) {
- Indexer indexer = IndexerRegistryUtil.getIndexer(
- JournalArticle.class);
- indexer.delete(article);
- }
- JournalContentUtil.clearCache(
- article.getGroupId(), article.getArticleId(),
- article.getTemplateId());
- companyIds.add(article.getCompanyId());
- }
- for (long companyId : companyIds) {
- CacheUtil.clearCache(companyId);
- }
- articles = journalArticleFinder.findByReviewDate(
- now, new Date(now.getTime() - _JOURNAL_ARTICLE_CHECK_INTERVAL));
- if (_log.isDebugEnabled()) {
- _log.debug(
- "Sending review notifications for " + articles.size() +
- " articles");
- }
- for (JournalArticle article : articles) {
- String articleURL = StringPool.BLANK;
- long ownerId = article.getGroupId();
- int ownerType = PortletKeys.PREFS_OWNER_TYPE_GROUP;
- long plid = PortletKeys.PREFS_PLID_SHARED;
- String portletId = PortletKeys.JOURNAL;
- PortletPreferences preferences =
- portletPreferencesLocalService.getPreferences(
- article.getCompanyId(), ownerId, ownerType, plid,
- portletId);
- try {
- sendEmail(article, articleURL, preferences, "review");
- }
- catch (IOException ioe) {
- throw new SystemException(ioe);
- }
- }
- }
- public void checkNewLine(long groupId, String articleId, double version)
- throws PortalException, SystemException {
- JournalArticle article = journalArticlePersistence.findByG_A_V(
- groupId, articleId, version);
- String content = GetterUtil.getString(article.getContent());
- if (content.indexOf("\\n") != -1) {
- content = StringUtil.replace(
- content,
- new String[] {"\\n", "\\r"},
- new String[] {"\n", "\r"});
- article.setContent(content);
- journalArticlePersistence.update(article, false);
- }
- }
- public void checkStructure(long groupId, String articleId, double version)
- throws PortalException, SystemException {
- JournalArticle article = journalArticlePersistence.findByG_A_V(
- groupId, articleId, version);
- if (Validator.isNull(article.getStructureId())) {
- return;
- }
- try {
- checkStructure(article);
- }
- catch (DocumentException de) {
- _log.error(de, de);
- }
- }
- public JournalArticle copyArticle(
- long userId, long groupId, String oldArticleId, String newArticleId,
- boolean autoArticleId, double version)
- throws PortalException, SystemException {
- // Article
- User user = userPersistence.findByPrimaryKey(userId);
- oldArticleId = oldArticleId.trim().toUpperCase();
- newArticleId = newArticleId.trim().toUpperCase();
- Date now = new Date();
- JournalArticle oldArticle = journalArticlePersistence.findByG_A_V(
- groupId, oldArticleId, version);
- if (autoArticleId) {
- newArticleId = String.valueOf(counterLocalService.increment());
- }
- else {
- validate(newArticleId);
- JournalArticle newArticle = journalArticlePersistence.fetchByG_A_V(
- groupId, newArticleId, version);
- if (newArticle != null) {
- throw new DuplicateArticleIdException();
- }
- }
- long id = counterLocalService.increment();
- long resourcePrimKey =
- journalArticleResourceLocalService.getArticleResourcePrimKey(
- groupId, newArticleId);
- JournalArticle newArticle = journalArticlePersistence.create(id);
- newArticle.setResourcePrimKey(resourcePrimKey);
- newArticle.setGroupId(groupId);
- newArticle.setCompanyId(user.getCompanyId());
- newArticle.setUserId(user.getUserId());
- newArticle.setUserName(user.getFullName());
- newArticle.setCreateDate(now);
- newArticle.setModifiedDate(now);
- newArticle.setArticleId(newArticleId);
- newArticle.setVersion(JournalArticleConstants.DEFAULT_VERSION);
- newArticle.setTitle(oldArticle.getTitle());
- newArticle.setDescription(oldArticle.getDescription());
- try {
- copyArticleImages(oldArticle, newArticle);
- }
- catch (Exception e) {
- newArticle.setContent(oldArticle.getContent());
- }
- newArticle.setType(oldArticle.getType());
- newArticle.setStructureId(oldArticle.getStructureId());
- newArticle.setTemplateId(oldArticle.getTemplateId());
- newArticle.setLayoutUuid(oldArticle.getLayoutUuid());
- newArticle.setDisplayDate(oldArticle.getDisplayDate());
- newArticle.setExpirationDate(oldArticle.getExpirationDate());
- newArticle.setReviewDate(oldArticle.getReviewDate());
- newArticle.setIndexable(oldArticle.isIndexable());
- newArticle.setSmallImage(oldArticle.isSmallImage());
- newArticle.setSmallImageId(counterLocalService.increment());
- newArticle.setSmallImageURL(oldArticle.getSmallImageURL());
- newArticle.setStatus(oldArticle.getStatus());
- journalArticlePersistence.update(newArticle, false);
- // Resources
- addArticleResources(newArticle, true, true);
- // Small image
- if (oldArticle.getSmallImage()) {
- Image image = imageLocalService.getImage(
- oldArticle.getSmallImageId());
- byte[] smallBytes = image.getTextObj();
- imageLocalService.updateImage(
- newArticle.getSmallImageId(), smallBytes);
- }
- // Asset
- String[] assetTagNames = assetTagLocalService.getTagNames(
- JournalArticle.class.getName(), oldArticle.getResourcePrimKey());
- updateAsset(userId, newArticle, null, assetTagNames);
- return newArticle;
- }
- public void deleteArticle(
- JournalArticle article, String articleURL,
- ServiceContext serviceContext)
- throws PortalException, SystemException {
- if (article.isApproved() &&
- isLatestVersion(
- article.getGroupId(), article.getArticleId(),
- article.getVersion(), WorkflowConstants.STATUS_APPROVED)) {
- updatePreviousApprovedArticle(article);
- }
- // Email
- PortletPreferences preferences =
- ServiceContextUtil.getPortletPreferences(serviceContext);
- if ((preferences != null) && !article.isApproved() &&
- isLatestVersion(
- article.getGroupId(), article.getArticleId(),
- article.getVersion())) {
- try {
- sendEmail(article, articleURL, preferences, "denied");
- }
- catch (IOException ioe) {
- throw new SystemException(ioe);
- }
- }
- // Images
- journalArticleImageLocalService.deleteImages(
- article.getGroupId(), article.getArticleId(), article.getVersion());
- // Workflow
- workflowInstanceLinkLocalService.deleteWorkflowInstanceLink(
- article.getCompanyId(), article.getGroupId(),
- JournalArticle.class.getName(), article.getResourcePrimKey());
- int articlesCount = journalArticlePersistence.countByG_A(
- article.getGroupId(), article.getArticleId());
- if (articlesCount == 1) {
- // Ratings
- ratingsStatsLocalService.deleteStats(
- JournalArticle.class.getName(), article.getResourcePrimKey());
- // Message boards
- mbMessageLocalService.deleteDiscussionMessages(
- JournalArticle.class.getName(), article.getResourcePrimKey());
- // Asset
- assetEntryLocalService.deleteEntry(
- JournalArticle.class.getName(), article.getResourcePrimKey());
- // Content searches
- journalContentSearchLocalService.deleteArticleContentSearches(
- article.getGroupId(), article.getArticleId());
- // Small image
- imageLocalService.deleteImage(article.getSmallImageId());
- // Expando
- expandoValueLocalService.deleteValues(
- JournalArticle.class.getName(), article.getResourcePrimKey());
- // Resources
- resourceLocalService.deleteResource(
- article.getCompanyId(), JournalArticle.class.getName(),
- ResourceConstants.SCOPE_INDIVIDUAL,
- article.getResourcePrimKey());
- // Resource
- try {
- journalArticleResourceLocalService.deleteArticleResource(
- article.getGroupId(), article.getArticleId());
- }
- catch (NoSuchArticleResourceException nsare) {
- }
- }
- // Article
- journalArticlePersistence.remove(article);
- }
- public void deleteArticle(
- long groupId, String articleId, double version, String articleURL,
- ServiceContext serviceContext)
- throws PortalException, SystemException {
- JournalArticle article = journalArticlePersistence.findByG_A_V(
- groupId, articleId, version);
- deleteArticle(article, articleURL, serviceContext);
- }
- public void deleteArticle(
- long groupId, String articleId, ServiceContext serviceContext)
- throws PortalException, SystemException {
- List<JournalArticle> articles = journalArticlePersistence.findByG_A(
- groupId, articleId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
- new ArticleVersionComparator(true));
- for (JournalArticle article : articles) {
- deleteArticle(article, null, serviceContext);
- }
- }
- public void deleteArticles(long groupId)
- throws PortalException, SystemException {
- for (JournalArticle article :
- journalArticlePersistence.findByGroupId(groupId)) {
- deleteArticle(article, null, null);
- }
- }
- public JournalArticle expireArticle(
- long userId, long groupId, String articleId, double version,
- String articleURL, ServiceContext serviceContext)
- throws PortalException, SystemException {
- return updateStatus(
- userId, groupId, articleId, version,
- WorkflowConstants.STATUS_EXPIRED, articleURL, serviceContext);
- }
- public void expireArticle(
- long userId, long groupId, String articleId, String articleURL,
- ServiceContext serviceContext)
- throws PortalException, SystemException {
- List<JournalArticle> articles = journalArticlePersistence.findByG_A(
- groupId, articleId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
- new ArticleVersionComparator(true));
- for (JournalArticle article : articles) {
- expireArticle(
- userId, groupId, article.getArticleId(), article.getVersion(),
- articleURL, serviceContext);
- }
- }
- public JournalArticle getArticle(long id)
- throws PortalException, SystemException {
- return journalArticlePersistence.findByPrimaryKey(id);
- }
- public JournalArticle getArticle(long groupId, String articleId)
- throws PortalException, SystemException {
- // Get the latest article that is approved, if none are approved, get
- // the latest unapproved article
- try {
- return getLatestArticle(
- groupId, articleId, WorkflowConstants.STATUS_APPROVED);
- }
- catch (NoSuchArticleException nsae) {
- return getLatestArticle(
- groupId, articleId, WorkflowConstants.STATUS_ANY);
- }
- }
- public JournalArticle getArticle(
- long groupId, String articleId, double version)
- throws PortalException, SystemException {
- return journalArticlePersistence.findByG_A_V(
- groupId, articleId, version);
- }
- public JournalArticle getArticleByUrlTitle(long groupId, String urlTitle)
- throws PortalException, SystemException {
- // Get the latest article that is approved, if none are approved, get
- // the latest unapproved article
- try {
- return getLatestArticleByUrlTitle(
- groupId, urlTitle, WorkflowConstants.STATUS_APPROVED);
- }
- catch (NoSuchArticleException nsae) {
- return getLatestArticleByUrlTitle(
- groupId, urlTitle, WorkflowConstants.STATUS_PENDING);
- }
- }
- public String getArticleContent(
- JournalArticle article, String templateId, String viewMode,
- String languageId, ThemeDisplay themeDisplay)
- throws PortalException, SystemException {
- JournalArticleDisplay articleDisplay = getArticleDisplay(
- article, templateId, viewMode, languageId, 1, null, themeDisplay);
- if (articleDisplay == null) {
- return StringPool.BLANK;
- }
- else {
- return articleDisplay.getContent();
- }
- }
- public String getArticleContent(
- long groupId, String articleId, double version, String viewMode,
- String templateId, String languageId, ThemeDisplay themeDisplay)
- throws PortalException, SystemException {
- JournalArticleDisplay articleDisplay = getArticleDisplay(
- groupId, articleId, version, templateId, viewMode, languageId,
- themeDisplay);
- if (articleDisplay == null) {
- return StringPool.BLANK;
- }
- else {
- return articleDisplay.getContent();
- }
- }
- public String getArticleContent(
- long groupId, String articleId, double version, String viewMode,
- String languageId, ThemeDisplay themeDisplay)
- throws PortalException, SystemException {
- return getArticleContent(
- groupId, articleId, version, viewMode, null, languageId,
- themeDisplay);
- }
- public String getArticleContent(
- long groupId, String articleId, String viewMode, String templateId,
- String languageId, ThemeDisplay themeDisplay)
- throws PortalException, SystemException {
- JournalArticleDisplay articleDisplay = getArticleDisplay(
- groupId, articleId, templateId, viewMode, languageId, themeDisplay);
- return articleDisplay.getContent();
- }
- public String getArticleContent(
- long groupId, String articleId, String viewMode, String languageId,
- ThemeDisplay themeDisplay)
- throws PortalException, SystemException {
- return getArticleContent(
- groupId, articleId, viewMode, null, languageId, themeDisplay);
- }
- public JournalArticleDisplay getArticleDisplay(
- JournalArticle article, String templateId, String viewMode,
- String languageId, int page, String xmlRequest,
- ThemeDisplay themeDisplay)
- throws PortalException, SystemException {
- String content = null;
- if (page < 1) {
- page = 1;
- }
- int numberOfPages = 1;
- boolean paginate = false;
- boolean pageFlow = false;
- boolean cacheable = true;
- if (Validator.isNull(xmlRequest)) {
- xmlRequest = "<request />";
- }
- Map<String, String> tokens = JournalUtil.getTokens(
- article.getGroupId(), themeDisplay, xmlRequest);
- tokens.put(
- "article_resource_pk",
- String.valueOf(article.getResourcePrimKey()));
- String defaultTemplateId = article.getTemplateId();
- if (article.isTemplateDriven()) {
- if (Validator.isNull(templateId)) {
- templateId = defaultTemplateId;
- }
- tokens.put("structure_id", article.getStructureId());
- tokens.put("template_id", templateId);
- }
- String xml = article.getContent();
- try {
- Document doc = null;
- Element root = null;
- if (article.isTemplateDriven()) {
- doc = SAXReaderUtil.read(xml);
- root = doc.getRootElement();
- Document request = SAXReaderUtil.read(xmlRequest);
- List<Element> pages = root.elements("page");
- if (pages.size() > 0) {
- pageFlow = true;
- String targetPage = request.valueOf(
- "/request/parameters/parameter[name='targetPage']/" +
- "value");
- Element pageEl = null;
- if (Validator.isNotNull(targetPage)) {
- XPath xpathSelector = SAXReaderUtil.createXPath(
- "/root/page[@id = '" + targetPage + "']");
- pageEl = (Element)xpathSelector.selectSingleNode(doc);
- }
- if (pageEl != null) {
- doc = SAXReaderUtil.createDocument(pageEl);
- root = doc.getRootElement();
- numberOfPages = pages.size();
- }
- else {
- if (page > pages.size()) {
- page = 1;
- }
- pageEl = pages.get(page - 1);
- doc = SAXReaderUtil.createDocument(pageEl);
- root = doc.getRootElement();
- numberOfPages = pages.size();
- paginate = true;
- }
- }
- root.add(request.getRootElement().createCopy());
- JournalUtil.addAllReservedEls(root, tokens, article);
- xml = DDMXMLUtil.formatXML(doc);
- }
- }
- catch (DocumentException de) {
- throw new SystemException(de);
- }
- catch (IOException ioe) {
- throw new SystemException(ioe);
- }
- try {
- if (_log.isDebugEnabled()) {
- _log.debug(
- "Transforming " + article.getArticleId() + " " +
- article.getVersion() + " " + languageId);
- }
- String script = null;
- String langType = null;
- if (article.isTemplateDriven()) {
- // Try with specified template first (in the current group and
- // the global group). If a template is not specified, use the
- // default one. If the specified template does not exit, use the
- // default one. If the default one does not exist, throw an
- // exception.
- JournalTemplate template = null;
- try {
- template = journalTemplatePersistence.findByG_T(
- article.getGroupId(), templateId);
- }
- catch (NoSuchTemplateException nste1) {
- try {
- Group companyGroup = groupLocalService.getCompanyGroup(
- article.getCompanyId());
- template = journalTemplatePersistence.findByG_T(
- companyGroup.getGroupId(), templateId);
- tokens.put(
- "group_id",
- String.valueOf(companyGroup.getGroupId()));
- }
- catch (NoSuchTemplateException nste2) {
- if (!defaultTemplateId.equals(templateId)) {
- template = journalTemplatePersistence.findByG_T(
- article.getGroupId(), defaultTemplateId);
- }
- else {
- throw nste1;
- }
- }
- }
- script = template.getXsl();
- langType = template.getLangType();
- cacheable = template.isCacheable();
- }
- content = JournalUtil.transform(
- themeDisplay, tokens, viewMode, languageId, xml, script,
- langType);
- if (!pageFlow) {
- String[] pieces = StringUtil.split(
- content, PropsValues.JOURNAL_ARTICLE_TOKEN_PAGE_BREAK);
- if (pieces.length > 1) {
- if (page > pieces.length) {
- page = 1;
- }
- content = pieces[page - 1];
- numberOfPages = pieces.length;
- paginate = true;
- }
- }
- }
- catch (Exception e) {
- throw new SystemException(e);
- }
- return new JournalArticleDisplayImpl(
- article.getCompanyId(), article.getId(),
- article.getResourcePrimKey(), article.getGroupId(),
- article.getUserId(), article.getArticleId(), article.getVersion(),
- article.getTitle(languageId), article.getUrlTitle(),
- article.getDescription(languageId), article.getAvailableLocales(),
- content, article.getType(), article.getStructureId(), templateId,
- article.isSmallImage(), article.getSmallImageId(),
- article.getSmallImageURL(), numberOfPages, page, paginate,
- cacheable);
- }
- public JournalArticleDisplay getArticleDisplay(
- long groupId, String articleId, double version, String templateId,
- String viewMode, String languageId, int page, String xmlRequest,
- ThemeDisplay themeDisplay)
- throws PortalException, SystemException {
- Date now = new Date();
- JournalArticle article = journalArticlePersistence.findByG_A_V(
- groupId, articleId, version);
- if (article.isExpired()) {
- Date expirationDate = article.getExpirationDate();
- if ((expirationDate != null) && expirationDate.before(now)) {
- return null;
- }
- }
- if (article.getDisplayDate().after(now)) {
- return null;
- }
- return getArticleDisplay(
- article, templateId, viewMode, languageId, page, xmlRequest,
- themeDisplay);
- }
- public JournalArticleDisplay getArticleDisplay(
- long groupId, String articleId, double version, String templateId,
- String viewMode, String languageId, ThemeDisplay themeDisplay)
- throws PortalException, SystemException {
- return getArticleDisplay(
- groupId, articleId, version, templateId, viewMode, languageId, 1,
- null, themeDisplay);
- }
- public JournalArticleDisplay getArticleDisplay(
- long groupId, String articleId, String viewMode, String languageId,
- int page, String xmlRequest, ThemeDisplay themeDisplay)
- throws PortalException, SystemException {
- return getArticleDisplay(
- groupId, articleId, null, viewMode, languageId, page, xmlRequest,
- themeDisplay);
- }
- public JournalArticleDisplay getArticleDisplay(
- long groupId, String articleId, String templateId, String viewMode,
- String languageId, int page, String xmlRequest,
- ThemeDisplay themeDisplay)
- throws PortalException, SystemException {
- JournalArticle article = getDisplayArticle(groupId, articleId);
- return getArticleDisplay(
- groupId, articleId, article.getVersion(), templateId, viewMode,
- languageId, page, xmlRequest, themeDisplay);
- }
- public JournalArticleDisplay getArticleDisplay(
- long groupId, String articleId, String templateId, String viewMode,
- String languageId, ThemeDisplay themeDisplay)
- throws PortalException, SystemException {
- JournalArticle article = getDisplayArticle(groupId, articleId);
- return getArticleDisplay(
- groupId, articleId, article.getVersion(), templateId, viewMode,
- languageId, themeDisplay);
- }
- public JournalArticleDisplay getArticleDisplay(
- long groupId, String articleId, String viewMode, String languageId,
- ThemeDisplay themeDisplay)
- throws PortalException, SystemException {
- return getArticleDisplay(
- groupId, articleId, null, viewMode, languageId, themeDisplay);
- }
- public List<JournalArticle> getArticles() throws SystemException {
- return journalArticlePersistence.findAll();
- }
- public List<JournalArticle> getArticles(long groupId)
- throws SystemException {
- return journalArticlePersistence.findByGroupId(groupId);
- }
- public List<JournalArticle> getArticles(long groupId, int start, int end)
- throws SystemException {
- return journalArticlePersistence.findByGroupId(groupId, start, end);
- }
- public List<JournalArticle> getArticles(
- long groupId, int start, int end, OrderByComparator obc)
- throws SystemException {
- return journalArticlePersistence.findByGroupId(
- groupId, start, end, obc);
- }
- public List<JournalArticle> getArticles(long groupId, String articleId)
- throws SystemException {
- return journalArticlePersistence.findByG_A(groupId, articleId);
- }
- public List<JournalArticle> getArticlesBySmallImageId(long smallImageId)
- throws SystemException {
- return journalArticlePersistence.findBySmallImageId(smallImageId);
- }
- public int getArticlesCount(long groupId) throws SystemException {
- return journalArticlePersistence.countByGroupId(groupId);
- }
- public List<JournalArticle> getCompanyArticles(
- long companyId, int status, int start, int end)
- throws SystemException {
- if (status == WorkflowConstants.STATUS_ANY) {
- return journalArticlePersistence.findByCompanyId(
- companyId, start, end, new ArticleIDComparator(true));
- }
- else {
- return journalArticlePersistence.findByC_ST(
- companyId, status, start, end, new ArticleIDComparator(true));
- }
- }
- public int getCompanyArticlesCount(long companyId, int status)
- throws SystemException {
- if (status == WorkflowConstants.STATUS_ANY) {
- return journalArticlePersistence.countByCompanyId(companyId);
- }
- else {
- return journalArticlePersistence.countByC_ST(companyId, status);
- }
- }
- public JournalArticle getDisplayArticle(long groupId, String articleId)
- throws PortalException, SystemException {
- List<JournalArticle> articles = journalArticlePersistence.findByG_A_ST(
- groupId, articleId, WorkflowConstants.STATUS_APPROVED);
- if (articles.size() == 0) {
- throw new NoSuchArticleException(
- "No approved JournalArticle with the key {groupId=" + groupId +
- ", " + "articleId=" + articleId + "}");
- }
- Date now = new Date();
- for (int i = 0; i < articles.size(); i++) {
- JournalArticle article = articles.get(i);
- Date expirationDate = article.getExpirationDate();
- if (article.getDisplayDate().before(now) &&
- ((expirationDate == null) || expirationDate.after(now))) {
- return article;
- }
- }
- return articles.get(0);
- }
- public JournalArticle getLatestArticle(long resourcePrimKey)
- throws PortalException, SystemException {
- return getLatestArticle(resourcePrimKey, WorkflowConstants.STATUS_ANY);
- }
- public JournalArticle getLatestArticle(long resourcePrimKey, int status)
- throws PortalException, SystemException {
- return getLatestArticle(resourcePrimKey, status, true);
- }
- public JournalArticle getLatestArticle(
- long resourcePrimKey, int status, boolean preferApproved)
- throws PortalException, SystemException {
- List<JournalArticle> articles = null;
- OrderByComparator orderByComparator = new ArticleVersionComparator();
- if (status == WorkflowConstants.STATUS_ANY) {
- if (preferApproved) {
- articles = journalArticlePersistence.findByR_ST(
- resourcePrimKey, WorkflowConstants.STATUS_APPROVED, 0, 1,
- orderByComparator);
- }
- if ((articles == null) || (articles.size() == 0)) {
- articles = journalArticlePersistence.findByResourcePrimKey(
- resourcePrimKey, 0, 1, orderByComparator);
- }
- }
- else {
- articles = journalArticlePersistence.findByR_ST(
- resourcePrimKey, status, 0, 1, orderByComparator);
- }
- if (articles.size() == 0) {
- throw new NoSuchArticleException(
- "No JournalArticle with the key {resourcePrimKey=" +
- resourcePrimKey + "}");
- }
- return articles.get(0);
- }
- public JournalArticle getLatestArticle(long groupId, String articleId)
- throws PortalException, SystemException {
- return getLatestArticle(
- groupId, articleId, WorkflowConstants.STATUS_ANY);
- }
- public JournalArticle getLatestArticle(
- long groupId, String articleId, int status)
- throws PortalException, SystemException {
- List<JournalArticle> articles = null;
- OrderByComparator orderByComparator = new ArticleVersionComparator();
- if (status == WorkflowConstants.STATUS_ANY) {
- articles = journalArticlePersistence.findByG_A(
- groupId, articleId, 0, 1, orderByComparator);
- }
- else {
- articles = journalArticlePersistence.findByG_A_ST(
- groupId, articleId, status, 0, 1, orderByComparator);
- }
- if (articles.size() == 0) {
- throw new NoSuchArticleException(
- "No JournalArticle with the key {groupId=" + groupId +
- ", articleId=" + articleId + ", status=" + status + "}");
- }
- return articles.get(0);
- }
- public JournalArticle getLatestArticleByUrlTitle(
- long groupId, String urlTitle, int status)
- throws PortalException, SystemException {
- List<JournalArticle> articles = null;
- OrderByComparator orderByComparator = new ArticleVersionComparator();
- if (status == WorkflowConstants.STATUS_ANY) {
- articles = journalArticlePersistence.findByG_UT(
- groupId, urlTitle, 0, 1, orderByComparator);
- }
- else {
- articles = journalArticlePersistence.findByG_UT_ST(
- groupId, urlTitle, status, 0, 1, orderByComparator);
- }
- if (articles.size() == 0) {
- throw new NoSuchArticleException(
- "No JournalArticle with the key {groupId=" + groupId +
- ", urlTitle=" + urlTitle + ", status=" + status + "}");
- }
- return articles.get(0);
- }
- public double getLatestVersion(long groupId, String articleId)
- throws PortalException, SystemException {
- JournalArticle article = getLatestArticle(groupId, articleId);
- return article.getVersion();
- }
- public double getLatestVersion(
- long groupId, String articleId, int status)
- throws PortalException, SystemException {
- JournalArticle article = getLatestArticle(groupId, articleId, status);
- return article.getVersion();
- }
- public List<JournalArticle> getStructureArticles(
- long groupId, String structureId)
- throws SystemException {
- return journalArticlePersistence.findByG_S(groupId, structureId);
- }
- public List<JournalArticle> getStructureArticles(
- long groupId, String structureId, int start, int end,
- OrderByComparator obc)
- throws SystemException {
- return journalArticlePersistence.findByG_S(
- groupId, structureId, start, end, obc);
- }
- public int getStructureArticlesCount(long groupId, String structureId)
- throws SystemException {
- return journalArticlePersistence.countByG_S(groupId, structureId);
- }
- public List<JournalArticle> getTemplateArticles(
- long groupId, String templateId)
- throws SystemException {
- return journalArticlePersistence.findByG_T(groupId, templateId);
- }
- public List<JournalArticle> getTemplateArticles(
- long groupId, String templateId, int start, int end,
- OrderByComparator obc)
- throws SystemException {
- return journalArticlePersistence.findByG_T(
- groupId, templateId, start, end, obc);
- }
- public int getTemplateArticlesCount(long groupId, String templateId)
- throws SystemException {
- return journalArticlePersistence.countByG_T(groupId, templateId);
- }
- public boolean hasArticle(long groupId, String articleId)
- throws SystemException {
- try {
- getArticle(groupId, articleId);
- return true;
- }
- catch (PortalException pe) {
- return false;
- }
- }
- public boolean isLatestVersion(
- long groupId, String articleId, double version)
- throws PortalException, SystemException {
- if (getLatestVersion(groupId, articleId) == version) {
- return true;
- }
- else {
- return false;
- }
- }
- public boolean isLatestVersion(
- long groupId, String articleId, double version, int status)
- throws PortalException, SystemException {
- if (getLatestVersion(groupId, articleId, status) == version) {
- return true;
- }
- else {
- return false;
- }
- }
- public JournalArticle removeArticleLocale(
- long groupId, String articleId, double version, String languageId)
- throws PortalException, SystemException {
- JournalArticle article = journalArticlePersistence.findByG_A_V(
- groupId, articleId, version);
- String title = article.getTitle();
- title = LocalizationUtil.removeLocalization(
- title, "static-content", languageId, true);
- article.setTitle(title);
- String description = article.getDescription();
- description = LocalizationUtil.removeLocalization(
- description, "static-content", languageId, true);
- article.setDescription(description);
- String content = article.getContent();
- if (article.isTemplateDriven()) {
- content = JournalUtil.removeArticleLocale(content, languageId);
- }
- else {
- content = LocalizationUtil.removeLocalization(
- content, "static-content", languageId, true);
- }
- article.setContent(content);
- journalArticlePersistence.update(article, false);
- return article;
- }
- public List<JournalArticle> search(
- long companyId, long groupId, String keywords, Double version,
- String type, String structureId, String templateId,
- Date displayDateGT, Date displayDateLT, int status, Date reviewDate,
- int start, int end, OrderByComparator obc)
- throws SystemException {
- return journalArticleFinder.findByKeywords(
- companyId, groupId, keywords, version, type, structureId,
- templateId, displayDateGT, displayDateLT, status, reviewDate, start,
- end, obc);
- }
- public List<JournalArticle> search(
- long companyId, long groupId, String articleId, Double version,
- String title, String description, String content, String type,
- String structureId, String templateId, Date displayDateGT,
- Date displayDateLT, int status, Date reviewDate,
- boolean andOperator, int start, int end, OrderByComparator obc)
- throws SystemException {
- return journalArticleFinder.findByC_G_A_V_T_D_C_T_S_T_D_S_R(
- companyId, groupId, articleId, version, title, description, content,
- type, structureId, templateId, displayDateGT, displayDateLT,
- status, reviewDate, andOperator, start, end, obc);
- }
- public List<JournalArticle> search(
- long companyId, long groupId, String articleId, Double version,
- String title, String description, String content, String type,
- String[] structureIds, String[] templateIds, Date displayDateGT,
- Date displayDateLT, int status, Date reviewDate,
- boolean andOperator, int start, int end, OrderByComparator obc)
- throws SystemException {
- return journalArticleFinder.findByC_G_A_V_T_D_C_T_S_T_D_S_R(
- companyId, groupId, articleId, version, title, description, content,
- type, structureIds, templateIds, displayDateGT, displayDateLT,
- status, reviewDate, andOperator, start, end, obc);
- }
- public int searchCount(
- long companyId, long groupId, String keywords, Double version,
- String type, String structureId, String templateId,
- Date displayDateGT, Date displayDateLT, int status, Date reviewDate)
- throws SystemException {
- return journalArticleFinder.countByKeywords(
- companyId, groupId, keywords, version, type, structureId,
- templateId, displayDateGT, displayDateLT, status, reviewDate);
- }
- public int searchCount(
- long companyId, long groupId, String articleId, Double version,
- String title, String description, String content, String type,
- String structureId, String templateId, Date displayDateGT,
- Date displayDateLT, int status, Date reviewDate,
- boolean andOperator)
- throws SystemException {
- return journalArticleFinder.countByC_G_A_V_T_D_C_T_S_T_D_S_R(
- companyId, groupId, articleId, version, title, description, content,
- type, structureId, templateId, displayDateGT, displayDateLT,
- status, reviewDate, andOperator);
- }
- public int searchCount(
- long companyId, long groupId, String articleId, Double version,
- String title, String description, String content, String type,
- String[] structureIds, String[] templateIds, Date displayDateGT,
- Date displayDateLT, int status, Date reviewDate,
- boolean andOperator)
- throws SystemException {
- return journalArticleFinder.countByC_G_A_V_T_D_C_T_S_T_D_S_R(
- companyId, groupId, articleId, version, title, description, content,
- type, structureIds, templateIds, displayDateGT, displayDateLT,
- status, reviewDate, andOperator);
- }
- public void subscribe(long userId, long groupId)
- throws PortalException, SystemException {
- subscriptionLocalService.addSubscription(
- userId, groupId, JournalArticle.class.getName(), groupId);
- }
- public void unsubscribe(long userId, long groupId)
- throws PortalException, SystemException {
- subscriptionLocalService.deleteSubscription(
- userId, JournalArticle.class.getName(), groupId);
- }
- public JournalArticle updateArticle(
- long userId, long groupId, String articleId, double version,
- Map<Locale, String> titleMap, Map<Locale, String> descriptionMap,
- String content, String layoutUuid, ServiceContext serviceContext)
- throws PortalException, SystemException {
- User user = userPersistence.findByPrimaryKey(userId);
- JournalArticle article = journalArticlePersistence.findByG_A_V(
- groupId, articleId, version);
- Date displayDate = article.getDisplayDate();
- int displayDateMonth = 0;
- int displayDateDay = 0;
- int displayDateYear = 0;
- int displayDateHour = 0;
- int displayDateMinute = 0;
- if (displayDate != null) {
- Calendar displayCal = CalendarFactoryUtil.getCalendar(
- user.getTimeZone());
- displayCal.setTime(displayDate);
- displayDateMonth = displayCal.get(Calendar.MONTH);
- displayDateDay = displayCal.get(Calendar.DATE);
- displayDateYear = displayCal.get(Calendar.YEAR);
- displayDateHour = displayCal.get(Calendar.HOUR);
- displayDateMinute = displayCal.get(Calendar.MINUTE);
- if (displayCal.get(Calendar.AM_PM) == Calendar.PM) {
- displayDateHour += 12;
- }
- }
- Date expirationDate = article.getExpirationDate();
- int expirationDateMonth = 0;
- int expirationDateDay = 0;
- int expirationDateYear = 0;
- int expirationDateHour = 0;
- int expirationDateMinute = 0;
- boolean neverExpire = true;
- if (expirationDate != null) {
- Calendar expirationCal = CalendarFactoryUtil.getCalendar(
- user.getTimeZone());
- expirationCal.setTime(expirationDate);
- expirationDateMonth = expirationCal.get(Calendar.MONTH);
- expirationDateDay = expirationCal.get(Calendar.DATE);
- expirationDateYear = expirationCal.get(Calendar.YEAR);
- expirationDateHour = expirationCal.get(Calendar.HOUR);
- expirationDateMinute = expirationCal.get(Calendar.MINUTE);
- neverExpire = false;
- if (expirationCal.get(Calendar.AM_PM) == Calendar.PM) {
- expirationDateHour += 12;
- }
- }
- Date reviewDate = article.getReviewDate();
- int reviewDateMonth = 0;
- int reviewDateDay = 0;
- int reviewDateYear = 0;
- int reviewDateHour = 0;
- int reviewDateMinute = 0;
- boolean neverReview = true;
- if (reviewDate != null) {
- Calendar reviewCal = CalendarFactoryUtil.getCalendar(
- user.getTimeZone());
- reviewCal.setTime(reviewDate);
- reviewDateMonth = reviewCal.get(Calendar.MONTH);
- reviewDateDay = reviewCal.get(Calendar.DATE);
- reviewDateYear = reviewCal.get(Calendar.YEAR);
- reviewDateHour = reviewCal.get(Calendar.HOUR);
- reviewDateMinute = reviewCal.get(Calendar.MINUTE);
- neverReview = false;
- if (reviewCal.get(Calendar.AM_PM) == Calendar.PM) {
- reviewDateHour += 12;
- }
- }
- return updateArticle(
- userId, groupId, articleId, version, titleMap, descriptionMap,
- content, article.getType(), article.getStructureId(),
- article.getTemplateId(), layoutUuid, displayDateMonth,
- displayDateDay, displayDateYear, displayDateHour, displayDateMinute,
- expirationDateMonth, expirationDateDay, expirationDateYear,
- expirationDateHour, expirationDateMinute, neverExpire,
- reviewDateMonth, reviewDateDay, reviewDateYear, reviewDateHour,
- reviewDateMinute, neverReview, article.getIndexable(),
- article.isSmallImage(), article.getSmallImageURL(), null, null,
- null, serviceContext);
- }
- public JournalArticle updateArticle(
- long userId, long groupId, String articleId, double version,
- Map<Locale, String> titleMap, Map<Locale, String> descriptionMap,
- String content, String type, String struct