Search in sources :

Example 11 with NamespaceDomainInfo

use of com.vip.saturn.job.console.domain.NamespaceDomainInfo in project Saturn by vipshop.

the class NamespaceManagementRestApiController method create.

@Audit(type = AuditType.REST)
@RequestMapping(value = "/namespaces", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public ResponseEntity<Object> create(@RequestBody Map<String, Object> reqParams, HttpServletRequest request) throws SaturnJobConsoleException {
    try {
        NamespaceDomainInfo namespaceInfo = constructNamespaceDomainInfo(reqParams);
        registryCenterService.createNamespace(namespaceInfo);
        return new ResponseEntity<>(HttpStatus.CREATED);
    } catch (SaturnJobConsoleException e) {
        throw e;
    } catch (Exception e) {
        throw new SaturnJobConsoleHttpException(HttpStatus.INTERNAL_SERVER_ERROR.value(), e.getMessage(), e);
    }
}
Also used : ResponseEntity(org.springframework.http.ResponseEntity) SaturnJobConsoleException(com.vip.saturn.job.console.exception.SaturnJobConsoleException) NamespaceDomainInfo(com.vip.saturn.job.console.domain.NamespaceDomainInfo) SaturnJobConsoleHttpException(com.vip.saturn.job.console.exception.SaturnJobConsoleHttpException) SaturnJobConsoleException(com.vip.saturn.job.console.exception.SaturnJobConsoleException) SaturnJobConsoleHttpException(com.vip.saturn.job.console.exception.SaturnJobConsoleHttpException) Audit(com.vip.saturn.job.console.aop.annotation.Audit) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 12 with NamespaceDomainInfo

use of com.vip.saturn.job.console.domain.NamespaceDomainInfo in project Saturn by vipshop.

the class NamespaceManagementRestApiController method constructNamespaceDomainInfo.

private NamespaceDomainInfo constructNamespaceDomainInfo(Map<String, Object> reqParams) throws SaturnJobConsoleException {
    NamespaceDomainInfo namespaceInfo = new NamespaceDomainInfo();
    namespaceInfo.setNamespace(checkAndGetParametersValueAsString(reqParams, "namespace", true));
    namespaceInfo.setZkCluster(checkAndGetParametersValueAsString(reqParams, "zkCluster", true));
    namespaceInfo.setContent("");
    return namespaceInfo;
}
Also used : NamespaceDomainInfo(com.vip.saturn.job.console.domain.NamespaceDomainInfo)

Aggregations

NamespaceDomainInfo (com.vip.saturn.job.console.domain.NamespaceDomainInfo)12 SaturnJobConsoleHttpException (com.vip.saturn.job.console.exception.SaturnJobConsoleHttpException)7 SaturnJobConsoleException (com.vip.saturn.job.console.exception.SaturnJobConsoleException)5 ResponseEntity (org.springframework.http.ResponseEntity)4 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)4 AbstractSaturnConsoleTest (com.vip.saturn.job.console.AbstractSaturnConsoleTest)3 Test (org.junit.Test)3 WebMvcTest (org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest)3 HttpHeaders (org.springframework.http.HttpHeaders)2 MvcResult (org.springframework.test.web.servlet.MvcResult)2 JSONObject (com.alibaba.fastjson.JSONObject)1 Audit (com.vip.saturn.job.console.aop.annotation.Audit)1 NamespaceZkClusterMapping (com.vip.saturn.job.console.mybatis.entity.NamespaceZkClusterMapping)1