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
3ebc7c62
authored
Jun 08, 2017
by
Adi Amir
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
bugfix: got null execption when no url for download found.
parent
2bc0411f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
8 deletions
src/main/java/logic/GEManager.java
src/main/java/logic/GEManager.java
View file @
3ebc7c62
...
...
@@ -150,18 +150,31 @@ public class GEManager {
SimpleHttpResponse
httpFileUrlResp
=
httpClient
.
processRequest
(
httpRequest
);
if
(
httpFileUrlResp
.
getStatusCode
()
!=
200
)
{
logHttpError
(
"ge.getLatestMediaFile/getLatestMediaURL"
,
httpFileUrlResp
);
return
errorHttpResponse
(
httpFileUrlResp
);
return
errorHttpResponse
(
httpFileUrlResp
,
"getLatestMediaFile() failed"
);
}
// get url
String
url
=
null
;
contentObj
=
objMapper
.
readTree
(
httpFileUrlResp
.
getContent
());
JsonNode
arrNode
=
contentObj
.
get
(
"content"
);
String
url
=
arrNode
.
get
(
0
).
get
(
"url"
).
asText
();
if
(
arrNode
!=
null
&&
arrNode
.
isNull
()
==
false
)
{
JsonNode
mediaInfo
=
arrNode
.
get
(
0
);
if
(
mediaInfo
!=
null
&&
mediaInfo
.
isNull
()
==
false
)
{
JsonNode
jsUrl
=
mediaInfo
.
get
(
"url"
);
if
(
jsUrl
!=
null
&&
jsUrl
.
isNull
()
==
false
)
url
=
jsUrl
.
asText
();
}
}
if
(
url
==
null
)
{
return
errorResponse
(
"No latest media file found for camId: "
+
camId
);
}
// step 2: get/download latest media file data (e.g: https://ie-cities-media.run.asv-pr-pub.ice.predix.io/v2/file/CAMERA-STG-HYP1052-CAM-L_1487807853000_0_IMAGE.JPG)
httpRequest
=
buildDownloadLatestMediaFileRequest
(
url
);
SimpleHttpResponse
httpFileDataResp
=
httpClient
.
processRequest
(
httpRequest
);
if
(
httpFileDataResp
.
getStatusCode
()
!=
200
)
{
logHttpError
(
"ge.getLatestMediaFile/downloadLatestMediaFile"
,
httpFileDataResp
);
return
errorHttpResponse
(
httpFileDataResp
);
return
errorHttpResponse
(
httpFileDataResp
,
"failed to download file: "
+
url
);
}
String
fileData
=
httpFileDataResp
.
getContent
();
...
...
@@ -202,7 +215,7 @@ public class GEManager {
brr
=
buildCameraListResp
(
httpResp
);
else
{
logHttpError
(
"getCameraList"
,
httpResp
);
return
errorHttpResponse
(
httpResp
);
return
errorHttpResponse
(
httpResp
,
"getCameraList() faild"
);
}
}
catch
(
Exception
e
)
{
...
...
@@ -228,7 +241,7 @@ public class GEManager {
brr
=
buildCameraDetailsResp
(
httpResp
);
else
{
logHttpError
(
"ge.getCameraDetails"
,
httpResp
);
return
errorHttpResponse
(
httpResp
);
return
errorHttpResponse
(
httpResp
,
"getCameraDetails() failed"
);
}
}
catch
(
Exception
e
)
{
...
...
@@ -270,7 +283,7 @@ public class GEManager {
brr
=
buildSensorLatestEventResp
(
httpResp
);
else
{
logHttpError
(
"getSensorLatestEvent"
,
httpResp
);
return
errorHttpResponse
(
httpResp
);
return
errorHttpResponse
(
httpResp
,
"getSensorLatestEvent() failed"
);
}
}
catch
(
Exception
e
)
{
...
...
@@ -366,7 +379,7 @@ public class GEManager {
brr
=
buildSensorListResp
(
httpResp
);
else
{
logHttpError
(
"getSensorList"
,
httpResp
);
return
errorHttpResponse
(
httpResp
);
return
errorHttpResponse
(
httpResp
,
"failed to fetch sensor list"
);
}
}
catch
(
Exception
e
)
{
...
...
@@ -707,10 +720,11 @@ public class GEManager {
return
apiString
;
}
private
BaseRestResponse
errorHttpResponse
(
SimpleHttpResponse
httpResp
)
{
private
BaseRestResponse
errorHttpResponse
(
SimpleHttpResponse
httpResp
,
String
description
)
{
BaseRestResponse
errResp
=
new
BaseRestResponse
(
false
,
null
);
ObjectNode
objectNode
=
objMapper
.
createObjectNode
();
objectNode
.
put
(
"description"
,
description
);
objectNode
.
put
(
"statusCode"
,
httpResp
.
getStatusCode
());
objectNode
.
put
(
"content"
,
httpResp
.
getContent
());
errResp
.
objectNode
=
objectNode
;
...
...
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