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.portal.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.model.LayoutRevision;
023    import com.liferay.portal.security.permission.ResourceActionsUtil;
024    import com.liferay.portal.service.LayoutRevisionLocalServiceUtil;
025    import com.liferay.portal.service.ServiceContext;
026    import com.liferay.portal.theme.ThemeDisplay;
027    
028    import java.io.Serializable;
029    
030    import java.util.Locale;
031    import java.util.Map;
032    
033    /**
034     * @author Raymond Augé
035     */
036    public class LayoutRevisionWorkflowHandler extends BaseWorkflowHandler {
037    
038            @Override
039            public String getClassName() {
040                    return LayoutRevision.class.getName();
041            }
042    
043            @Override
044            public String getType(Locale locale) {
045                    return ResourceActionsUtil.getModelResource(locale, getClassName());
046            }
047    
048            @Override
049            public Object updateStatus(
050                            int status, Map<String, Serializable> workflowContext)
051                    throws PortalException, SystemException {
052    
053                    long userId = GetterUtil.getLong(
054                            (String)workflowContext.get(WorkflowConstants.CONTEXT_USER_ID));
055                    long layoutRevisionId = GetterUtil.getLong(
056                            (String)workflowContext.get(
057                                    WorkflowConstants.CONTEXT_ENTRY_CLASS_PK));
058    
059                    ServiceContext serviceContext = (ServiceContext)workflowContext.get(
060                            "serviceContext");
061    
062                    return LayoutRevisionLocalServiceUtil.updateStatus(
063                            userId, layoutRevisionId, status, serviceContext);
064            }
065    
066            @Override
067            protected String getIconPath(ThemeDisplay themeDisplay) {
068                    return themeDisplay.getPathThemeImages() + "/common/pages.png";
069            }
070    
071    }