001    /**
002     * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portlet.blogs.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.blogs.model.BlogsEntry;
026    import com.liferay.portlet.blogs.service.BlogsEntryLocalServiceUtil;
027    
028    import java.io.Serializable;
029    
030    import java.util.Locale;
031    import java.util.Map;
032    
033    /**
034     * @author Jorge Ferrer
035     */
036    public class BlogsEntryWorkflowHandler extends BaseWorkflowHandler {
037    
038            public static final String CLASS_NAME = BlogsEntry.class.getName();
039    
040            public String getClassName() {
041                    return CLASS_NAME;
042            }
043    
044            public String getType(Locale locale) {
045                    return ResourceActionsUtil.getModelResource(locale, CLASS_NAME);
046            }
047    
048            public BlogsEntry updateStatus(
049                            int status, Map<String, Serializable> workflowContext)
050                    throws PortalException, SystemException {
051    
052                    long userId = GetterUtil.getLong(
053                            (String)workflowContext.get(WorkflowConstants.CONTEXT_USER_ID));
054                    long classPK = GetterUtil.getLong(
055                            (String)workflowContext.get(
056                                    WorkflowConstants.CONTEXT_ENTRY_CLASS_PK));
057    
058                    ServiceContext serviceContext = (ServiceContext)workflowContext.get(
059                            "serviceContext");
060    
061                    return BlogsEntryLocalServiceUtil.updateStatus(
062                            userId, classPK, status, serviceContext);
063            }
064    
065            protected String getIconPath(ThemeDisplay themeDisplay) {
066                    return themeDisplay.getPathThemeImages() + "/blogs/blogs.png";
067            }
068    
069    }