use of org.wso2.carbon.apimgt.rest.api.publisher.dto.APIInfoDTO in project carbon-apimgt by wso2.
the class APIMappingUtil method toAPIInfo.
/**
* Converts {@link API} List to an {@link APIInfoDTO} List.
*
* @param apiSummaryList List of APIs
* @return List of APIInfoDTO
*/
private static List<APIInfoDTO> toAPIInfo(List<API> apiSummaryList) {
List<APIInfoDTO> apiInfoList = new ArrayList<APIInfoDTO>();
for (API apiSummary : apiSummaryList) {
APIInfoDTO apiInfo = new APIInfoDTO();
apiInfo.setId(apiSummary.getId());
apiInfo.setContext(apiSummary.getContext());
apiInfo.setDescription(apiSummary.getDescription());
apiInfo.setName(apiSummary.getName());
apiInfo.setProvider(apiSummary.getProvider());
apiInfo.setLifeCycleStatus(apiSummary.getLifeCycleStatus());
apiInfo.setVersion(apiSummary.getVersion());
apiInfoList.add(apiInfo);
}
return apiInfoList;
}
use of org.wso2.carbon.apimgt.rest.api.publisher.dto.APIInfoDTO in project carbon-apimgt by wso2.
the class AnalyticsMappingUtil method fromAPIInfoToDTO.
private static APIInfoDTO fromAPIInfoToDTO(APIInfo apiInfo, ZoneId zoneId) {
APIInfoDTO apiInfoDTO = new APIInfoDTO();
apiInfoDTO.setId(apiInfo.getId());
apiInfoDTO.setName(apiInfo.getName());
apiInfoDTO.setVersion(apiInfo.getVersion());
apiInfoDTO.setContext(apiInfo.getContext());
apiInfoDTO.setDescription(apiInfo.getDescription());
apiInfoDTO.setLifeCycleStatus(apiInfo.getLifeCycleStatus());
apiInfoDTO.setProvider(apiInfo.getProvider());
apiInfoDTO.setWorkflowStatus(apiInfo.getWorkflowStatus());
apiInfoDTO.setTime(epochToISO8601DateTime(apiInfo.getCreatedTime(), zoneId));
return apiInfoDTO;
}
use of org.wso2.carbon.apimgt.rest.api.publisher.dto.APIInfoDTO in project carbon-apimgt by wso2.
the class ApiMgtDAO method getSubscribedUsersForAPI.
/**
* Get API key information for given API
*
* @param apiInfoDTO API info
* @return APIKeyInfoDTO[]
* @throws APIManagementException if failed to get key info for given API
*/
public APIKeyInfoDTO[] getSubscribedUsersForAPI(APIInfoDTO apiInfoDTO) throws APIManagementException {
APIKeyInfoDTO[] apiKeyInfoDTOs = null;
Connection conn = null;
PreparedStatement ps = null;
ResultSet rs = null;
List<APIKeyInfoDTO> apiKeyInfoList = new ArrayList<APIKeyInfoDTO>();
String sqlQuery = SQLConstants.GET_SUBSCRIBED_USERS_FOR_API_SQL;
try {
conn = APIMgtDBUtil.getConnection();
ps = conn.prepareStatement(sqlQuery);
ps.setString(1, APIUtil.replaceEmailDomainBack(apiInfoDTO.getProviderId()));
ps.setString(2, apiInfoDTO.getApiName());
ps.setString(3, apiInfoDTO.getVersion());
rs = ps.executeQuery();
while (rs.next()) {
String userId = rs.getString(APIConstants.SUBSCRIBER_FIELD_USER_ID);
APIKeyInfoDTO apiKeyInfoDTO = new APIKeyInfoDTO();
apiKeyInfoDTO.setUserId(userId);
apiKeyInfoList.add(apiKeyInfoDTO);
}
apiKeyInfoDTOs = apiKeyInfoList.toArray(new APIKeyInfoDTO[apiKeyInfoList.size()]);
} catch (SQLException e) {
handleException("Error while executing SQL", e);
} finally {
APIMgtDBUtil.closeAllConnections(ps, conn, rs);
}
return apiKeyInfoDTOs;
}
use of org.wso2.carbon.apimgt.rest.api.publisher.dto.APIInfoDTO in project carbon-apimgt by wso2.
the class APIMgtDAOTest method testGetSubscribedUsersForAPI.
@Test
public void testGetSubscribedUsersForAPI() throws Exception {
APIInfoDTO apiInfoDTO = new APIInfoDTO();
apiInfoDTO.setApiName("API1");
apiInfoDTO.setProviderId("SUMEDHA");
apiInfoDTO.setVersion("V1.0.0");
APIKeyInfoDTO[] apiKeyInfoDTO = apiMgtDAO.getInstance().getSubscribedUsersForAPI(apiInfoDTO);
assertNotNull(apiKeyInfoDTO);
assertTrue(apiKeyInfoDTO.length > 1);
}
use of org.wso2.carbon.apimgt.rest.api.publisher.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