Commit d35b39bb by Yiming Liu

Merge pull request #124 from lepdou/lepdou_master

load namespaces handle release NotFountException
parents 6161b573 b29eddd8
package com.ctrip.apollo.portal.service; package com.ctrip.apollo.portal.service;
import com.google.gson.Gson;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.web.client.HttpClientErrorException;
import com.ctrip.apollo.core.enums.Env; import com.ctrip.apollo.core.enums.Env;
import com.ctrip.apollo.core.dto.ItemChangeSets; import com.ctrip.apollo.core.dto.ItemChangeSets;
...@@ -42,7 +46,7 @@ public class ConfigService { ...@@ -42,7 +46,7 @@ public class ConfigService {
@Autowired @Autowired
private ConfigTextResolver resolver; private ConfigTextResolver resolver;
private ObjectMapper objectMapper = new ObjectMapper(); private Gson gson = new Gson();
/** /**
* load cluster all namespace info with items * load cluster all namespace info with items
...@@ -86,16 +90,17 @@ public class ConfigService { ...@@ -86,16 +90,17 @@ public class ConfigService {
String namespaceName = namespace.getNamespaceName(); String namespaceName = namespace.getNamespaceName();
//latest createRelease //latest Release
ReleaseDTO release = releaseAPI.loadLatestRelease(appId, env, clusterName, namespaceName); ReleaseDTO release = null;
Map<String, String> releaseItems = new HashMap<>(); Map<String, String> releaseItems = new HashMap<>();
if (release != null) {
try { try {
releaseItems = objectMapper.readValue(release.getConfigurations(), Map.class); release = releaseAPI.loadLatestRelease(appId, env, clusterName, namespaceName);
} catch (IOException e) { releaseItems = gson.fromJson(release.getConfigurations(), Map.class);
logger.error("parse createRelease json error. appId:{},env:{},clusterName:{},namespace:{}", appId, }catch (HttpClientErrorException e){
env, clusterName, namespaceName); if (e.getStatusCode() == HttpStatus.NOT_FOUND){
return namespaceVO; //ignore maybe new app has no release.
}else {
throw e;
} }
} }
......
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