use of com.alibaba.nacos.naming.selector.NoneSelector in project nacos by alibaba.
the class ServiceController method parseSelector.
private Selector parseSelector(String selectorJsonString) throws Exception {
if (StringUtils.isBlank(selectorJsonString)) {
return new NoneSelector();
}
JsonNode selectorJson = JacksonUtils.toObj(URLDecoder.decode(selectorJsonString, "UTF-8"));
String type = Optional.ofNullable(selectorJson.get("type")).orElseThrow(() -> new NacosException(NacosException.INVALID_PARAM, "not match any type of selector!")).asText();
String expression = Optional.ofNullable(selectorJson.get("expression")).map(JsonNode::asText).orElse(null);
Selector selector = selectorManager.parseSelector(type, expression);
if (Objects.isNull(selector)) {
throw new NacosException(NacosException.INVALID_PARAM, "not match any type of selector!");
}
return selector;
}
use of com.alibaba.nacos.naming.selector.NoneSelector in project nacos by alibaba.
the class ServiceControllerV2 method parseSelector.
private Selector parseSelector(String selectorJsonString) throws Exception {
if (StringUtils.isBlank(selectorJsonString)) {
return new NoneSelector();
}
JsonNode selectorJson = JacksonUtils.toObj(URLDecoder.decode(selectorJsonString, "UTF-8"));
String type = Optional.ofNullable(selectorJson.get("type")).orElseThrow(() -> new NacosException(NacosException.INVALID_PARAM, "not match any type of selector!")).asText();
String expression = Optional.ofNullable(selectorJson.get("expression")).map(JsonNode::asText).orElse(null);
Selector selector = selectorManager.parseSelector(type, expression);
if (Objects.isNull(selector)) {
throw new NacosException(NacosException.INVALID_PARAM, "not match any type of selector!");
}
return selector;
}
use of com.alibaba.nacos.naming.selector.NoneSelector in project nacos by alibaba.
the class UpgradeOpsController method parseSelector.
private Selector parseSelector(String selectorJsonString) throws Exception {
if (StringUtils.isBlank(selectorJsonString)) {
return new NoneSelector();
}
JsonNode selectorJson = JacksonUtils.toObj(URLDecoder.decode(selectorJsonString, "UTF-8"));
String type = Optional.ofNullable(selectorJson.get("type")).orElseThrow(() -> new NacosException(NacosException.INVALID_PARAM, "not match any type of selector!")).asText();
String expression = Optional.ofNullable(selectorJson.get("expression")).map(JsonNode::asText).orElse(null);
Selector selector = selectorManager.parseSelector(type, expression);
if (Objects.isNull(selector)) {
throw new NacosException(NacosException.INVALID_PARAM, "not match any type of selector!");
}
return selector;
}
use of com.alibaba.nacos.naming.selector.NoneSelector in project nacos by alibaba.
the class ServiceMetadataTest method testGetSelector.
@Test
public void testGetSelector() {
Selector selector = serviceMetadata.getSelector();
Assert.assertNotNull(selector);
boolean result = selector instanceof NoneSelector;
Assert.assertTrue(result);
}
Aggregations