View Javadoc

1   package de.tivsource.page.admin.actions.system.property;
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  
12  import de.tivsource.ejb3plugin.InjectEJB;
13  import de.tivsource.page.admin.actions.EmptyAction;
14  import de.tivsource.page.dao.property.PropertyDaoLocal;
15  import de.tivsource.page.entity.property.Property;
16  
17  /**
18   * 
19   * @author Marc Michele
20   *
21   */
22  public class AddAction extends EmptyAction {
23  
24  	/**
25  	 * Serial Version UID.
26  	 */
27      private static final long serialVersionUID = -1217385198172019511L;
28  
29      /**
30       * Statischer Logger der Klasse.
31       */
32      private static final Logger LOGGER = LogManager.getLogger(AddAction.class);
33  
34      @InjectEJB(name="PropertyDao")
35      private PropertyDaoLocal propertyDaoLocal;
36  
37      private Property property;
38  
39      public Property getProperty() {
40          return property;
41      }
42  
43      public void setProperty(Property property) {
44          this.property = property;
45      }
46  
47      @Override
48      @Actions({
49          @Action(
50          		value = "add", 
51          		results = { 
52          				@Result(name = "success", type = "redirectAction", location = "index.html"),
53          				@Result(name = "input", type="tiles", location = "propertyAddForm"),
54          				@Result(name = "error", type="tiles", location = "propertyAddError")
55          				}
56          )
57      })
58      public String execute() throws Exception {
59      	LOGGER.info("execute() aufgerufen.");
60  
61          String remoteUser    = ServletActionContext.getRequest().getRemoteUser();
62          String remoteAddress = ServletActionContext.getRequest().getRemoteAddr();
63  
64      	if(property != null) {
65      	    property.setModified(new Date());
66      	    property.setModifiedBy(remoteUser);
67      	    property.setModifiedAddress(remoteAddress);
68      	    propertyDaoLocal.merge(property);
69              return SUCCESS;
70      	}
71      	else {
72      		return ERROR;
73      	}
74      	
75      	
76      }// Ende execute()
77  
78  }// Ende class