Skip to content

Commit

Permalink
Update TransportGetFindingsSearchAction.kt
Browse files Browse the repository at this point in the history
  • Loading branch information
Annie Lee committed Mar 30, 2022
1 parent 18a8e84 commit a43ca25
Showing 1 changed file with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ class TransportGetFindingsSearchAction @Inject constructor(
val doc_ids = finding.relatedDocId.split(",").toTypedArray()
val docs = mutableListOf<FindingDocument>()
for (doc_id in doc_ids) {
searchDocument(doc_id, finding.index, docs, actionListener)
val findingDocument = searchDocument(doc_id, finding.index, docs, actionListener)
}
val findingWithDoc = FindingWithDocs(finding, docs)
findingsWithDocs.add(findingWithDoc)
Expand All @@ -161,8 +161,9 @@ class TransportGetFindingsSearchAction @Inject constructor(
sourceIndex: String,
docs: List<FindingDocument>,
actionListener: ActionListener<GetFindingsSearchResponse>
) {
): FindingDocument? {
val getRequest = GetRequest(sourceIndex, documentId)
var findingDocument: FindingDocument? = null
client.threadPool().threadContext.stashContext().use {
client.get(
getRequest,
Expand All @@ -184,11 +185,15 @@ class TransportGetFindingsSearchAction @Inject constructor(
val xcp = XContentFactory.xContent(XContentType.JSON)
.createParser(xContentRegistry, LoggingDeprecationHandler.INSTANCE, response.toString())
XContentParserUtils.ensureExpectedToken(XContentParser.Token.START_OBJECT, xcp.nextToken(), xcp)
val findingDocument = FindingDocument.parse(xcp)
findingDocument = FindingDocument.parse(xcp)
docs.add(findingDocument)
// TODO: remove debug log
log.info("Response not empty")
log.info("findingDocument: $findingDocument")
val docStr = findingDocument.toXContent(
XContentBuilder.builder(XContentType.JSON.xContent()),
ToXContent.EMPTY_PARAMS
).string()
log.info("findingDocument: $docStr")
}
}

Expand All @@ -198,5 +203,6 @@ class TransportGetFindingsSearchAction @Inject constructor(
}
)
}
return findingDocument
}
}

0 comments on commit a43ca25

Please sign in to comment.