Search in sources :

Example 1 with AlertTypesListDTO

use of org.wso2.carbon.apimgt.rest.api.admin.v1.dto.AlertTypesListDTO in project carbon-apimgt by wso2.

the class AlertTypesApiServiceImpl method getAdminAlertTypes.

@Override
public Response getAdminAlertTypes(MessageContext messageContext) throws APIManagementException {
    try {
        AdminAlertConfigurator adminAlertConfigurator = (AdminAlertConfigurator) AlertConfigManager.getInstance().getAlertConfigurator(AlertMgtConstants.ADMIN_DASHBOARD_AGENT);
        List<org.wso2.carbon.apimgt.impl.dto.AlertTypeDTO> alertTypes = adminAlertConfigurator.getSupportedAlertTypes();
        AlertTypesListDTO alertTypesListDTO = AlertsMappingUtil.fromAlertTypesListToAlertTypeListDTO(alertTypes);
        return Response.status(Response.Status.OK).entity(alertTypesListDTO).build();
    } catch (APIManagementException e) {
        RestApiUtil.handleInternalServerError("Internal Server Error Occurred while retrieving alert types", e, log);
    } catch (AlertManagementException e) {
        log.warn("API Manager Analytics is not enabled", e);
        return Response.status(Response.Status.NO_CONTENT).build();
    }
    return Response.status(Response.Status.NO_CONTENT).build();
}
Also used : APIManagementException(org.wso2.carbon.apimgt.api.APIManagementException) AlertManagementException(org.wso2.carbon.apimgt.impl.alertmgt.exception.AlertManagementException) AdminAlertConfigurator(org.wso2.carbon.apimgt.impl.alertmgt.AdminAlertConfigurator) AlertTypesListDTO(org.wso2.carbon.apimgt.rest.api.admin.v1.dto.AlertTypesListDTO)

Example 2 with AlertTypesListDTO

use of org.wso2.carbon.apimgt.rest.api.admin.v1.dto.AlertTypesListDTO in project carbon-apimgt by wso2.

the class AlertsMappingUtil method fromAlertTypesListToAlertTypeListDTO.

/**
 * Map AlertTypeDTO list to AlertTypesListDTO
 *
 * @param alertTypes
 * @return
 */
public static AlertTypesListDTO fromAlertTypesListToAlertTypeListDTO(List<org.wso2.carbon.apimgt.impl.dto.AlertTypeDTO> alertTypes) {
    AlertTypesListDTO alertTypesListDTO = new AlertTypesListDTO();
    List<AlertTypeDTO> alertTypeDTOList = fromAlertTypesListToAlertTypeDTOList(alertTypes);
    alertTypesListDTO.setAlerts(alertTypeDTOList);
    alertTypesListDTO.setCount(alertTypeDTOList.size());
    return alertTypesListDTO;
}
Also used : AlertTypeDTO(org.wso2.carbon.apimgt.rest.api.admin.v1.dto.AlertTypeDTO) AlertTypesListDTO(org.wso2.carbon.apimgt.rest.api.admin.v1.dto.AlertTypesListDTO)

Aggregations

AlertTypesListDTO (org.wso2.carbon.apimgt.rest.api.admin.v1.dto.AlertTypesListDTO)2 APIManagementException (org.wso2.carbon.apimgt.api.APIManagementException)1 AdminAlertConfigurator (org.wso2.carbon.apimgt.impl.alertmgt.AdminAlertConfigurator)1 AlertManagementException (org.wso2.carbon.apimgt.impl.alertmgt.exception.AlertManagementException)1 AlertTypeDTO (org.wso2.carbon.apimgt.rest.api.admin.v1.dto.AlertTypeDTO)1