Project

General

Profile

1
package eu.dnetlib.validator.admin.actions.rules;
2

    
3

    
4
import org.apache.log4j.Logger;
5

    
6
import com.opensymphony.xwork2.Action;
7

    
8
import eu.dnetlib.validator.admin.actions.BaseValidatorAction;
9
import eu.dnetlib.validator.admin.api.AdminAPIException;
10

    
11
public class DeleteRule extends BaseValidatorAction {
12

    
13
	private static final long serialVersionUID = -2888943921398211370L;
14
	private static final Logger logger = Logger.getLogger(DeleteRule.class);
15
	private int ruleId;
16
	
17
	public String execute() {
18
		this.clearErrorsAndMessages();
19
		logger.debug("deleting rule");
20
		String ret = null;
21
		try {
22
			logger.debug("deleting rule with id "+ruleId);
23
			ret = this.getAdminAPI().deleteRule(ruleId);
24
		}
25
		catch (AdminAPIException e) {
26
			logger.error("Error deleting rule with id "+ruleId, e);
27
			this.addActionError(this.getText("generic.error"));
28
			reportException(e);
29
			return "exception";
30
		}
31
		
32
		if (ret != null) {
33
			this.addActionError(this.getText(ret));
34
			return "input-problem";
35
		}
36
		this.addActionMessage(this.getText("deleteRule.success"));
37
		return Action.SUCCESS;
38
	}
39

    
40
	public int getRuleId() {
41
		return ruleId;
42
	}
43

    
44
	public void setRuleId(int ruleId) {
45
		this.ruleId = ruleId;
46
	}
47
	
48
}
(2-2/8)