提交 8314ed1a 编写于 作者: L lepdou

fix create app namespace format maybe null

上级 05fb4738
......@@ -11,7 +11,9 @@ import com.ctrip.framework.apollo.common.entity.AppNamespace;
import com.ctrip.framework.apollo.biz.service.AppNamespaceService;
import com.ctrip.framework.apollo.common.utils.BeanUtils;
import com.ctrip.framework.apollo.core.dto.AppNamespaceDTO;
import com.ctrip.framework.apollo.core.enums.ConfigFileFormat;
import com.ctrip.framework.apollo.core.exception.BadRequestException;
import com.ctrip.framework.apollo.core.utils.StringUtils;
import java.util.List;
......@@ -31,7 +33,11 @@ public class AppNamespaceController {
throw new BadRequestException("app namespaces already exist.");
}
entity = appNamespaceService.createAppNamespace(entity, entity.getDataChangeCreatedBy());
if (StringUtils.isEmpty(appNamespace.getFormat())){
appNamespace.setFormat(ConfigFileFormat.Properties.getValue());
}
entity = appNamespaceService.createAppNamespace(entity);
return BeanUtils.transfrom(AppNamespaceDTO.class, entity);
......
......@@ -71,7 +71,8 @@ public class AppNamespaceService {
}
@Transactional
public AppNamespace createAppNamespace(AppNamespace appNamespace, String createBy){
public AppNamespace createAppNamespace(AppNamespace appNamespace){
String createBy = appNamespace.getDataChangeCreatedBy();
if (!isAppNamespaceNameUnique(appNamespace.getAppId(), appNamespace.getName())) {
throw new ServiceException("appnamespace not unique");
}
......
......@@ -72,7 +72,7 @@ public class NamespaceController {
// TODO: 16/6/17 某些环境创建失败,统一处理这种场景
namespaceService.createNamespace(Env.valueOf(model.getEnv()), namespace);
} catch (Exception e) {
logger.error("createItem namespace error.", e);
logger.error("create namespace error.", e);
}
}
return ResponseEntity.ok().build();
......
......@@ -36,7 +36,7 @@ public class ServerConfigController {
ServerConfig storedConfig = serverConfigRepository.findByKey(serverConfig.getKey());
if (storedConfig == null) {//createItem
if (storedConfig == null) {//create
serverConfig.setDataChangeCreatedBy(modifiedBy);
serverConfig.setDataChangeLastModifiedBy(modifiedBy);
return serverConfigRepository.save(serverConfig);
......
......@@ -68,9 +68,9 @@ public class ConfigService {
long namespaceId = model.getNamespaceId();
String configText = model.getConfigText();
ConfigTextResolver
resolver =
ConfigTextResolver resolver =
model.getFormat() == ConfigFileFormat.Properties ? propertyResolver : fileTextResolver;
ItemChangeSets changeSets = resolver.resolve(namespaceId, configText,
itemAPI.findItems(appId, env, clusterName, namespaceName));
if (changeSets.isEmpty()) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册