use of com.ctrip.framework.apollo.portal.entity.vo.NamespaceIdentifier in project apollo by ctripcorp.
the class ItemService method syncItems.
public void syncItems(List<NamespaceIdentifier> comparedNamespaces, List<ItemDTO> sourceItems) {
List<ItemDiffs> itemDiffs = compare(comparedNamespaces, sourceItems);
for (ItemDiffs itemDiff : itemDiffs) {
NamespaceIdentifier namespaceIdentifier = itemDiff.getNamespace();
ItemChangeSets changeSets = itemDiff.getDiffs();
changeSets.setDataChangeLastModifiedBy(userInfoHolder.getUser().getUserId());
String appId = namespaceIdentifier.getAppId();
Env env = namespaceIdentifier.getEnv();
String clusterName = namespaceIdentifier.getClusterName();
String namespaceName = namespaceIdentifier.getNamespaceName();
itemAPI.updateItemsByChangeSet(appId, env, clusterName, namespaceName, changeSets);
Tracer.logEvent(TracerEventType.SYNC_NAMESPACE, String.format("%s+%s+%s+%s", appId, env, clusterName, namespaceName));
}
}
use of com.ctrip.framework.apollo.portal.entity.vo.NamespaceIdentifier in project apollo by ctripcorp.
the class ItemService method compare.
public List<ItemDiffs> compare(List<NamespaceIdentifier> comparedNamespaces, List<ItemDTO> sourceItems) {
List<ItemDiffs> result = new LinkedList<>();
for (NamespaceIdentifier namespace : comparedNamespaces) {
ItemDiffs itemDiffs = new ItemDiffs(namespace);
try {
itemDiffs.setDiffs(parseChangeSets(namespace, sourceItems));
} catch (BadRequestException e) {
itemDiffs.setDiffs(new ItemChangeSets());
itemDiffs.setExtInfo("该集群下没有名为 " + namespace.getNamespaceName() + " 的namespace");
}
result.add(itemDiffs);
}
return result;
}
Aggregations