001/* 002 * Copyright 2022 Anyware Services 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package org.ametys.plugins.forms.workflow; 017 018import java.util.Map; 019 020import org.apache.avalon.framework.component.Component; 021import org.apache.avalon.framework.logger.AbstractLogEnabled; 022import org.apache.avalon.framework.service.ServiceException; 023import org.apache.avalon.framework.service.ServiceManager; 024import org.apache.avalon.framework.service.Serviceable; 025 026import org.ametys.cms.workflow.AmetysObjectCheckRightsCondition; 027import org.ametys.plugins.forms.helper.LimitedEntriesHelper; 028import org.ametys.plugins.forms.repository.FormEntry; 029 030import com.opensymphony.module.propertyset.PropertySet; 031import com.opensymphony.workflow.FunctionProvider; 032import com.opensymphony.workflow.WorkflowException; 033 034/** 035 * OS workflow function to deactive the entry 036 */ 037public class DeactiveEntryFunction extends AbstractLogEnabled implements Component, FunctionProvider, Serviceable 038{ 039 /** The handling limited entries helper */ 040 protected LimitedEntriesHelper _handleLimitedEntriesHelper; 041 042 public void service(ServiceManager manager) throws ServiceException 043 { 044 _handleLimitedEntriesHelper = (LimitedEntriesHelper) manager.lookup(LimitedEntriesHelper.ROLE); 045 } 046 047 @Override 048 public void execute(Map transientVars, Map args, PropertySet ps) throws WorkflowException 049 { 050 FormEntry entryRefused = (FormEntry) transientVars.get(AmetysObjectCheckRightsCondition.AMETYS_OBJECT_KEY); 051 _handleLimitedEntriesHelper.deactivateEntry(entryRefused.getId()); 052 } 053 054}