Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
datasid
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
simmctic
datasid
Commits
c8e149c4
Commit
c8e149c4
authored
Oct 11, 2013
by
Eduardo L. Buratti
Browse files
Options
Downloads
Patches
Plain Diff
webservice: Remove DB transactions (until database is fully developed)
Signed-off-by:
Eduardo L. Buratti
<
elb09@c3sl.ufpr.br
>
parent
a62bf509
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
webservice/DataSID.java
+18
-15
18 additions, 15 deletions
webservice/DataSID.java
with
18 additions
and
15 deletions
webservice/DataSID.java
+
18
−
15
View file @
c8e149c4
...
...
@@ -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
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment