001/* 002 * Copyright 2016 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.odf.cdmfr; 017 018import java.util.Map; 019import java.util.Set; 020 021import org.apache.avalon.framework.service.ServiceException; 022import org.apache.avalon.framework.service.ServiceManager; 023 024import org.ametys.cms.workflow.AbstractContentWorkflowComponent; 025import org.ametys.odf.program.Program; 026import org.ametys.plugins.workflow.EnhancedFunction; 027import org.ametys.runtime.i18n.I18nizableText; 028 029import com.opensymphony.module.propertyset.PropertySet; 030import com.opensymphony.workflow.WorkflowException; 031 032/** 033 * This function calls a WS on remote server to delete a Program 034 * This function should be executed as a post-function of "unpublish" action 035 */ 036public class DeleteRemoteProgramFunction extends AbstractContentWorkflowComponent implements EnhancedFunction 037{ 038 /** The delete remote program processor */ 039 protected DeleteRemoteProgramProcessor _deleteRemoteProgramProcessor; 040 041 @Override 042 public void service(ServiceManager smanager) throws ServiceException 043 { 044 super.service(smanager); 045 _deleteRemoteProgramProcessor = (DeleteRemoteProgramProcessor) smanager.lookup(DeleteRemoteProgramProcessor.ROLE); 046 } 047 048 @Override 049 public void execute(Map transientVars, Map args, PropertySet ps) throws WorkflowException 050 { 051 // Retrieve current content 052 if (getContent(transientVars) instanceof Program program) 053 { 054 _deleteRemoteProgramProcessor.processPrograms(Set.of(program)); 055 } 056 } 057 058 @Override 059 public FunctionType getFunctionExecType() 060 { 061 return FunctionType.POST; 062 } 063 064 @Override 065 public I18nizableText getLabel() 066 { 067 return new I18nizableText("plugin.odf", "PLUGINS_ODF_DELETE_REMOTE_PROGRAM_FUNCTION_LABEL"); 068 } 069}