use of com.ctrip.framework.apollo.biz.entity.Cluster in project apollo by ctripcorp.
the class AppNamespaceService method createNamespaceForAppNamespaceInAllCluster.
public void createNamespaceForAppNamespaceInAllCluster(String appId, String namespaceName, String createBy) {
List<Cluster> clusters = clusterService.findParentClusters(appId);
for (Cluster cluster : clusters) {
// in case there is some dirty data, e.g. public namespace deleted in other app and now created in this app
if (!namespaceService.isNamespaceUnique(appId, cluster.getName(), namespaceName)) {
continue;
}
Namespace namespace = new Namespace();
namespace.setClusterName(cluster.getName());
namespace.setAppId(appId);
namespace.setNamespaceName(namespaceName);
namespace.setDataChangeCreatedBy(createBy);
namespace.setDataChangeLastModifiedBy(createBy);
namespaceService.save(namespace);
}
}
use of com.ctrip.framework.apollo.biz.entity.Cluster in project apollo by ctripcorp.
the class ClusterService method saveWithoutInstanceOfAppNamespaces.
@Transactional
public Cluster saveWithoutInstanceOfAppNamespaces(Cluster entity) {
if (!isClusterNameUnique(entity.getAppId(), entity.getName())) {
throw new BadRequestException("cluster not unique");
}
// protection
entity.setId(0);
Cluster cluster = clusterRepository.save(entity);
auditService.audit(Cluster.class.getSimpleName(), cluster.getId(), Audit.OP.INSERT, cluster.getDataChangeCreatedBy());
return cluster;
}
use of com.ctrip.framework.apollo.biz.entity.Cluster in project apollo by ctripcorp.
the class ClusterService method delete.
@Transactional
public void delete(long id, String operator) {
Cluster cluster = clusterRepository.findById(id).orElse(null);
if (cluster == null) {
throw new BadRequestException("cluster not exist");
}
// delete linked namespaces
namespaceService.deleteByAppIdAndClusterName(cluster.getAppId(), cluster.getName(), operator);
cluster.setDeleted(true);
cluster.setDataChangeLastModifiedBy(operator);
clusterRepository.save(cluster);
auditService.audit(Cluster.class.getSimpleName(), id, Audit.OP.DELETE, operator);
}
use of com.ctrip.framework.apollo.biz.entity.Cluster in project apollo by ctripcorp.
the class ClusterService method createDefaultCluster.
@Transactional
public void createDefaultCluster(String appId, String createBy) {
if (!isClusterNameUnique(appId, ConfigConsts.CLUSTER_NAME_DEFAULT)) {
throw new ServiceException("cluster not unique");
}
Cluster cluster = new Cluster();
cluster.setName(ConfigConsts.CLUSTER_NAME_DEFAULT);
cluster.setAppId(appId);
cluster.setDataChangeCreatedBy(createBy);
cluster.setDataChangeLastModifiedBy(createBy);
clusterRepository.save(cluster);
auditService.audit(Cluster.class.getSimpleName(), cluster.getId(), Audit.OP.INSERT, createBy);
}
Aggregations