use of com.orion.ops.entity.request.ApplicationConfigEnvRequest in project orion-ops by lijiahangmax.
the class ApplicationEnvServiceImpl method configAppEnv.
@Override
@Transactional(rollbackFor = Exception.class)
public void configAppEnv(ApplicationConfigRequest request) {
ApplicationEnvService self = SpringHolder.getBean(ApplicationEnvService.class);
StageType stageType = StageType.of(request.getStageType());
List<ApplicationEnvRequest> list = Lists.newList();
Long appId = request.getAppId();
Long profileId = request.getProfileId();
ApplicationConfigEnvRequest requestEnv = request.getEnv();
// 构建产物目录
String bundlePath = requestEnv.getBundlePath();
if (!Strings.isBlank(bundlePath)) {
ApplicationEnvRequest bundlePathEnv = new ApplicationEnvRequest();
bundlePathEnv.setKey(ApplicationEnvAttr.BUNDLE_PATH.getKey());
bundlePathEnv.setValue(bundlePath);
bundlePathEnv.setDescription(ApplicationEnvAttr.BUNDLE_PATH.getDescription());
list.add(bundlePathEnv);
}
// 产物传输目录
String transferPath = requestEnv.getTransferPath();
if (!Strings.isBlank(transferPath)) {
ApplicationEnvRequest transferPathEnv = new ApplicationEnvRequest();
transferPathEnv.setKey(ApplicationEnvAttr.TRANSFER_PATH.getKey());
transferPathEnv.setValue(transferPath);
transferPathEnv.setDescription(ApplicationEnvAttr.TRANSFER_PATH.getDescription());
list.add(transferPathEnv);
}
// 产物传输类型
String transferDirType = requestEnv.getTransferDirType();
if (!Strings.isBlank(transferDirType)) {
ApplicationEnvRequest transferDirTypeEnv = new ApplicationEnvRequest();
transferDirTypeEnv.setKey(ApplicationEnvAttr.TRANSFER_DIR_TYPE.getKey());
transferDirTypeEnv.setValue(TransferDirType.of(transferDirType).getValue());
transferDirTypeEnv.setDescription(ApplicationEnvAttr.TRANSFER_DIR_TYPE.getDescription());
list.add(transferDirTypeEnv);
}
// 发布序列
Integer releaseSerial = requestEnv.getReleaseSerial();
if (releaseSerial != null) {
ApplicationEnvRequest releaseSerialEnv = new ApplicationEnvRequest();
releaseSerialEnv.setKey(ApplicationEnvAttr.RELEASE_SERIAL.getKey());
releaseSerialEnv.setValue(SerialType.of(releaseSerial).getValue());
releaseSerialEnv.setDescription(ApplicationEnvAttr.RELEASE_SERIAL.getDescription());
list.add(releaseSerialEnv);
}
// 异常处理
Integer exceptionHandler = requestEnv.getExceptionHandler();
if (exceptionHandler != null) {
ApplicationEnvRequest exceptionHandlerEnv = new ApplicationEnvRequest();
exceptionHandlerEnv.setKey(ApplicationEnvAttr.EXCEPTION_HANDLER.getKey());
exceptionHandlerEnv.setValue(ExceptionHandlerType.of(exceptionHandler).getValue());
exceptionHandlerEnv.setDescription(ApplicationEnvAttr.EXCEPTION_HANDLER.getDescription());
list.add(exceptionHandlerEnv);
}
// 构建检查是否有构建序列
if (StageType.BUILD.equals(stageType)) {
self.checkInitSystemEnv(appId, profileId);
}
// 添加环境变量
for (ApplicationEnvRequest env : list) {
env.setAppId(appId);
env.setProfileId(profileId);
self.addAppEnv(env);
}
}
Aggregations