use of com.ctrip.framework.apollo.biz.entity.Cluster in project apollo by ctripcorp.
the class ClusterService method saveWithInstanceOfAppNamespaces.
@Transactional
public Cluster saveWithInstanceOfAppNamespaces(Cluster entity) {
Cluster savedCluster = saveWithoutInstanceOfAppNamespaces(entity);
namespaceService.instanceOfAppNamespaces(savedCluster.getAppId(), savedCluster.getName(), savedCluster.getDataChangeCreatedBy());
return savedCluster;
}
use of com.ctrip.framework.apollo.biz.entity.Cluster in project apollo by ctripcorp.
the class ClusterService method update.
@Transactional
public Cluster update(Cluster cluster) {
Cluster managedCluster = clusterRepository.findByAppIdAndName(cluster.getAppId(), cluster.getName());
BeanUtils.copyEntityProperties(cluster, managedCluster);
managedCluster = clusterRepository.save(managedCluster);
auditService.audit(Cluster.class.getSimpleName(), managedCluster.getId(), Audit.OP.UPDATE, managedCluster.getDataChangeLastModifiedBy());
return managedCluster;
}
use of com.ctrip.framework.apollo.biz.entity.Cluster in project apollo by ctripcorp.
the class AdminService method deleteApp.
@Transactional
public void deleteApp(App app, String operator) {
String appId = app.getAppId();
logger.info("{} is deleting App:{}", operator, appId);
List<Cluster> managedClusters = clusterService.findParentClusters(appId);
// 1. delete clusters
if (Objects.nonNull(managedClusters)) {
for (Cluster cluster : managedClusters) {
clusterService.delete(cluster.getId(), operator);
}
}
// 2. delete appNamespace
appNamespaceService.batchDelete(appId, operator);
// 3. delete app
appService.delete(app.getId(), operator);
}
use of com.ctrip.framework.apollo.biz.entity.Cluster in project apollo by ctripcorp.
the class ClusterController method create.
@PostMapping("/apps/{appId}/clusters")
public ClusterDTO create(@PathVariable("appId") String appId, @RequestParam(value = "autoCreatePrivateNamespace", defaultValue = "true") boolean autoCreatePrivateNamespace, @Valid @RequestBody ClusterDTO dto) {
Cluster entity = BeanUtils.transform(Cluster.class, dto);
Cluster managedEntity = clusterService.findOne(appId, entity.getName());
if (managedEntity != null) {
throw new BadRequestException("cluster already exist.");
}
if (autoCreatePrivateNamespace) {
entity = clusterService.saveWithInstanceOfAppNamespaces(entity);
} else {
entity = clusterService.saveWithoutInstanceOfAppNamespaces(entity);
}
return BeanUtils.transform(ClusterDTO.class, entity);
}
use of com.ctrip.framework.apollo.biz.entity.Cluster in project apollo by ctripcorp.
the class ClusterControllerTest method testDeleteSuccess.
@Test
public void testDeleteSuccess() {
Cluster cluster = new Cluster();
when(clusterService.findOne(any(String.class), any(String.class))).thenReturn(cluster);
clusterController.delete("1", "2", "d");
verify(clusterService, times(1)).findOne("1", "2");
}
Aggregations