Skip to content
Snippets Groups Projects
Commit c8e149c4 authored by Eduardo L. Buratti's avatar Eduardo L. Buratti
Browse files

webservice: Remove DB transactions (until database is fully developed)

parent a62bf509
No related branches found
No related tags found
No related merge requests found
......@@ -175,14 +175,14 @@ public class DataSID {
*/
public static String setInventory(String xmlData) {
try {
InitialContext cxt = new InitialContext();
/*InitialContext cxt = new InitialContext();
DataSource ds = (DataSource) cxt.lookup("java:/comp/env/jdbc/datasid");
if (ds == null)
throw new Exception("Data source not found!");
Connection con = ds.getConnection();
if (con == null)
throw new Exception("Failed to get a database connection!");
throw new Exception("Failed to get a database connection!");*/
SchemaFactory factory = SchemaFactory.newInstance("http://www.w3.org/2001/XMLSchema");
Schema schema = factory.newSchema(XML_INVENTORY_SCHEMA);
......@@ -200,12 +200,12 @@ public class DataSID {
// Decode the XML into a Java Object
JAXBElement<CollectedData> element = (JAXBElement<CollectedData>) unmarshaller.unmarshal(is);
CollectedData collected = element.getValue();
// contact_date = current date
Calendar cal = Calendar.getInstance();
java.sql.Date contactDate = new java.sql.Date(cal.getTimeInMillis());
PreparedStatement st = createInventoryStatement(con, collected, contactDate);
st.executeUpdate();
/*PreparedStatement st = createInventoryStatement(con, collected, contactDate);
st.executeUpdate();*/
List<User> users = collected.getUserHistory().getUser();
String superid = collected.getTelecentroInfo().getSuperid();
......@@ -215,11 +215,13 @@ public class DataSID {
macaddr.setValue(interfaces.get(0).getMacAddress());
for(User user: users) {
st = createUserHistoryStatement(con, contactDate, superid, macaddr, user.getName(), user.getLogin(), user.getLogout());
st.executeUpdate();
/*st = createUserHistoryStatement(con, contactDate, superid, macaddr, user.getName(), user.getLogin(), user.getLogout());
st.executeUpdate();*/
}
con.close();
//con.close();
log(INFO, "setInventory(superid=" + collected.getTelecentroInfo().getSuperid() + ", macaddr=" + interfaces.get(0).getMacAddress() + ")");
return "Success";
} catch (Exception e) {
log(ERROR, e.getMessage() + " " + xmlData);
......@@ -410,14 +412,14 @@ public class DataSID {
public static String setNetUsage(String xmlData)
{
try {
InitialContext cxt = new InitialContext();
/*InitialContext cxt = new InitialContext();
DataSource ds = (DataSource) cxt.lookup("java:/comp/env/jdbc/datasid");
if (ds == null)
throw new Exception("Data source not found!");
Connection con = ds.getConnection();
if (con == null)
throw new Exception("Failed to get a database connection!");
throw new Exception("Failed to get a database connection!");*/
SchemaFactory factory = SchemaFactory.newInstance("http://www.w3.org/2001/XMLSchema");
Schema schema = factory.newSchema(XML_NET_USAGE_SCHEMA);
......@@ -449,12 +451,13 @@ public class DataSID {
List<NetUse> netUses = netCollectedData.getBandwidthUsage().getNetuse();
for(NetUse netUse : netUses) {
PreparedStatement st = createNetUsageStatement(con, contactDate, netCollectedData.getTelecentroId(), (Object)macaddr, netUse.getDate(), netUse.getTime(), netUse.getRx().getBytes(), netUse.getRx().getPackets(), netUse.getTx().getBytes(), netUse.getTx().getPackets());
/*PreparedStatement st = createNetUsageStatement(con, contactDate, netCollectedData.getTelecentroId(), (Object)macaddr, netUse.getDate(), netUse.getTime(), netUse.getRx().getBytes(), netUse.getRx().getPackets(), netUse.getTx().getBytes(), netUse.getTx().getPackets());
st.executeUpdate();
st.executeUpdate();*/
}
con.close();
//con.close();
log(DEBUG, "setNetUsage(telecentro-id=" + netCollectedData.getTelecentroId() + ", macaddr=" + interfaces.get(0).getMacAddress() + ")");
return "Success";
} catch (Exception e) {
log(ERROR, e.getMessage() + " " + xmlData);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment