Skip to content

Commit

Permalink
Enable getting GOKb jobId with token-based authentification (#274)
Browse files Browse the repository at this point in the history
  • Loading branch information
philboeselager committed Oct 28, 2020
1 parent d7c4922 commit 4059815
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/groovy/de/hbznrw/ygor/processing/SendPackageThreadGokb.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import groovy.util.logging.Log4j
import groovyx.net.http.ContentType
import groovyx.net.http.HTTPBuilder
import groovyx.net.http.Method
import org.apache.commons.lang.StringUtils
import ygor.AutoUpdateService
import ygor.Enrichment

Expand Down Expand Up @@ -139,7 +140,7 @@ class SendPackageThreadGokb extends UploadThreadGokb{
return null
}
if (updateResponse){
gokbStatusResponse = getGokbStatusResponse(jobId)
gokbStatusResponse = getGokbStatusResponse(jobId, enrichment?.dataContainer?.pkgHeader?.token)
}
String[] path = responseKey.split("\\.")
def response = gokbStatusResponse
Expand All @@ -153,14 +154,19 @@ class SendPackageThreadGokb extends UploadThreadGokb{
}


protected Map getGokbStatusResponse(String jobId){
if (user == null || password == null || jobId == null){
protected Map getGokbStatusResponse(String jobId, String token){
if (jobId == null){
return null
}
def uri = Holders.config.gokbApi.xrJobInfo.toString().concat("/").concat(jobId)
if (!StringUtils.isEmpty(token)){
uri = uri.concat("?updateToken=").concat(token)
}
def http = new HTTPBuilder(uri)
Map<String, Object> result = new HashMap<>()
http.auth.basic user, password
if (user != null && password != null){
http.auth.basic user, password
}
http.request(Method.GET, ContentType.JSON){ req ->
response.success = { response, resultMap ->
if (response.headers.'Content-Type' == 'application/json;charset=UTF-8'){
Expand Down

0 comments on commit 4059815

Please sign in to comment.