001    /**
002     * Copyright (c) 2000-present 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.spring.osgi.OSGiBeanProperties;
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    
027    import java.io.Serializable;
028    
029    import java.util.Locale;
030    import java.util.Map;
031    
032    /**
033     * @author Raymond Aug??
034     */
035    @OSGiBeanProperties
036    public class LayoutRevisionWorkflowHandler
037            extends BaseWorkflowHandler<LayoutRevision> {
038    
039            @Override
040            public String getClassName() {
041                    return LayoutRevision.class.getName();
042            }
043    
044            @Override
045            public String getType(Locale locale) {
046                    return ResourceActionsUtil.getModelResource(locale, getClassName());
047            }
048    
049            @Override
050            public LayoutRevision updateStatus(
051                            int status, Map<String, Serializable> workflowContext)
052                    throws PortalException {
053    
054                    long userId = GetterUtil.getLong(
055                            (String)workflowContext.get(WorkflowConstants.CONTEXT_USER_ID));
056                    long layoutRevisionId = GetterUtil.getLong(
057                            (String)workflowContext.get(
058                                    WorkflowConstants.CONTEXT_ENTRY_CLASS_PK));
059    
060                    ServiceContext serviceContext = (ServiceContext)workflowContext.get(
061                            "serviceContext");
062    
063                    return LayoutRevisionLocalServiceUtil.updateStatus(
064                            userId, layoutRevisionId, status, serviceContext);
065            }
066    
067    }