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

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

Introduction

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

Prototype

int ACTION_SAVE_DRAFT

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

Click Source Link

Usage

From source file:fi.javaguru.akismet.mb.hook.service.AkismetMBMessageLocalServiceImpl.java

License:Open Source License

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, SystemException {

    if (!isEnabled(serviceContext.getCompanyId())) {
        return super.addMessage(userId, userName, groupId, categoryId, threadId, parentMessageId, subject, body,
                format, inputStreamOVPs, anonymous, priority, allowPingbacks, serviceContext);
    }//from   ww w .  ja va2s.  c o m

    int workflowAction = serviceContext.getWorkflowAction();

    serviceContext.setWorkflowAction(WorkflowConstants.ACTION_SAVE_DRAFT);

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

    AkismetComment comment = createComment(mbMessage.getMessageId(), userId, userName,
            subject.concat("\n\n").concat(body), serviceContext);

    boolean spam = checkSpam(comment, serviceContext);

    if (spam) {
        serviceContext.setWorkflowAction(WorkflowConstants.ACTION_SAVE_DRAFT);
    } else {
        serviceContext.setWorkflowAction(workflowAction);
    }

    updateStatus(userId, spam, comment, mbMessage, serviceContext);

    return mbMessage;
}

From source file:fi.javaguru.akismet.mb.hook.service.AkismetMBMessageLocalServiceImpl.java

License:Open Source License

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

    if (!isEnabled(serviceContext.getCompanyId())) {
        return super.addMessage(userId, userName, groupId, categoryId, subject, body, format, inputStreamOVPs,
                anonymous, priority, allowPingbacks, serviceContext);
    }//from  w w  w.  jav a  2  s .  co m

    int workflowAction = serviceContext.getWorkflowAction();

    serviceContext.setWorkflowAction(WorkflowConstants.ACTION_SAVE_DRAFT);

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

    AkismetComment comment = createComment(mbMessage.getMessageId(), userId, userName,
            subject.concat("\n\n").concat(body), serviceContext);

    boolean spam = checkSpam(comment, serviceContext);

    if (spam) {
        serviceContext.setWorkflowAction(WorkflowConstants.ACTION_SAVE_DRAFT);
    } else {
        serviceContext.setWorkflowAction(workflowAction);
    }

    updateStatus(userId, spam, comment, mbMessage, serviceContext);

    return mbMessage;
}

From source file:fi.javaguru.akismet.mb.hook.service.AkismetMBMessageLocalServiceImpl.java

License:Open Source License

public MBMessage updateMessage(long userId, long messageId, String subject, String body,
        List<ObjectValuePair<String, InputStream>> inputStreamOVPs, List<String> existingFiles, double priority,
        boolean allowPingbacks, ServiceContext serviceContext) throws PortalException, SystemException {

    if (!isEnabled(serviceContext.getCompanyId())) {
        return super.updateMessage(userId, messageId, subject, body, inputStreamOVPs, existingFiles, priority,
                allowPingbacks, serviceContext);
    }/*www  .  j  a v a  2 s .  c  o m*/

    int workflowAction = serviceContext.getWorkflowAction();

    serviceContext.setWorkflowAction(WorkflowConstants.ACTION_SAVE_DRAFT);

    MBMessage mbMessage = super.updateMessage(userId, messageId, subject, body, inputStreamOVPs, existingFiles,
            priority, allowPingbacks, serviceContext);

    AkismetComment comment = createComment(mbMessage.getMessageId(), userId, null,
            subject.concat("\n\n").concat(body), serviceContext);

    boolean spam = checkSpam(comment, serviceContext);

    if (spam) {
        serviceContext.setWorkflowAction(WorkflowConstants.ACTION_SAVE_DRAFT);
    } else {
        serviceContext.setWorkflowAction(workflowAction);
    }

    updateStatus(userId, spam, comment, mbMessage, serviceContext);

    return mbMessage;

}