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
6a7e8284
authored
Mar 28, 2017
by
Adi Amir
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
support cisco login and parking
parent
4d6225d0
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
37 additions
and
29 deletions
docker-compose.yml
src/main/java/logic/CiscoManager.java
src/main/java/logic/GEManager.java
src/main/java/logic/MdeManager.java
docker-compose.yml
View file @
6a7e8284
mde
:
mde
:
environment
:
environment
:
IPG_ENV_PARAMS
:
"
-Dds.IpAddress=172.16.1.151:8012#
\
IPG_ENV_PARAMS
:
"
-Dds.IpAddress=172.16.1.151:8012#
\
-Dredis.host=172.16.1.151"
-Dredis.host=172.16.1.151#
\
-Dmde.cisco.username=devoperator11@cdp.com#
\
-Dmde.cisco.password=z9E+H=9$J#
\
-Dmde.cisco.clientId=a27b18484c3c4e08a7c193e42c639347#
\
-Dmde.cisco.clientSecret=b863de8f453c4a05A88126F45B958CF1"
USE_DEBUG
:
"
yes"
USE_DEBUG
:
"
yes"
image
:
172.16.1.212:5050/mcx/mde
image
:
172.16.1.212:5050/mcx/mde
ports
:
ports
:
...
...
src/main/java/logic/CiscoManager.java
0 → 100644
View file @
6a7e8284
This diff is collapsed.
Click to expand it.
src/main/java/logic/GEManager.java
View file @
6a7e8284
...
@@ -77,7 +77,7 @@ public class GEManager {
...
@@ -77,7 +77,7 @@ public class GEManager {
BaseRestResponse
brr
=
new
BaseRestResponse
(
false
,
null
);
BaseRestResponse
brr
=
new
BaseRestResponse
(
false
,
null
);
long
tStart
=
System
.
currentTimeMillis
();
long
tStart
=
System
.
currentTimeMillis
();
logger
.
info
(
"executeRequest() started: "
+
getApiIdString
(
apiIdAsParams
));
logger
.
info
(
"
ge.
executeRequest() started: "
+
getApiIdString
(
apiIdAsParams
));
if
(
apiIdAsParams
.
length
==
1
&&
apiIdAsParams
[
0
].
equals
(
"cameras"
))
{
if
(
apiIdAsParams
.
length
==
1
&&
apiIdAsParams
[
0
].
equals
(
"cameras"
))
{
brr
=
getCameraList
(
requestContext
);
brr
=
getCameraList
(
requestContext
);
...
@@ -98,24 +98,24 @@ public class GEManager {
...
@@ -98,24 +98,24 @@ public class GEManager {
brr
=
getSensorLatestEvent
(
apiIdAsParams
[
1
]
/*sensorId*/
,
requestContext
);
brr
=
getSensorLatestEvent
(
apiIdAsParams
[
1
]
/*sensorId*/
,
requestContext
);
}
}
else
{
else
{
String
err
=
"executeRequest() failed. Unknown api: "
+
getApiIdString
(
apiIdAsParams
);
String
err
=
"
ge.
executeRequest() failed. Unknown api: "
+
getApiIdString
(
apiIdAsParams
);
brr
=
errorResponse
(
err
);
brr
=
errorResponse
(
err
);
}
}
// if the request failed due to invalid token - fetch a new one & try again
// if the request failed due to invalid token - fetch a new one & try again
if
(
isAccessDenied
(
brr
))
{
if
(
isAccessDenied
(
brr
))
{
logger
.
info
(
"executeRequest() - access denied. fetch a new token & try again"
);
logger
.
info
(
"
ge.
executeRequest() - access denied. fetch a new token & try again"
);
if
(
getNewAccessToken
()
==
true
)
{
if
(
getNewAccessToken
()
==
true
)
{
brr
=
executeRequest
(
serviceId
,
apiIdAsParams
,
requestContext
);
brr
=
executeRequest
(
serviceId
,
apiIdAsParams
,
requestContext
);
}
}
else
{
else
{
brr
=
errorResponse
(
"executeRequest() failed to obtain access token"
);
brr
=
errorResponse
(
"
ge.
executeRequest() failed to obtain access token"
);
}
}
}
}
long
tEnd
=
System
.
currentTimeMillis
();
long
tEnd
=
System
.
currentTimeMillis
();
double
elapsedTime
=
((
double
)(
tEnd
-
tStart
))
/
1000.0
;
double
elapsedTime
=
((
double
)(
tEnd
-
tStart
))
/
1000.0
;
logger
.
info
(
"executeRequest finished. time= "
+
elapsedTime
+
" success="
+
brr
.
success
+
" api="
+
getApiIdString
(
apiIdAsParams
));
logger
.
info
(
"
ge.
executeRequest finished. time= "
+
elapsedTime
+
" success="
+
brr
.
success
+
" api="
+
getApiIdString
(
apiIdAsParams
));
return
brr
;
return
brr
;
}
}
...
@@ -129,7 +129,7 @@ public class GEManager {
...
@@ -129,7 +129,7 @@ public class GEManager {
BaseRestResponse
brr
=
null
;
BaseRestResponse
brr
=
null
;
JsonNode
contentObj
=
null
;
JsonNode
contentObj
=
null
;
logger
.
info
(
"getLatestMediaFile() activated. camId="
+
camId
);
logger
.
info
(
"ge
.ge
tLatestMediaFile() activated. camId="
+
camId
);
// execute the request
// execute the request
// example: ie-cities-media.run.asv-pr-pub.ice.predix.io/assets/{camId}/media/latest?mediaType=IMAGE
// example: ie-cities-media.run.asv-pr-pub.ice.predix.io/assets/{camId}/media/latest?mediaType=IMAGE
...
@@ -139,7 +139,7 @@ public class GEManager {
...
@@ -139,7 +139,7 @@ public class GEManager {
SimpleHttpRequest
httpRequest
=
buildLatestMediaFileUrlRequest
(
camId
,
mediaType
);
SimpleHttpRequest
httpRequest
=
buildLatestMediaFileUrlRequest
(
camId
,
mediaType
);
SimpleHttpResponse
httpFileUrlResp
=
httpClient
.
processRequest
(
httpRequest
);
SimpleHttpResponse
httpFileUrlResp
=
httpClient
.
processRequest
(
httpRequest
);
if
(
httpFileUrlResp
.
getStatusCode
()
!=
200
)
{
if
(
httpFileUrlResp
.
getStatusCode
()
!=
200
)
{
logHttpError
(
"getLatestMediaFile/getLatestMediaURL"
,
httpFileUrlResp
);
logHttpError
(
"ge
.ge
tLatestMediaFile/getLatestMediaURL"
,
httpFileUrlResp
);
return
errorHttpResponse
(
httpFileUrlResp
);
return
errorHttpResponse
(
httpFileUrlResp
);
}
}
contentObj
=
objMapper
.
readTree
(
httpFileUrlResp
.
getContent
());
contentObj
=
objMapper
.
readTree
(
httpFileUrlResp
.
getContent
());
...
@@ -150,7 +150,7 @@ public class GEManager {
...
@@ -150,7 +150,7 @@ public class GEManager {
httpRequest
=
buildDownloadLatestMediaFileRequest
(
url
);
httpRequest
=
buildDownloadLatestMediaFileRequest
(
url
);
SimpleHttpResponse
httpFileDataResp
=
httpClient
.
processRequest
(
httpRequest
);
SimpleHttpResponse
httpFileDataResp
=
httpClient
.
processRequest
(
httpRequest
);
if
(
httpFileDataResp
.
getStatusCode
()
!=
200
)
{
if
(
httpFileDataResp
.
getStatusCode
()
!=
200
)
{
logHttpError
(
"getLatestMediaFile/downloadLatestMediaFile"
,
httpFileDataResp
);
logHttpError
(
"ge
.ge
tLatestMediaFile/downloadLatestMediaFile"
,
httpFileDataResp
);
return
errorHttpResponse
(
httpFileDataResp
);
return
errorHttpResponse
(
httpFileDataResp
);
}
}
String
fileData
=
httpFileDataResp
.
getContent
();
String
fileData
=
httpFileDataResp
.
getContent
();
...
@@ -169,7 +169,7 @@ public class GEManager {
...
@@ -169,7 +169,7 @@ public class GEManager {
brr
=
buildLatestMediaFileResp
(
fileData
,
url
);
brr
=
buildLatestMediaFileResp
(
fileData
,
url
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
String
err
=
"getLatestMediaFile() failed with exception. camId="
+
camId
+
" e="
+
e
.
toString
();
String
err
=
"ge
.ge
tLatestMediaFile() failed with exception. camId="
+
camId
+
" e="
+
e
.
toString
();
logger
.
error
(
err
);
logger
.
error
(
err
);
return
errorResponse
(
err
);
return
errorResponse
(
err
);
}
}
...
@@ -182,7 +182,7 @@ public class GEManager {
...
@@ -182,7 +182,7 @@ public class GEManager {
SimpleHttpResponse
httpResp
=
null
;
SimpleHttpResponse
httpResp
=
null
;
BaseRestResponse
brr
=
new
BaseRestResponse
(
false
,
null
);
BaseRestResponse
brr
=
new
BaseRestResponse
(
false
,
null
);
logger
.
info
(
"getCamerasList() activated."
);
logger
.
info
(
"ge
.ge
tCamerasList() activated."
);
// execute the request ...
// execute the request ...
req
=
buildCameraListRequest
(
requestContext
);
req
=
buildCameraListRequest
(
requestContext
);
...
@@ -196,7 +196,7 @@ public class GEManager {
...
@@ -196,7 +196,7 @@ public class GEManager {
}
}
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
String
err
=
"getCameraList() failed with exception. e="
+
e
.
toString
();
String
err
=
"ge
.ge
tCameraList() failed with exception. e="
+
e
.
toString
();
logger
.
error
(
err
);
logger
.
error
(
err
);
return
errorResponse
(
err
);
return
errorResponse
(
err
);
}
}
...
@@ -208,7 +208,7 @@ public class GEManager {
...
@@ -208,7 +208,7 @@ public class GEManager {
SimpleHttpResponse
httpResp
=
null
;
SimpleHttpResponse
httpResp
=
null
;
BaseRestResponse
brr
=
new
BaseRestResponse
(
false
,
null
);
BaseRestResponse
brr
=
new
BaseRestResponse
(
false
,
null
);
logger
.
info
(
"getCameraDetails() activated. camId="
+
cameraId
);
logger
.
info
(
"ge
.ge
tCameraDetails() activated. camId="
+
cameraId
);
// execute the request ...
// execute the request ...
req
=
buildCameraDetailsRequest
(
cameraId
);
req
=
buildCameraDetailsRequest
(
cameraId
);
...
@@ -217,17 +217,17 @@ public class GEManager {
...
@@ -217,17 +217,17 @@ public class GEManager {
if
(
httpResp
.
getStatusCode
()
==
200
)
if
(
httpResp
.
getStatusCode
()
==
200
)
brr
=
buildCameraDetailsResp
(
httpResp
);
brr
=
buildCameraDetailsResp
(
httpResp
);
else
{
else
{
logHttpError
(
"getCameraDetails"
,
httpResp
);
logHttpError
(
"ge
.ge
tCameraDetails"
,
httpResp
);
return
errorHttpResponse
(
httpResp
);
return
errorHttpResponse
(
httpResp
);
}
}
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
String
err
=
"getCameraDetails() failed with exception. e="
+
e
.
toString
();
String
err
=
"ge
.ge
tCameraDetails() failed with exception. e="
+
e
.
toString
();
logger
.
error
(
err
);
logger
.
error
(
err
);
return
errorResponse
(
err
);
return
errorResponse
(
err
);
}
}
logger
.
info
(
"getCameraDetails() successfull. camId="
+
cameraId
);
logger
.
info
(
"ge
.ge
tCameraDetails() successfull. camId="
+
cameraId
);
return
brr
;
return
brr
;
}
}
private
BaseRestResponse
getSensorLatestEvent
(
String
sensorId
,
RequestContext
requestContext
)
{
private
BaseRestResponse
getSensorLatestEvent
(
String
sensorId
,
RequestContext
requestContext
)
{
...
@@ -235,7 +235,7 @@ public class GEManager {
...
@@ -235,7 +235,7 @@ public class GEManager {
SimpleHttpResponse
httpResp
=
null
;
SimpleHttpResponse
httpResp
=
null
;
BaseRestResponse
brr
=
new
BaseRestResponse
(
false
,
null
);
BaseRestResponse
brr
=
new
BaseRestResponse
(
false
,
null
);
logger
.
info
(
"getSensorLatestEvent() activated. camId="
+
sensorId
);
logger
.
info
(
"ge
.ge
tSensorLatestEvent() activated. camId="
+
sensorId
);
// execute the request ...
// execute the request ...
// envType
// envType
...
@@ -264,12 +264,12 @@ public class GEManager {
...
@@ -264,12 +264,12 @@ public class GEManager {
}
}
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
String
err
=
"getSensorLatestEvent() failed with exception. e="
+
e
.
toString
();
String
err
=
"ge
.ge
tSensorLatestEvent() failed with exception. e="
+
e
.
toString
();
logger
.
error
(
err
);
logger
.
error
(
err
);
return
errorResponse
(
err
);
return
errorResponse
(
err
);
}
}
logger
.
info
(
"getSensorLatestEvent() successfull. camId="
+
sensorId
);
logger
.
info
(
"ge
.ge
tSensorLatestEvent() successfull. camId="
+
sensorId
);
return
brr
;
return
brr
;
}
}
...
@@ -318,7 +318,7 @@ public class GEManager {
...
@@ -318,7 +318,7 @@ public class GEManager {
SimpleHttpRequest
req
=
null
;
SimpleHttpRequest
req
=
null
;
SimpleHttpResponse
httpResp
=
null
;
SimpleHttpResponse
httpResp
=
null
;
logger
.
info
(
"getNewAccessToken() activated."
);
logger
.
info
(
"ge
.ge
tNewAccessToken() activated."
);
req
=
buildGetTokenRequest
();
req
=
buildGetTokenRequest
();
try
{
try
{
...
@@ -331,11 +331,11 @@ public class GEManager {
...
@@ -331,11 +331,11 @@ public class GEManager {
return
true
;
return
true
;
}
}
else
{
else
{
logHttpError
(
"getNewAccessToken"
,
httpResp
);
logHttpError
(
"ge
.ge
tNewAccessToken"
,
httpResp
);
return
false
;
return
false
;
}
}
}
catch
(
Exception
e
){
}
catch
(
Exception
e
){
logger
.
error
(
"getNewAccessToken() failed with exception. e: "
+
e
.
toString
());
logger
.
error
(
"ge
.ge
tNewAccessToken() failed with exception. e: "
+
e
.
toString
());
return
false
;
return
false
;
}
}
...
@@ -346,7 +346,7 @@ public class GEManager {
...
@@ -346,7 +346,7 @@ public class GEManager {
SimpleHttpResponse
httpResp
=
null
;
SimpleHttpResponse
httpResp
=
null
;
BaseRestResponse
brr
=
new
BaseRestResponse
(
false
,
null
);
BaseRestResponse
brr
=
new
BaseRestResponse
(
false
,
null
);
logger
.
info
(
"getSensorList() activated."
);
logger
.
info
(
"ge
.ge
tSensorList() activated."
);
// execute the request ...
// execute the request ...
req
=
buildSensorListRequest
(
requestContext
);
req
=
buildSensorListRequest
(
requestContext
);
...
@@ -360,7 +360,7 @@ public class GEManager {
...
@@ -360,7 +360,7 @@ public class GEManager {
}
}
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
String
err
=
"getSensorList() failed with exception. e="
+
e
.
toString
();
String
err
=
"ge
.ge
tSensorList() failed with exception. e="
+
e
.
toString
();
logger
.
error
(
err
);
logger
.
error
(
err
);
return
errorResponse
(
err
);
return
errorResponse
(
err
);
}
}
...
@@ -398,7 +398,7 @@ public class GEManager {
...
@@ -398,7 +398,7 @@ public class GEManager {
// String[3]: fileName
// String[3]: fileName
String
[]
urlParts
=
getMediaFileName
(
url
,
"latest"
);
String
[]
urlParts
=
getMediaFileName
(
url
,
"latest"
);
if
(
urlParts
==
null
)
{
if
(
urlParts
==
null
)
{
String
err
=
"buildLatestMediaFileResp() - failed to parse file url: "
+
url
;
String
err
=
"
ge.
buildLatestMediaFileResp() - failed to parse file url: "
+
url
;
logger
.
error
(
err
);
logger
.
error
(
err
);
return
new
BaseRestResponse
(
false
,
err
);
return
new
BaseRestResponse
(
false
,
err
);
}
}
...
@@ -410,7 +410,7 @@ public class GEManager {
...
@@ -410,7 +410,7 @@ public class GEManager {
brr
.
objectNode
=
dataObj
;
brr
.
objectNode
=
dataObj
;
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
String
err
=
"buildLatestMediaFileResp() failed with exception. e: "
+
e
.
toString
();
String
err
=
"
ge.
buildLatestMediaFileResp() failed with exception. e: "
+
e
.
toString
();
logger
.
error
(
err
);
logger
.
error
(
err
);
return
new
BaseRestResponse
(
false
,
err
);
return
new
BaseRestResponse
(
false
,
err
);
}
}
...
...
src/main/java/logic/MdeManager.java
View file @
6a7e8284
...
@@ -36,6 +36,7 @@ public class MdeManager {
...
@@ -36,6 +36,7 @@ public class MdeManager {
private
ServicesRepository
servicesRepository
;
private
ServicesRepository
servicesRepository
;
private
GEManager
geManager
=
null
;
private
GEManager
geManager
=
null
;
private
CiscoManager
ciscoManager
=
null
;
public
MdeManager
(
ILogger
logger
)
throws
Exception
{
public
MdeManager
(
ILogger
logger
)
throws
Exception
{
...
@@ -45,6 +46,7 @@ public class MdeManager {
...
@@ -45,6 +46,7 @@ public class MdeManager {
this
.
logger
=
logger
;
this
.
logger
=
logger
;
geManager
=
new
GEManager
(
logger
);
geManager
=
new
GEManager
(
logger
);
ciscoManager
=
new
CiscoManager
(
logger
);
LoadServices
(
logger
);
LoadServices
(
logger
);
loadAdapters
(
logger
);
loadAdapters
(
logger
);
ValidityCheck
();
ValidityCheck
();
...
@@ -76,13 +78,15 @@ public class MdeManager {
...
@@ -76,13 +78,15 @@ public class MdeManager {
serviceId
=
getServiceId
(
requestContext
,
offset
);
serviceId
=
getServiceId
(
requestContext
,
offset
);
String
[]
apiIdAsParams
=
getApiIdAsParams
(
requestContext
,
offset
);
String
[]
apiIdAsParams
=
getApiIdAsParams
(
requestContext
,
offset
);
String
ver
=
serviceId
.
split
(
"\\."
)[
0
];
String
[]
idTokens
=
serviceId
.
split
(
"\\."
);
if
(
ver
.
equals
(
"v2"
))
String
verAndTenant
=
idTokens
[
0
]
+
"."
+
idTokens
[
1
];
if
(
verAndTenant
.
equals
(
"v2.ge"
))
brr
=
geManager
.
executeRequest
(
serviceId
,
apiIdAsParams
,
requestContext
);
brr
=
geManager
.
executeRequest
(
serviceId
,
apiIdAsParams
,
requestContext
);
else
if
(
verAndTenant
.
equals
(
"v1.cisco"
))
brr
=
ciscoManager
.
executeRequest
(
serviceId
,
apiIdAsParams
,
requestContext
);
else
else
brr
=
executeRequest
(
serviceId
,
apiIdAsParams
,
requestContext
,
null
,
isMaintenanceRequest
);
brr
=
executeRequest
(
serviceId
,
apiIdAsParams
,
requestContext
,
null
,
isMaintenanceRequest
);
return
brr
;
return
brr
;
}
}
...
...
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