use of com.ctrip.framework.apollo.common.dto.GrayReleaseRuleItemDTO in project apollo by ctripcorp.
the class OpenApiBeanUtils method transformToGrayReleaseRuleDTO.
public static GrayReleaseRuleDTO transformToGrayReleaseRuleDTO(OpenGrayReleaseRuleDTO openGrayReleaseRuleDTO) {
Preconditions.checkArgument(openGrayReleaseRuleDTO != null);
String appId = openGrayReleaseRuleDTO.getAppId();
String branchName = openGrayReleaseRuleDTO.getBranchName();
String clusterName = openGrayReleaseRuleDTO.getClusterName();
String namespaceName = openGrayReleaseRuleDTO.getNamespaceName();
GrayReleaseRuleDTO grayReleaseRuleDTO = new GrayReleaseRuleDTO(appId, clusterName, namespaceName, branchName);
Set<OpenGrayReleaseRuleItemDTO> openGrayReleaseRuleItemDTOSet = openGrayReleaseRuleDTO.getRuleItems();
openGrayReleaseRuleItemDTOSet.forEach(openGrayReleaseRuleItemDTO -> {
String clientAppId = openGrayReleaseRuleItemDTO.getClientAppId();
Set<String> clientIpList = openGrayReleaseRuleItemDTO.getClientIpList();
Set<String> clientLabelList = openGrayReleaseRuleItemDTO.getClientLabelList();
GrayReleaseRuleItemDTO ruleItem = new GrayReleaseRuleItemDTO(clientAppId, clientIpList, clientLabelList);
grayReleaseRuleDTO.addRuleItem(ruleItem);
});
return grayReleaseRuleDTO;
}
use of com.ctrip.framework.apollo.common.dto.GrayReleaseRuleItemDTO in project apollo by ctripcorp.
the class GrayPublishEmailBuilder method renderGrayReleaseRuleContent.
private String renderGrayReleaseRuleContent(String bodyTemplate, ReleaseHistoryBO releaseHistory) {
Map<String, Object> context = releaseHistory.getOperationContext();
Object rules = context.get("rules");
List<GrayReleaseRuleItemDTO> ruleItems = rules == null ? null : gson.fromJson(rules.toString(), GsonType.RULE_ITEMS);
if (CollectionUtils.isEmpty(ruleItems)) {
return bodyTemplate.replaceAll(EMAIL_CONTENT_GRAY_RULES_MODULE, "<br><h4>无灰度规则</h4>");
}
StringBuilder rulesHtmlBuilder = new StringBuilder();
for (GrayReleaseRuleItemDTO ruleItem : ruleItems) {
String clientAppId = ruleItem.getClientAppId();
Set<String> ips = ruleItem.getClientIpList();
rulesHtmlBuilder.append("<b>AppId: </b>").append(clientAppId).append(" <b>IP: </b>");
IP_JOINER.appendTo(rulesHtmlBuilder, ips);
}
String grayRulesModuleContent = portalConfig.emailGrayRulesModuleTemplate().replaceAll(EMAIL_CONTENT_GRAY_RULES_CONTENT, Matcher.quoteReplacement(rulesHtmlBuilder.toString()));
return bodyTemplate.replaceAll(EMAIL_CONTENT_GRAY_RULES_MODULE, Matcher.quoteReplacement(grayRulesModuleContent));
}
Aggregations