use of com.ctrip.framework.apollo.portal.component.txtresolver.ConfigTextResolver in project apollo by ctripcorp.
the class ItemService method updateConfigItemByText.
/**
* parse config text and update config items
*
* @return parse result
*/
public void updateConfigItemByText(NamespaceTextModel model) {
String appId = model.getAppId();
Env env = model.getEnv();
String clusterName = model.getClusterName();
String namespaceName = model.getNamespaceName();
NamespaceDTO namespace = namespaceAPI.loadNamespace(appId, env, clusterName, namespaceName);
if (namespace == null) {
throw new BadRequestException("namespace:" + namespaceName + " not exist in env:" + env + ", cluster:" + clusterName);
}
long namespaceId = namespace.getId();
String configText = model.getConfigText();
ConfigTextResolver resolver = model.getFormat() == ConfigFileFormat.Properties ? propertyResolver : fileTextResolver;
ItemChangeSets changeSets = resolver.resolve(namespaceId, configText, itemAPI.findItems(appId, env, clusterName, namespaceName));
if (changeSets.isEmpty()) {
return;
}
String operator = model.getOperator();
if (StringUtils.isBlank(operator)) {
operator = userInfoHolder.getUser().getUserId();
}
changeSets.setDataChangeLastModifiedBy(operator);
updateItems(appId, env, clusterName, namespaceName, changeSets);
Tracer.logEvent(TracerEventType.MODIFY_NAMESPACE_BY_TEXT, String.format("%s+%s+%s+%s", appId, env, clusterName, namespaceName));
Tracer.logEvent(TracerEventType.MODIFY_NAMESPACE, String.format("%s+%s+%s+%s", appId, env, clusterName, namespaceName));
}
Aggregations