Search in sources :

Example 11 with ServiceException

use of com.ctrip.framework.apollo.common.exception.ServiceException 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);
}
Also used : ServiceException(com.ctrip.framework.apollo.common.exception.ServiceException) Cluster(com.ctrip.framework.apollo.biz.entity.Cluster) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

ServiceException (com.ctrip.framework.apollo.common.exception.ServiceException)11 Transactional (org.springframework.transaction.annotation.Transactional)4 App (com.ctrip.framework.apollo.common.entity.App)3 ServiceDTO (com.ctrip.framework.apollo.core.dto.ServiceDTO)3 IOException (java.io.IOException)3 AppNamespace (com.ctrip.framework.apollo.common.entity.AppNamespace)2 Transaction (com.ctrip.framework.apollo.tracer.spi.Transaction)2 Cluster (com.ctrip.framework.apollo.biz.entity.Cluster)1 Namespace (com.ctrip.framework.apollo.biz.entity.Namespace)1 AppDTO (com.ctrip.framework.apollo.common.dto.AppDTO)1 BadRequestException (com.ctrip.framework.apollo.common.exception.BadRequestException)1 NamespaceBO (com.ctrip.framework.apollo.portal.entity.bo.NamespaceBO)1 InputStream (java.io.InputStream)1 ZipInputStream (java.util.zip.ZipInputStream)1 ZipOutputStream (java.util.zip.ZipOutputStream)1 Test (org.junit.Test)1 HttpEntity (org.springframework.http.HttpEntity)1 HttpHeaders (org.springframework.http.HttpHeaders)1 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)1 GetMapping (org.springframework.web.bind.annotation.GetMapping)1