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

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

Introduction

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

Prototype

int STATUS_IN_TRASH

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

Click Source Link

Usage

From source file:com.liferay.journal.trash.test.JournalArticleTrashHandlerTest.java

License:Open Source License

@Test
public void testArticleImages() throws Exception {
    ServiceContext serviceContext = ServiceContextTestUtil.getServiceContext(group.getGroupId());

    Class<?> clazz = getClass();

    ClassLoader classLoader = clazz.getClassLoader();

    String definition = StringUtil.read(classLoader,
            "com/liferay/journal/dependencies" + "/test-ddm-structure-image-field.xml");

    DDMForm ddmForm = _ddmFormXSDDeserializer.deserialize(definition);

    DDMStructure ddmStructure = DDMStructureTestUtil.addStructure(serviceContext.getScopeGroupId(),
            JournalArticle.class.getName(), ddmForm);

    DDMTemplate ddmTemplate = DDMTemplateTestUtil.addTemplate(serviceContext.getScopeGroupId(),
            ddmStructure.getStructureId(), PortalUtil.getClassNameId(JournalArticle.class));

    InputStream inputStream = classLoader.getResourceAsStream("/com/liferay/journal/dependencies/liferay.png");

    FileEntry tempFileEntry = TempFileEntryUtil.addTempFileEntry(group.getGroupId(),
            TestPropsValues.getUserId(), JournalArticle.class.getName(), "liferay.png", inputStream,
            ContentTypes.IMAGE_PNG);//from   ww w. j a  va  2 s  .co  m

    String content = StringUtil.read(classLoader,
            "com/liferay/journal/dependencies/test-journal-content-image-" + "field.xml");

    Document document = SAXReaderUtil.read(content);

    Element dynamicContent = (Element) document.selectSingleNode("//dynamic-content");

    JSONObject jsonObject = JSONFactoryUtil.createJSONObject();

    jsonObject.put("groupId", group.getGroupId());
    jsonObject.put("name", "liferay.png");
    jsonObject.put("tempFile", Boolean.TRUE.toString());
    jsonObject.put("title", "liferay.png");
    jsonObject.put("type", "journal");
    jsonObject.put("uuid", tempFileEntry.getUuid());

    dynamicContent.setText(jsonObject.toString());

    baseModel = JournalTestUtil.addArticleWithXMLContent(JournalFolderConstants.DEFAULT_PARENT_FOLDER_ID,
            document.asXML(), ddmStructure.getStructureKey(), ddmTemplate.getTemplateKey(), serviceContext);

    JournalArticle article = (JournalArticle) baseModel;

    long folderId = article.getImagesFolderId();

    Assert.assertEquals(1, PortletFileRepositoryUtil.getPortletFileEntriesCount(group.getGroupId(), folderId));

    moveBaseModelToTrash((Long) baseModel.getPrimaryKeyObj());

    Assert.assertEquals(0, PortletFileRepositoryUtil.getPortletFileEntriesCount(group.getGroupId(), folderId,
            WorkflowConstants.STATUS_APPROVED));
    Assert.assertEquals(1, PortletFileRepositoryUtil.getPortletFileEntriesCount(group.getGroupId(), folderId,
            WorkflowConstants.STATUS_IN_TRASH));

    TrashHandler trashHandler = TrashHandlerRegistryUtil.getTrashHandler(getBaseModelClassName());

    trashHandler.deleteTrashEntry(getTrashEntryClassPK(baseModel));

    Assert.assertEquals(0, PortletFileRepositoryUtil.getPortletFileEntriesCount(group.getGroupId(), folderId));
}

From source file:com.liferay.journal.util.impl.JournalUtil.java

License:Open Source License

public static boolean isHead(JournalArticle article) {
    JournalArticle latestArticle = JournalArticleLocalServiceUtil.fetchLatestArticle(
            article.getResourcePrimKey(),
            new int[] { WorkflowConstants.STATUS_APPROVED, WorkflowConstants.STATUS_IN_TRASH });

    if ((latestArticle != null) && !latestArticle.isIndexable()) {
        return false;
    } else if ((latestArticle != null) && (article.getId() == latestArticle.getId())) {

        return true;
    }//from w w w  . j a va2  s . co  m

    return false;
}

From source file:com.liferay.journal.util.impl.JournalUtil.java

License:Open Source License

public static boolean isHeadListable(JournalArticle article) {
    JournalArticle latestArticle = JournalArticleLocalServiceUtil
            .fetchLatestArticle(article.getResourcePrimKey(), new int[] { WorkflowConstants.STATUS_APPROVED,
                    WorkflowConstants.STATUS_IN_TRASH, WorkflowConstants.STATUS_SCHEDULED });

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

        return true;
    }/*  w  w w.ja  v  a2s .  co  m*/

    return false;
}

From source file:com.liferay.maven.test.sb.service.base.AssignmentLocalServiceBaseImpl.java

License:Open Source License

@Override
public ExportActionableDynamicQuery getExportActionableDynamicQuery(
        final PortletDataContext portletDataContext) {
    final ExportActionableDynamicQuery exportActionableDynamicQuery = new ExportActionableDynamicQuery() {
        @Override/*ww w  . j a v  a  2 s.  c  o  m*/
        public long performCount() throws PortalException {
            ManifestSummary manifestSummary = portletDataContext.getManifestSummary();

            StagedModelType stagedModelType = getStagedModelType();

            long modelAdditionCount = super.performCount();

            manifestSummary.addModelAdditionCount(stagedModelType, modelAdditionCount);

            long modelDeletionCount = ExportImportHelperUtil.getModelDeletionCount(portletDataContext,
                    stagedModelType);

            manifestSummary.addModelDeletionCount(stagedModelType, modelDeletionCount);

            return modelAdditionCount;
        }
    };

    initActionableDynamicQuery(exportActionableDynamicQuery);

    exportActionableDynamicQuery.setAddCriteriaMethod(new ActionableDynamicQuery.AddCriteriaMethod() {
        @Override
        public void addCriteria(DynamicQuery dynamicQuery) {
            Criterion modifiedDateCriterion = portletDataContext.getDateRangeCriteria("modifiedDate");
            Criterion statusDateCriterion = portletDataContext.getDateRangeCriteria("statusDate");

            if ((modifiedDateCriterion != null) && (statusDateCriterion != null)) {
                Disjunction disjunction = RestrictionsFactoryUtil.disjunction();

                disjunction.add(modifiedDateCriterion);
                disjunction.add(statusDateCriterion);

                dynamicQuery.add(disjunction);
            }

            Property workflowStatusProperty = PropertyFactoryUtil.forName("status");

            if (portletDataContext.isInitialPublication()) {
                dynamicQuery.add(workflowStatusProperty.ne(WorkflowConstants.STATUS_IN_TRASH));
            } else {
                StagedModelDataHandler<?> stagedModelDataHandler = StagedModelDataHandlerRegistryUtil
                        .getStagedModelDataHandler(Assignment.class.getName());

                dynamicQuery.add(workflowStatusProperty.in(stagedModelDataHandler.getExportableStatuses()));
            }
        }
    });

    exportActionableDynamicQuery.setCompanyId(portletDataContext.getCompanyId());

    exportActionableDynamicQuery
            .setPerformActionMethod(new ActionableDynamicQuery.PerformActionMethod<Assignment>() {
                @Override
                public void performAction(Assignment assignment) throws PortalException {
                    StagedModelDataHandlerUtil.exportStagedModel(portletDataContext, assignment);
                }
            });
    exportActionableDynamicQuery
            .setStagedModelType(new StagedModelType(PortalUtil.getClassNameId(Assignment.class.getName())));

    return exportActionableDynamicQuery;
}

From source file:com.liferay.mentions.hook.service.impl.MentionsBlogsEntryServiceImpl.java

License:Open Source License

@Override
public BlogsEntry updateStatus(long userId, long entryId, int status, ServiceContext serviceContext,
        Map<String, Serializable> workflowContext) throws PortalException {

    BlogsEntry entry = BlogsEntryLocalServiceUtil.getEntry(entryId);

    int oldStatus = entry.getStatus();

    entry = super.updateStatus(userId, entryId, status, serviceContext, workflowContext);

    if ((status != WorkflowConstants.STATUS_APPROVED) || (oldStatus == WorkflowConstants.STATUS_APPROVED)
            || (oldStatus == WorkflowConstants.STATUS_IN_TRASH)) {

        return entry;
    }//  w w  w .  j  a  v  a2s  . c  o  m

    long siteGroupId = PortalUtil.getSiteGroupId(entry.getGroupId());

    if (!MentionsUtil.isMentionsEnabled(siteGroupId)) {
        return entry;
    }

    MentionsNotifier mentionsNotifier = new MentionsNotifier();

    String contentURL = (String) serviceContext.getAttribute("contentURL");

    if (Validator.isNull(contentURL)) {
        serviceContext.setAttribute("contentURL", workflowContext.get("url"));
    }

    mentionsNotifier.notify(entry.getUserId(), entry.getGroupId(), entry.getContent(),
            BlogsEntry.class.getName(), entry.getEntryId(),
            ContentUtil.get(PortletPropsValues.ASSET_ENTRY_MENTION_EMAIL_SUBJECT),
            ContentUtil.get(PortletPropsValues.ASSET_ENTRY_MENTION_EMAIL_BODY), serviceContext);

    return entry;
}

From source file:com.liferay.mentions.hook.service.impl.MentionsMessageServiceImpl.java

License:Open Source License

@Override
public MBMessage updateStatus(long userId, long messageId, int status, ServiceContext serviceContext,
        Map<String, Serializable> workflowContext) throws PortalException {

    MBMessage message = MBMessageLocalServiceUtil.getMessage(messageId);

    int oldStatus = message.getStatus();

    message = super.updateStatus(userId, messageId, status, serviceContext, workflowContext);

    if ((status != WorkflowConstants.STATUS_APPROVED) || (oldStatus == WorkflowConstants.STATUS_APPROVED)
            || (oldStatus == WorkflowConstants.STATUS_IN_TRASH)) {

        return message;
    }/*from   w  w w. ja v a 2 s .  c  o  m*/

    long siteGroupId = PortalUtil.getSiteGroupId(message.getGroupId());

    if (!MentionsUtil.isMentionsEnabled(siteGroupId)) {
        return message;
    }

    MentionsNotifier mentionsNotifier = new MentionsNotifier();

    String content = message.getBody();

    if (message.isFormatBBCode()) {
        content = BBCodeTranslatorUtil.getHTML(content);
    }

    content = HtmlUtil.extractText(content);

    String subject = ContentUtil.get(PortletPropsValues.COMMENT_MENTION_EMAIL_SUBJECT);
    String body = ContentUtil.get(PortletPropsValues.COMMENT_MENTION_EMAIL_BODY);

    if (!message.isDiscussion()) {
        subject = ContentUtil.get(PortletPropsValues.ASSET_ENTRY_MENTION_EMAIL_SUBJECT);
        body = ContentUtil.get(PortletPropsValues.ASSET_ENTRY_MENTION_EMAIL_BODY);
    }

    String contentURL = (String) serviceContext.getAttribute("contentURL");

    if (Validator.isNull(contentURL)) {
        serviceContext.setAttribute("contentURL", workflowContext.get("url"));
    }

    mentionsNotifier.notify(message.getUserId(), message.getGroupId(), content, message.getModelClassName(),
            message.getMessageId(), subject, body, serviceContext);

    return message;
}

From source file:com.liferay.mentions.internal.service.MentionsBlogsEntryServiceWrapper.java

License:Open Source License

@Override
public BlogsEntry updateStatus(long userId, long entryId, int status, ServiceContext serviceContext,
        Map<String, Serializable> workflowContext) throws PortalException {

    BlogsEntry entry = _blogsEntryLocalService.getEntry(entryId);

    int oldStatus = entry.getStatus();

    entry = super.updateStatus(userId, entryId, status, serviceContext, workflowContext);

    if ((status != WorkflowConstants.STATUS_APPROVED) || (oldStatus == WorkflowConstants.STATUS_IN_TRASH)) {

        return entry;
    }/*from w w w. j  a  v a2  s  .  co  m*/

    long siteGroupId = _portal.getSiteGroupId(entry.getGroupId());

    if (!MentionsUtil.isMentionsEnabled(siteGroupId)) {
        return entry;
    }

    String contentURL = (String) serviceContext.getAttribute("contentURL");

    if (Validator.isNull(contentURL)) {
        serviceContext.setAttribute("contentURL", workflowContext.get("url"));
    }

    MentionsGroupServiceConfiguration mentionsGroupServiceConfiguration = _configurationProvider
            .getCompanyConfiguration(MentionsGroupServiceConfiguration.class, entry.getCompanyId());

    _mentionsNotifier.notify(userId, entry.getGroupId(), entry.getTitle(), entry.getContent(),
            BlogsEntry.class.getName(), entry.getEntryId(),
            mentionsGroupServiceConfiguration.assetEntryMentionEmailSubject(),
            mentionsGroupServiceConfiguration.assetEntryMentionEmailBody(), serviceContext);

    return entry;
}

From source file:com.liferay.mentions.internal.service.MentionsMessageServiceWrapper.java

License:Open Source License

@Override
public MBMessage updateStatus(long userId, long messageId, int status, ServiceContext serviceContext,
        Map<String, Serializable> workflowContext) throws PortalException {

    MBMessage message = _mbMessageLocalService.getMessage(messageId);

    int oldStatus = message.getStatus();

    message = super.updateStatus(userId, messageId, status, serviceContext, workflowContext);

    if ((status != WorkflowConstants.STATUS_APPROVED) || (oldStatus == WorkflowConstants.STATUS_IN_TRASH)) {

        return message;
    }/*from   w  ww .ja va2s .  co m*/

    long siteGroupId = _portal.getSiteGroupId(message.getGroupId());

    if (!MentionsUtil.isMentionsEnabled(siteGroupId)) {
        return message;
    }

    String content = message.getBody();

    if (message.isFormatBBCode()) {
        content = BBCodeTranslatorUtil.getHTML(content);
    }

    String title = message.getSubject();

    if (message.isDiscussion()) {
        title = StringUtil.shorten(HtmlUtil.extractText(content), 100);
    }

    MentionsGroupServiceConfiguration mentionsGroupServiceConfiguration = _configurationProvider
            .getCompanyConfiguration(MentionsGroupServiceConfiguration.class, message.getCompanyId());

    LocalizedValuesMap subjectLocalizedValuesMap = mentionsGroupServiceConfiguration
            .commentMentionEmailSubject();
    LocalizedValuesMap bodyLocalizedValuesMap = mentionsGroupServiceConfiguration.commentMentionEmailBody();

    if (!message.isDiscussion()) {
        subjectLocalizedValuesMap = mentionsGroupServiceConfiguration.assetEntryMentionEmailSubject();
        bodyLocalizedValuesMap = mentionsGroupServiceConfiguration.assetEntryMentionEmailBody();
    }

    String contentURL = (String) serviceContext.getAttribute("contentURL");

    if (Validator.isNull(contentURL)) {
        serviceContext.setAttribute("contentURL", workflowContext.get("url"));
    }

    _mentionsNotifier.notify(userId, message.getGroupId(), title, content, message.getModelClassName(),
            message.getMessageId(), subjectLocalizedValuesMap, bodyLocalizedValuesMap, serviceContext);

    return message;
}

From source file:com.liferay.mentions.internal.service.MentionsWikiPageServiceWrapper.java

License:Open Source License

@Override
public WikiPage updateStatus(long userId, WikiPage page, int status, ServiceContext serviceContext,
        Map<String, Serializable> workflowContext) throws PortalException {

    int oldStatus = page.getStatus();

    page = super.updateStatus(userId, page, status, serviceContext, workflowContext);

    WikiGroupServiceOverriddenConfiguration wikiGroupServiceOverriddenConfiguration = _configurationProvider
            .getConfiguration(WikiGroupServiceOverriddenConfiguration.class,
                    new GroupServiceSettingsLocator(page.getGroupId(), WikiConstants.SERVICE_NAME));

    // Subscriptions

    if (status == WorkflowConstants.STATUS_APPROVED) {
        if (NotificationThreadLocal.isEnabled()
                && (!page.isMinorEdit() || wikiGroupServiceOverriddenConfiguration.pageMinorEditSendEmail())) {

            notifySubscribers(userId, page, (String) workflowContext.get(WorkflowConstants.CONTEXT_URL),
                    serviceContext);/*from   w  w  w.  j av  a2s. c om*/
        }
    }

    if ((status != WorkflowConstants.STATUS_APPROVED) || (oldStatus == WorkflowConstants.STATUS_IN_TRASH)) {

        return page;
    }

    long siteGroupId = PortalUtil.getSiteGroupId(page.getGroupId());

    if (!MentionsUtil.isMentionsEnabled(siteGroupId)) {
        return page;
    }

    String contentURL = (String) serviceContext.getAttribute("contentURL");

    if (Validator.isNull(contentURL)) {
        serviceContext.setAttribute("contentURL", workflowContext.get("url"));
    }

    String portalURL = serviceContext.getPortalURL();

    String attachmentURLPrefix = WikiUtil.getAttachmentURLPrefix(serviceContext.getPathMain(),
            serviceContext.getPlid(), page.getNodeId(), page.getTitle());

    attachmentURLPrefix = portalURL + attachmentURLPrefix;

    String pageContent = _wikiEngineRenderer.convert(page, null, null, attachmentURLPrefix);

    MentionsGroupServiceConfiguration mentionsGroupServiceConfiguration = _configurationProvider
            .getCompanyConfiguration(MentionsGroupServiceConfiguration.class, page.getCompanyId());

    _mentionsNotifier.notify(page.getUserId(), page.getGroupId(), page.getTitle(), pageContent,
            WikiPage.class.getName(), page.getPageId(),
            mentionsGroupServiceConfiguration.assetEntryMentionEmailSubject(),
            mentionsGroupServiceConfiguration.assetEntryMentionEmailBody(), serviceContext);

    return page;
}

From source file:com.liferay.message.boards.comment.internal.MBCommentManagerImpl.java

License:Open Source License

@Override
public void moveDiscussionToTrash(String className, long classPK) {
    List<MBMessage> messages = _mbMessageLocalService.getMessages(className, classPK,
            WorkflowConstants.STATUS_APPROVED);

    for (MBMessage message : messages) {
        message.setStatus(WorkflowConstants.STATUS_IN_TRASH);

        _mbMessageLocalService.updateMBMessage(message);
    }//from  w  w  w  .  java2 s.  c om
}