View Javadoc

1   package de.tivsource.page.admin.actions.others.manual;
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.manual.ManualDaoLocal;
15  import de.tivsource.page.entity.manual.Manual;
16  
17  /**
18   * 
19   * @author Marc Michele
20   *
21   */
22  public class DeleteAction extends EmptyAction {
23  
24      /**
25       * Serial Version UID.
26       */
27  	private static final long serialVersionUID = -8955242912078594369L;
28  
29  	/**
30       * Statischer Logger der Klasse.
31       */
32      private static final Logger LOGGER = LogManager.getLogger(DeleteAction.class);
33  
34      @InjectEJB(name="ManualDao")
35      private ManualDaoLocal manualDaoLocal;
36  
37      private Manual manual;
38  
39      public Manual getManual() {
40          return manual;
41      }
42  
43      public void setManual(Manual manual) {
44          this.manual = manual;
45      }
46  
47  	@Override
48      @Actions({
49          @Action(
50          		value = "delete", 
51          		results = { 
52          				@Result(name = "success", type = "redirectAction", location = "index.html"),
53          				@Result(name = "input", type="tiles", location = "manualDeleteForm"),
54          				@Result(name = "error", type="tiles", location = "manualDeleteError")
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(manual != null) {
65      		Manual dbManual = manualDaoLocal.findByUuid(manual.getUuid());
66      		dbManual.setModified(new Date());
67      		dbManual.setModifiedBy(remoteUser);
68      		dbManual.setModifiedAddress(remoteAddress);
69      		manualDaoLocal.merge(dbManual);
70      		manualDaoLocal.delete(dbManual);
71              return SUCCESS;
72      	}
73      	else {
74      		return ERROR;
75      	}
76      	
77      	
78      }// Ende execute()
79  	
80  }// Ende class