Search in sources :

Example 1 with EventLog

use of com.orion.ops.annotation.EventLog in project orion-ops by lijiahangmax.

the class ApplicationReleaseController method submitAppRelease.

/**
 * 提交发布
 */
@RequestMapping("/submit")
@EventLog(EventType.SUBMIT_RELEASE)
public Long submitAppRelease(@RequestBody ApplicationReleaseRequest request) {
    Valid.notBlank(request.getTitle());
    Valid.notNull(request.getAppId());
    Valid.notNull(request.getProfileId());
    Valid.notNull(request.getBuildId());
    Valid.notEmpty(request.getMachineIdList());
    TimedReleaseType timedReleaseType = Valid.notNull(TimedReleaseType.of(request.getTimedRelease()));
    if (TimedReleaseType.TIMED.equals(timedReleaseType)) {
        Date timedReleaseTime = Valid.notNull(request.getTimedReleaseTime());
        Valid.isTrue(timedReleaseTime.compareTo(new Date()) > 0, MessageConst.TIMED_GREATER_THAN_NOW);
    }
    // 提交
    Long id = applicationReleaseService.submitAppRelease(request);
    // 提交任务
    if (TimedReleaseType.TIMED.equals(timedReleaseType)) {
        taskRegister.submit(TaskType.RELEASE, request.getTimedReleaseTime(), id);
    }
    return id;
}
Also used : TimedReleaseType(com.orion.ops.consts.app.TimedReleaseType) Date(java.util.Date) EventLog(com.orion.ops.annotation.EventLog) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 2 with EventLog

use of com.orion.ops.annotation.EventLog in project orion-ops by lijiahangmax.

the class SftpController method uploadFile.

/**
 * 上传文件
 */
@RequestMapping("/upload/exec")
@EventLog(EventType.SFTP_UPLOAD)
public void uploadFile(@RequestParam("accessToken") String accessToken, @RequestParam("remotePath") String remotePath, @RequestParam("files") List<MultipartFile> files) throws IOException {
    // 检查路径
    Valid.checkNormalize(remotePath);
    Valid.notBlank(accessToken);
    Valid.notEmpty(files);
    // 检查token
    Long machineId = sftpService.checkUploadAccessToken(accessToken);
    List<FileUploadRequest> requestFiles = Lists.newList();
    for (MultipartFile file : files) {
        // 传输文件到本地
        String fileToken = ObjectIds.next();
        String localPath = PathBuilders.getSftpUploadFilePath(fileToken);
        Path localAbsolutePath = Paths.get(SystemEnvAttr.SWAP_PATH.getValue(), localPath);
        Files1.touch(localAbsolutePath);
        file.transferTo(localAbsolutePath);
        // 提交任务
        FileUploadRequest request = new FileUploadRequest();
        request.setMachineId(machineId);
        request.setFileToken(fileToken);
        request.setLocalPath(localPath);
        request.setRemotePath(Files1.getPath(remotePath, file.getOriginalFilename()));
        request.setSize(file.getSize());
        requestFiles.add(request);
    }
    sftpService.upload(machineId, requestFiles);
}
Also used : Path(java.nio.file.Path) MultipartFile(org.springframework.web.multipart.MultipartFile) EventLog(com.orion.ops.annotation.EventLog)

Example 3 with EventLog

use of com.orion.ops.annotation.EventLog in project orion-ops by lijiahangmax.

the class SystemController method cleanSystemFile.

/**
 * 清理系统文件
 */
@RequestMapping("/clean-system-file")
@EventLog(EventType.CLEAN_SYSTEM_FILE)
@RequireRole(RoleType.ADMINISTRATOR)
public HttpWrapper<?> cleanSystemFile(@RequestBody SystemFileCleanRequest request) {
    SystemCleanType cleanType = Valid.notNull(SystemCleanType.of(request.getCleanType()));
    systemService.cleanSystemFile(cleanType);
    return HttpWrapper.ok();
}
Also used : SystemCleanType(com.orion.ops.consts.system.SystemCleanType) EventLog(com.orion.ops.annotation.EventLog) RequireRole(com.orion.ops.annotation.RequireRole) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 4 with EventLog

use of com.orion.ops.annotation.EventLog in project orion-ops by lijiahangmax.

the class SystemEnvController method viewSave.

/**
 * 视图保存
 */
@RequestMapping("/view-save")
@EventLog(EventType.SAVE_SYSTEM_ENV)
public Integer viewSave(@RequestBody SystemEnvRequest request) {
    String value = Valid.notBlank(request.getValue());
    EnvViewType viewType = Valid.notNull(EnvViewType.of(request.getViewType()));
    try {
        MutableLinkedHashMap<String, String> result = viewType.toMap(value);
        systemEnvService.saveEnv(result);
        return result.size();
    } catch (Exception e) {
        throw Exceptions.argument(MessageConst.PARSE_ERROR, e);
    }
}
Also used : EnvViewType(com.orion.ops.consts.env.EnvViewType) EventLog(com.orion.ops.annotation.EventLog) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 5 with EventLog

use of com.orion.ops.annotation.EventLog in project orion-ops by lijiahangmax.

the class MachineInfoController method add.

/**
 * 添加
 */
@RequestMapping("/add")
@EventLog(EventType.ADD_MACHINE)
public Long add(@RequestBody MachineInfoRequest request) {
    this.check(request);
    MachineAuthType machineAuthTypeEnum = Valid.notNull(MachineAuthType.of(request.getAuthType()));
    if (MachineAuthType.PASSWORD.equals(machineAuthTypeEnum)) {
        Valid.notBlank(request.getPassword());
    }
    return machineInfoService.addMachine(request);
}
Also used : MachineAuthType(com.orion.ops.consts.machine.MachineAuthType) EventLog(com.orion.ops.annotation.EventLog) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

EventLog (com.orion.ops.annotation.EventLog)10 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)8 RequireRole (com.orion.ops.annotation.RequireRole)3 Date (java.util.Date)2 AuditStatus (com.orion.ops.consts.AuditStatus)1 TimedReleaseType (com.orion.ops.consts.app.TimedReleaseType)1 VcsAuthType (com.orion.ops.consts.app.VcsAuthType)1 EnvViewType (com.orion.ops.consts.env.EnvViewType)1 MachineAuthType (com.orion.ops.consts.machine.MachineAuthType)1 SftpPackageType (com.orion.ops.consts.sftp.SftpPackageType)1 SystemCleanType (com.orion.ops.consts.system.SystemCleanType)1 SystemConfigKey (com.orion.ops.consts.system.SystemConfigKey)1 Path (java.nio.file.Path)1 MultipartFile (org.springframework.web.multipart.MultipartFile)1