Example usage for com.liferay.portal.kernel.workflow WorkflowConstants STATUS_EXPIRED

List of usage examples for com.liferay.portal.kernel.workflow WorkflowConstants STATUS_EXPIRED

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.workflow WorkflowConstants STATUS_EXPIRED.

Prototype

int STATUS_EXPIRED

To view the source code for com.liferay.portal.kernel.workflow WorkflowConstants STATUS_EXPIRED.

Click Source Link

Usage

From source file:at.meduni.liferay.portlet.bbmrieric.model.D2BiobankClp.java

License:Open Source License

@Override
public boolean isExpired() {
    if (getStatus() == WorkflowConstants.STATUS_EXPIRED) {
        return true;
    } else {//from   ww w.j  ava  2s . com
        return false;
    }
}

From source file:com.inkwell.internet.slogan.model.impl.SloganModelImpl.java

License:Open Source License

public boolean isExpired() {
    if (getStatus() == WorkflowConstants.STATUS_EXPIRED) {
        return true;
    } else {//from w  w  w.  ja  v  a2s .c  o m
        return false;
    }
}

From source file:com.liferay.journal.content.web.internal.exportimport.portlet.preferences.processor.JournalContentExportImportPortletPreferencesProcessor.java

License:Open Source License

@Override
public PortletPreferences processExportPortletPreferences(PortletDataContext portletDataContext,
        PortletPreferences portletPreferences) throws PortletDataException {

    String portletId = portletDataContext.getPortletId();

    try {/* w  ww.j  av a 2s  .  c  o  m*/
        portletDataContext.addPortletPermissions(JournalPermission.RESOURCE_NAME);
    } catch (PortalException pe) {
        throw new PortletDataException("Unable to export portlet permissions", pe);
    }

    String articleId = portletPreferences.getValue("articleId", null);

    if (articleId == null) {
        if (_log.isDebugEnabled()) {
            _log.debug("No article ID found in preferences of portlet " + portletId);
        }

        return portletPreferences;
    }

    long articleGroupId = GetterUtil.getLong(portletPreferences.getValue("groupId", StringPool.BLANK));

    if (articleGroupId <= 0) {
        if (_log.isWarnEnabled()) {
            _log.warn("No group ID found in preferences of portlet " + portletId);
        }

        return portletPreferences;
    }

    Group group = _groupLocalService.fetchGroup(articleGroupId);

    if (ExportImportThreadLocal.isStagingInProcess() && !group.isStagedPortlet(JournalPortletKeys.JOURNAL)) {

        if (_log.isDebugEnabled()) {
            _log.debug("Web content is not staged in the site " + group.getName());
        }

        return portletPreferences;
    }

    long previousScopeGroupId = portletDataContext.getScopeGroupId();

    if (articleGroupId != previousScopeGroupId) {
        portletDataContext.setScopeGroupId(articleGroupId);
    }

    JournalArticle article = null;

    article = _journalArticleLocalService.fetchLatestArticle(articleGroupId, articleId,
            WorkflowConstants.STATUS_APPROVED);

    if (article == null) {
        article = _journalArticleLocalService.fetchLatestArticle(articleGroupId, articleId,
                WorkflowConstants.STATUS_EXPIRED);
    }

    if (article == null) {
        if (_log.isWarnEnabled()) {
            _log.warn("Portlet " + portletId + " refers to an invalid article ID " + articleId);
        }

        portletDataContext.setScopeGroupId(previousScopeGroupId);

        return portletPreferences;
    }

    if (!MapUtil.getBoolean(portletDataContext.getParameterMap(), PortletDataHandlerKeys.PORTLET_DATA)
            && MergeLayoutPrototypesThreadLocal.isInProgress()) {

        portletDataContext.setScopeGroupId(previousScopeGroupId);

        return portletPreferences;
    }

    StagedModelDataHandlerUtil.exportReferenceStagedModel(portletDataContext, portletId, article);

    String defaultDDMTemplateKey = article.getDDMTemplateKey();
    String preferenceDDMTemplateKey = portletPreferences.getValue("ddmTemplateKey", null);

    if (Validator.isNotNull(defaultDDMTemplateKey) && Validator.isNotNull(preferenceDDMTemplateKey)
            && !defaultDDMTemplateKey.equals(preferenceDDMTemplateKey)) {

        try {
            DDMTemplate ddmTemplate = _ddmTemplateLocalService.fetchTemplate(article.getGroupId(),
                    _portal.getClassNameId(DDMStructure.class), preferenceDDMTemplateKey, true);

            if (ddmTemplate == null) {
                ddmTemplate = _ddmTemplateLocalService.getTemplate(article.getGroupId(),
                        _portal.getClassNameId(DDMStructure.class), defaultDDMTemplateKey, true);

                portletPreferences.setValue("ddmTemplateKey", defaultDDMTemplateKey);
            }

            StagedModelDataHandlerUtil.exportReferenceStagedModel(portletDataContext, article, ddmTemplate,
                    PortletDataContext.REFERENCE_TYPE_STRONG);
        } catch (PortalException | ReadOnlyException e) {
            throw new PortletDataException("Unable to export referenced article template", e);
        }
    }

    portletDataContext.setScopeGroupId(previousScopeGroupId);

    return portletPreferences;
}

From source file:com.liferay.journal.exportimport.data.handler.JournalArticleStagedModelDataHandler.java

License:Open Source License

@Override
public int[] getExportableStatuses() {
    return new int[] { WorkflowConstants.STATUS_APPROVED, WorkflowConstants.STATUS_EXPIRED,
            WorkflowConstants.STATUS_SCHEDULED };
}

From source file:com.liferay.journal.exportimport.data.handler.JournalArticleStagedModelDataHandler.java

License:Open Source License

@Override
protected void doImportStagedModel(PortletDataContext portletDataContext, JournalArticle article)
        throws Exception {

    long userId = portletDataContext.getUserId(article.getUserUuid());

    long authorId = _journalCreationStrategy.getAuthorUserId(portletDataContext, article);

    if (authorId != JournalCreationStrategy.USE_DEFAULT_USER_ID_STRATEGY) {
        userId = authorId;//from w  ww.java2 s. com
    }

    User user = _userLocalService.getUser(userId);

    Map<Long, Long> folderIds = (Map<Long, Long>) portletDataContext.getNewPrimaryKeysMap(JournalFolder.class);

    long folderId = MapUtil.getLong(folderIds, article.getFolderId(), article.getFolderId());

    String articleId = article.getArticleId();

    boolean autoArticleId = false;

    if (Validator.isNumber(articleId)
            || (_journalArticleLocalService.fetchArticle(portletDataContext.getScopeGroupId(), articleId,
                    JournalArticleConstants.VERSION_DEFAULT) != null)) {

        autoArticleId = true;
    }

    Map<String, String> articleIds = (Map<String, String>) portletDataContext
            .getNewPrimaryKeysMap(JournalArticle.class + ".articleId");

    String newArticleId = articleIds.get(articleId);

    if (Validator.isNotNull(newArticleId)) {

        // A sibling of a different version was already assigned a new
        // article id

        articleId = newArticleId;
        autoArticleId = false;
    }

    String content = article.getContent();

    content = _journalArticleExportImportContentProcessor.replaceImportContentReferences(portletDataContext,
            article, content);

    article.setContent(content);

    String newContent = _journalCreationStrategy.getTransformedContent(portletDataContext, article);

    if (newContent != JournalCreationStrategy.ARTICLE_CONTENT_UNCHANGED) {
        article.setContent(newContent);
    }

    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;
        }
    }

    Map<String, String> ddmStructureKeys = (Map<String, String>) portletDataContext
            .getNewPrimaryKeysMap(DDMStructure.class + ".ddmStructureKey");

    String parentDDMStructureKey = MapUtil.getString(ddmStructureKeys, article.getDDMStructureKey(),
            article.getDDMStructureKey());

    Map<String, Long> ddmStructureIds = (Map<String, Long>) portletDataContext
            .getNewPrimaryKeysMap(DDMStructure.class);

    long ddmStructureId = 0;

    if (article.getClassNameId() != 0) {
        ddmStructureId = ddmStructureIds.get(article.getClassPK());
    }

    Map<String, String> ddmTemplateKeys = (Map<String, String>) portletDataContext
            .getNewPrimaryKeysMap(DDMTemplate.class + ".ddmTemplateKey");

    String parentDDMTemplateKey = MapUtil.getString(ddmTemplateKeys, article.getDDMTemplateKey(),
            article.getDDMTemplateKey());

    File smallFile = null;

    try {
        Element articleElement = portletDataContext.getImportDataStagedModelElement(article);

        if (article.isSmallImage()) {
            String smallImagePath = articleElement.attributeValue("small-image-path");

            if (Validator.isNotNull(article.getSmallImageURL())) {
                String smallImageURL = _journalArticleExportImportContentProcessor
                        .replaceImportContentReferences(portletDataContext, article,
                                article.getSmallImageURL());

                article.setSmallImageURL(smallImageURL);
            } else if (Validator.isNotNull(smallImagePath)) {
                byte[] bytes = portletDataContext.getZipEntryAsByteArray(smallImagePath);

                if (bytes != null) {
                    smallFile = FileUtil.createTempFile(article.getSmallImageType());

                    FileUtil.write(smallFile, bytes);
                }
            }
        }

        JournalArticle latestArticle = _journalArticleLocalService
                .fetchLatestArticle(article.getResourcePrimKey());

        if ((latestArticle != null) && (latestArticle.getId() == article.getId())) {

            List<Element> attachmentElements = portletDataContext.getReferenceDataElements(article,
                    DLFileEntry.class, PortletDataContext.REFERENCE_TYPE_WEAK);

            for (Element attachmentElement : attachmentElements) {
                String path = attachmentElement.attributeValue("path");

                FileEntry fileEntry = (FileEntry) portletDataContext.getZipEntryAsObject(path);

                InputStream inputStream = null;

                try {
                    String binPath = attachmentElement.attributeValue("bin-path");

                    if (Validator.isNull(binPath) && portletDataContext.isPerformDirectBinaryImport()) {

                        try {
                            inputStream = FileEntryUtil.getContentStream(fileEntry);
                        } catch (NoSuchFileException nsfe) {
                        }
                    } else {
                        inputStream = portletDataContext.getZipEntryAsInputStream(binPath);
                    }

                    if (inputStream == null) {
                        if (_log.isWarnEnabled()) {
                            _log.warn("Unable to import attachment for file " + "entry "
                                    + fileEntry.getFileEntryId());
                        }

                        continue;
                    }

                    TempFileEntryUtil.addTempFileEntry(portletDataContext.getScopeGroupId(), userId,
                            JournalArticleStagedModelDataHandler.class.getName(), fileEntry.getFileName(),
                            inputStream, fileEntry.getMimeType());
                } finally {
                    StreamUtil.cleanUp(inputStream);
                }
            }
        }

        String articleURL = null;

        boolean addGroupPermissions = _journalCreationStrategy.addGroupPermissions(portletDataContext, article);
        boolean addGuestPermissions = _journalCreationStrategy.addGuestPermissions(portletDataContext, article);

        ServiceContext serviceContext = portletDataContext.createServiceContext(article);

        serviceContext.setAddGroupPermissions(addGroupPermissions);
        serviceContext.setAddGuestPermissions(addGuestPermissions);

        if ((expirationDate != null) && expirationDate.before(new Date())) {
            article.setStatus(WorkflowConstants.STATUS_EXPIRED);
        }

        if ((article.getStatus() != WorkflowConstants.STATUS_APPROVED)
                && (article.getStatus() != WorkflowConstants.STATUS_SCHEDULED)) {

            serviceContext.setWorkflowAction(WorkflowConstants.ACTION_SAVE_DRAFT);
        }

        JournalArticle importedArticle = null;

        String articleResourceUuid = articleElement.attributeValue("article-resource-uuid");

        // Used when importing LARs with journal schemas under 1.1.0

        _setLegacyValues(article);

        if (portletDataContext.isDataStrategyMirror()) {
            serviceContext.setUuid(article.getUuid());
            serviceContext.setAttribute("articleResourceUuid", articleResourceUuid);
            serviceContext.setAttribute("urlTitle", article.getUrlTitle());

            boolean preloaded = GetterUtil.getBoolean(articleElement.attributeValue("preloaded"));

            JournalArticle existingArticle = fetchExistingArticle(articleResourceUuid,
                    portletDataContext.getScopeGroupId(), articleId, newArticleId, preloaded);

            JournalArticle existingArticleVersion = null;

            if (existingArticle != null) {
                existingArticleVersion = fetchExistingArticleVersion(article.getUuid(),
                        portletDataContext.getScopeGroupId(), existingArticle.getArticleId(),
                        article.getVersion());
            }

            if ((existingArticle != null) && (existingArticleVersion == null)) {

                autoArticleId = false;
                articleId = existingArticle.getArticleId();
            }

            if (existingArticleVersion == null) {
                importedArticle = _journalArticleLocalService.addArticle(userId,
                        portletDataContext.getScopeGroupId(), folderId, article.getClassNameId(),
                        ddmStructureId, articleId, autoArticleId, article.getVersion(), article.getTitleMap(),
                        article.getDescriptionMap(), article.getContent(), parentDDMStructureKey,
                        parentDDMTemplateKey, article.getLayoutUuid(), displayDateMonth, displayDateDay,
                        displayDateYear, displayDateHour, displayDateMinute, expirationDateMonth,
                        expirationDateDay, expirationDateYear, expirationDateHour, expirationDateMinute,
                        neverExpire, reviewDateMonth, reviewDateDay, reviewDateYear, reviewDateHour,
                        reviewDateMinute, neverReview, article.isIndexable(), article.isSmallImage(),
                        article.getSmallImageURL(), smallFile, null, articleURL, serviceContext);
            } else {
                importedArticle = _journalArticleLocalService.updateArticle(userId,
                        existingArticle.getGroupId(), folderId, existingArticle.getArticleId(),
                        article.getVersion(), article.getTitleMap(), article.getDescriptionMap(),
                        article.getContent(), parentDDMStructureKey, parentDDMTemplateKey,
                        article.getLayoutUuid(), displayDateMonth, displayDateDay, displayDateYear,
                        displayDateHour, displayDateMinute, expirationDateMonth, expirationDateDay,
                        expirationDateYear, expirationDateHour, expirationDateMinute, neverExpire,
                        reviewDateMonth, reviewDateDay, reviewDateYear, reviewDateHour, reviewDateMinute,
                        neverReview, article.isIndexable(), article.isSmallImage(), article.getSmallImageURL(),
                        smallFile, null, articleURL, serviceContext);

                String articleUuid = article.getUuid();
                String importedArticleUuid = importedArticle.getUuid();

                if (!articleUuid.equals(importedArticleUuid)) {
                    importedArticle.setUuid(articleUuid);

                    _journalArticleLocalService.updateJournalArticle(importedArticle);
                }
            }
        } else {
            importedArticle = _journalArticleLocalService.addArticle(userId,
                    portletDataContext.getScopeGroupId(), folderId, article.getClassNameId(), ddmStructureId,
                    articleId, autoArticleId, article.getVersion(), article.getTitleMap(),
                    article.getDescriptionMap(), article.getContent(), parentDDMStructureKey,
                    parentDDMTemplateKey, article.getLayoutUuid(), displayDateMonth, displayDateDay,
                    displayDateYear, displayDateHour, displayDateMinute, expirationDateMonth, expirationDateDay,
                    expirationDateYear, expirationDateHour, expirationDateMinute, neverExpire, reviewDateMonth,
                    reviewDateDay, reviewDateYear, reviewDateHour, reviewDateMinute, neverReview,
                    article.isIndexable(), article.isSmallImage(), article.getSmallImageURL(), smallFile, null,
                    articleURL, serviceContext);
        }

        portletDataContext.importClassedModel(article, importedArticle);

        if (Validator.isNull(newArticleId)) {
            articleIds.put(article.getArticleId(), importedArticle.getArticleId());
        }

        Map<Long, Long> articlePrimaryKeys = (Map<Long, Long>) portletDataContext
                .getNewPrimaryKeysMap(JournalArticle.class + ".primaryKey");

        articlePrimaryKeys.put(article.getPrimaryKey(), importedArticle.getPrimaryKey());
    } finally {
        if (smallFile != null) {
            smallFile.delete();
        }
    }
}

From source file:com.liferay.journal.service.impl.JournalArticleLocalServiceImpl.java

License:Open Source License

/**
 * Adds a web content article with additional parameters.
 *
 * <p>//from  w  w w  .j  av  a2  s  . com
 * The web content articles hold HTML content wrapped in XML. The XML lets
 * you specify the article's default locale and available locales. Here is a
 * content example:
 * </p>
 *
 * <p>
 * <pre>
 * <code>
 * &lt;?xml version='1.0' encoding='UTF-8'?&gt;
 * &lt;root default-locale="en_US" available-locales="en_US"&gt;
 *    &lt;static-content language-id="en_US"&gt;
 *       &lt;![CDATA[&lt;p&gt;&lt;b&gt;&lt;i&gt;test&lt;i&gt; content&lt;b&gt;&lt;/p&gt;]]&gt;
 *    &lt;/static-content&gt;
 * &lt;/root&gt;
 * </code>
 * </pre>
 * </p>
 *
 * @param  userId the primary key of the web content article's creator/owner
 * @param  groupId the primary key of the web content article's group
 * @param  folderId the primary key of the web content article folder
 * @param  classNameId the primary key of the DDMStructure class if the web
 *         content article is related to a DDM structure, the primary key of
 *         the class name associated with the article, or
 *         JournalArticleConstants.CLASSNAME_ID_DEFAULT in the journal-api
 *         module otherwise
 * @param  classPK the primary key of the DDM structure, if the primary key
 *         of the DDMStructure class is given as the
 *         <code>classNameId</code> parameter, the primary key of the class
 *         associated with the web content article, or <code>0</code>
 *         otherwise
 * @param  articleId the primary key of the web content article
 * @param  autoArticleId whether to auto generate the web content article ID
 * @param  version the web content article's version
 * @param  titleMap the web content article's locales and localized titles
 * @param  descriptionMap the web content article's locales and localized
 *         descriptions
 * @param  content the HTML content wrapped in XML
 * @param  ddmStructureKey the primary key of the web content article's DDM
 *         structure, if the article is related to a DDM structure, or
 *         <code>null</code> otherwise
 * @param  ddmTemplateKey the primary key of the web content article's DDM
 *         template
 * @param  layoutUuid the unique string identifying the web content
 *         article's display page
 * @param  displayDateMonth the month the web content article is set to
 *         display
 * @param  displayDateDay the calendar day the web content article is set to
 *         display
 * @param  displayDateYear the year the web content article is set to
 *         display
 * @param  displayDateHour the hour the web content article is set to
 *         display
 * @param  displayDateMinute the minute the web content article is set to
 *         display
 * @param  expirationDateMonth the month the web content article is set to
 *         expire
 * @param  expirationDateDay the calendar day the web content article is set
 *         to expire
 * @param  expirationDateYear the year the web content article is set to
 *         expire
 * @param  expirationDateHour the hour the web content article is set to
 *         expire
 * @param  expirationDateMinute the minute the web content article is set to
 *         expire
 * @param  neverExpire whether the web content article is not set to auto
 *         expire
 * @param  reviewDateMonth the month the web content article is set for
 *         review
 * @param  reviewDateDay the calendar day the web content article is set for
 *         review
 * @param  reviewDateYear the year the web content article is set for review
 * @param  reviewDateHour the hour the web content article is set for review
 * @param  reviewDateMinute the minute the web content article is set for
 *         review
 * @param  neverReview whether the web content article is not set for review
 * @param  indexable whether the web content article is searchable
 * @param  smallImage whether the web content article has a small image
 * @param  smallImageURL the web content article's small image URL
 * @param  smallImageFile the web content article's small image file
 * @param  images the web content's images
 * @param  articleURL the web content article's accessible URL
 * @param  serviceContext the service context to be applied. Can set the
 *         UUID, creation date, modification date, expando bridge
 *         attributes, guest permissions, group permissions, asset category
 *         IDs, asset tag names, asset link entry IDs, URL title, and
 *         workflow actions for the web content article. Can also set
 *         whether to add the default guest and group permissions.
 * @return the web content article
 */
@Indexable(type = IndexableType.REINDEX)
@Override
public JournalArticle addArticle(long userId, long groupId, long folderId, long classNameId, long classPK,
        String articleId, boolean autoArticleId, double version, Map<Locale, String> titleMap,
        Map<Locale, String> descriptionMap, String content, String ddmStructureKey, String ddmTemplateKey,
        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 smallImageFile,
        Map<String, byte[]> images, String articleURL, ServiceContext serviceContext) throws PortalException {

    // Article

    User user = userLocalService.getUser(userId);
    articleId = StringUtil.toUpperCase(StringUtil.trim(articleId));

    Date displayDate = null;
    Date expirationDate = null;
    Date reviewDate = null;

    if (classNameId == JournalArticleConstants.CLASSNAME_ID_DEFAULT) {
        displayDate = PortalUtil.getDate(displayDateMonth, displayDateDay, displayDateYear, displayDateHour,
                displayDateMinute, user.getTimeZone(), null);

        if (!neverExpire) {
            expirationDate = PortalUtil.getDate(expirationDateMonth, expirationDateDay, expirationDateYear,
                    expirationDateHour, expirationDateMinute, user.getTimeZone(),
                    ArticleExpirationDateException.class);
        }

        if (!neverReview) {
            reviewDate = PortalUtil.getDate(reviewDateMonth, reviewDateDay, reviewDateYear, reviewDateHour,
                    reviewDateMinute, user.getTimeZone(), ArticleReviewDateException.class);
        }
    }

    byte[] smallImageBytes = null;

    try {
        smallImageBytes = FileUtil.getBytes(smallImageFile);
    } catch (IOException ioe) {
    }

    Date now = new Date();

    validateDDMStructureId(groupId, folderId, ddmStructureKey);

    if (autoArticleId) {
        articleId = String.valueOf(counterLocalService.increment());
    }

    validate(user.getCompanyId(), groupId, classNameId, articleId, autoArticleId, version, titleMap, content,
            ddmStructureKey, ddmTemplateKey, displayDate, expirationDate, smallImage, smallImageURL,
            smallImageFile, smallImageBytes, serviceContext);

    validateReferences(groupId, ddmStructureKey, ddmTemplateKey, layoutUuid, smallImage, smallImageURL,
            smallImageBytes, 0, content);

    serviceContext.setAttribute("articleId", articleId);

    long id = counterLocalService.increment();

    String articleResourceUuid = GetterUtil.getString(serviceContext.getAttribute("articleResourceUuid"));

    long resourcePrimKey = journalArticleResourceLocalService.getArticleResourcePrimKey(articleResourceUuid,
            groupId, articleId);

    JournalArticle article = journalArticlePersistence.create(id);

    Locale locale = getArticleDefaultLocale(content);

    String title = titleMap.get(locale);

    article.setUuid(serviceContext.getUuid());
    article.setResourcePrimKey(resourcePrimKey);
    article.setGroupId(groupId);
    article.setCompanyId(user.getCompanyId());
    article.setUserId(user.getUserId());
    article.setUserName(user.getFullName());
    article.setFolderId(folderId);
    article.setClassNameId(classNameId);
    article.setClassPK(classPK);
    article.setTreePath(article.buildTreePath());
    article.setArticleId(articleId);
    article.setVersion(version);
    article.setUrlTitle(getUniqueUrlTitle(id, groupId, articleId, title, null, serviceContext));

    content = format(user, groupId, article, content);

    article.setContent(content);

    article.setDDMStructureKey(ddmStructureKey);
    article.setDDMTemplateKey(ddmTemplateKey);
    article.setDefaultLanguageId(LocaleUtil.toLanguageId(locale));
    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);
    }

    article.setStatusByUserId(userId);
    article.setStatusDate(serviceContext.getModifiedDate(now));
    article.setExpandoBridgeAttributes(serviceContext);

    journalArticlePersistence.update(article);

    // Article localization

    _addArticleLocalizedFields(user.getCompanyId(), article.getId(), titleMap, descriptionMap);

    // Resources

    if (serviceContext.isAddGroupPermissions() || serviceContext.isAddGuestPermissions()) {

        addArticleResources(article, serviceContext.isAddGroupPermissions(),
                serviceContext.isAddGuestPermissions());
    } else {
        addArticleResources(article, serviceContext.getGroupPermissions(),
                serviceContext.getGuestPermissions());
    }

    // Small image

    saveImages(smallImage, article.getSmallImageId(), smallImageFile, smallImageBytes);

    // Asset

    updateAsset(userId, article, serviceContext.getAssetCategoryIds(), serviceContext.getAssetTagNames(),
            serviceContext.getAssetLinkEntryIds(), serviceContext.getAssetPriority());

    // Dynamic data mapping

    if (classNameLocalService.getClassNameId(DDMStructure.class) == classNameId) {

        updateDDMStructurePredefinedValues(classPK, content, serviceContext);
    } else {
        updateDDMLinks(id, groupId, ddmStructureKey, ddmTemplateKey, true);
    }

    // Email

    PortletPreferences preferences = ServiceContextUtil.getPortletPreferences(serviceContext);

    articleURL = buildArticleURL(articleURL, groupId, folderId, articleId);

    serviceContext.setAttribute("articleURL", articleURL);

    sendEmail(article, articleURL, preferences, "requested", serviceContext);

    // Workflow

    if (classNameId == JournalArticleConstants.CLASSNAME_ID_DEFAULT) {
        startWorkflowInstance(userId, article, serviceContext);
    } else {
        updateStatus(userId, article, WorkflowConstants.STATUS_APPROVED, null, serviceContext,
                new HashMap<String, Serializable>());
    }

    return journalArticlePersistence.findByPrimaryKey(article.getId());
}

From source file:com.liferay.journal.service.impl.JournalArticleLocalServiceImpl.java

License:Open Source License

/**
 * Expires the web content article matching the group, article ID, and
 * version.//  ww  w. j  a v a  2  s  . c om
 *
 * @param  userId the primary key of the user updating the web content
 *         article
 * @param  groupId the primary key of the web content article's group
 * @param  articleId the primary key of the web content article
 * @param  version the web content article's version
 * @param  articleURL the web content article's accessible URL
 * @param  serviceContext the service context to be applied. Can set the
 *         modification date, status date, portlet preferences, and can set
 *         whether to add the default command update for the web content
 *         article. With respect to social activities, by setting the
 *         service context's command to {@link Constants#UPDATE}, the
 *         invocation is considered a web content update activity; otherwise
 *         it is considered a web content add activity.
 * @return the web content article
 */
@Indexable(type = IndexableType.REINDEX)
@Override
public JournalArticle expireArticle(long userId, long groupId, String articleId, double version,
        String articleURL, ServiceContext serviceContext) throws PortalException {

    return updateStatus(userId, groupId, articleId, version, WorkflowConstants.STATUS_EXPIRED, articleURL,
            new HashMap<String, Serializable>(), serviceContext);
}

From source file:com.liferay.journal.service.impl.JournalArticleLocalServiceImpl.java

License:Open Source License

/**
 * Updates the web content article with additional parameters.
 *
 * @param  userId the primary key of the user updating the web content
 *         article/*ww  w. jav  a  2 s. com*/
 * @param  groupId the primary key of the web content article's group
 * @param  folderId the primary key of the web content article folder
 * @param  articleId the primary key of the web content article
 * @param  version the web content article's version
 * @param  titleMap the web content article's locales and localized titles
 * @param  descriptionMap the web content article's locales and localized
 *         descriptions
 * @param  content the HTML content wrapped in XML. For more information,
 *         see the content example in the {@link #addArticle(long, long,
 *         long, long, long, String, boolean, double, Map, Map, String,
 *         String, String, String, int, int, int, int, int, int, int, int,
 *         int, int, boolean, int, int, int, int, int, boolean, boolean,
 *         boolean, String, File, Map, String, ServiceContext)} description.
 * @param  ddmStructureKey the primary key of the web content article's DDM
 *         structure, if the article is related to a DDM structure, or
 *         <code>null</code> otherwise
 * @param  ddmTemplateKey the primary key of the web content article's DDM
 *         template
 * @param  layoutUuid the unique string identifying the web content
 *         article's display page
 * @param  displayDateMonth the month the web content article is set to
 *         display
 * @param  displayDateDay the calendar day the web content article is set to
 *         display
 * @param  displayDateYear the year the web content article is set to
 *         display
 * @param  displayDateHour the hour the web content article is set to
 *         display
 * @param  displayDateMinute the minute the web content article is set to
 *         display
 * @param  expirationDateMonth the month the web content article is set to
 *         expire
 * @param  expirationDateDay the calendar day the web content article is set
 *         to expire
 * @param  expirationDateYear the year the web content article is set to
 *         expire
 * @param  expirationDateHour the hour the web content article is set to
 *         expire
 * @param  expirationDateMinute the minute the web content article is set to
 *         expire
 * @param  neverExpire whether the web content article is not set to auto
 *         expire
 * @param  reviewDateMonth the month the web content article is set for
 *         review
 * @param  reviewDateDay the calendar day the web content article is set for
 *         review
 * @param  reviewDateYear the year the web content article is set for review
 * @param  reviewDateHour the hour the web content article is set for review
 * @param  reviewDateMinute the minute the web content article is set for
 *         review
 * @param  neverReview whether the web content article is not set for review
 * @param  indexable whether the web content is searchable
 * @param  smallImage whether to update web content article's a small image.
 *         A file must be passed in as <code>smallImageFile</code> value,
 *         otherwise the current small image is deleted.
 * @param  smallImageURL the web content article's small image URL
 *         (optionally <code>null</code>)
 * @param  smallImageFile the web content article's new small image file
 *         (optionally <code>null</code>). Must pass in
 *         <code>smallImage</code> value of <code>true</code> to replace the
 *         article's small image file.
 * @param  images the web content's images (optionally <code>null</code>)
 * @param  articleURL the web content article's accessible URL (optionally
 *         <code>null</code>)
 * @param  serviceContext the service context to be applied. Can set the
 *         modification date, expando bridge attributes, asset category IDs,
 *         asset tag names, asset link entry IDs, asset priority, workflow
 *         actions, URL title , and can set whether to add the default
 *         command update for the web content article. With respect to
 *         social activities, by setting the service context's command to
 *         {@link Constants#UPDATE}, the invocation is considered a web
 *         content update activity; otherwise it is considered a web content
 *         add activity.
 * @return the updated web content article
 */
@Indexable(type = IndexableType.REINDEX)
@Override
public JournalArticle updateArticle(long userId, long groupId, long folderId, String articleId, double version,
        Map<Locale, String> titleMap, Map<Locale, String> descriptionMap, String content,
        String ddmStructureKey, String ddmTemplateKey, 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 smallImageFile, Map<String, byte[]> images,
        String articleURL, ServiceContext serviceContext) throws PortalException {

    // Article

    User user = userLocalService.getUser(userId);
    articleId = StringUtil.toUpperCase(StringUtil.trim(articleId));

    byte[] smallImageBytes = null;

    try {
        smallImageBytes = FileUtil.getBytes(smallImageFile);
    } catch (IOException ioe) {
    }

    JournalArticle latestArticle = getLatestArticle(groupId, articleId, WorkflowConstants.STATUS_ANY);

    JournalArticle article = latestArticle;

    boolean imported = ExportImportThreadLocal.isImportInProcess();

    double latestVersion = latestArticle.getVersion();

    boolean addNewVersion = false;

    if (imported) {
        article = getArticle(groupId, articleId, version);
    } else {
        if ((version > 0) && (version != latestVersion)) {
            StringBundler sb = new StringBundler(4);

            sb.append("Version ");
            sb.append(version);
            sb.append(" is not the same as ");
            sb.append(latestVersion);

            throw new ArticleVersionException(sb.toString());
        }

        serviceContext.validateModifiedDate(latestArticle, ArticleVersionException.class);

        if (latestArticle.isApproved() || latestArticle.isExpired() || latestArticle.isScheduled()) {

            addNewVersion = true;

            version = getNextVersion(article);
        }
    }

    Date displayDate = null;
    Date expirationDate = null;
    Date reviewDate = null;

    if (article.getClassNameId() == JournalArticleConstants.CLASSNAME_ID_DEFAULT) {

        displayDate = PortalUtil.getDate(displayDateMonth, displayDateDay, displayDateYear, displayDateHour,
                displayDateMinute, user.getTimeZone(), null);

        if (!neverExpire) {
            expirationDate = PortalUtil.getDate(expirationDateMonth, expirationDateDay, expirationDateYear,
                    expirationDateHour, expirationDateMinute, user.getTimeZone(),
                    ArticleExpirationDateException.class);
        }

        if (!neverReview) {
            reviewDate = PortalUtil.getDate(reviewDateMonth, reviewDateDay, reviewDateYear, reviewDateHour,
                    reviewDateMinute, user.getTimeZone(), ArticleReviewDateException.class);
        }
    }

    Date now = new Date();

    boolean expired = false;

    if ((expirationDate != null) && expirationDate.before(now)) {
        expired = true;
    }

    validate(user.getCompanyId(), groupId, latestArticle.getClassNameId(), titleMap, content, ddmStructureKey,
            ddmTemplateKey, displayDate, expirationDate, smallImage, smallImageURL, smallImageFile,
            smallImageBytes, serviceContext);

    validateReferences(groupId, ddmStructureKey, ddmTemplateKey, layoutUuid, smallImage, smallImageURL,
            smallImageBytes, latestArticle.getSmallImageId(), content);

    if (addNewVersion) {
        long id = counterLocalService.increment();

        article = journalArticlePersistence.create(id);

        article.setResourcePrimKey(latestArticle.getResourcePrimKey());
        article.setGroupId(latestArticle.getGroupId());
        article.setCompanyId(latestArticle.getCompanyId());
        article.setUserId(user.getUserId());
        article.setUserName(user.getFullName());
        article.setCreateDate(latestArticle.getCreateDate());
        article.setClassNameId(latestArticle.getClassNameId());
        article.setClassPK(latestArticle.getClassPK());
        article.setArticleId(articleId);
        article.setVersion(version);
        article.setSmallImageId(latestArticle.getSmallImageId());

        _addArticleLocalizedFields(article.getCompanyId(), article.getId(), titleMap, descriptionMap);
    } else {
        _updateArticleLocalizedFields(article.getCompanyId(), article.getId(), titleMap, descriptionMap);
    }

    Locale locale = getArticleDefaultLocale(content);

    String title = titleMap.get(locale);

    content = format(user, groupId, article, content);

    article.setFolderId(folderId);
    article.setTreePath(article.buildTreePath());
    article.setUrlTitle(getUniqueUrlTitle(article.getId(), groupId, article.getArticleId(), title,
            latestArticle.getUrlTitle(), serviceContext));
    article.setContent(content);
    article.setDDMStructureKey(ddmStructureKey);
    article.setDDMTemplateKey(ddmTemplateKey);
    article.setDefaultLanguageId(LocaleUtil.toLanguageId(locale));
    article.setLayoutUuid(layoutUuid);
    article.setDisplayDate(displayDate);
    article.setExpirationDate(expirationDate);
    article.setReviewDate(reviewDate);
    article.setIndexable(indexable);
    article.setSmallImage(smallImage);

    if (smallImage) {
        if ((smallImageFile != null) && (smallImageBytes != null)) {
            article.setSmallImageId(counterLocalService.increment());
        }
    } else {
        article.setSmallImageId(0);
    }

    article.setSmallImageURL(smallImageURL);

    if (latestArticle.isPending()) {
        article.setStatus(latestArticle.getStatus());
    } else if (!expired) {
        article.setStatus(WorkflowConstants.STATUS_DRAFT);
    } else {
        article.setStatus(WorkflowConstants.STATUS_EXPIRED);
    }

    ExpandoBridgeUtil.setExpandoBridgeAttributes(latestArticle.getExpandoBridge(), article.getExpandoBridge(),
            serviceContext);

    journalArticlePersistence.update(article);

    // Asset

    if (hasModifiedLatestApprovedVersion(groupId, articleId, version)) {
        updateAsset(userId, article, serviceContext.getAssetCategoryIds(), serviceContext.getAssetTagNames(),
                serviceContext.getAssetLinkEntryIds(), serviceContext.getAssetPriority());
    }

    // Dynamic data mapping

    if (classNameLocalService.getClassNameId(DDMStructure.class) == article.getClassNameId()) {

        updateDDMStructurePredefinedValues(article.getClassPK(), content, serviceContext);
    } else {
        updateDDMLinks(article.getId(), groupId, ddmStructureKey, ddmTemplateKey, addNewVersion);
    }

    // Small image

    saveImages(smallImage, article.getSmallImageId(), smallImageFile, smallImageBytes);

    // Email

    PortletPreferences preferences = ServiceContextUtil.getPortletPreferences(serviceContext);

    // Workflow

    if (expired && imported) {
        updateStatus(userId, article, article.getStatus(), articleURL, serviceContext,
                new HashMap<String, Serializable>());
    }

    if (serviceContext.getWorkflowAction() == WorkflowConstants.ACTION_PUBLISH) {

        articleURL = buildArticleURL(articleURL, groupId, folderId, articleId);

        serviceContext.setAttribute("articleURL", articleURL);

        sendEmail(article, articleURL, preferences, "requested", serviceContext);

        startWorkflowInstance(userId, article, serviceContext);
    }

    return journalArticlePersistence.findByPrimaryKey(article.getId());
}

From source file:com.liferay.journal.service.impl.JournalArticleLocalServiceImpl.java

License:Open Source License

/**
 * Updates the workflow status of the web content article.
 *
 * @param  userId the primary key of the user updating the web content
 *         article's status//  w  w  w.  j a v  a2s.  com
 * @param  article the web content article
 * @param  status the web content article's workflow status. For more
 *         information see {@link WorkflowConstants} for constants starting
 *         with the "STATUS_" prefix.
 * @param  articleURL the web content article's accessible URL
 * @param  serviceContext the service context to be applied. Can set the
 *         modification date, status date, and portlet preferences. With
 *         respect to social activities, by setting the service context's
 *         command to {@link Constants#UPDATE}, the invocation is considered
 *         a web content update activity; otherwise it is considered a web
 *         content add activity.
 * @param  workflowContext the web content article's configured workflow
 *         context
 * @return the updated web content article
 */
@Indexable(type = IndexableType.REINDEX)
@Override
public JournalArticle updateStatus(long userId, JournalArticle article, int status, String articleURL,
        ServiceContext serviceContext, Map<String, Serializable> workflowContext) throws PortalException {

    // Article

    User user = userLocalService.getUser(userId);
    Date now = new Date();

    if ((status == WorkflowConstants.STATUS_APPROVED)
            && (article.getClassNameId() == JournalArticleConstants.CLASSNAME_ID_DEFAULT)
            && (article.getDisplayDate() != null) && now.before(article.getDisplayDate())) {

        status = WorkflowConstants.STATUS_SCHEDULED;
    }

    int oldStatus = article.getStatus();

    Date modifiedDate = serviceContext.getModifiedDate(now);

    article.setModifiedDate(modifiedDate);

    if (status == WorkflowConstants.STATUS_APPROVED) {
        Date expirationDate = article.getExpirationDate();

        if ((expirationDate != null) && expirationDate.before(now)) {
            article.setExpirationDate(null);
        }
    }

    if (status == WorkflowConstants.STATUS_EXPIRED) {
        article.setExpirationDate(now);
    }

    article.setStatus(status);
    article.setStatusByUserId(user.getUserId());
    article.setStatusByUserName(user.getFullName());
    article.setStatusDate(modifiedDate);

    journalArticlePersistence.update(article);

    if (isExpireAllArticleVersions(article.getCompanyId())) {
        setArticlesExpirationDate(article);
    }

    if (hasModifiedLatestApprovedVersion(article.getGroupId(), article.getArticleId(), article.getVersion())) {

        if (status == WorkflowConstants.STATUS_APPROVED) {
            updateUrlTitles(article.getGroupId(), article.getArticleId(), article.getUrlTitle());

            // Asset

            String title = article.getTitleMapAsXML();
            String description = article.getDescriptionMapAsXML();

            if ((oldStatus != WorkflowConstants.STATUS_APPROVED)
                    && (article.getVersion() != JournalArticleConstants.VERSION_DEFAULT)) {

                AssetEntry draftAssetEntry = assetEntryLocalService.fetchEntry(JournalArticle.class.getName(),
                        article.getPrimaryKey());

                if (draftAssetEntry != null) {
                    long[] assetCategoryIds = draftAssetEntry.getCategoryIds();
                    String[] assetTagNames = draftAssetEntry.getTagNames();

                    List<AssetLink> assetLinks = assetLinkLocalService.getDirectLinks(
                            draftAssetEntry.getEntryId(), AssetLinkConstants.TYPE_RELATED, false);

                    long[] assetLinkEntryIds = ListUtil.toLongArray(assetLinks, AssetLink.ENTRY_ID2_ACCESSOR);

                    AssetEntry assetEntry = assetEntryLocalService.updateEntry(userId, article.getGroupId(),
                            article.getCreateDate(), article.getModifiedDate(), JournalArticle.class.getName(),
                            article.getResourcePrimKey(), article.getUuid(), getClassTypeId(article),
                            assetCategoryIds, assetTagNames, isListable(article), false, null, null, null, null,
                            ContentTypes.TEXT_HTML, title, description, description, null,
                            article.getLayoutUuid(), 0, 0, draftAssetEntry.getPriority());

                    assetLinkLocalService.updateLinks(userId, assetEntry.getEntryId(), assetLinkEntryIds,
                            AssetLinkConstants.TYPE_RELATED);

                    assetEntryLocalService.deleteEntry(draftAssetEntry);
                }
            }

            if (article.getClassNameId() == JournalArticleConstants.CLASSNAME_ID_DEFAULT) {

                assetEntryLocalService.updateEntry(JournalArticle.class.getName(), article.getResourcePrimKey(),
                        article.getDisplayDate(), article.getExpirationDate(), isListable(article), true);
            }

            // Social

            JSONObject extraDataJSONObject = JSONFactoryUtil.createJSONObject();

            extraDataJSONObject.put("title", title);

            if (serviceContext.isCommandUpdate()) {
                SocialActivityManagerUtil.addActivity(user.getUserId(), article,
                        JournalActivityKeys.UPDATE_ARTICLE, extraDataJSONObject.toString(), 0);
            } else {
                SocialActivityManagerUtil.addUniqueActivity(user.getUserId(), article,
                        JournalActivityKeys.ADD_ARTICLE, extraDataJSONObject.toString(), 0);
            }
        } else if (oldStatus == WorkflowConstants.STATUS_APPROVED) {
            updatePreviousApprovedArticle(article);
        }
    }

    if ((article.getClassNameId() == JournalArticleConstants.CLASSNAME_ID_DEFAULT)
            && (oldStatus != WorkflowConstants.STATUS_IN_TRASH)
            && (status != WorkflowConstants.STATUS_IN_TRASH)) {

        // Email

        if ((oldStatus == WorkflowConstants.STATUS_PENDING) && ((status == WorkflowConstants.STATUS_APPROVED)
                || (status == WorkflowConstants.STATUS_DENIED))) {

            String msg = "granted";

            if (status == WorkflowConstants.STATUS_DENIED) {
                msg = "denied";
            }

            try {
                PortletPreferences preferences = ServiceContextUtil.getPortletPreferences(serviceContext);

                articleURL = buildArticleURL(articleURL, article.getGroupId(), article.getFolderId(),
                        article.getArticleId());

                sendEmail(article, articleURL, preferences, msg, serviceContext);
            } catch (Exception e) {
                _log.error("Unable to send email to notify the change of status " + "to " + msg
                        + " for article " + article.getId() + ": " + e.getMessage());
            }
        }

        // Subscriptions

        String action = "update";

        if (article.getVersion() == 1.0) {
            action = "add";
        }

        notifySubscribers(user.getUserId(), article, action, serviceContext);
    }

    return article;
}

From source file:com.liferay.journal.service.impl.JournalArticleLocalServiceImpl.java

License:Open Source License

protected void checkArticlesByExpirationDate(Date expirationDate) throws PortalException {

    List<JournalArticle> articles = journalArticleFinder.findByExpirationDate(
            JournalArticleConstants.CLASSNAME_ID_DEFAULT,
            new Date(expirationDate.getTime() + getArticleCheckInterval()),
            new QueryDefinition<JournalArticle>(WorkflowConstants.STATUS_APPROVED));

    if (_log.isDebugEnabled()) {
        _log.debug("Expiring " + articles.size() + " articles");
    }//from   w ww. j  a  v a2  s.c  o  m

    for (JournalArticle article : articles) {
        if (isExpireAllArticleVersions(article.getCompanyId())) {
            List<JournalArticle> currentArticles = journalArticlePersistence.findByG_A(article.getGroupId(),
                    article.getArticleId(), QueryUtil.ALL_POS, QueryUtil.ALL_POS,
                    new ArticleVersionComparator(true));

            for (JournalArticle currentArticle : currentArticles) {
                if ((currentArticle.getExpirationDate() == null)
                        || (currentArticle.getVersion() > article.getVersion())) {

                    continue;
                }

                currentArticle.setExpirationDate(article.getExpirationDate());
                currentArticle.setStatus(WorkflowConstants.STATUS_EXPIRED);

                journalArticlePersistence.update(currentArticle);
            }
        } else {
            article.setStatus(WorkflowConstants.STATUS_EXPIRED);

            journalArticlePersistence.update(article);
        }

        updatePreviousApprovedArticle(article);

        Indexer<JournalArticle> indexer = IndexerRegistryUtil.nullSafeGetIndexer(JournalArticle.class);

        indexer.reindex(article);
    }

    if (_previousCheckDate == null) {
        _previousCheckDate = new Date(expirationDate.getTime() - getArticleCheckInterval());
    }
}