001/* 002 * Copyright 2024 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.io.IOException; 019import java.io.InputStream; 020import java.util.HashMap; 021import java.util.Map; 022 023import org.apache.cocoon.util.log.SLF4JLoggerAdapter; 024import org.apache.excalibur.source.Source; 025 026import org.ametys.cms.repository.DefaultContent; 027import org.ametys.odf.CallWSHelper; 028import org.ametys.odf.ProgramItem; 029import org.ametys.odf.program.Program; 030 031/** 032 * Processor to delete the program on remote servers. 033 */ 034public class DeleteRemoteProgramProcessor extends SendCDMfrProcessor 035{ 036 /** The component role. */ 037 @SuppressWarnings("hiding") 038 public static final String ROLE = DeleteRemoteProgramProcessor.class.getName(); 039 040 @Override 041 protected Source _getCDMfrContent(Program program) throws IOException 042 { 043 // We don't need the CDM-fr content for this process 044 return null; 045 } 046 047 @Override 048 protected void processProgram(Program program, InputStream cdmfrContent) throws IOException 049 { 050 Map<String, String> params = new HashMap<>(); 051 params.put(ProgramItem.CODE, program.getCode()); 052 params.put(ProgramItem.CATALOG, program.getCatalog()); 053 params.put(DefaultContent.METADATA_LANGUAGE, program.getLanguage()); 054 055 // Delete program on remote application 056 CallWSHelper.callWS("_odf-sync/delete-program", params, new SLF4JLoggerAdapter(getLogger())); 057 } 058}