Search in sources :

Example 1 with SharedScopeUsedAPIInfoDTO

use of org.wso2.carbon.apimgt.rest.api.publisher.v1.dto.SharedScopeUsedAPIInfoDTO 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;
}
Also used : SharedScopeUsedAPIResourceInfoDTO(org.wso2.carbon.apimgt.rest.api.publisher.v1.dto.SharedScopeUsedAPIResourceInfoDTO) ArrayList(java.util.ArrayList) URITemplate(org.wso2.carbon.apimgt.api.model.URITemplate) API(org.wso2.carbon.apimgt.api.model.API) APIIdentifier(org.wso2.carbon.apimgt.api.model.APIIdentifier) SharedScopeUsageDTO(org.wso2.carbon.apimgt.rest.api.publisher.v1.dto.SharedScopeUsageDTO) SharedScopeUsedAPIInfoDTO(org.wso2.carbon.apimgt.rest.api.publisher.v1.dto.SharedScopeUsedAPIInfoDTO)

Aggregations

ArrayList (java.util.ArrayList)1 API (org.wso2.carbon.apimgt.api.model.API)1 APIIdentifier (org.wso2.carbon.apimgt.api.model.APIIdentifier)1 URITemplate (org.wso2.carbon.apimgt.api.model.URITemplate)1 SharedScopeUsageDTO (org.wso2.carbon.apimgt.rest.api.publisher.v1.dto.SharedScopeUsageDTO)1 SharedScopeUsedAPIInfoDTO (org.wso2.carbon.apimgt.rest.api.publisher.v1.dto.SharedScopeUsedAPIInfoDTO)1 SharedScopeUsedAPIResourceInfoDTO (org.wso2.carbon.apimgt.rest.api.publisher.v1.dto.SharedScopeUsedAPIResourceInfoDTO)1