1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106
| package fr.limayrac.servlet;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import fr.limayrac.utils.ErrorsHandler;
import fr.limayrac.utils.UtilsFunctions;
import fr.limayrac.utils.UtilsVariables;
import fr.limayrac.xml.XMLParser;
@WebServlet("/SuiviMateriel")
public class S_SuiviMateriel extends HttpServlet {
private static final long serialVersionUID = 1L;
public void doGet(HttpServletRequest request, HttpServletResponse response) {
try {
request.setCharacterEncoding("UTF-8");
} catch (UnsupportedEncodingException e) {
ErrorsHandler.write(UtilsVariables.ERRORLVL_WARNING, UtilsVariables.ErrorTypes.ServletError, e.getMessage());
}
HttpSession session = request.getSession();
if(session.getAttribute("id_profil") == null) {
try {
response.sendError(401);
} catch (IOException e) {
ErrorsHandler.write(UtilsVariables.ERRORLVL_WARNING, UtilsVariables.ErrorTypes.ServletError, e.getMessage());
}
} else if((session.getAttribute("id_profil").toString().equals("1"))||(session.getAttribute("id_profil").toString().equals("2"))||(session.getAttribute("id_profil").toString().equals("3"))) {
String user = session.getAttribute("prenom_utilisateur").toString() + " " + session.getAttribute("nom_utilisateur").toString().toUpperCase();
request.setAttribute("user", user);
String lang = UtilsFunctions.langById(session.getAttribute("id_lang").toString());
String rank = UtilsFunctions.rankById((Integer)session.getAttribute("id_profil"), lang);
request.setAttribute("rank", rank);
//Menu
request.setAttribute("M_log", XMLParser.getText(lang, "menu", "log"));
//Page SuiviMateriel
request.setAttribute("M_home", XMLParser.getText(lang, "menu", "home"));
request.setAttribute("M_view", XMLParser.getText(lang, "menu", "view"));
request.setAttribute("M_graphic", XMLParser.getText(lang, "menu", "graphic"));
request.setAttribute("M_site", XMLParser.getText(lang, "menu", "site"));
request.setAttribute("M_monitoring", XMLParser.getText(lang, "menu", "monitoring"));
request.setAttribute("M_summary", XMLParser.getText(lang, "menu", "summary"));
request.setAttribute("M_export", XMLParser.getText(lang, "menu", "export"));
request.setAttribute("M_administration", XMLParser.getText(lang, "menu", "administration"));
request.setAttribute("M_profile", XMLParser.getText(lang, "menu", "profile"));
request.setAttribute("M_station", XMLParser.getText(lang, "menu", "station"));
request.setAttribute("M_user", XMLParser.getText(lang, "menu", "user"));
request.setAttribute("M_log", XMLParser.getText(lang, "menu", "log"));
request.setAttribute("M_SuiviMateriel", XMLParser.getText(lang, "menu", "SuiviMateriel"));
request.setAttribute("M_graphic", XMLParser.getText(lang, "menu", "webmastergraphic"));
request.setAttribute("M_mnemonique", XMLParser.getText(lang, "menu", "webmastermnemonique"));
//Page Ref
request.setAttribute("P_title", XMLParser.getText(lang, "SuiviMateriel", "title"));
request.setAttribute("P_comment", XMLParser.getText(lang, "SuiviMateriel", "comment"));
request.setAttribute("P_Chosir", XMLParser.getText(lang, "SuiviMateriel", "ChoiseStation"));
request.setAttribute("P_Materiel", XMLParser.getText(lang, "SuiviMateriel", "materiel"));
request.setAttribute("P_Capteur", XMLParser.getText(lang, "SuiviMateriel", "capteur"));
request.setAttribute("P_StockMateriel", XMLParser.getText(lang, "SuiviMateriel", "stockMateriel"));
request.setAttribute("P_StockCapteur", XMLParser.getText(lang, "SuiviMateriel", "stockCapteur"));
request.setAttribute("P_HistoriqueMateriel", XMLParser.getText(lang, "SuiviMateriel", "HistoriqueMateriel"));
request.setAttribute("P_HistoriqueCapteur", XMLParser.getText(lang, "SuiviMateriel", "HistoriqueCapteur"));
request.setAttribute("P_TextExport", XMLParser.getText(lang, "SuiviMateriel", "TextExport"));
request.setAttribute("P_Export", XMLParser.getText(lang, "SuiviMateriel", "Export"));
request.setAttribute("P_Fermer", XMLParser.getText(lang, "SuiviMateriel", "Fermer"));
request.setAttribute("P_Libel", XMLParser.getText(lang, "SuiviMateriel", "Libel"));
request.setAttribute("P_Change", XMLParser.getText(lang, "SuiviMateriel", "Change"));
request.setAttribute("P_Libel", XMLParser.getText(lang, "SuiviMateriel", "Libel"));
request.setAttribute("P_manage", XMLParser.getText(lang, "SuiviMateriel", "manage"));
request.setAttribute("P_SelectAll", XMLParser.getText(lang, "SuiviMateriel", "select"));
request.setAttribute("P_ihmcustom", XMLParser.getText(lang, "profil", "ihmcustom"));
request.setAttribute("P_save", XMLParser.getText(lang, "generic", "save"));
request.setAttribute("P_add", XMLParser.getText(lang, "generic", "add"));
request.setAttribute("P_capteur", XMLParser.getText(lang, "materiel", "capteur"));
request.setAttribute("P_selectCap", XMLParser.getText(lang, "materiel", "selectCap"));
//On rattache le servlet à sa vue
try {
this.getServletContext().getRequestDispatcher("/WEB-INF/V_SuiviMateriel.jsp").forward(request, response);
} catch (ServletException | IOException e) {
ErrorsHandler.write(UtilsVariables.ERRORLVL_WARNING, UtilsVariables.ErrorTypes.ServletError, e.getMessage());
}
} else {
try {
response.sendError(401);
} catch (IOException e) {
ErrorsHandler.write(UtilsVariables.ERRORLVL_WARNING, UtilsVariables.ErrorTypes.ServletError, e.getMessage());
}
}
}
} |
Partager