use of org.wso2.carbon.apimgt.rest.api.admin.v1.dto.BlockingConditionListDTO in project carbon-apimgt by wso2.
the class BlockingConditionMappingUtil method fromBlockConditionListToListDTO.
/**
* Converts a List of Block Condition in to REST API LIST DTO Object
*
* @param blockConditionList A List of Block Conditions
* @return REST API List DTO object derived from Block Condition list
*/
public static BlockingConditionListDTO fromBlockConditionListToListDTO(List<BlockConditionsDTO> blockConditionList) throws ParseException {
BlockingConditionListDTO listDTO = new BlockingConditionListDTO();
List<BlockingConditionDTO> blockingConditionDTOList = new ArrayList<>();
if (blockConditionList != null) {
for (BlockConditionsDTO blockCondition : blockConditionList) {
BlockingConditionDTO dto = fromBlockingConditionToDTO(blockCondition);
blockingConditionDTOList.add(dto);
}
}
listDTO.setCount(blockingConditionDTOList.size());
listDTO.setList(blockingConditionDTOList);
return listDTO;
}
use of org.wso2.carbon.apimgt.rest.api.admin.v1.dto.BlockingConditionListDTO in project carbon-apimgt by wso2.
the class BlacklistApiServiceImpl method blacklistGet.
@Override
public Response blacklistGet(String accept, Request request) throws NotFoundException {
try {
APIMgtAdminService apiMgtAdminService = APIManagerFactory.getInstance().getAPIMgtAdminService();
List<BlockConditions> blockConditionsList = apiMgtAdminService.getBlockConditions();
BlockingConditionListDTO blockingConditionListDTO = MappingUtil.fromBlockConditionListToListDTO(blockConditionsList);
return Response.ok(blockingConditionListDTO).build();
} catch (APIManagementException e) {
String errorMessage = "Error while retrieving block conditions";
ErrorDTO errorDTO = RestApiUtil.getErrorDTO(e.getErrorHandler());
log.error(errorMessage, e);
return Response.status(e.getErrorHandler().getHttpStatusCode()).header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).entity(errorDTO).build();
}
}
use of org.wso2.carbon.apimgt.rest.api.admin.v1.dto.BlockingConditionListDTO in project carbon-apimgt by wso2.
the class BlockingConditionMappingUtil method fromBlockConditionListToListDTO.
/**
* Converts a List of Block Condition in to REST API LIST DTO Object.
*
* @param blockConditionList A List of Block Conditions
* @return REST API List DTO object derived from Block Condition list
* @throws UnsupportedThrottleLimitTypeException - If error occurs
*/
public static BlockingConditionListDTO fromBlockConditionListToListDTO(List<BlockConditions> blockConditionList) throws UnsupportedThrottleLimitTypeException {
BlockingConditionListDTO listDTO = new BlockingConditionListDTO();
List<BlockingConditionDTO> blockingConditionDTOList = new ArrayList<>();
if (blockConditionList != null) {
for (BlockConditions blockCondition : blockConditionList) {
BlockingConditionDTO dto = fromBlockingConditionToDTO(blockCondition);
blockingConditionDTOList.add(dto);
}
}
listDTO.setCount(blockingConditionDTOList.size());
listDTO.setList(blockingConditionDTOList);
return listDTO;
}
use of org.wso2.carbon.apimgt.rest.api.admin.v1.dto.BlockingConditionListDTO in project carbon-apimgt by wso2.
the class ThrottlingApiServiceImpl method throttlingDenyPoliciesGet.
/**
* Retrieves all Block Conditions
*
* @param accept Accept header value
* @return All matched block conditions to the given request
*/
@Override
public Response throttlingDenyPoliciesGet(String accept, MessageContext messageContext) {
try {
APIProvider apiProvider = RestApiCommonUtil.getLoggedInUserProvider();
List<BlockConditionsDTO> blockConditions = apiProvider.getBlockConditions();
BlockingConditionListDTO listDTO = BlockingConditionMappingUtil.fromBlockConditionListToListDTO(blockConditions);
return Response.ok().entity(listDTO).build();
} catch (APIManagementException | ParseException e) {
String errorMessage = "Error while retrieving Block Conditions";
RestApiUtil.handleInternalServerError(errorMessage, e, log);
}
return null;
}
Aggregations