Search in sources :

Example 1 with BotDetectionDataListDTO

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"));
    }
}
Also used : APIManagementException(org.wso2.carbon.apimgt.api.APIManagementException) APIAdmin(org.wso2.carbon.apimgt.api.APIAdmin) BotDetectionData(org.wso2.carbon.apimgt.api.model.botDataAPI.BotDetectionData) BotDetectionDataListDTO(org.wso2.carbon.apimgt.rest.api.admin.v1.dto.BotDetectionDataListDTO) APIAdminImpl(org.wso2.carbon.apimgt.impl.APIAdminImpl)

Example 2 with BotDetectionDataListDTO

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;
}
Also used : BotDetectionDataDTO(org.wso2.carbon.apimgt.rest.api.admin.v1.dto.BotDetectionDataDTO) ArrayList(java.util.ArrayList) BotDetectionDataListDTO(org.wso2.carbon.apimgt.rest.api.admin.v1.dto.BotDetectionDataListDTO) BotDetectionData(org.wso2.carbon.apimgt.api.model.botDataAPI.BotDetectionData)

Aggregations

BotDetectionData (org.wso2.carbon.apimgt.api.model.botDataAPI.BotDetectionData)2 BotDetectionDataListDTO (org.wso2.carbon.apimgt.rest.api.admin.v1.dto.BotDetectionDataListDTO)2 ArrayList (java.util.ArrayList)1 APIAdmin (org.wso2.carbon.apimgt.api.APIAdmin)1 APIManagementException (org.wso2.carbon.apimgt.api.APIManagementException)1 APIAdminImpl (org.wso2.carbon.apimgt.impl.APIAdminImpl)1 BotDetectionDataDTO (org.wso2.carbon.apimgt.rest.api.admin.v1.dto.BotDetectionDataDTO)1