List of usage examples for org.w3c.dom Element getNodeName
public String getNodeName();
From source file:com.portfolio.data.provider.MysqlAdminProvider.java
@Override public String putInfUser(int userId, int userid2, String in) throws SQLException { String result1 = null;/*from w w w .j av a 2s. co m*/ Integer id = 0; String password = null; String email = null; String result = null; String username = null; String firstname = null; String lastname = null; String active = null; String is_admin = null; //On prepare les requetes SQL PreparedStatement st; String sql; //On recupere le body Document doc; Element infUser = null; try { doc = DomUtils.xmlString2Document(in, new StringBuffer()); infUser = doc.getDocumentElement(); } catch (Exception e) { e.printStackTrace(); } NodeList children = null; children = infUser.getChildNodes(); // if(infUser.getNodeName().equals("users")) // { // for(int i=0;i<children.getLength();i++) // { if (infUser.getNodeName().equals("user")) { //On recupere les attributs if (infUser.getAttributes().getNamedItem("id") != null) { id = Integer.parseInt(infUser.getAttributes().getNamedItem("id").getNodeValue()); } else { id = null; } NodeList children2 = null; children2 = infUser.getChildNodes(); for (int y = 0; y < children2.getLength(); y++) { if (children2.item(y).getNodeName().equals("username")) { username = DomUtils.getInnerXml(children2.item(y)); sql = "UPDATE credential SET login = ? WHERE userid = ?"; st = connection.prepareStatement(sql); st.setString(1, username); st.setInt(2, userid2); st.executeUpdate(); } if (children2.item(y).getNodeName().equals("password")) { password = DomUtils.getInnerXml(children2.item(y)); sql = "UPDATE credential SET password = UNHEX(SHA1(?)) WHERE userid = ?"; if (dbserveur.equals("oracle")) { sql = "UPDATE credential SET password = crypt(?) WHERE userid = ?"; } st = connection.prepareStatement(sql); st.setString(1, password); st.setInt(2, userid2); st.executeUpdate(); } if (children2.item(y).getNodeName().equals("firstname")) { firstname = DomUtils.getInnerXml(children2.item(y)); sql = "UPDATE credential SET display_firstname = ? WHERE userid = ?"; st = connection.prepareStatement(sql); st.setString(1, firstname); st.setInt(2, userid2); st.executeUpdate(); } if (children2.item(y).getNodeName().equals("lastname")) { lastname = DomUtils.getInnerXml(children2.item(y)); sql = "UPDATE credential SET display_lastname = ? WHERE userid = ?"; st = connection.prepareStatement(sql); st.setString(1, lastname); st.setInt(2, userid2); st.executeUpdate(); } if (children2.item(y).getNodeName().equals("email")) { email = DomUtils.getInnerXml(children2.item(y)); sql = "UPDATE credential SET email = ? WHERE userid = ?"; st = connection.prepareStatement(sql); st.setString(1, email); st.setInt(2, userid2); st.executeUpdate(); } if (children2.item(y).getNodeName().equals("is_admin")) { is_admin = DomUtils.getInnerXml(children2.item(y)); int is_adminInt = Integer.parseInt(is_admin); sql = "UPDATE credential SET is_admin = ? WHERE userid = ?"; st = connection.prepareStatement(sql); st.setInt(1, is_adminInt); st.setInt(2, userid2); st.executeUpdate(); } if (children2.item(y).getNodeName().equals("active")) { active = DomUtils.getInnerXml(children2.item(y)); int activeInt = Integer.parseInt(active); sql = "UPDATE credential SET active = ? WHERE userid = ?"; st = connection.prepareStatement(sql); st.setInt(1, activeInt); st.setInt(2, userid2); st.executeUpdate(); } } } result1 = "" + userid2; return result1; }
From source file:com.portfolio.data.provider.MysqlDataProvider.java
@Override public Object postGroup(String in, int userId) throws Exception { if (!credential.isAdmin(userId)) throw new RestWebApplicationException(Status.FORBIDDEN, "No admin right"); String result = null;/* www . jav a 2s . c om*/ Integer grid = 0; int owner = 0; String label = null; //On prepare les requetes SQL PreparedStatement stInsert; String sqlInsert; //On recupere le body Document doc = DomUtils.xmlString2Document(in, new StringBuffer()); Element etu = doc.getDocumentElement(); //On verifie le bon format if (etu.getNodeName().equals("group")) { //On recupere les attributs try { if (etu.getAttributes().getNamedItem("grid") != null) { grid = Integer.parseInt(etu.getAttributes().getNamedItem("grid").getNodeValue()); } else { grid = null; } } catch (Exception ex) { } try { if (etu.getAttributes().getNamedItem("owner") != null) { owner = Integer.parseInt(etu.getAttributes().getNamedItem("owner").getNodeValue()); if (owner == 0) owner = userId; } else { owner = userId; } } catch (Exception ex) { } try { if (etu.getAttributes().getNamedItem("label") != null) { label = etu.getAttributes().getNamedItem("label").getNodeValue(); } } catch (Exception ex) { } } else { result = "Erreur lors de la recuperation des attributs du groupe dans le XML"; } if (grid == null) return ""; //On ajoute le groupe dans la base de donnees sqlInsert = "REPLACE INTO group_info(grid, owner, label) VALUES (?, ?, ?)"; if (dbserveur.equals("oracle")) { sqlInsert = "MERGE INTO group_info d using (SELECT ? grid,? owner,? label from dual) s ON (1=2) WHEN NOT MATCHED THEN INSERT (d.grid, d.owner, d.label) values (s.grid, s.owner, s.label)"; } stInsert = connection.prepareStatement(sqlInsert); stInsert.setInt(1, grid); stInsert.setInt(2, owner); stInsert.setString(3, label); stInsert.executeUpdate(); //On renvoie le body pour qu'il soit stock dans le log result = "<group "; result += DomUtils.getXmlAttributeOutputInt("grid", grid) + " "; result += DomUtils.getXmlAttributeOutputInt("owner", owner) + " "; result += DomUtils.getXmlAttributeOutput("label", label) + " "; result += ">"; result += "</group>"; return result; }
From source file:com.portfolio.data.provider.MysqlDataProvider.java
@Override public String postAddNodeType(int userId, Integer type, Integer nodeid, Integer parentid, Integer instance, String data) {/*w w w .ja v a 2s . com*/ if (!credential.isAdmin(userId)) throw new RestWebApplicationException(Status.FORBIDDEN, "No admin right"); /** * Format que l'on reoit: * <asm*> * <asmResource xsi_type='nodeRes'>{node_data}</asmResource> * <asmResource xsi_type='context'>{node_data}</asmResource> * <asmResource xsi_type='*'>{node_data}</asmResource> * </asm*> */ String sql = ""; PreparedStatement st; Integer output = 0; Integer parentId = 0; String asmtype = ""; String xsitype = ""; try { /// Prpare les donnes pour les requtes // Parse DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder(); Document document = documentBuilder.parse(new ByteArrayInputStream(data.getBytes("UTF-8"))); // Traite le noeud racine des donnes, retourne l'identifiant du noeud racine Element nodeData = document.getDocumentElement(); asmtype = nodeData.getNodeName(); connection.setAutoCommit(true); // Utilise parentid si on rattache un autre groupe de noeud en dessous d'un noeud existant sql = "INSERT INTO definition_type(def_id,asm_type,parent_node,instance_rule) " + "VALUE(?,?,?,?)"; st = connection.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS); if (dbserveur.equals("oracle")) { st = connection.prepareStatement(sql, new String[] { "node_id" }); } st.setInt(1, type); st.setString(2, asmtype); if (parentid == null) st.setNull(3, Types.BIGINT); else st.setInt(3, parentid); if (instance == null) st.setNull(4, Types.BIGINT); else st.setInt(4, instance); output = st.executeUpdate(); ResultSet key = st.getGeneratedKeys(); // On rcure l'identifiant du noeud 'racine' des donnes ajouts if (key.next()) parentId = key.getInt(1); st.close(); // Soit 2 ou 3 resources asmtype = "asmResource"; NodeList resources = document.getElementsByTagName("asmResource"); sql = "INSERT INTO definition_type(def_id,asm_type,xsi_type,parent_node,node_data,instance_rule) " + "VALUE(?,?,?,?,?,?)"; st = connection.prepareStatement(sql); st.setInt(1, type); st.setString(2, asmtype); st.setInt(4, parentId); for (int i = 0; i < resources.getLength(); ++i) { Element resource = (Element) resources.item(i); xsitype = resource.getAttribute("xsi_type"); String resContent = DomUtils.getInnerXml(resource); st.setString(3, xsitype); st.setString(5, resContent); if (instance == null) st.setNull(6, Types.BIGINT); else st.setInt(6, instance); // On ajoute les donnes des ressources restante output = st.executeUpdate(); } st.close(); } catch (Exception e) { try { connection.rollback(); } catch (SQLException e1) { e1.printStackTrace(); } e.printStackTrace(); } finally { try { connection.setAutoCommit(true); connection.close(); } catch (SQLException e) { e.printStackTrace(); } } return output.toString(); }
From source file:com.portfolio.data.provider.MysqlDataProvider.java
@Override public Object postUser(String in, int userId) throws Exception { if (!credential.isAdmin(userId)) throw new RestWebApplicationException(Status.FORBIDDEN, "No admin right"); String result = null;/*from ww w . j a v a 2 s .co m*/ String login = null; String firstname = null; String lastname = null; String label = null; String password = null; String active = "1"; Integer uuid = 0; Integer newId = 0; //On prepare les requetes SQL PreparedStatement stInsert; String sqlInsert; //On recupere le body Document doc = DomUtils.xmlString2Document(in, new StringBuffer()); Element etu = doc.getDocumentElement(); //On verifie le bon format if (etu.getNodeName().equals("user")) { //On recupere les attributs try { if (etu.getAttributes().getNamedItem("uid") != null) { login = etu.getAttributes().getNamedItem("uid").getNodeValue(); if (getMysqlUserUid(login) != null) { uuid = Integer.parseInt(getMysqlUserUid(login)); } } } catch (Exception ex) { } try { if (etu.getAttributes().getNamedItem("firstname") != null) { firstname = etu.getAttributes().getNamedItem("firstname").getNodeValue(); } } catch (Exception ex) { } try { if (etu.getAttributes().getNamedItem("lastname") != null) { lastname = etu.getAttributes().getNamedItem("lastname").getNodeValue(); } } catch (Exception ex) { } try { if (etu.getAttributes().getNamedItem("label") != null) { label = etu.getAttributes().getNamedItem("label").getNodeValue(); } } catch (Exception ex) { } try { if (etu.getAttributes().getNamedItem("password") != null) { password = etu.getAttributes().getNamedItem("password").getNodeValue(); } } catch (Exception ex) { } try { if (etu.getAttributes().getNamedItem("active") != null) { active = etu.getAttributes().getNamedItem("active").getNodeValue(); } } catch (Exception ex) { } } else { result = "Erreur lors de la recuperation des attributs de l'utilisateur dans le XML"; } //On ajoute l'utilisateur dans la base de donnees if (etu.getAttributes().getNamedItem("firstname") != null && etu.getAttributes().getNamedItem("lastname") != null && etu.getAttributes().getNamedItem("label") == null) { sqlInsert = "REPLACE INTO credential(userid, login, display_firstname, display_lastname, password, active) VALUES (?, ?, ?, ?, UNHEX(SHA1(?)),?)"; stInsert = connection.prepareStatement(sqlInsert, Statement.RETURN_GENERATED_KEYS); if (dbserveur.equals("oracle")) { sqlInsert = "MERGE INTO credential d USING (SELECT ? userid,? login,? display_firstname,? display_lastname,crypt(?) password,? active FROM DUAL) s ON (d.userid=s.userid) WHEN MATCHED THEN UPDATE SET d.login=s.login, d.display_firstname = s.display_firstname, d.display_lastname = s.display_lastname, d.password = s.password, d.active = s.active WHEN NOT MATCHED THEN INSERT (d.userid, d.login, d.display_firstname, d.display_lastname, d.password, d.active) VALUES (s.userid, s.login, s.display_firstname, s.display_lastname, s.password, s.active)"; stInsert = connection.prepareStatement(sqlInsert, new String[] { "userid" }); } stInsert.setInt(1, uuid); stInsert.setString(2, login); stInsert.setString(3, firstname); stInsert.setString(4, lastname); stInsert.setString(5, password); stInsert.setString(6, active); stInsert.executeUpdate(); } else { sqlInsert = "REPLACE INTO credential(userid, login, display_firstname, display_lastname, password, active) VALUES (?, ?, ?, ?, UNHEX(SHA1(?)),?)"; stInsert = connection.prepareStatement(sqlInsert, Statement.RETURN_GENERATED_KEYS); if (dbserveur.equals("oracle")) { sqlInsert = "MERGE INTO credential d USING (SELECT ? userid,? login,? display_firstname,? display_lastname,crypt(?) password,? active FROM DUAL) s ON (d.userid=s.userid) WHEN MATCHED THEN UPDATE SET d.login=s.login, d.display_firstname = s.display_firstname, d.display_lastname = s.display_lastname, d.password = s.password, d.active = s.active WHEN NOT MATCHED THEN INSERT (d.userid, d.login, d.display_firstname, d.display_lastname, d.password, d.active) VALUES (s.userid, s.login, s.display_firstname, s.display_lastname, s.password, s.active)"; stInsert = connection.prepareStatement(sqlInsert, new String[] { "userid" }); } stInsert.setInt(1, uuid); stInsert.setString(2, login); stInsert.setString(3, " "); stInsert.setString(4, label); stInsert.setString(5, password); stInsert.setString(6, active); stInsert.executeUpdate(); } ResultSet rs = stInsert.getGeneratedKeys(); if (rs.next()) { newId = rs.getInt(1); } //On renvoie le body pour qu'il soit stock dans le log result = "<user "; result += DomUtils.getXmlAttributeOutput("uid", login) + " "; result += DomUtils.getXmlAttributeOutput("firstname", firstname) + " "; result += DomUtils.getXmlAttributeOutput("lastname", lastname) + " "; result += DomUtils.getXmlAttributeOutput("label", label) + " "; result += DomUtils.getXmlAttributeOutput("password", password) + " "; result += DomUtils.getXmlAttributeOutputInt("uuid", newId) + " "; result += ">"; result += "</user>"; return result; }
From source file:com.portfolio.data.provider.MysqlDataProvider.java
@Override public Object putRole(String xmlRole, int userId, int roleId) throws Exception { if (!credential.isAdmin(userId)) throw new RestWebApplicationException(Status.FORBIDDEN, "No admin right"); String result = null;//from www . j a va 2s.c om String username = null; String password = null; String firstname = null; String lastname = null; String email = null; String label = null; int id = 0; //On prepare les requetes SQL PreparedStatement stInsert; String sqlInsert; //On recupere le body Document doc; doc = DomUtils.xmlString2Document(xmlRole, new StringBuffer()); Element role = doc.getDocumentElement(); NodeList children = null; children = role.getChildNodes(); // On parcourt une premire fois les enfants pour rcuperer la liste crire en base //On verifie le bon format if (role.getNodeName().equals("role")) { for (int i = 0; i < children.getLength(); i++) { if (children.item(i).getNodeName().equals("label")) { label = DomUtils.getInnerXml(children.item(i)); } } } else { result = "Erreur lors de la recuperation des attributs de l'utilisateur dans le XML"; } //On ajoute l'utilisateur dans la base de donnees try { sqlInsert = "REPLACE INTO credential(login, display_firstname, display_lastname,email, password) VALUES (?, ?, ?, ?, UNHEX(SHA1(?)))"; stInsert = connection.prepareStatement(sqlInsert, Statement.RETURN_GENERATED_KEYS); if (dbserveur.equals("oracle")) { sqlInsert = "INSERT INTO credential(login, display_firstname, display_lastname,email, password) VALUES (?, ?, ?, ?, crypt(?))"; stInsert = connection.prepareStatement(sqlInsert, new String[] { "userid" }); } stInsert.setString(1, username); stInsert.setString(2, firstname); stInsert.setString(3, lastname); stInsert.setString(4, email); stInsert.setString(5, password); stInsert.executeUpdate(); ResultSet rs = stInsert.getGeneratedKeys(); if (rs.next()) { id = rs.getInt(1); } } catch (SQLException e) { e.printStackTrace(); } result = "" + id; return result; }
From source file:com.portfolio.data.provider.MysqlDataProvider.java
@Override public Object postModels(MimeType mimeType, String xmlModel, int userId) throws Exception { if (!credential.isAdmin(userId)) throw new RestWebApplicationException(Status.FORBIDDEN, "No admin right"); String pm_label = null;//from w w w. jav a 2 s .co m String portfolio_id = null; String result = ""; //On recupere le body Document doc; doc = DomUtils.xmlString2Document(xmlModel, new StringBuffer()); Element users = doc.getDocumentElement(); NodeList children = null; children = users.getChildNodes(); // On parcourt une premire fois les enfants pour rcuperer la liste crire en base //On verifie le bon format if (users.getNodeName().equals("models")) { for (int i = 0; i < children.getLength(); i++) { if (children.item(i).getNodeName().equals("model")) { NodeList children2 = null; children2 = children.item(i).getChildNodes(); for (int y = 0; y < children2.getLength(); y++) { if (children2.item(y).getNodeName().equals("label")) { pm_label = DomUtils.getInnerXml(children2.item(y)); } if (children2.item(y).getNodeName().equals("treeid")) { portfolio_id = DomUtils.getInnerXml(children2.item(y)); } //requete sql refaire // sqlInsert = "REPLACE INTO portfolio_(login, display_firstname, display_lastname,email, password) VALUES (?, ?, ?, ?, UNHEX(SHA1(?)))"; // stInsert = connection.prepareStatement(sqlInsert, Statement.RETURN_GENERATED_KEYS); // if (dbserveur.equals("oracle")){ // } // // stInsert.setString(1, pm_label); // stInsert.setString(2, portfolio_id); // stInsert.executeUpdate(); // ResultSet rs = stInsert.getGeneratedKeys(); // if (rs.next()) { // id = rs.getInt(1); // } // // // result += "<model "; // result += DomUtils.getXmlAttributeOutputInt("id", id)+" "; // result += ">"; // result += DomUtils.getXmlElementOutput("label", pm_label); // result += DomUtils.getXmlElementOutput("treeid", portfolio_id); // result += "</user>"; } } } } else { result = "Erreur lors de la recuperation des attributs de l'utilisateur dans le XML"; } return result; }
From source file:com.portfolio.data.provider.MysqlDataProvider.java
@Override public String postUsers(String in, int userId) throws Exception { if (!credential.isAdmin(userId)) throw new RestWebApplicationException(Status.FORBIDDEN, "No admin right"); String result = null;//from ww w . jav a 2 s .c om String username = null; String password = null; String firstname = null; String lastname = null; String email = null; String designerstr = null; String active = "1"; int id = 0; int designer; //On prepare les requetes SQL PreparedStatement stInsert; String sqlInsert; //On recupere le body Document doc; doc = DomUtils.xmlString2Document(in, new StringBuffer()); Element users = doc.getDocumentElement(); NodeList children = null; children = users.getChildNodes(); // On parcourt une premire fois les enfants pour rcuperer la liste crire en base //On verifie le bon format if (users.getNodeName().equals("users")) { for (int i = 0; i < children.getLength(); i++) { if (children.item(i).getNodeName().equals("user")) { NodeList children2 = null; children2 = children.item(i).getChildNodes(); for (int y = 0; y < children2.getLength(); y++) { if (children2.item(y).getNodeName().equals("username")) { username = DomUtils.getInnerXml(children2.item(y)); } if (children2.item(y).getNodeName().equals("password")) { password = DomUtils.getInnerXml(children2.item(y)); } if (children2.item(y).getNodeName().equals("firstname")) { firstname = DomUtils.getInnerXml(children2.item(y)); } if (children2.item(y).getNodeName().equals("lastname")) { lastname = DomUtils.getInnerXml(children2.item(y)); } if (children2.item(y).getNodeName().equals("email")) { email = DomUtils.getInnerXml(children2.item(y)); } if (children2.item(y).getNodeName().equals("active")) { active = DomUtils.getInnerXml(children2.item(y)); } if (children2.item(y).getNodeName().equals("designer")) { designerstr = DomUtils.getInnerXml(children2.item(y)); } } } } } else { result = "Erreur lors de la recuperation des attributs de l'utilisateur dans le XML"; } //On ajoute l'utilisateur dans la base de donnees try { sqlInsert = "REPLACE INTO credential(login, display_firstname, display_lastname,email, password, active, is_designer) VALUES (?, ?, ?, ?, UNHEX(SHA1(?)),?,?)"; stInsert = connection.prepareStatement(sqlInsert, Statement.RETURN_GENERATED_KEYS); if (dbserveur.equals("oracle")) { sqlInsert = "INSERT INTO credential(login, display_firstname, display_lastname,email, password, active, is_designer) VALUES (?, ?, ?, ?, crypt(?),?,?)"; stInsert = connection.prepareStatement(sqlInsert, new String[] { "userid" }); } stInsert.setString(1, username); if (firstname == null) { firstname = " "; stInsert.setString(2, firstname); } else { stInsert.setString(2, firstname); } if (lastname == null) { lastname = " "; stInsert.setString(3, lastname); } else { stInsert.setString(3, lastname); } if (email == null) { email = " "; stInsert.setString(4, email); } else { stInsert.setString(4, email); } stInsert.setString(5, password); if (active == null) { active = " "; stInsert.setString(6, active); } else { stInsert.setString(6, active); } if (designerstr == null) { designer = 0; stInsert.setInt(7, designer); } else { designer = Integer.parseInt(designerstr); stInsert.setInt(7, designer); } stInsert.executeUpdate(); ResultSet rs = stInsert.getGeneratedKeys(); if (rs.next()) { id = rs.getInt(1); } } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } //On renvoie le body pour qu'il soit stock dans le log result = "<users>"; result += "<user "; result += DomUtils.getXmlAttributeOutputInt("id", id); result += ">"; result += DomUtils.getXmlElementOutput("username", username); result += DomUtils.getXmlElementOutput("password", password); result += DomUtils.getXmlElementOutput("firstname", firstname); result += DomUtils.getXmlElementOutput("lastname", lastname); result += DomUtils.getXmlElementOutput("email", email); result += DomUtils.getXmlElementOutput("active", active); result += DomUtils.getXmlElementOutput("designer", designerstr); result += "</user>"; result += "</users>"; return result; }
From source file:com.portfolio.data.provider.MysqlDataProvider.java
@Override public String putInfUser(int userId, int userid2, String in) throws SQLException { String result1 = null;// ww w . ja va 2s . c om Integer id = 0; String password = null; String email = null; String username = null; String firstname = null; String lastname = null; String active = null; String is_admin = null; String is_designer = null; //On prepare les requetes SQL PreparedStatement st; String sql; //On recupere le body Document doc; Element infUser = null; try { doc = DomUtils.xmlString2Document(in, new StringBuffer()); infUser = doc.getDocumentElement(); } catch (Exception e) { e.printStackTrace(); } NodeList children = null; children = infUser.getChildNodes(); // if(infUser.getNodeName().equals("users")) // { // for(int i=0;i<children.getLength();i++) // { if (infUser.getNodeName().equals("user")) { //On recupere les attributs if (infUser.getAttributes().getNamedItem("id") != null) { id = Integer.parseInt(infUser.getAttributes().getNamedItem("id").getNodeValue()); } else { id = null; } NodeList children2 = null; children2 = infUser.getChildNodes(); for (int y = 0; y < children2.getLength(); y++) { if (children2.item(y).getNodeName().equals("username")) { username = DomUtils.getInnerXml(children2.item(y)); sql = "UPDATE credential SET login = ? WHERE userid = ?"; st = connection.prepareStatement(sql); st.setString(1, username); st.setInt(2, userid2); st.executeUpdate(); } if (children2.item(y).getNodeName().equals("password")) { password = DomUtils.getInnerXml(children2.item(y)); sql = "UPDATE credential SET password = UNHEX(SHA1(?)) WHERE userid = ?"; if (dbserveur.equals("oracle")) { sql = "UPDATE credential SET password = crypt(?) WHERE userid = ?"; } st = connection.prepareStatement(sql); st.setString(1, password); st.setInt(2, userid2); st.executeUpdate(); } if (children2.item(y).getNodeName().equals("firstname")) { firstname = DomUtils.getInnerXml(children2.item(y)); sql = "UPDATE credential SET display_firstname = ? WHERE userid = ?"; st = connection.prepareStatement(sql); st.setString(1, firstname); st.setInt(2, userid2); st.executeUpdate(); } if (children2.item(y).getNodeName().equals("lastname")) { lastname = DomUtils.getInnerXml(children2.item(y)); sql = "UPDATE credential SET display_lastname = ? WHERE userid = ?"; st = connection.prepareStatement(sql); st.setString(1, lastname); st.setInt(2, userid2); st.executeUpdate(); } if (children2.item(y).getNodeName().equals("email")) { email = DomUtils.getInnerXml(children2.item(y)); sql = "UPDATE credential SET email = ? WHERE userid = ?"; st = connection.prepareStatement(sql); st.setString(1, email); st.setInt(2, userid2); st.executeUpdate(); } if (children2.item(y).getNodeName().equals("admin")) { is_admin = DomUtils.getInnerXml(children2.item(y)); int is_adminInt = Integer.parseInt(is_admin); sql = "UPDATE credential SET is_admin = ? WHERE userid = ?"; st = connection.prepareStatement(sql); st.setInt(1, is_adminInt); st.setInt(2, userid2); st.executeUpdate(); } // /* if (children2.item(y).getNodeName().equals("designer")) { is_designer = DomUtils.getInnerXml(children2.item(y)); int is_designerInt = Integer.parseInt(is_designer); sql = "UPDATE credential SET is_designer = ? WHERE userid = ?"; st = connection.prepareStatement(sql); st.setInt(1, is_designerInt); st.setInt(2, userid2); st.executeUpdate(); } //*/ if (children2.item(y).getNodeName().equals("active")) { active = DomUtils.getInnerXml(children2.item(y)); int activeInt = Integer.parseInt(active); sql = "UPDATE credential SET active = ? WHERE userid = ?"; st = connection.prepareStatement(sql); st.setInt(1, activeInt); st.setInt(2, userid2); st.executeUpdate(); } } } // } // }else{ // result = "Erreur lors de la recuperation des attributs du groupe dans le XML"; // } // try { // // sql = "UPDATE credential SET login = ?, display_firstname = ?, display_lastname = ?, password = ?, email = ? WHERE userid = ?"; // // st = connection.prepareStatement(sql); // st.setString(1, username); // st.setString(2, firstname); // st.setString(3, lastname); // st.setString(4, password); // st.setString(5, email); // st.setInt(6, userid2); // // st.executeUpdate(); // // } catch (SQLException e) { // // TODO Auto-generated catch block // e.printStackTrace(); // } // result1 = "<users>"; // // result1 += "<user "; // result1 += DomUtils.getXmlAttributeOutputInt("id", id)+" "; // result1 += ">"; // result1 += DomUtils.getXmlElementOutput("password", password)+" "; // result1 += DomUtils.getXmlElementOutput("email", password)+" "; // result1 += "</user>"; // result1 += "</users>"; result1 = "" + userid2; return result1; }
From source file:net.wastl.webmail.xml.XMLMessagePart.java
public void quoteContent() { NodeList nl = part.getChildNodes(); StringBuilder text = new StringBuilder(); for (int i = 0; i < nl.getLength(); i++) { Element elem = (Element) nl.item(i); if (elem.getNodeName().equals("CONTENT")) { String value = XMLCommon.getElementTextValue(elem); StringTokenizer tok = new StringTokenizer(value, "\n"); while (tok.hasMoreTokens()) { text.append("> ").append(tok.nextToken()).append("\n"); }//from ww w.ja v a 2 s .co m } } removeAllContent(); addContent(text.toString(), 0); }
From source file:net.ymate.platform.plugin.impl.DefaultPluginParser.java
/** * ???//ww w . j a v a2 s . co m * * @param classLoader * @param pluginPath * @param configFileUrl * @return * @throws IOException * @throws SAXException * @throws ParserConfigurationException */ private List<PluginMeta> __doManifestFileProcess(ClassLoader classLoader, String pluginPath, URL configFileUrl) throws IOException, SAXException, ParserConfigurationException { _LOG.info(I18N.formatMessage(YMP.__LSTRING_FILE, null, null, "ymp.plugin.parse_plugin_file", configFileUrl.getFile())); List<PluginMeta> _returnValue = new ArrayList<PluginMeta>(); // List<Element> _pluginElements = new ArrayList<Element>(); // InputStream _in = configFileUrl.openStream(); Document _document = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(_in); Element _rootElement = _document.getDocumentElement(); // ? boolean _pluginGroupFlag = false; String _pluginAuthor = _rootElement.getAttribute(ATTR_AUTHOR); String _pluginEmail = _rootElement.getAttribute(ATTR_EMAIL); String _pluginVersion = _rootElement.getAttribute(ATTR_VERSION); boolean _authorNotNull = StringUtils.isNotBlank(_pluginAuthor); boolean _emailNotNull = StringUtils.isNotBlank(_pluginEmail); boolean _versionNotNull = StringUtils.isNotBlank(_pluginVersion); // if (_rootElement.getNodeName().equals(PLUGIN_TAG)) { _pluginElements.add(_rootElement); } else { // ???????? _pluginGroupFlag = true; _pluginAuthor = _rootElement.getAttribute(ATTR_AUTHOR); _pluginEmail = _rootElement.getAttribute(ATTR_EMAIL); _pluginVersion = _rootElement.getAttribute(ATTR_VERSION); // NodeList _pluginNodes = _rootElement.getElementsByTagName(PLUGIN_TAG); for (int _idx = 0; _idx < _pluginNodes.getLength(); _idx++) { _pluginElements.add((Element) _pluginNodes.item(_idx)); } } for (Element _pluginElement : _pluginElements) { PluginMeta _pluginMeta = __doPluginElementProcess(classLoader, _pluginElement, pluginPath, configFileUrl); if (_pluginMeta != null) { // ?????? if (_pluginGroupFlag) { if (_authorNotNull && StringUtils.isBlank(_pluginMeta.getAuthor())) { _pluginMeta.setAuthor(_pluginAuthor); } if (_emailNotNull && StringUtils.isBlank(_pluginMeta.getEmail())) { _pluginMeta.setEmail(_pluginEmail); } if (_versionNotNull && StringUtils.isBlank(_pluginMeta.getVersion())) { _pluginMeta.setVersion(_pluginVersion); } } _returnValue.add(_pluginMeta); } } return _returnValue; }