Skip to content

Commit

Permalink
Remove unused utility function
Browse files Browse the repository at this point in the history
Signed-off-by: Derek Ho <[email protected]>
  • Loading branch information
derek-ho committed Oct 11, 2023
1 parent 84522f1 commit 9382ff3
Showing 1 changed file with 0 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -186,38 +186,4 @@ public static XContentBuilder convertToXContent(DataSourceMetadata metadata) thr
builder.endObject();
return builder;
}

/**
* Converts Map<String, Object> (partial DataSourceMetadata) to XContentBuilder.
*
* @param dataSourceData
* @return XContentBuilder {@link XContentBuilder}
* @throws Exception Exception.
*/
public static XContentBuilder convertMapToXContent(Map<String, Object> dataSourceData)
throws Exception {

XContentBuilder builder = XContentFactory.jsonBuilder();
builder.startObject();
if (dataSourceData.containsKey(DESCRIPTION_FIELD)) {
builder.field(DESCRIPTION_FIELD, dataSourceData.get(DESCRIPTION_FIELD));
}
if (dataSourceData.containsKey(ALLOWED_ROLES_FIELD)) {
builder.field(
ALLOWED_ROLES_FIELD, ((List<String>) dataSourceData.get(ALLOWED_ROLES_FIELD)).toArray());
}
if (dataSourceData.containsKey(PROPERTIES_FIELD)) {
builder.startObject(PROPERTIES_FIELD);
for (Map.Entry<String, String> entry :
((Map<String, String>) dataSourceData.get(PROPERTIES_FIELD)).entrySet()) {
builder.field(entry.getKey(), entry.getValue());
}
builder.endObject();
}
if (dataSourceData.containsKey(RESULT_INDEX_FIELD)) {
builder.field(RESULT_INDEX_FIELD, dataSourceData.get(RESULT_INDEX_FIELD));
}
builder.endObject();
return builder;
}
}

0 comments on commit 9382ff3

Please sign in to comment.