Commit cf6dda53 by Jason Song

Merge pull request #90 from lepdou/portal

npe fix
parents e46d33ee fb6359a4
...@@ -21,6 +21,7 @@ import org.springframework.util.MultiValueMap; ...@@ -21,6 +21,7 @@ import org.springframework.util.MultiValueMap;
import org.springframework.web.client.HttpClientErrorException; import org.springframework.web.client.HttpClientErrorException;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections;
import java.util.List; import java.util.List;
...@@ -74,7 +75,7 @@ public class AdminServiceAPI { ...@@ -74,7 +75,7 @@ public class AdminServiceAPI {
public List<ItemDTO> findItems(String appId, Apollo.Env env, String clusterName, String namespace) { public List<ItemDTO> findItems(String appId, Apollo.Env env, String clusterName, String namespace) {
if (StringUtils.isContainEmpty(appId, clusterName, namespace)) { if (StringUtils.isContainEmpty(appId, clusterName, namespace)) {
return null; return Collections.EMPTY_LIST;
} }
return Arrays.asList(restTemplate.getForObject(getAdminServiceHost(env) + String return Arrays.asList(restTemplate.getForObject(getAdminServiceHost(env) + String
...@@ -140,7 +141,8 @@ public class AdminServiceAPI { ...@@ -140,7 +141,8 @@ public class AdminServiceAPI {
ResponseEntity<ReleaseDTO> response = restTemplate.postForEntity(getAdminServiceHost(env) + String. ResponseEntity<ReleaseDTO> response = restTemplate.postForEntity(getAdminServiceHost(env) + String.
format("apps/%s/clusters/%s/namespaces/%s/releases", appId, clusterName, namespace), format("apps/%s/clusters/%s/namespaces/%s/releases", appId, clusterName, namespace),
entity, ReleaseDTO.class); entity, ReleaseDTO.class);
if (response.getStatusCode() == HttpStatus.OK){
if (response != null && response.getStatusCode() == HttpStatus.OK){
return response.getBody(); return response.getBody();
}else { }else {
logger.error("release fail.id:{}, env:{}, clusterName:{}, namespace:{},releaseBy{}",appId, env, clusterName, namespace, releaseBy); logger.error("release fail.id:{}, env:{}, clusterName:{}, namespace:{},releaseBy{}",appId, env, clusterName, namespace, releaseBy);
......
...@@ -44,12 +44,15 @@ public class ConfigController { ...@@ -44,12 +44,15 @@ public class ConfigController {
@PathVariable String clusterName, @PathVariable String namespaceName, @PathVariable String clusterName, @PathVariable String namespaceName,
@RequestBody NamespaceModifyModel model) { @RequestBody NamespaceModifyModel model) {
if (model == null){
return ResponseEntity.badRequest().body(new SimpleMsg("form data exception."));
}
model.setAppId(appId); model.setAppId(appId);
model.setClusterName(clusterName); model.setClusterName(clusterName);
model.setEnv(env); model.setEnv(env);
model.setNamespaceName(namespaceName); model.setNamespaceName(namespaceName);
if (model == null || model.isInvalid()){ if (model.isInvalid()){
return ResponseEntity.badRequest().body(new SimpleMsg("form data exception.")); return ResponseEntity.badRequest().body(new SimpleMsg("form data exception."));
} }
...@@ -66,12 +69,15 @@ public class ConfigController { ...@@ -66,12 +69,15 @@ public class ConfigController {
public ResponseEntity<SimpleMsg> createRelease(@PathVariable String appId, @PathVariable String env, public ResponseEntity<SimpleMsg> createRelease(@PathVariable String appId, @PathVariable String env,
@PathVariable String clusterName, @PathVariable String namespaceName, @PathVariable String clusterName, @PathVariable String namespaceName,
@RequestBody NamespaceReleaseModel model){ @RequestBody NamespaceReleaseModel model){
if (model == null){
return ResponseEntity.badRequest().body(new SimpleMsg("form data exception."));
}
model.setAppId(appId); model.setAppId(appId);
model.setClusterName(clusterName); model.setClusterName(clusterName);
model.setEnv(env); model.setEnv(env);
model.setNamespaceName(namespaceName); model.setNamespaceName(namespaceName);
if (model == null || model.isInvalid()){ if (model.isInvalid()){
return ResponseEntity.badRequest().body(new SimpleMsg("form data exception.")); return ResponseEntity.badRequest().body(new SimpleMsg("form data exception."));
} }
......
...@@ -90,8 +90,11 @@ public class PropertyResolver implements ConfigTextResolver { ...@@ -90,8 +90,11 @@ public class PropertyResolver implements ConfigTextResolver {
int keyCount = 0; int keyCount = 0;
for (String item: newItems){ for (String item: newItems){
if (!isCommentItem(item) && !isBlankItem(item)){ if (!isCommentItem(item) && !isBlankItem(item)){
keyCount ++; keyCount++;
keys.add(parseKeyValueFromItem(item)[0]); String[] kv = parseKeyValueFromItem(item);
if (kv != null) {
keys.add(kv[0]);
}
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment