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

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

Introduction

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

Prototype

int STATUS_APPROVED

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

Click Source Link

Usage

From source file:com.inkwell.internet.slogan.util.ActionUtil.java

License:Open Source License

/**
 * Gets slogans out of the service layer.
 *
 * @param request//w  w  w.j a  v  a 2  s .c  om
 * @return List<Slogans>
 */
@SuppressWarnings("unchecked")
public static List<Slogan> getSlogans(RenderRequest request, int start, int end, OrderByComparator obc) {

    List<Slogan> slogans;

    ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);

    long groupId = themeDisplay.getScopeGroupId();

    try {
        slogans = SloganLocalServiceUtil.getSlogans(groupId, WorkflowConstants.STATUS_APPROVED, start, end,
                obc);
    } catch (SystemException e) {
        slogans = Collections.EMPTY_LIST;
    }

    return slogans;
}

From source file:com.inkwell.internet.slogan.util.ActionUtil.java

License:Open Source License

public static List<Slogan> getSlogans(RenderRequest request, int start, int end) {

    List<Slogan> slogans;//w  ww  .  j a  v a2  s.co  m

    ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);

    long groupId = themeDisplay.getScopeGroupId();

    try {
        slogans = SloganLocalServiceUtil.getSlogans(groupId, WorkflowConstants.STATUS_APPROVED, start, end);
    } catch (SystemException e) {
        slogans = Collections.EMPTY_LIST;
    }

    return slogans;
}

From source file:com.inkwell.internet.slogan.util.ActionUtil.java

License:Open Source License

public static int getSlogansCount(RenderRequest request) {

    ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);

    long groupId = themeDisplay.getScopeGroupId();

    try {/*w ww .  ja  v  a  2 s. c o  m*/
        return SloganLocalServiceUtil.getSlogansCount(groupId, WorkflowConstants.STATUS_APPROVED);
    } catch (SystemException e) {
        return 0;
    }
}

From source file:com.liferay.adaptive.media.document.library.internal.exportimport.data.handler.AdaptiveMediaImageDLPluggableContentDataHandler.java

License:Open Source License

private void _exportMedia(PortletDataContext portletDataContext, FileEntry fileEntry)
        throws IOException, PortalException {

    List<FileVersion> fileVersions = fileEntry.getFileVersions(WorkflowConstants.STATUS_APPROVED);

    for (FileVersion fileVersion : fileVersions) {
        Stream<AdaptiveMedia<AdaptiveMediaImageProcessor>> adaptiveMediaStream = _adaptiveMediaImageFinder
                .getAdaptiveMediaStream(queryBuilder -> queryBuilder.allForVersion(fileVersion).done());

        List<AdaptiveMedia<AdaptiveMediaImageProcessor>> adaptiveMediaList = adaptiveMediaStream
                .collect(Collectors.toList());

        for (AdaptiveMedia<AdaptiveMediaImageProcessor> adaptiveMedia : adaptiveMediaList) {

            _exportMedia(portletDataContext, fileVersion, adaptiveMedia);
        }// w w  w  . j a va2 s .  c  om
    }
}

From source file:com.liferay.adaptive.media.document.library.internal.exportimport.data.handler.AdaptiveMediaImageDLPluggableContentDataHandler.java

License:Open Source License

private void _importGeneratedMedia(PortletDataContext portletDataContext, FileEntry importedFileEntry,
        AdaptiveMediaImageConfigurationEntry configurationEntry) throws IOException, PortalException {

    String configuration = portletDataContext
            .getZipEntryAsString(_getConfigurationEntryBinPath(configurationEntry));

    if (configuration == null) {
        return;/*w  w  w  . j av a2 s .c o  m*/
    }

    AdaptiveMediaImageConfigurationEntry importedConfigurationEntry = _adaptiveMediaImageConfigurationEntrySerializer
            .deserialize(configuration);

    if (!importedConfigurationEntry.equals(configurationEntry)) {
        return;
    }

    List<FileVersion> fileVersions = importedFileEntry.getFileVersions(WorkflowConstants.STATUS_APPROVED);

    for (FileVersion fileVersion : fileVersions) {
        AdaptiveMedia<AdaptiveMediaImageProcessor> adaptiveMedia = _getExportedMedia(portletDataContext,
                fileVersion, configurationEntry);

        if (adaptiveMedia == null) {
            continue;
        }

        Optional<Integer> contentLengthOptional = adaptiveMedia
                .getValueOptional(AdaptiveMediaAttribute.contentLength());

        Optional<Integer> widthOptional = adaptiveMedia
                .getValueOptional(AdaptiveMediaImageAttribute.IMAGE_WIDTH);

        Optional<Integer> heightOptional = adaptiveMedia
                .getValueOptional(AdaptiveMediaImageAttribute.IMAGE_HEIGHT);

        if (!contentLengthOptional.isPresent() || !widthOptional.isPresent() || !heightOptional.isPresent()) {

            continue;
        }

        AdaptiveMediaImageEntry adaptiveMediaImageEntry = _adaptiveMediaImageEntryLocalService
                .fetchAdaptiveMediaImageEntry(configurationEntry.getUUID(), fileVersion.getFileVersionId());

        if (adaptiveMediaImageEntry != null) {
            _adaptiveMediaImageEntryLocalService.deleteAdaptiveMediaImageEntryFileVersion(
                    configurationEntry.getUUID(), fileVersion.getFileVersionId());
        }

        try (InputStream inputStream = adaptiveMedia.getInputStream()) {
            _adaptiveMediaImageEntryLocalService.addAdaptiveMediaImageEntry(configurationEntry, fileVersion,
                    widthOptional.get(), heightOptional.get(), inputStream, contentLengthOptional.get());
        }
    }
}

From source file:com.liferay.akismet.hook.action.AkismetEditDiscussionAction.java

License:Open Source License

protected void updateStatus(HttpServletRequest request, HttpServletResponse response) throws PortalException {

    ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);

    long messageId = ParamUtil.getLong(request, "messageId");

    boolean spam = ParamUtil.getBoolean(request, "spam");

    ServiceContext serviceContext = ServiceContextFactory.getInstance(request);

    if (spam) {/*from   w  w w . java  2  s  . c o  m*/
        MBMessage message = MBMessageLocalServiceUtil.updateStatus(themeDisplay.getUserId(), messageId,
                WorkflowConstants.STATUS_DENIED, serviceContext);

        if (AkismetUtil.isMessageBoardsEnabled(message.getCompanyId())) {
            AkismetUtil.submitSpam(message);
        }
    } else {
        MBMessage message = MBMessageLocalServiceUtil.updateStatus(themeDisplay.getUserId(), messageId,
                WorkflowConstants.STATUS_APPROVED, serviceContext);

        if (AkismetUtil.isMessageBoardsEnabled(message.getCompanyId())) {
            AkismetUtil.submitHam(message);
        }
    }
}

From source file:com.liferay.akismet.hook.action.AkismetEditMessageAction.java

License:Open Source License

protected void updateStatus(ActionRequest actionRequest, ActionResponse actionResponse) throws PortalException {

    ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);

    checkPermission(themeDisplay.getScopeGroupId());

    long messageId = ParamUtil.getLong(actionRequest, "messageId");

    boolean spam = ParamUtil.getBoolean(actionRequest, "spam");

    ServiceContext serviceContext = ServiceContextFactory.getInstance(actionRequest);

    if (spam) {/*from w  ww  . j a  v a  2  s .  c om*/
        MBMessage message = MBMessageLocalServiceUtil.updateStatus(themeDisplay.getUserId(), messageId,
                WorkflowConstants.STATUS_DENIED, serviceContext);

        if (AkismetUtil.isMessageBoardsEnabled(message.getCompanyId())) {
            AkismetUtil.submitSpam(message);
        }
    } else {
        MBMessage message = MBMessageLocalServiceUtil.updateStatus(themeDisplay.getUserId(), messageId,
                WorkflowConstants.STATUS_APPROVED, serviceContext);

        if (AkismetUtil.isMessageBoardsEnabled(message.getCompanyId())) {
            AkismetUtil.submitHam(message);
        }
    }
}

From source file:com.liferay.akismet.hook.action.AkismetEditPageAction.java

License:Open Source License

protected void updateSummary(ActionRequest actionRequest, ActionResponse actionResponse)
        throws PortalException {

    ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);

    checkPermission(themeDisplay.getScopeGroupId());

    long pageId = ParamUtil.getLong(actionRequest, "pageId");
    boolean spam = ParamUtil.getBoolean(actionRequest, "spam");

    WikiPage wikiPage = WikiPageLocalServiceUtil.getPageByPageId(pageId);

    WikiPage latestVersionWikiPage = AkismetUtil.getWikiPage(wikiPage.getNodeId(), wikiPage.getTitle(),
            wikiPage.getVersion(), false);

    String latestContent = null;//from   w w w.ja v  a 2  s. c  om
    double latestVersion = -1;

    if (latestVersionWikiPage != null) {
        latestContent = latestVersionWikiPage.getContent();
        latestVersion = latestVersionWikiPage.getVersion();
    }

    WikiPage previousVersionWikiPage = AkismetUtil.getWikiPage(wikiPage.getNodeId(), wikiPage.getTitle(),
            wikiPage.getVersion(), true);

    String previousContent = null;
    double previousVersion = -1;

    if (previousVersionWikiPage != null) {
        previousContent = previousVersionWikiPage.getContent();
        previousVersion = previousVersionWikiPage.getVersion();
    }

    String pattern = StringPool.BLANK;

    ServiceContext serviceContext = ServiceContextFactory.getInstance(actionRequest);

    if (spam) {
        pattern = "version-x-was-marked-as-spam";

        // Selected version

        wikiPage.setStatus(WorkflowConstants.STATUS_APPROVED);
        wikiPage.setSummary(AkismetConstants.WIKI_PAGE_PENDING_APPROVAL);

        wikiPage = WikiPageLocalServiceUtil.updateWikiPage(wikiPage);

        // Latest version

        if ((wikiPage.getVersion() >= latestVersion) && (previousVersionWikiPage != null)) {

            WikiPageLocalServiceUtil.revertPage(themeDisplay.getUserId(), wikiPage.getNodeId(),
                    wikiPage.getTitle(), previousVersion, serviceContext);
        }

        // Akismet

        if (AkismetUtil.isWikiEnabled(themeDisplay.getCompanyId())) {
            AkismetUtil.submitSpam(wikiPage);
        }
    } else {
        pattern = "version-x-was-marked-as-not-spam";

        // Selected version

        wikiPage.setStatus(WorkflowConstants.STATUS_APPROVED);
        wikiPage.setSummary(StringPool.BLANK);

        wikiPage = WikiPageLocalServiceUtil.updateWikiPage(wikiPage);

        // Latest version

        if ((latestContent != null) && ((previousContent == null) || latestContent.equals(previousContent))) {

            WikiPageLocalServiceUtil.revertPage(themeDisplay.getUserId(), wikiPage.getNodeId(),
                    wikiPage.getTitle(), wikiPage.getVersion(), serviceContext);
        } else {
            SessionMessages.add(actionRequest, "anotherUserHasMadeChanges");
        }

        // Akismet

        if (AkismetUtil.isWikiEnabled(themeDisplay.getCompanyId())) {
            AkismetUtil.submitHam(wikiPage);
        }
    }

    String value = LanguageUtil.format(themeDisplay.getLocale(), pattern, String.valueOf(wikiPage.getVersion()),
            false);

    SessionMessages.add(actionRequest, "requestProcessed", value);
}

From source file:com.liferay.akismet.hook.service.impl.AkismetMBMessageLocalServiceImpl.java

License:Open Source License

@Override
public MBMessage addDiscussionMessage(long userId, String userName, long groupId, String className,
        long classPK, long threadId, long parentMessageId, String subject, String body,
        ServiceContext serviceContext) throws PortalException {

    boolean enabled = isDiscussionsEnabled(userId, serviceContext);

    if (enabled) {
        serviceContext.setWorkflowAction(WorkflowConstants.ACTION_SAVE_DRAFT);
    }/*from  w  ww. j av a  2  s .  co m*/

    MBMessage message = super.addDiscussionMessage(userId, userName, groupId, className, classPK, threadId,
            parentMessageId, subject, body, serviceContext);

    AkismetData akismetData = updateAkismetData(message, serviceContext);

    if (!enabled) {
        return message;
    }

    String content = subject + "\n\n" + body;

    int status = WorkflowConstants.STATUS_APPROVED;

    if (AkismetUtil.isSpam(userId, content, akismetData)) {
        status = WorkflowConstants.STATUS_DENIED;
    }

    return super.updateStatus(userId, message.getMessageId(), status, serviceContext);
}

From source file:com.liferay.akismet.hook.service.impl.AkismetMBMessageLocalServiceImpl.java

License:Open Source License

@Override
public MBMessage addMessage(long userId, String userName, long groupId, long categoryId, long threadId,
        long parentMessageId, String subject, String body, String format,
        List<ObjectValuePair<String, InputStream>> inputStreamOVPs, boolean anonymous, double priority,
        boolean allowPingbacks, ServiceContext serviceContext) throws PortalException {

    boolean enabled = isMessageBoardsEnabled(userId, groupId, serviceContext);

    if (enabled) {
        serviceContext.setWorkflowAction(WorkflowConstants.ACTION_SAVE_DRAFT);
    }// w w  w.j a  va  2 s. c om

    MBMessage message = super.addMessage(userId, userName, groupId, categoryId, threadId, parentMessageId,
            subject, body, format, inputStreamOVPs, anonymous, priority, allowPingbacks, serviceContext);

    AkismetData akismetData = updateAkismetData(message, serviceContext);

    if (!enabled) {
        return message;
    }

    String content = subject + "\n\n" + body;

    int status = WorkflowConstants.STATUS_APPROVED;

    if (AkismetUtil.isSpam(userId, content, akismetData)) {
        status = WorkflowConstants.STATUS_DENIED;
    }

    return super.updateStatus(userId, message.getMessageId(), status, serviceContext);
}