1 package de.tivsource.page.admin.actions.system.property;
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
9 import de.tivsource.ejb3plugin.InjectEJB;
10 import de.tivsource.page.admin.actions.EmptyAction;
11 import de.tivsource.page.dao.property.PropertyDaoLocal;
12 import de.tivsource.page.entity.property.Property;
13
14
15
16
17
18
19 public class DeleteAction extends EmptyAction {
20
21
22
23
24 private static final long serialVersionUID = -6168653546389713341L;
25
26
27
28
29 private static final Logger LOGGER = LogManager.getLogger(DeleteAction.class);
30
31 @InjectEJB(name="PropertyDao")
32 private PropertyDaoLocal propertyDaoLocal;
33
34 private Property property;
35
36 public Property getProperty() {
37 return property;
38 }
39
40 public void setProperty(Property property) {
41 this.property = property;
42 }
43
44 @Override
45 @Actions({
46 @Action(
47 value = "delete",
48 results = {
49 @Result(name = "success", type = "redirectAction", location = "index.html"),
50 @Result(name = "input", type="tiles", location = "propertyDeleteForm"),
51 @Result(name = "error", type="tiles", location = "propertyDeleteError")
52 }
53 )
54 })
55 public String execute() throws Exception {
56 LOGGER.info("execute() aufgerufen.");
57
58 if(property != null) {
59 Property dbProperty = propertyDaoLocal.findByKey(property.getKey());
60 propertyDaoLocal.delete(dbProperty);
61 return SUCCESS;
62 }
63 else {
64 return ERROR;
65 }
66
67
68 }
69
70 }