use of org.ballerinalang.jvm.values.api.BArray in project product-microgateway by wso2.
the class MGWJWTGeneratorInvoker method getRetrievedClaims.
public static BMap<String, Object> getRetrievedClaims(BMap<String, Object> authContext) {
try {
List<ClaimDTO> claimList = abstractMGWClaimRetriever.retrieveClaims(convertBMapToMap(authContext));
if (claimList == null) {
return null;
}
BPackage packageId = new BPackage("wso2", "gateway", "3.2.1");
BMap<String, Object> bMap = BValueCreator.createRecordValue(packageId, "RetrievedUserClaimsListDTO");
bMap.put("count", claimList.size());
BArray bArray = (BArray) bMap.get("list");
for (Object claimDTO : claimList) {
bArray.append(BValueCreator.createRecordValue(packageId, "ClaimDTO", (Map<String, Object>) claimDTO));
}
return bMap;
// Not to break the flow if an exception occured during claim retrieval
} catch (Exception e) {
log.error("Error while retrieving user claims from remote url.", e);
return null;
}
}
use of org.ballerinalang.jvm.values.api.BArray in project product-microgateway by wso2.
the class Request method getQueryParamValue.
/**
* Gets the query param value associated with the given key.
*
* @param key Represents the query param key.
* @return Returns the query param value associated with the given key as a string. If multiple param values are
* present, then the first value is returned. Null is returned if no key is found.
*/
public String getQueryParamValue(String key) {
BMap mapValue = getNativeQueryParams();
BArray arrayValue = ((MapValue) mapValue).getArrayValue(key);
if (arrayValue != null) {
return arrayValue.get(0).toString();
}
return null;
}
use of org.ballerinalang.jvm.values.api.BArray in project product-microgateway by wso2.
the class Request method getQueryParamValues.
/**
* Gets all the query param values associated with the given key.
*
* @param key Represents the query param key.
* @return Returns all the query param values associated with the given key as a `String[]`.
* Null is returned if no key is found.
*/
public String[] getQueryParamValues(String key) {
BMap mapValue = getNativeQueryParams();
BArray arrayValue = ((MapValue) mapValue).getArrayValue(key);
if (arrayValue != null) {
return arrayValue.getStringArray();
}
return null;
}
Aggregations