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
61b50af3
authored
Mar 13, 2017
by
Adi Amir
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
inject viewDir from cameraList + add api for cameraGroup
parent
1cbca8c0
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
64 additions
and
0 deletions
src/main/java/logic/GEManager.java
src/main/java/logic/GEManager.java
View file @
61b50af3
...
...
@@ -66,6 +66,9 @@ public class GEManager {
else
if
(
apiIdAsParams
.
length
==
3
&&
apiIdAsParams
[
0
].
equals
(
"camera"
)
&&
apiIdAsParams
[
2
].
equals
(
"latestImage"
))
{
brr
=
getLatestMediaFile
(
apiIdAsParams
[
1
]
/*camId*/
,
"IMAGE"
,
requestContext
);
}
else
if
(
apiIdAsParams
.
length
==
3
&&
apiIdAsParams
[
0
].
equals
(
"camera"
)
&&
apiIdAsParams
[
2
].
equals
(
"details"
))
{
brr
=
getCameraDetails
(
apiIdAsParams
[
1
]
/*camId*/
,
requestContext
);
}
else
{
String
err
=
"executeRequest() failed. Unknown api: "
+
getApiIdString
(
apiIdAsParams
);
return
errorResponse
(
err
);
...
...
@@ -227,6 +230,67 @@ public class GEManager {
return
brr
;
}
private
BaseRestResponse
getCameraDetails
(
String
cameraId
,
RequestContext
requestContext
)
{
SimpleHttpRequest
req
=
null
;
SimpleHttpResponse
httpResp
=
null
;
BaseRestResponse
brr
=
new
BaseRestResponse
(
false
,
null
);
logger
.
info
(
"getCameraDetails() activated. camId="
+
cameraId
);
// execute the request ...
req
=
buildCameraDetailsHttpRequest
(
cameraId
);
try
{
httpResp
=
httpClient
.
processRequest
(
req
);
if
(
httpResp
.
getStatusCode
()
==
200
)
brr
=
buildCameraDetailsResp
(
httpResp
);
else
{
logHttpError
(
"getCameraDetails"
,
httpResp
);
return
errorHttpResponse
(
httpResp
);
}
}
catch
(
Exception
e
)
{
String
err
=
"getCameraDetails() failed with exception. e="
+
e
.
toString
();
logger
.
error
(
err
);
return
errorResponse
(
err
);
}
logger
.
info
(
"getCameraDetails() successfull. camId="
+
cameraId
);
return
brr
;
}
private
SimpleHttpRequest
buildCameraDetailsHttpRequest
(
String
camId
)
{
SimpleHttpRequest
request
=
new
SimpleHttpRequest
();
request
.
setProtocol
(
"https"
);
request
.
setDomain
(
METADATA_URL
);
request
.
setPort
(
443
);
request
.
setMethod
(
SimpleHttpRequest
.
Method
.
GET
);
String
path
=
ASSETS_URL
+
"/"
+
camId
;
request
.
setPath
(
path
);
request
.
addHeader
(
"Authorization"
,
"Bearer "
+
TOKEN
);
request
.
addHeader
(
"Predix-Zone-Id"
,
PARKING_ZONE_ID
);
return
request
;
}
private
BaseRestResponse
buildCameraDetailsResp
(
SimpleHttpResponse
resp
)
{
BaseRestResponse
brr
=
new
BaseRestResponse
(
true
,
null
);
int
size
;
String
content
=
resp
.
getContent
();
ObjectMapper
mapper
=
new
ObjectMapper
();
try
{
JsonNode
contentObj
=
mapper
.
readTree
(
content
);
String
view
=
contentObj
.
at
(
"/properties/VIEW"
).
asText
();
ObjectNode
objectNode
=
mapper
.
createObjectNode
();
objectNode
.
put
(
"view"
,
view
);
brr
.
objectNode
=
objectNode
;
}
catch
(
IOException
e
)
{
return
new
BaseRestResponse
(
false
,
e
.
toString
());
}
return
brr
;
}
private
boolean
getNewAccessToken
()
{
SimpleHttpRequest
req
=
null
;
SimpleHttpResponse
httpResp
=
null
;
...
...
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