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
4b908432
authored
Mar 07, 2017
by
Adi Amir
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
support binary content
parent
0d8514fa
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
37 additions
and
8 deletions
build.gradle
src/main/java/logic/GEManager.java
src/main/java/logic/MdeManager.java
build.gradle
View file @
4b908432
...
...
@@ -4,7 +4,7 @@ apply plugin: 'maven-publish'
def
gitLog
()
{
return
"git log --pretty=format:'%h' -n 1"
.
execute
().
text
.
trim
().
replaceAll
(
"'"
,
""
)
}
group
=
'com.ipgallery'
version
=
'1.0.
1
'
+
gitLog
()
version
=
'1.0.
2
'
+
gitLog
()
sourceCompatibility
=
1.8
repositories
{
...
...
@@ -16,7 +16,7 @@ repositories {
dependencies
{
// compile 'com.flipkart.zjsonpatch:zjsonpatch:0.2.1'
// compile group:'com.ipgallery.common', name:'microservice', version:'1.2.0'
compile
group:
'com.ipgallery.common'
,
name:
'microservice'
,
version:
'1.4.
0-local
'
compile
group:
'com.ipgallery.common'
,
name:
'microservice'
,
version:
'1.4.
1
'
compile
group:
'com.ipgallery.common'
,
name:
'itc'
,
version:
'1.0.0'
// compile 'com.ipgallery.common:utils:1.1.0'
compile
'io.swagger:swagger-annotations:1.5.7'
...
...
src/main/java/logic/GEManager.java
View file @
4b908432
...
...
@@ -8,6 +8,7 @@ import http.simpleHttpClient.SimpleHttpClient;
import
http.simpleHttpClient.SimpleHttpRequest
;
import
http.simpleHttpClient.SimpleHttpResponse
;
import
microservice.RequestContext
;
import
microservice.io.iface.ILogger
;
import
microservice.types.BaseRestResponse
;
import
org.apache.commons.io.IOUtils
;
import
org.apache.http.HttpResponse
;
...
...
@@ -45,8 +46,10 @@ public class GEManager {
public
static
String
TOKEN
=
"NOT_VALID"
;
private
SimpleHttpClient
httpClient
=
null
;
private
ILogger
logger
;
public
GEManager
()
throws
Exception
{
public
GEManager
(
ILogger
logger
)
throws
Exception
{
this
.
logger
=
logger
;
httpClient
=
new
SimpleHttpClient
();
httpClient
.
Initialize
(
100
);
}
...
...
@@ -77,6 +80,7 @@ public class GEManager {
req
=
buildCameraHttpRequest
(
requestContext
,
content
,
apiIdAsParams
);
try
{
resp
=
httpClient
.
processRequest
(
req
);
}
catch
(
UnsupportedEncodingException
e
)
{
e
.
printStackTrace
();
}
...
...
@@ -88,6 +92,9 @@ public class GEManager {
else
brr
.
setError
(
"failed to retrieve a valid token"
);
}
else
{
brr
.
setError
(
"processRequest() failed. path: "
+
req
.
getPath
()
+
" resp: "
+
resp
.
toString
());
}
return
brr
;
}
...
...
@@ -145,13 +152,25 @@ public class GEManager {
ObjectNode
objectNode
=
mapper
.
createObjectNode
();
JsonNode
contentObj
=
mapper
.
readTree
(
content
);
JsonNode
arrNode
=
contentObj
.
get
(
"content"
);
if
(
arrNode
.
isArray
())
{
req
=
buildOpenCameraLinkRequest
(
arrNode
.
get
(
0
).
get
(
"url"
).
asText
()
);
String
url
=
arrNode
.
get
(
0
).
get
(
"url"
).
asText
();
req
=
buildOpenCameraLinkRequest
(
url
);
resp
=
httpClient
.
processRequest
(
req
);
if
(
resp
.
getStatusCode
()
==
200
)
{
ObjectNode
dataObj
=
mapper
.
createObjectNode
();
// file name
String
filename
=
getImageFileName
(
url
);
String
[]
fileNameTokens
=
filename
.
split
(
"\\."
);
filename
=
fileNameTokens
[
0
]
+
".latest"
+
"."
+
fileNameTokens
[
1
];
dataObj
.
put
(
"fileName"
,
filename
);
// data
dataObj
.
put
(
"data"
,
resp
.
getContent
());
brr
.
objectNode
=
dataObj
;
}
// brr.objectNode = resp.getContent();
}
catch
(
IOException
e
)
{
}
catch
(
Exception
e
)
{
String
err
=
"buildCameraResp() failed. e: "
+
e
.
toString
();
logger
.
error
(
err
);
e
.
printStackTrace
();
return
new
BaseRestResponse
(
false
,
err
);
}
return
brr
;
}
...
...
@@ -275,6 +294,15 @@ public class GEManager {
return
newArray
;
}
private
String
getImageFileName
(
String
link
)
{
String
[]
linkTokens
=
link
.
split
(
"/"
);
if
(
linkTokens
.
length
>
1
)
{
return
linkTokens
[
linkTokens
.
length
-
1
];
}
else
return
null
;
}
private
BaseRestResponse
testGetImage
(
RequestContext
requestContext
,
String
[]
apiIds
)
{
try
{
...
...
src/main/java/logic/MdeManager.java
View file @
4b908432
...
...
@@ -35,7 +35,7 @@ public class MdeManager {
private
AdaptersRepository
adaptersRepository
;
private
ServicesRepository
servicesRepository
;
private
GEManager
geManager
=
n
ew
GEManager
()
;
private
GEManager
geManager
=
n
ull
;
public
MdeManager
(
ILogger
logger
)
throws
Exception
{
...
...
@@ -44,6 +44,7 @@ public class MdeManager {
jsonPatchAddAppKey
=
Utils
.
readJsonNodeFromFile
(
Constants
.
CONFIG_LOCATION
+
"jsonPatchAddAppKey.json"
);
this
.
logger
=
logger
;
geManager
=
new
GEManager
(
logger
);
LoadServices
(
logger
);
loadAdapters
(
logger
);
ValidityCheck
();
...
...
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