use of org.wso2.carbon.apimgt.rest.api.admin.v1.dto.APIInfoDTO in project carbon-apimgt by wso2.
the class ServicesApiServiceImpl method getServiceUsage.
@Override
public Response getServiceUsage(String serviceId, MessageContext messageContext) {
String userName = RestApiCommonUtil.getLoggedInUsername();
int tenantId = APIUtil.getTenantId(userName);
try {
List<API> apiList = serviceCatalog.getServiceUsage(serviceId, tenantId);
if (apiList != null) {
APIListDTO apiListDTO = new APIListDTO();
List<APIInfoDTO> apiInfoDTOList = new ArrayList<>();
for (API api : apiList) {
apiInfoDTOList.add(ServiceEntryMappingUtil.fromAPIToAPIInfoDTO(api));
}
apiListDTO.setList(apiInfoDTOList);
apiListDTO.setCount(apiList.size());
return Response.ok().entity(apiListDTO).build();
} else {
RestApiUtil.handleResourceNotFoundError("Service", serviceId, log);
}
} catch (APIManagementException e) {
String errorMessage = "Error while retrieving API usage of service";
RestApiUtil.handleInternalServerError(errorMessage, e, log);
}
return null;
}
use of org.wso2.carbon.apimgt.rest.api.admin.v1.dto.APIInfoDTO in project carbon-apimgt by wso2.
the class ServiceEntryMappingUtil method fromAPIToAPIInfoDTO.
public static APIInfoDTO fromAPIToAPIInfoDTO(API api) {
APIInfoDTO apiInfoDTO = new APIInfoDTO();
apiInfoDTO.setName(api.getId().getApiName());
apiInfoDTO.setVersion(api.getId().getVersion());
apiInfoDTO.setContext(api.getContext());
apiInfoDTO.setId(api.getUuid());
apiInfoDTO.setProvider(api.getId().getProviderName());
return apiInfoDTO;
}
use of org.wso2.carbon.apimgt.rest.api.admin.v1.dto.APIInfoDTO in project carbon-apimgt by wso2.
the class APIInfoMappingUtil method fromAPIInfoToDTO.
/**
* Converts a APIIdentifier object into APIInfoDTO
*
* @param apiId APIIdentifier object
* @return APIInfoDTO corresponds to APIIdentifier object
*/
private static APIInfoDTO fromAPIInfoToDTO(APIIdentifier apiId) throws UnsupportedEncodingException {
APIInfoDTO apiInfoDTO = new APIInfoDTO();
APIIdentifier apiIdEmailReplacedBack = new APIIdentifier(APIUtil.replaceEmailDomainBack(apiId.getProviderName()).replace(RestApiConstants.API_ID_DELIMITER, RestApiConstants.URL_ENCODED_API_ID_DELIMITER), URLEncoder.encode(apiId.getApiName(), RestApiConstants.CHARSET).replace(RestApiConstants.API_ID_DELIMITER, RestApiConstants.URL_ENCODED_API_ID_DELIMITER), apiId.getVersion().replace(RestApiConstants.API_ID_DELIMITER, RestApiConstants.URL_ENCODED_API_ID_DELIMITER));
apiInfoDTO.setName(apiIdEmailReplacedBack.getApiName());
apiInfoDTO.setVersion(apiIdEmailReplacedBack.getVersion());
apiInfoDTO.setProvider(apiIdEmailReplacedBack.getProviderName());
return apiInfoDTO;
}
Aggregations