Search in sources :

Example 1 with Audit

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

the class AuthorizationController method addUserRoles.

@ApiResponses(value = { @ApiResponse(code = 200, message = "Success/Fail", response = RequestResult.class) })
@Audit
@PostMapping("/addUserRoles")
public SuccessResponseEntity addUserRoles(@AuditParam("userName") @RequestParam String userName, @AuditParam("roleKey") @RequestParam String roleKey, @AuditParam("namespace") @RequestParam String namespace, @AuditParam("needApproval") @RequestParam Boolean needApproval, HttpSession httpSession) throws SaturnJobConsoleException {
    assertIsSystemAdmin();
    String currentLoginUserName = getCurrentLoginUserName();
    Date now = new Date();
    UserRole userRole = new UserRole();
    userRole.setUserName(userName);
    userRole.setRoleKey(roleKey);
    userRole.setNamespace(namespace);
    userRole.setNeedApproval(needApproval);
    userRole.setIsDeleted(false);
    userRole.setCreatedBy(currentLoginUserName);
    userRole.setCreateTime(now);
    userRole.setLastUpdatedBy(currentLoginUserName);
    userRole.setLastUpdateTime(now);
    User user = new User();
    user.setUserName(userName);
    user.setPassword("");
    user.setRealName("");
    user.setEmployeeId("");
    user.setEmail("");
    user.setCreatedBy(currentLoginUserName);
    user.setCreateTime(now);
    user.setLastUpdatedBy(currentLoginUserName);
    user.setLastUpdateTime(now);
    user.setIsDeleted(false);
    userRole.setUser(user);
    authorizationService.addUserRole(userRole);
    return new SuccessResponseEntity();
}
Also used : User(com.vip.saturn.job.console.mybatis.entity.User) UserRole(com.vip.saturn.job.console.mybatis.entity.UserRole) SuccessResponseEntity(com.vip.saturn.job.console.controller.SuccessResponseEntity) Date(java.util.Date) Audit(com.vip.saturn.job.console.aop.annotation.Audit) PostMapping(org.springframework.web.bind.annotation.PostMapping) ApiResponses(io.swagger.annotations.ApiResponses)

Example 2 with Audit

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

the class AuthorizationController 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, HttpSession httpSession) throws SaturnJobConsoleException {
    assertIsSystemAdmin();
    UserRole userRole = new UserRole();
    userRole.setUserName(userName);
    userRole.setRoleKey(roleKey);
    userRole.setNamespace(namespace);
    String currentLoginUserName = getCurrentLoginUserName();
    userRole.setLastUpdatedBy(currentLoginUserName);
    authorizationService.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 3 with Audit

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

the class SystemConfigController method createOrUpdateConfig.

/**
 * 创建或者更新配置项。
 *
 * @param key 配置key
 * @param value 配置值
 */
@ApiResponses(value = { @ApiResponse(code = 200, message = "Success/Fail", response = RequestResult.class) })
@Audit
@PostMapping
public SuccessResponseEntity createOrUpdateConfig(@AuditParam(value = "key") @RequestParam String key, @AuditParam(value = "value") @RequestParam String value) throws SaturnJobConsoleException {
    assertIsPermitted(Permissions.systemConfig);
    SystemConfig systemConfig = new SystemConfig();
    systemConfig.setProperty(key);
    systemConfig.setValue(value);
    systemConfigService.insertOrUpdate(systemConfig);
    return new SuccessResponseEntity();
}
Also used : SystemConfig(com.vip.saturn.job.console.mybatis.entity.SystemConfig) 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 4 with Audit

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

the class ConsoleConfigController method updateConfig.

/**
 * 更新配置项。
 *
 * @param key 配置key
 * @param value 配置值
 */
@ApiResponses(value = { @ApiResponse(code = 200, message = "Success/Fail", response = RequestResult.class) })
@Audit
@PostMapping("/update")
public SuccessResponseEntity updateConfig(@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.updateConfig(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)

Example 5 with Audit

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

the class NamespaceAndJobRestApiController method create.

@Audit(type = AuditType.REST)
@RequestMapping(value = "/namespaces/createNamespaceAndImportJobs", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public ResponseEntity<Object> create(@RequestBody Map<String, Object> reqParams, HttpServletRequest request) throws SaturnJobConsoleException {
    try {
        String namespace = checkAndGetParametersValueAsString(reqParams, "namespace", true);
        if (StringUtils.isBlank(namespace)) {
            throw new SaturnJobConsoleException("namespace is empty");
        }
        String zkClusterName = checkAndGetParametersValueAsString(reqParams, "zkCluster", true);
        if (StringUtils.isBlank(zkClusterName)) {
            throw new SaturnJobConsoleException("zkCluster is empty");
        }
        String srcNamespace = checkAndGetParametersValueAsString(reqParams, "srcNamespace", true);
        if (StringUtils.isBlank(srcNamespace)) {
            throw new SaturnJobConsoleException("srcNamespace is empty");
        }
        String createBy = checkAndGetParametersValueAsString(reqParams, "createBy", true);
        namespaceAndJobService.createNamespaceAndCloneJobs(srcNamespace, namespace, zkClusterName, createBy);
        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) 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)

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