001: /*
002: * SalomeTMF is a Test Management Framework
003: * Copyright (C) 2005 France Telecom R&D
004: *
005: * This library is free software; you can redistribute it and/or
006: * modify it under the terms of the GNU Lesser General Public
007: * License as published by the Free Software Foundation; either
008: * version 2 of the License, or (at your option) any later version.
009: *
010: * This library is distributed in the hope that it will be useful,
011: * but WITHOUT ANY WARRANTY; without even the implied warranty of
012: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
013: * Lesser General Public License for more details.
014: *
015: * You should have received a copy of the GNU Lesser General Public
016: * License along with this library; if not, write to the Free Software
017: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
018: *
019: * @author Fayçal SOUGRATI
020: *
021: * Contact: mikael.marche@rd.francetelecom.com
022: */
023:
024: package org.objectweb.salome_tmf.api.api2ihm.adminVT;
025:
026: import java.sql.PreparedStatement;
027: import java.util.Properties;
028: import java.sql.SQLException;
029:
030: import org.objectweb.salome_tmf.api.api2db.DataBase;
031:
032: /**
033: * Fonctions de mise à jour relatives à l'aire fonctionnelle "Administrer SalomeTMF"
034: */
035:
036: public class AdminVTUpdateImpl implements AdminVTUpdate {
037: /**
038: * Base de données SalomeTMF
039: */
040: DataBase database;
041:
042: /**
043: * Fichier "properties" contenant les requetes SQL relatives a l'administration
044: */
045: Properties prop;
046:
047: /**
048: * Modifie le mot de passe de l'administrateur VT
049: * @param userLogin
050: * @param newPassword
051: */
052: public void updateAdminPassword(String userLogin, String newPassword) {
053: int _num = -1;
054: try {
055: _num = org.objectweb.salome_tmf.api.Api.beginTrans();
056:
057: // Mise a jour du mot de passe
058: PreparedStatement prep = database.prepareStatement(prop
059: .getProperty("updatePassword"));
060: newPassword = org.objectweb.salome_tmf.api.MD5paswd
061: .getEncodedPassword(newPassword);
062: prep.setString(1, newPassword);
063: prep.setString(2, userLogin);
064: prep.executeUpdate();
065: } catch (SQLException e) {
066: e.printStackTrace();
067: org.objectweb.salome_tmf.api.Api.addException(
068: "updatePassword", null, e);
069: } catch (Exception ex) {
070: ex.printStackTrace();
071: org.objectweb.salome_tmf.api.Api.addException(null, null,
072: ex);
073: }
074: org.objectweb.salome_tmf.api.Api.commitTrans(_num);
075:
076: }
077:
078: /**
079: * Constructeur
080: * @param db
081: * @param pr
082: */
083: public AdminVTUpdateImpl(DataBase db, Properties pr) {
084: database = db;
085: prop = pr;
086: }
087:
088: /**
089: * Modifier le nom et la description d'un projet
090: * @param oldProject L'ID du projet
091: * @param newName Nouveau nom du projet
092: * @param newDesc Nouvelle description du projet
093: */
094: public void updateProject(int idProject, String newName,
095: String newDesc) {
096: int _num = -1;
097: try {
098: _num = org.objectweb.salome_tmf.api.Api.beginTrans();
099:
100: // Mise a jour
101: System.out.println("Ancien nom du projet");
102: PreparedStatement prep = database.prepareStatement(prop
103: .getProperty("updateProject"));
104: prep.setString(1, newName);
105: prep.setString(2, newDesc);
106: prep.setInt(3, idProject);
107: prep.executeUpdate();
108: } catch (SQLException e) {
109: e.printStackTrace();
110: org.objectweb.salome_tmf.api.Api.addException(
111: "updateProject", null, e);
112: } catch (Exception ex) {
113: ex.printStackTrace();
114: org.objectweb.salome_tmf.api.Api.addException(null, null,
115: ex);
116: }
117: org.objectweb.salome_tmf.api.Api.commitTrans(_num);
118: }
119:
120: /**
121: * Modifier les infos d'une personne
122: * @param oldPerson,
123: * @param newLogin,
124: * @param newName,
125: * @param newFirstName,
126: * @param newDesc,
127: * @param newEmail,
128: * @param newTel
129: */
130: public void updatePerson(int idPerson, String newLogin,
131: String newName, String newFirstName, String newDesc,
132: String newEmail, String newTel) {
133: int _num = -1;
134: try {
135: _num = org.objectweb.salome_tmf.api.Api.beginTrans();
136:
137: // Mise a jour
138: PreparedStatement prep = database.prepareStatement(prop
139: .getProperty("updatePerson"));
140: prep.setString(1, newLogin);
141: prep.setString(2, newName);
142: prep.setString(3, newFirstName);
143: prep.setString(4, newDesc);
144: prep.setString(5, newEmail);
145: prep.setString(6, newTel);
146: prep.setInt(7, idPerson);
147: prep.executeUpdate();
148: } catch (SQLException e) {
149: e.printStackTrace();
150: org.objectweb.salome_tmf.api.Api.addException(
151: "updatePerson", null, e);
152: } catch (Exception ex) {
153: ex.printStackTrace();
154: org.objectweb.salome_tmf.api.Api.addException(null, null,
155: ex);
156: }
157: org.objectweb.salome_tmf.api.Api.commitTrans(_num);
158: }
159:
160: }
|