use of org.wso2.carbon.identity.configuration.mgt.core.search.Condition in project carbon-apimgt by wso2.
the class CommonThrottleMappingUtil method fromConditionalGroupDTOToPipeline.
/**
* Converts a single Conditional Group DTO into a Pipeline object
*
* @param dto Conditional Group DTO
* @return Derived Pipeline object from Conditional Group DTO
* @throws UnsupportedThrottleLimitTypeException
* @throws UnsupportedThrottleConditionTypeException
*/
public static Pipeline fromConditionalGroupDTOToPipeline(ConditionalGroupDTO dto) throws UnsupportedThrottleLimitTypeException, UnsupportedThrottleConditionTypeException {
Pipeline pipeline = new Pipeline();
pipeline.setDescription(dto.getDescription());
pipeline.setEnabled(true);
pipeline.setQuotaPolicy(fromDTOToQuotaPolicy(dto.getLimit()));
List<Condition> conditions = fromDTOListToConditionList(dto.getConditions());
pipeline.setConditions(conditions);
return pipeline;
}
use of org.wso2.carbon.identity.configuration.mgt.core.search.Condition in project carbon-apimgt by wso2.
the class CommonThrottleMappingUtil method fromDTOToQueryParameterCondition.
/**
* Converts a Query Parameter Condition DTO object into a model object
*
* @param dto Query Parameter Condition DTO object
* @param invertCondition Invert condition relevant to the DTO
* @return Query Parameter Condition model object derived from Query Parameter Condition DTO
*/
public static QueryParameterCondition fromDTOToQueryParameterCondition(QueryParameterConditionDTO dto, boolean invertCondition) {
QueryParameterCondition queryParameterCondition = new QueryParameterCondition();
queryParameterCondition.setConditionEnabled(Boolean.TRUE.toString());
queryParameterCondition.setInvertCondition(invertCondition);
queryParameterCondition.setParameter(dto.getParameterName());
queryParameterCondition.setValue(dto.getParameterValue());
return queryParameterCondition;
}
use of org.wso2.carbon.identity.configuration.mgt.core.search.Condition in project carbon-apimgt by wso2.
the class CommonThrottleMappingUtil method fromHeaderConditionToDTO.
/**
* Converts a Header Condition model object into a DTO
*
* @param headerCondition Header Condition model object
* @return DTO object that was derived from Header Condition model object
*/
public static HeaderConditionDTO fromHeaderConditionToDTO(HeaderCondition headerCondition) {
HeaderConditionDTO dto = new HeaderConditionDTO();
dto.setHeaderName(headerCondition.getHeaderName());
dto.setHeaderValue(headerCondition.getValue());
return dto;
}
use of org.wso2.carbon.identity.configuration.mgt.core.search.Condition in project carbon-apimgt by wso2.
the class CommonThrottleMappingUtil method fromDTOListToConditionList.
/**
* Converts a list of Throttle Condition DTOs into a list of Condition model objects
*
* @param throttleConditionDTOs list of Throttle Condition DTOs
* @return Derived list of Condition model objects from Throttle Condition DTOs
* @throws UnsupportedThrottleConditionTypeException
*/
public static List<Condition> fromDTOListToConditionList(List<ThrottleConditionDTO> throttleConditionDTOs) throws UnsupportedThrottleConditionTypeException {
List<Condition> conditions = new ArrayList<>();
String errorMessage;
if (throttleConditionDTOs != null) {
for (ThrottleConditionDTO dto : throttleConditionDTOs) {
ThrottleConditionDTO.TypeEnum conditionType = dto.getType();
if (conditionType != null) {
switch(conditionType) {
case HEADERCONDITION:
{
if (dto.getHeaderCondition() != null) {
conditions.add(fromDTOToHeaderCondition(dto.getHeaderCondition(), dto.isInvertCondition()));
} else {
errorMessage = RestApiAdminUtils.constructMissingThrottleObjectErrorMessage(ThrottleConditionDTO.TypeEnum.HEADERCONDITION) + dto.toString();
throw new UnsupportedThrottleConditionTypeException(errorMessage);
}
break;
}
case IPCONDITION:
{
if (dto.getIpCondition() != null) {
conditions.add(fromDTOToIPCondition(dto.getIpCondition(), dto.isInvertCondition()));
} else {
errorMessage = RestApiAdminUtils.constructMissingThrottleObjectErrorMessage(ThrottleConditionDTO.TypeEnum.IPCONDITION) + dto.toString();
throw new UnsupportedThrottleConditionTypeException(errorMessage);
}
break;
}
case QUERYPARAMETERCONDITION:
{
if (dto.getQueryParameterCondition() != null) {
conditions.add(fromDTOToQueryParameterCondition(dto.getQueryParameterCondition(), dto.isInvertCondition()));
} else {
errorMessage = RestApiAdminUtils.constructMissingThrottleObjectErrorMessage(ThrottleConditionDTO.TypeEnum.QUERYPARAMETERCONDITION) + dto.toString();
throw new UnsupportedThrottleConditionTypeException(errorMessage);
}
break;
}
case JWTCLAIMSCONDITION:
{
if (dto.getJwtClaimsCondition() != null) {
conditions.add(fromDTOToJWTClaimsCondition(dto.getJwtClaimsCondition(), dto.isInvertCondition()));
} else {
errorMessage = RestApiAdminUtils.constructMissingThrottleObjectErrorMessage(ThrottleConditionDTO.TypeEnum.JWTCLAIMSCONDITION) + dto.toString();
throw new UnsupportedThrottleConditionTypeException(errorMessage);
}
break;
}
default:
return null;
}
} else {
errorMessage = "Condition item 'type' property has not been specified\n" + dto.toString();
throw new UnsupportedThrottleConditionTypeException(errorMessage);
}
}
}
return conditions;
}
use of org.wso2.carbon.identity.configuration.mgt.core.search.Condition in project carbon-apimgt by wso2.
the class CommonThrottleMappingUtil method fromDTOToIPCondition.
/**
* Converts a IP Condition DTO object into a model object
*
* @param dto IP Condition DTO object
* @param invertCondition Invert condition relevant to the DTO
* @return IP Condition model object derived from DTO
*/
public static IPCondition fromDTOToIPCondition(IPConditionDTO dto, boolean invertCondition) {
String ipConditionType = mapIPConditionTypeFromDTOToModel(dto.getIpConditionType());
IPCondition ipCondition = new IPCondition(ipConditionType);
ipCondition.setConditionEnabled(Boolean.TRUE.toString());
ipCondition.setInvertCondition(invertCondition);
ipCondition.setSpecificIP(dto.getSpecificIP());
ipCondition.setStartingIP(dto.getStartingIP());
ipCondition.setEndingIP(dto.getEndingIP());
return ipCondition;
}
Aggregations