1 package de.tivsource.page.user.actions.location;
2
3 import java.util.List;
4
5 import org.apache.logging.log4j.LogManager;
6 import org.apache.logging.log4j.Logger;
7 import org.apache.struts2.convention.annotation.Action;
8 import org.apache.struts2.convention.annotation.Actions;
9 import org.apache.struts2.convention.annotation.Result;
10 import org.apache.struts2.tiles.annotation.TilesDefinition;
11 import org.apache.struts2.tiles.annotation.TilesDefinitions;
12 import org.apache.struts2.tiles.annotation.TilesPutAttribute;
13
14 import de.tivsource.ejb3plugin.InjectEJB;
15 import de.tivsource.page.dao.location.LocationDaoLocal;
16 import de.tivsource.page.dao.page.PageDaoLocal;
17 import de.tivsource.page.dao.property.PropertyDaoLocal;
18 import de.tivsource.page.entity.location.Location;
19 import de.tivsource.page.entity.page.Page;
20 import de.tivsource.page.user.actions.EmptyAction;
21
22
23
24
25
26
27 @TilesDefinitions({
28 @TilesDefinition(name="location", extend = "userTemplate", putAttributes = {
29 @TilesPutAttribute(name = "content", value = "/WEB-INF/tiles/active/view/location/location.jsp")
30 })
31 })
32 public class IndexAction extends EmptyAction {
33
34
35
36
37 private static final long serialVersionUID = -3431822966540867695L;
38
39
40
41
42 private static final Logger LOGGER = LogManager.getLogger(IndexAction.class);
43
44 @InjectEJB(name="PageDao")
45 private PageDaoLocal pageDaoLocal;
46
47 @InjectEJB(name="PropertyDao")
48 private PropertyDaoLocal propertyDaoLocal;
49
50 @InjectEJB(name="LocationDao")
51 private LocationDaoLocal locationDaoLocal;
52
53 private Page page;
54
55 @Override
56 public void prepare() {
57
58 page = pageDaoLocal.findByTechnical("location");
59 }
60
61 @Override
62 @Actions({
63 @Action(
64 value = "index",
65 results = {
66 @Result(name = "success", type="tiles", location = "location"),
67 @Result(name = "error", type = "redirectAction", location = "index.html", params={"namespace", "/"})
68 }
69 )
70 })
71 public String execute() throws Exception {
72 LOGGER.info("execute() aufgerufen.");
73
74
75 boolean moduleEnabled = propertyDaoLocal.findByKey("module.location").getValue().equals("true") ? true : false;
76
77
78 if(moduleEnabled) {
79
80 this.getLanguageFromActionContext();
81 return SUCCESS;
82 } else {
83
84 return ERROR;
85 }
86 }
87
88 public Page getPage() {
89 return page;
90 }
91
92 public List<Location> getList() {
93 return locationDaoLocal.findAllVisible(0, locationDaoLocal.countAllVisible());
94 }
95
96 }