1 package de.tivsource.page.admin.actions.others.contententry;
2
3 import java.util.Date;
4
5 import org.apache.logging.log4j.LogManager;
6 import org.apache.logging.log4j.Logger;
7 import org.apache.struts2.ServletActionContext;
8 import org.apache.struts2.convention.annotation.Action;
9 import org.apache.struts2.convention.annotation.Actions;
10 import org.apache.struts2.convention.annotation.Result;
11 import org.apache.struts2.tiles.annotation.TilesDefinition;
12 import org.apache.struts2.tiles.annotation.TilesDefinitions;
13 import org.apache.struts2.tiles.annotation.TilesPutAttribute;
14
15 import de.tivsource.ejb3plugin.InjectEJB;
16 import de.tivsource.page.admin.actions.EmptyAction;
17 import de.tivsource.page.common.menuentry.ContentEntry;
18 import de.tivsource.page.dao.contententry.ContentEntryDaoLocal;
19
20
21
22
23
24
25 @TilesDefinitions({
26 @TilesDefinition(name="contentEntryDeleteForm", extend = "adminTemplate", putAttributes = {
27 @TilesPutAttribute(name = "meta", value = "/WEB-INF/tiles/active/meta/chosen.jsp"),
28 @TilesPutAttribute(name = "navigation", value = "/WEB-INF/tiles/active/navigation/others.jsp"),
29 @TilesPutAttribute(name = "content", value = "/WEB-INF/tiles/active/view/contententry/delete_form.jsp")
30 }),
31 @TilesDefinition(name="contentEntryDeleteError", extend = "adminTemplate", putAttributes = {
32 @TilesPutAttribute(name = "meta", value = "/WEB-INF/tiles/active/meta/chosen.jsp"),
33 @TilesPutAttribute(name = "navigation", value = "/WEB-INF/tiles/active/navigation/others.jsp"),
34 @TilesPutAttribute(name = "content", value = "/WEB-INF/tiles/active/view/contententry/delete_error.jsp")
35 })
36 })
37 public class DeleteAction extends EmptyAction {
38
39
40
41
42 private static final long serialVersionUID = -8831104942787907704L;
43
44
45
46
47 private static final Logger LOGGER = LogManager.getLogger(DeleteAction.class);
48
49 @InjectEJB(name="ContentEntryDao")
50 private ContentEntryDaoLocal contentEntryDaoLocal;
51
52 private ContentEntry contentEntry;
53
54 public ContentEntry getContentEntry() {
55 return contentEntry;
56 }
57
58 public void setContentEntry(ContentEntry contentEntry) {
59 this.contentEntry = contentEntry;
60 }
61
62 @Override
63 @Actions({
64 @Action(
65 value = "delete",
66 results = {
67 @Result(name = "success", type = "redirectAction", location = "index.html"),
68 @Result(name = "input", type="tiles", location = "contentEntryDeleteForm"),
69 @Result(name = "error", type="tiles", location = "contentEntryDeleteError")
70 }
71 )
72 })
73 public String execute() throws Exception {
74 LOGGER.info("execute() aufgerufen.");
75
76 String remoteUser = ServletActionContext.getRequest().getRemoteUser();
77 String remoteAddress = ServletActionContext.getRequest().getRemoteAddr();
78
79 if(contentEntry != null) {
80 ContentEntry dbContentEntry = contentEntryDaoLocal.findByUuid(contentEntry.getUuid());
81 dbContentEntry.setModified(new Date());
82 dbContentEntry.setModifiedBy(remoteUser);
83 dbContentEntry.setModifiedAddress(remoteAddress);
84 contentEntryDaoLocal.merge(dbContentEntry);
85 contentEntryDaoLocal.delete(dbContentEntry);
86 return SUCCESS;
87 }
88 else {
89 return ERROR;
90 }
91
92
93 }
94
95 }