1 package de.tivsource.page.admin.actions.system.captcha;
2
3 import org.apache.logging.log4j.LogManager;
4 import org.apache.logging.log4j.Logger;
5 import org.apache.struts2.convention.annotation.Action;
6 import org.apache.struts2.convention.annotation.Actions;
7 import org.apache.struts2.convention.annotation.Result;
8 import org.apache.struts2.tiles.annotation.TilesDefinition;
9 import org.apache.struts2.tiles.annotation.TilesDefinitions;
10 import org.apache.struts2.tiles.annotation.TilesPutAttribute;
11
12 import de.tivsource.ejb3plugin.InjectEJB;
13 import de.tivsource.page.admin.actions.EmptyAction;
14 import de.tivsource.page.common.captcha.Captcha;
15 import de.tivsource.page.dao.captcha.CaptchaDaoLocal;
16
17
18
19
20
21
22 @TilesDefinitions({
23 @TilesDefinition(name="captchaDeleteForm", extend = "adminTemplate", putAttributes = {
24 @TilesPutAttribute(name = "navigation", value = "/WEB-INF/tiles/active/navigation/system.jsp"),
25 @TilesPutAttribute(name = "content", value = "/WEB-INF/tiles/active/view/captcha/delete_form.jsp")
26 }),
27 @TilesDefinition(name="captchaDeleteError", extend = "adminTemplate", putAttributes = {
28 @TilesPutAttribute(name = "navigation", value = "/WEB-INF/tiles/active/navigation/system.jsp"),
29 @TilesPutAttribute(name = "content", value = "/WEB-INF/tiles/active/view/captcha/delete_error.jsp")
30 })
31 })
32 public class DeleteAction extends EmptyAction {
33
34
35
36
37 private static final long serialVersionUID = -6168653546389713341L;
38
39
40
41
42 private static final Logger LOGGER = LogManager.getLogger(DeleteAction.class);
43
44 @InjectEJB(name="CaptchaDao")
45 private CaptchaDaoLocal captchaDaoLocal;
46
47 private Captcha captcha;
48
49 public Captcha getCaptcha() {
50 return captcha;
51 }
52
53 public void setCaptcha(Captcha captcha) {
54 this.captcha = captcha;
55 }
56
57 @Override
58 @Actions({
59 @Action(
60 value = "delete",
61 results = {
62 @Result(name = "success", type = "redirectAction", location = "index.html"),
63 @Result(name = "input", type="tiles", location = "captchaDeleteForm"),
64 @Result(name = "error", type="tiles", location = "captchaDeleteError")
65 }
66 )
67 })
68 public String execute() throws Exception {
69 LOGGER.info("execute() aufgerufen.");
70
71 if(captcha != null) {
72 Captcha dbCaptcha = captchaDaoLocal.findByUuid(captcha.getUuid());
73 captchaDaoLocal.delete(dbCaptcha);
74 return SUCCESS;
75 } else {
76 return ERROR;
77 }
78
79 }
80
81 }