001/* 002 * #%L 003 * Netarchivesuite - harvester 004 * %% 005 * Copyright (C) 2005 - 2014 The Royal Danish Library, the Danish State and University Library, 006 * the National Library of France and the Austrian National Library. 007 * %% 008 * This program is free software: you can redistribute it and/or modify 009 * it under the terms of the GNU Lesser General Public License as 010 * published by the Free Software Foundation, either version 2.1 of the 011 * License, or (at your option) any later version. 012 * 013 * This program is distributed in the hope that it will be useful, 014 * but WITHOUT ANY WARRANTY; without even the implied warranty of 015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 016 * GNU General Lesser Public License for more details. 017 * 018 * You should have received a copy of the GNU General Lesser Public 019 * License along with this program. If not, see 020 * <http://www.gnu.org/licenses/lgpl-2.1.html>. 021 * #L% 022 */ 023 024package dk.netarkivet.harvester.webinterface; 025 026import javax.servlet.jsp.PageContext; 027 028import dk.netarkivet.common.utils.I18n; 029 030/** 031 * Represents the various actions which can be carried out to modify Global Crawler Traps. 032 */ 033 034public enum TrapActionEnum { 035 036 /** 037 * Corresponds to uploading of a global crawler trap list, either as a new list or as an update to an existing list. 038 */ 039 CREATE_OR_UPDATE { 040 @Override 041 public TrapAction getTrapAction() { 042 return new TrapCreateOrUpdateAction(); 043 } 044 }, 045 /** 046 * Action to download an existing list to browser or file. 047 */ 048 READ { 049 @Override 050 public TrapAction getTrapAction() { 051 return new TrapReadAction(); 052 } 053 }, 054 /** 055 * Action to delete an existing list. 056 */ 057 DELETE { 058 @Override 059 public TrapAction getTrapAction() { 060 return new TrapDeleteAction(); 061 } 062 }, 063 /** 064 * Change an existing list from inactive to active. 065 */ 066 ACTIVATE { 067 @Override 068 public TrapAction getTrapAction() { 069 return new TrapActivationAction(true); 070 } 071 }, 072 /** 073 * Change an existing list from active to inactive. 074 */ 075 DEACTIVATE { 076 @Override 077 public TrapAction getTrapAction() { 078 return new TrapActivationAction(false); 079 } 080 }, 081 /** 082 * Do nothing. The existence of a null action is an architectural convenience. 083 */ 084 NULL_ACTION { 085 @Override 086 public TrapAction getTrapAction() { 087 /** 088 * The null action is sufficiently trivial that we can implement it inline rather than in a separate class. 089 */ 090 return new TrapAction() { 091 @Override 092 protected void doAction(PageContext context, I18n i18n) { 093 return; 094 } 095 }; 096 } 097 }; 098 099 /** 100 * Get the concrete TrapAction which can process this request. 101 * 102 * @return the correct TrapAction for this request type. 103 */ 104 public abstract TrapAction getTrapAction(); 105 106}