use of org.wso2.carbon.apimgt.rest.api.publisher.v1.dto.SubscriberInfoDTO in project carbon-apimgt by wso2.
the class SubscriptionMappingUtil method fromSubscriberClaimsToDTO.
/**
* Convert Subscriber claims information into SubscriberInfoDTO
*
* @param subscriberClaims list of subscriber claims
* @param subscriberName subscriber name
* @return SubscriberInfoDTO
* @throws APIManagementException If an error occurs when getting display name of claim
*/
public static SubscriberInfoDTO fromSubscriberClaimsToDTO(Map<String, String> subscriberClaims, String subscriberName) throws APIManagementException {
SubscriberInfoDTO subscriberInfoDTO = new SubscriberInfoDTO();
subscriberInfoDTO.setName(subscriberName);
List<ClaimDTO> claimDTOList = new ArrayList<>();
for (String key : subscriberClaims.keySet()) {
ClaimDTO claimDTO = new ClaimDTO();
claimDTO.setName(APIUtil.getClaimDisplayName(key, subscriberName));
claimDTO.setURI(key);
claimDTO.setValue(subscriberClaims.get(key));
claimDTOList.add(claimDTO);
}
subscriberInfoDTO.setClaims(claimDTOList);
return subscriberInfoDTO;
}
use of org.wso2.carbon.apimgt.rest.api.publisher.v1.dto.SubscriberInfoDTO in project carbon-apimgt by wso2.
the class SubscriptionsApiServiceImpl method getSubscriberInfoBySubscriptionId.
@Override
public Response getSubscriberInfoBySubscriptionId(String subscriptionId, MessageContext messageContext) throws APIManagementException {
if (StringUtils.isBlank(subscriptionId)) {
String errorMessage = "Subscription ID cannot be empty or null when getting subscriber info.";
RestApiUtil.handleBadRequest(errorMessage, log);
}
String username = RestApiCommonUtil.getLoggedInUsername();
APIProvider apiProvider = RestApiCommonUtil.getProvider(username);
String subscriberName = apiProvider.getSubscriber(subscriptionId);
Map subscriberClaims = apiProvider.getSubscriberClaims(subscriberName);
SubscriberInfoDTO subscriberInfoDTO = SubscriptionMappingUtil.fromSubscriberClaimsToDTO(subscriberClaims, subscriberName);
return Response.ok().entity(subscriberInfoDTO).build();
}
Aggregations