Search in sources :

Example 21 with Audit

use of com.vip.saturn.job.console.aop.annotation.Audit in project Saturn by vipshop.

the class AuthorizationManageController method deleteUserRole.

@ApiResponses(value = { @ApiResponse(code = 200, message = "Success/Fail", response = RequestResult.class) })
@Audit
@PostMapping("/deleteUserRole")
public SuccessResponseEntity deleteUserRole(@AuditParam("userName") @RequestParam String userName, @AuditParam("roleKey") @RequestParam String roleKey, @AuditParam("namespace") @RequestParam String namespace) throws SaturnJobConsoleException {
    assertIsSystemAdmin();
    UserRole userRole = new UserRole();
    userRole.setUserName(userName);
    userRole.setRoleKey(roleKey);
    userRole.setNamespace(namespace);
    String currentLoginUserName = getCurrentLoginUserName();
    userRole.setLastUpdatedBy(currentLoginUserName);
    authorizationManageService.deleteUserRole(userRole);
    return new SuccessResponseEntity();
}
Also used : UserRole(com.vip.saturn.job.console.mybatis.entity.UserRole) SuccessResponseEntity(com.vip.saturn.job.console.controller.SuccessResponseEntity) Audit(com.vip.saturn.job.console.aop.annotation.Audit) PostMapping(org.springframework.web.bind.annotation.PostMapping) ApiResponses(io.swagger.annotations.ApiResponses)

Example 22 with Audit

use of com.vip.saturn.job.console.aop.annotation.Audit in project Saturn by vipshop.

the class JobOverviewController method exportSelectedJobs.

// 导出选定的作业
@ApiResponses(value = { @ApiResponse(code = 200, message = "Success/Fail", response = RequestResult.class) })
@Audit
@GetMapping(value = "/exportSelected")
public void exportSelectedJobs(final HttpServletRequest request, @AuditParam("namespace") @PathVariable String namespace, @RequestParam(required = false) List<String> jobList, final HttpServletResponse response) throws SaturnJobConsoleException {
    // assertIsPermitted(PermissionKeys.jobExport, namespace);
    File exportJobFile = jobService.exportSelectedJobs(namespace, jobList);
    String currentTime = new SimpleDateFormat("yyyyMMddHHmmss").format(new Date());
    String exportFileName = namespace + "_" + currentTime + ".xls";
    SaturnConsoleUtils.exportFile(response, exportJobFile, exportFileName, true);
}
Also used : File(java.io.File) MultipartFile(org.springframework.web.multipart.MultipartFile) SimpleDateFormat(java.text.SimpleDateFormat) Audit(com.vip.saturn.job.console.aop.annotation.Audit) ApiResponses(io.swagger.annotations.ApiResponses)

Example 23 with Audit

use of com.vip.saturn.job.console.aop.annotation.Audit in project Saturn by vipshop.

the class ZkDiscoveryRestApiController method discoverZk.

@Audit(type = AuditType.REST)
@RequestMapping(value = "/discoverZk", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public ResponseEntity<Object> discoverZk(String namespace, HttpServletRequest request) throws SaturnJobConsoleException {
    HttpHeaders headers = new HttpHeaders();
    try {
        checkMissingParameter("namespace", namespace);
        String zkClusterKey = namespaceZkclusterMapping4SqlService.getZkClusterKey(namespace);
        if (zkClusterKey == null) {
            throw new SaturnJobConsoleHttpException(HttpStatus.NOT_FOUND.value(), "The namespace:[" + namespace + "] is not registered in Saturn.");
        }
        ZkClusterInfo zkClusterInfo = zkClusterInfoService.getByClusterKey(zkClusterKey);
        if (zkClusterInfo == null) {
            throw new SaturnJobConsoleHttpException(HttpStatus.INTERNAL_SERVER_ERROR.value(), "The clusterKey: [" + zkClusterKey + "] is not configured in db for " + namespace);
        }
        return new ResponseEntity<Object>(zkClusterInfo.getConnectString(), headers, HttpStatus.OK);
    } catch (SaturnJobConsoleException e) {
        throw e;
    } catch (Exception e) {
        throw new SaturnJobConsoleHttpException(HttpStatus.INTERNAL_SERVER_ERROR.value(), e.getMessage(), e);
    }
}
Also used : HttpHeaders(org.springframework.http.HttpHeaders) ResponseEntity(org.springframework.http.ResponseEntity) SaturnJobConsoleException(com.vip.saturn.job.console.exception.SaturnJobConsoleException) SaturnJobConsoleHttpException(com.vip.saturn.job.console.exception.SaturnJobConsoleHttpException) ZkClusterInfo(com.vip.saturn.job.console.mybatis.entity.ZkClusterInfo) 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 24 with Audit

use of com.vip.saturn.job.console.aop.annotation.Audit in project Saturn by vipshop.

the class ConsoleConfigController method createConfig.

/**
 * 创建配置项。
 *
 * @param key 配置key
 * @param value 配置值
 */
@ApiResponses(value = { @ApiResponse(code = 200, message = "Success/Fail", response = RequestResult.class) })
@Audit
@PostMapping("/create")
public SuccessResponseEntity createConfig(@AuditParam(value = "key") @RequestParam String key, @AuditParam(value = "value") @RequestParam String value) throws SaturnJobConsoleException {
    assertIsPermitted(PermissionKeys.systemConfig);
    // 不能更新EXECUTOR_CONFIGS
    if (SystemConfigProperties.EXECUTOR_CONFIGS.equals(key)) {
        throw new SaturnJobConsoleException(String.format("配置项不能为%s", key));
    }
    SystemConfig systemConfig = new SystemConfig();
    systemConfig.setProperty(key);
    systemConfig.setValue(value);
    systemConfigService.createConfig(systemConfig);
    return new SuccessResponseEntity();
}
Also used : SystemConfig(com.vip.saturn.job.console.mybatis.entity.SystemConfig) SaturnJobConsoleException(com.vip.saturn.job.console.exception.SaturnJobConsoleException) SuccessResponseEntity(com.vip.saturn.job.console.controller.SuccessResponseEntity) Audit(com.vip.saturn.job.console.aop.annotation.Audit) PostMapping(org.springframework.web.bind.annotation.PostMapping) ApiResponses(io.swagger.annotations.ApiResponses)

Aggregations

Audit (com.vip.saturn.job.console.aop.annotation.Audit)24 SaturnJobConsoleException (com.vip.saturn.job.console.exception.SaturnJobConsoleException)13 SaturnJobConsoleHttpException (com.vip.saturn.job.console.exception.SaturnJobConsoleHttpException)12 ApiResponses (io.swagger.annotations.ApiResponses)12 ResponseEntity (org.springframework.http.ResponseEntity)12 SuccessResponseEntity (com.vip.saturn.job.console.controller.SuccessResponseEntity)10 PostMapping (org.springframework.web.bind.annotation.PostMapping)10 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)8 UserRole (com.vip.saturn.job.console.mybatis.entity.UserRole)6 SystemConfig (com.vip.saturn.job.console.mybatis.entity.SystemConfig)4 Date (java.util.Date)4 HttpHeaders (org.springframework.http.HttpHeaders)3 JobConfig (com.vip.saturn.job.console.domain.JobConfig)2 AlarmInfo (com.vip.saturn.job.integrate.entity.AlarmInfo)2 File (java.io.File)2 SimpleDateFormat (java.text.SimpleDateFormat)2 MultipartFile (org.springframework.web.multipart.MultipartFile)2 JSONObject (com.alibaba.fastjson.JSONObject)1 JobDiffInfo (com.vip.saturn.job.console.domain.JobDiffInfo)1 NamespaceDomainInfo (com.vip.saturn.job.console.domain.NamespaceDomainInfo)1