use of org.wso2.carbon.apimgt.rest.api.admin.v1.dto.BotDetectionDataListDTO in project carbon-apimgt by wso2.
the class BotDetectionDataApiServiceImpl method getBotDetectionData.
/**
* Get all bot detected data
*
* @param messageContext CXF Message Context
* @return list of all bot detected data
* @throws APIManagementException if an error occurs when retrieving bot detection data
*/
public Response getBotDetectionData(MessageContext messageContext) throws APIManagementException {
if (APIUtil.isAnalyticsEnabled()) {
APIAdmin apiAdmin = new APIAdminImpl();
List<BotDetectionData> botDetectionDataList = apiAdmin.retrieveBotDetectionData();
BotDetectionDataListDTO listDTO = BotDetectionMappingUtil.fromBotDetectionModelToDTO(botDetectionDataList);
return Response.ok().entity(listDTO).build();
} else {
throw new APIManagementException("Analytics Not Enabled", ExceptionCodes.from(ExceptionCodes.ANALYTICS_NOT_ENABLED, "Bot Detection Data is", "Bot Detection Data"));
}
}
use of org.wso2.carbon.apimgt.rest.api.admin.v1.dto.BotDetectionDataListDTO in project carbon-apimgt by wso2.
the class BotDetectionMappingUtil method fromBotDetectionModelToDTO.
/**
* Converts a list of Bot Detection Data model objects into a List DTO
*
* @param botDetectionDataList list of Bot Detection data
* @return A List DTO of converted Bot Detection data
*/
public static BotDetectionDataListDTO fromBotDetectionModelToDTO(List<BotDetectionData> botDetectionDataList) {
BotDetectionDataListDTO listDTO = new BotDetectionDataListDTO();
List<BotDetectionDataDTO> botDetectionDataDTOs = new ArrayList<>();
for (BotDetectionData botData : botDetectionDataList) {
botDetectionDataDTOs.add(fromBotDetectionModelToDTO(botData));
}
listDTO.setList(botDetectionDataDTOs);
listDTO.setCount(botDetectionDataDTOs.size());
return listDTO;
}
Aggregations