001    /**
002     * Copyright (c) 2000-2013 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.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            public String getClassName() {
039                    return LayoutRevision.class.getName();
040            }
041    
042            public String getType(Locale locale) {
043                    return ResourceActionsUtil.getModelResource(locale, getClassName());
044            }
045    
046            public Object updateStatus(
047                            int status, Map<String, Serializable> workflowContext)
048                    throws PortalException, SystemException {
049    
050                    long userId = GetterUtil.getLong(
051                            (String)workflowContext.get(WorkflowConstants.CONTEXT_USER_ID));
052                    long layoutRevisionId = GetterUtil.getLong(
053                            (String)workflowContext.get(
054                                    WorkflowConstants.CONTEXT_ENTRY_CLASS_PK));
055    
056                    ServiceContext serviceContext = (ServiceContext)workflowContext.get(
057                            "serviceContext");
058    
059                    return LayoutRevisionLocalServiceUtil.updateStatus(
060                            userId, layoutRevisionId, status, serviceContext);
061            }
062    
063            @Override
064            protected String getIconPath(ThemeDisplay themeDisplay) {
065                    return themeDisplay.getPathThemeImages() + "/common/pages.png";
066            }
067    
068    }