1 package ch.ige.edossier.web.struts;
2
3 import java.util.List;
4 import javax.servlet.http.HttpServletRequest;
5 import javax.servlet.http.HttpServletResponse;
6 import javax.servlet.http.HttpSession;
7 import org.apache.log4j.Logger;
8 import org.apache.struts.action.*;
9 import ch.ige.edossier.util.RefreshState;
10 import ch.ige.edossier.web.server.EDossierControl;
11 import ch.ige.edossier.web.vo.AccountVO;
12 import ch.ige.edossier.web.vo.DossierOverviewVO;
13 import ch.ige.edossier.web.vo.InterceptionVO;
14
15
24 public class InterceptionDetailAction extends Action
25 {
26 private static final Logger LOG = Logger.getLogger( InterceptionDetailAction.class );
28
29
40 public ActionForward execute( ActionMapping actionMapping, ActionForm actionForm, HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse )
41 {
42 ActionErrors errors = new ActionErrors();
43 HttpSession session = httpServletRequest.getSession( false );
44 EDossierFacade eFacade = new EDossierControl();
45
46 try
47 {
48 if( session == null || ( ( Boolean )session.getAttribute( "token" ) ).booleanValue() == false )
50 {
51 return( actionMapping.findForward( "index" ) );
52 }
53
54 String idInterception = httpServletRequest.getParameter( "idInterception" );
55 int interceptionId = Integer.parseInt( idInterception );
56
57 InterceptionVO interceptionVO = eFacade.getInterception( interceptionId );
58 session.setAttribute( "interceptionVO", interceptionVO );
59
60 AccountVO accountVO = ( AccountVO )session.getAttribute( "accountVO" );
61 reloadSessionObjects( session, Integer.parseInt( idInterception ), 2, accountVO.getAccountId(), interceptionVO.getDossierId() );
63 }
64 catch( Exception ex )
65 {
66 if( ex == null )
67 {
68 return( actionMapping.findForward( "index" ) );
69 }
70 else
71 {
72 LOG.error( "Error: " + ex.getMessage() );
73 errors.add( "dossierVO", new ActionError( "errors.dossier", ex.getMessage() ) );
74 saveErrors( httpServletRequest, errors );
75 return( new ActionForward( actionMapping.getInput() ) );
76 }
77 }
78 return( actionMapping.findForward( "forward" ) );
79 }
80
81
89 private void reloadSessionObjects( HttpSession session, int idInterception, int state, int accountId, int dossierId )
90 {
91 RefreshState refrehState = new RefreshState();
92
93 if( refrehState.setState( idInterception, state ) )
94 {
95 DossierOverviewVO dossierOverVO = refrehState.updateDossiers( accountId );
97
98 if( dossierOverVO != null )
99 {
100 session.setAttribute( "dossierOverviewVO", dossierOverVO );
101
102 List listDossiers = refrehState.updateInterceptions( dossierId );
104 if( listDossiers != null && listDossiers.size() > 0 )
105 {
106 session.setAttribute( "alInterceptionVO", listDossiers );
107 }
108 }
109 }
110 }
111 }
112