Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
ipgallery
/
mde
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Registry
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
f25d9f84
authored
Mar 22, 2017
by
Adi Amir
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
change details api name to latestEvent
parent
b18d9b3e
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
13 deletions
src/main/java/logic/GEManager.java
src/main/java/logic/GEManager.java
View file @
f25d9f84
...
@@ -22,14 +22,12 @@ import org.apache.http.conn.scheme.SchemeRegistry;
...
@@ -22,14 +22,12 @@ import org.apache.http.conn.scheme.SchemeRegistry;
import
org.apache.http.conn.ssl.SSLSocketFactory
;
import
org.apache.http.conn.ssl.SSLSocketFactory
;
import
org.apache.http.impl.client.DefaultHttpClient
;
import
org.apache.http.impl.client.DefaultHttpClient
;
import
org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager
;
import
org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager
;
import
web.App
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.io.InputStream
;
import
java.nio.file.Files
;
import
java.nio.file.Files
;
import
java.nio.file.Path
;
import
java.nio.file.Path
;
import
java.nio.file.Paths
;
import
java.nio.file.Paths
;
import
java.text.DecimalFormat
;
import
java.util.Deque
;
import
java.util.Deque
;
import
java.util.Map
;
import
java.util.Map
;
...
@@ -96,8 +94,8 @@ public class GEManager {
...
@@ -96,8 +94,8 @@ public class GEManager {
else
if
(
apiIdAsParams
.
length
==
1
&&
apiIdAsParams
[
0
].
equals
(
"sensors"
))
{
else
if
(
apiIdAsParams
.
length
==
1
&&
apiIdAsParams
[
0
].
equals
(
"sensors"
))
{
brr
=
getSensorList
(
requestContext
);
brr
=
getSensorList
(
requestContext
);
}
}
else
if
(
apiIdAsParams
.
length
==
3
&&
apiIdAsParams
[
0
].
equals
(
"sensor"
)
&&
apiIdAsParams
[
2
].
equals
(
"
details
"
))
{
else
if
(
apiIdAsParams
.
length
==
3
&&
apiIdAsParams
[
0
].
equals
(
"sensor"
)
&&
apiIdAsParams
[
2
].
equals
(
"
latestEvent
"
))
{
brr
=
getSensor
Details
(
apiIdAsParams
[
1
]
/*sensorId*/
,
requestContext
);
brr
=
getSensor
LatestEvent
(
apiIdAsParams
[
1
]
/*sensorId*/
,
requestContext
);
}
}
else
{
else
{
String
err
=
"executeRequest() failed. Unknown api: "
+
getApiIdString
(
apiIdAsParams
);
String
err
=
"executeRequest() failed. Unknown api: "
+
getApiIdString
(
apiIdAsParams
);
...
@@ -232,12 +230,12 @@ public class GEManager {
...
@@ -232,12 +230,12 @@ public class GEManager {
logger
.
info
(
"getCameraDetails() successfull. camId="
+
cameraId
);
logger
.
info
(
"getCameraDetails() successfull. camId="
+
cameraId
);
return
brr
;
return
brr
;
}
}
private
BaseRestResponse
getSensor
Details
(
String
sensorId
,
RequestContext
requestContext
)
{
private
BaseRestResponse
getSensor
LatestEvent
(
String
sensorId
,
RequestContext
requestContext
)
{
SimpleHttpRequest
req
=
null
;
SimpleHttpRequest
req
=
null
;
SimpleHttpResponse
httpResp
=
null
;
SimpleHttpResponse
httpResp
=
null
;
BaseRestResponse
brr
=
new
BaseRestResponse
(
false
,
null
);
BaseRestResponse
brr
=
new
BaseRestResponse
(
false
,
null
);
logger
.
info
(
"getSensor
Details
() activated. camId="
+
sensorId
);
logger
.
info
(
"getSensor
LatestEvent
() activated. camId="
+
sensorId
);
// execute the request ...
// execute the request ...
// envType
// envType
...
@@ -255,27 +253,27 @@ public class GEManager {
...
@@ -255,27 +253,27 @@ public class GEManager {
return
errorResponse
(
"missing mandatory parameter: startTime"
);
return
errorResponse
(
"missing mandatory parameter: startTime"
);
Long
tsStartTime
=
Long
.
parseLong
(
startTime
);
Long
tsStartTime
=
Long
.
parseLong
(
startTime
);
req
=
buildSensor
Details
Request
(
sensorId
,
envType
,
tsStartTime
,
tsEndTime
);
req
=
buildSensor
LatestEvent
Request
(
sensorId
,
envType
,
tsStartTime
,
tsEndTime
);
try
{
try
{
httpResp
=
httpClient
.
processRequest
(
req
);
httpResp
=
httpClient
.
processRequest
(
req
);
if
(
httpResp
.
getStatusCode
()
==
200
)
if
(
httpResp
.
getStatusCode
()
==
200
)
brr
=
buildSensor
Details
Resp
(
httpResp
);
brr
=
buildSensor
LatestEvent
Resp
(
httpResp
);
else
{
else
{
logHttpError
(
"getSensor
Details
"
,
httpResp
);
logHttpError
(
"getSensor
LatestEvent
"
,
httpResp
);
return
errorHttpResponse
(
httpResp
);
return
errorHttpResponse
(
httpResp
);
}
}
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
String
err
=
"getSensor
Details
() failed with exception. e="
+
e
.
toString
();
String
err
=
"getSensor
LatestEvent
() failed with exception. e="
+
e
.
toString
();
logger
.
error
(
err
);
logger
.
error
(
err
);
return
errorResponse
(
err
);
return
errorResponse
(
err
);
}
}
logger
.
info
(
"getSensor
Details
() successfull. camId="
+
sensorId
);
logger
.
info
(
"getSensor
LatestEvent
() successfull. camId="
+
sensorId
);
return
brr
;
return
brr
;
}
}
private
SimpleHttpRequest
buildSensor
Details
Request
(
String
sensdorId
,
String
envType
,
Long
tsStartTime
,
Long
tsEndTime
)
{
private
SimpleHttpRequest
buildSensor
LatestEvent
Request
(
String
sensdorId
,
String
envType
,
Long
tsStartTime
,
Long
tsEndTime
)
{
SimpleHttpRequest
request
=
new
SimpleHttpRequest
();
SimpleHttpRequest
request
=
new
SimpleHttpRequest
();
request
.
setProtocol
(
"https"
);
request
.
setProtocol
(
"https"
);
request
.
setDomain
(
EVENT_URL
);
request
.
setDomain
(
EVENT_URL
);
...
@@ -296,7 +294,7 @@ public class GEManager {
...
@@ -296,7 +294,7 @@ public class GEManager {
return
request
;
return
request
;
}
}
private
BaseRestResponse
buildSensor
Details
Resp
(
SimpleHttpResponse
resp
)
{
private
BaseRestResponse
buildSensor
LatestEvent
Resp
(
SimpleHttpResponse
resp
)
{
BaseRestResponse
brr
=
new
BaseRestResponse
(
true
,
null
);
BaseRestResponse
brr
=
new
BaseRestResponse
(
true
,
null
);
int
size
;
int
size
;
String
content
=
resp
.
getContent
();
String
content
=
resp
.
getContent
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment