001    /**
002     * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
013     */
014    
015    package com.liferay.portlet.messageboards.workflow;
016    
017    import com.liferay.portal.kernel.exception.PortalException;
018    import com.liferay.portal.kernel.exception.SystemException;
019    import com.liferay.portal.kernel.util.GetterUtil;
020    import com.liferay.portal.kernel.workflow.BaseWorkflowHandler;
021    import com.liferay.portal.kernel.workflow.WorkflowConstants;
022    import com.liferay.portal.security.permission.ResourceActionsUtil;
023    import com.liferay.portal.service.ServiceContext;
024    import com.liferay.portal.theme.ThemeDisplay;
025    import com.liferay.portlet.messageboards.model.MBMessage;
026    import com.liferay.portlet.messageboards.service.MBMessageLocalServiceUtil;
027    
028    import java.io.Serializable;
029    
030    import java.util.Locale;
031    import java.util.Map;
032    
033    /**
034     * @author Alexander Chow
035     * @author Jorge Ferrer
036     * @author Julio Camarero
037     */
038    public class MBMessageWorkflowHandler extends BaseWorkflowHandler {
039    
040            public static final String CLASS_NAME = MBMessage.class.getName();
041    
042            @Override
043            public String getClassName() {
044                    return CLASS_NAME;
045            }
046    
047            @Override
048            public String getType(Locale locale) {
049                    return ResourceActionsUtil.getModelResource(locale, CLASS_NAME);
050            }
051    
052            @Override
053            public Object updateStatus(
054                            int status, Map<String, Serializable> workflowContext)
055                    throws PortalException, SystemException {
056    
057                    long userId = GetterUtil.getLong(
058                            (String)workflowContext.get(WorkflowConstants.CONTEXT_USER_ID));
059                    long classPK = GetterUtil.getLong(
060                            (String)workflowContext.get(
061                                    WorkflowConstants.CONTEXT_ENTRY_CLASS_PK));
062    
063                    ServiceContext serviceContext = (ServiceContext)workflowContext.get(
064                            "serviceContext");
065    
066                    return MBMessageLocalServiceUtil.updateStatus(
067                            userId, classPK, status, serviceContext);
068            }
069    
070            @Override
071            protected String getIconPath(ThemeDisplay themeDisplay) {
072                    return themeDisplay.getPathThemeImages() + "/common/conversation.png";
073            }
074    
075    }