View Javadoc

1   /*Copyright (C) 2004-... Stephane Gauchet for Hyphonem
2   
3    This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
4   
5    This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
6   
7    You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
8    
9    Written by St�phane Gauchet
10   mail me at : sgauchet@free.fr
11   */
12  package fr.hyphonem.conges;
13  
14  import java.util.Calendar;
15  
16  import javax.servlet.http.HttpServletRequest;
17  
18  import org.apache.struts.action.ActionError;
19  import org.apache.struts.action.ActionErrors;
20  
21  import fr.hyphonem.conges.data.EmployeeData;
22  
23  /**
24   * @author Stephane Gauchet pour Hyphonem
25   * 
26   */
27  public final class CheckData {
28  
29  	/**
30  	 * check data after login to be sure that xml files will be read correctly /
31  	 * verifie les donn�es dans les fichiers xml afin d'�viter les erreurs au
32  	 * login
33  	 * 
34  	 * @param request
35  	 * @param employee
36  	 * @param errors
37  	 * @return Map
38  	 */
39  	public static ActionErrors check(HttpServletRequest request,
40  			EmployeeData employee, ActionErrors errors) {
41  
42  		String dataDirPath = (String) request.getSession().getAttribute(
43  				"dataDirPath");
44  
45  		AccessData ad = new AccessDataMng().getInstance(dataDirPath);
46  
47  		try {
48  			ad.readNationalHolidays(employee.getPays(), ""
49  					+ Calendar.getInstance().get(Calendar.YEAR));
50  		} catch (Exception e) {
51  			System.out.println("CheckData NationalHolidays " + e.getMessage());
52  			errors.add("NationalHolidays", new ActionError(
53  					"error.data.not.ready"));
54  		}
55  
56  		try {
57  			ad.readCalendarData(employee);
58  		} catch (Exception e) {
59  			System.out.println("CheckData CalendarData " + e.getMessage());
60  			errors.add("CalendarData", new ActionError("error.data.not.ready"));
61  		}
62  
63  		try {
64  			ad.readParamMail();
65  		} catch (Exception e) {
66  			System.out.println("CheckData ParamMail " + e.getMessage());
67  			errors.add("ParamMail", new ActionError("error.data.not.ready"));
68  		}
69  
70  		try {
71  			ad.readParamPays();
72  		} catch (Exception e) {
73  			System.out.println("CheckData ParamPays " + e.getMessage());
74  			errors.add("ParamPays", new ActionError("error.data.not.ready"));
75  		}
76  
77  		try {
78  			ad.readParams();
79  		} catch (Exception e) {
80  			System.out.println("CheckData Param " + e.getMessage());
81  			errors.add("Param", new ActionError("error.data.not.ready"));
82  		}
83  
84  		try {
85  			ad.readReasons();
86  		} catch (Exception e) {
87  			System.out.println("CheckData Reasons " + e.getMessage());
88  			errors.add("Reasons", new ActionError("error.data.not.ready"));
89  		}
90  
91  		try {
92  			ad.readTeams();
93  		} catch (Exception e) {
94  			System.out.println("CheckData Teams " + e.getMessage());
95  			errors.add("Teams", new ActionError("error.data.not.ready"));
96  		}
97  
98  		try {
99  			ad.readUsers();
100 		} catch (Exception e) {
101 			System.out.println("CheckData Users " + e.getMessage());
102 			errors.add("Users", new ActionError("error.data.not.ready"));
103 		}
104 
105 		return errors;
106 	}
107 }