use of org.wso2.carbon.apimgt.rest.api.publisher.v1.dto.SharedScopeUsageDTO in project carbon-apimgt by wso2.
the class ScopesApiServiceImpl method getSharedScopeUsages.
@Override
public Response getSharedScopeUsages(String scopeId, MessageContext messageContext) throws APIManagementException {
APIProvider apiProvider = RestApiCommonUtil.getLoggedInUserProvider();
String tenantDomain = RestApiCommonUtil.getLoggedInUserTenantDomain();
int tenantId = APIUtil.getTenantIdFromTenantDomain(tenantDomain);
if (StringUtils.isEmpty(scopeId)) {
throw new APIManagementException("Scope Id cannot be null or empty", ExceptionCodes.SHARED_SCOPE_ID_NOT_SPECIFIED);
}
SharedScopeUsage sharedScopeUsage = apiProvider.getSharedScopeUsage(scopeId, tenantId);
SharedScopeUsageDTO sharedScopeUsageDTO = SharedScopeMappingUtil.fromSharedScopeUsageToDTO(sharedScopeUsage);
return Response.ok().entity(sharedScopeUsageDTO).build();
}
use of org.wso2.carbon.apimgt.rest.api.publisher.v1.dto.SharedScopeUsageDTO in project carbon-apimgt by wso2.
the class SharedScopeMappingUtil method fromSharedScopeUsageToDTO.
/**
* Converts SharedScopeUsage object into SharedScopeUsageDTO object.
*
* @param sharedScopeUsage SharedScopeUsage object
* @return SharedScopeUsageDTO object
*/
public static SharedScopeUsageDTO fromSharedScopeUsageToDTO(SharedScopeUsage sharedScopeUsage) {
SharedScopeUsageDTO sharedScopeUsageDTO = new SharedScopeUsageDTO();
sharedScopeUsageDTO.setId(sharedScopeUsage.getId());
sharedScopeUsageDTO.setName(sharedScopeUsage.getName());
List<SharedScopeUsedAPIInfoDTO> usedAPIInfoDTOList = new ArrayList<>();
for (API api : sharedScopeUsage.getApis()) {
APIIdentifier apiIdentifier = api.getId();
SharedScopeUsedAPIInfoDTO usedAPIInfoDTO = new SharedScopeUsedAPIInfoDTO();
usedAPIInfoDTO.setName(apiIdentifier.getName());
usedAPIInfoDTO.setVersion(apiIdentifier.getVersion());
usedAPIInfoDTO.setProvider(apiIdentifier.getProviderName());
usedAPIInfoDTO.setContext(api.getContext());
List<SharedScopeUsedAPIResourceInfoDTO> usedAPIResourceInfoDTOList = new ArrayList<>();
for (URITemplate uriTemplate : api.getUriTemplates()) {
SharedScopeUsedAPIResourceInfoDTO usedAPIResourceInfoDTO = new SharedScopeUsedAPIResourceInfoDTO();
usedAPIResourceInfoDTO.setTarget(uriTemplate.getUriTemplate());
usedAPIResourceInfoDTO.setVerb(uriTemplate.getHTTPVerb());
usedAPIResourceInfoDTOList.add(usedAPIResourceInfoDTO);
}
usedAPIInfoDTO.setUsedResourceList(usedAPIResourceInfoDTOList);
usedAPIInfoDTOList.add(usedAPIInfoDTO);
}
sharedScopeUsageDTO.setUsedApiList(usedAPIInfoDTOList);
return sharedScopeUsageDTO;
}
Aggregations