From 098d3347a0df808908aab8c554cd7c4febc5e6d9 Mon Sep 17 00:00:00 2001 From: 疯狂的狮子Li <15040126243@163.com> Date: 星期一, 26 八月 2024 11:43:59 +0800 Subject: [PATCH] !577 发布 5.2.2 正式版 安全性提升 Merge pull request !577 from 疯狂的狮子Li/dev --- ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/service/impl/ActProcessDefinitionServiceImpl.java | 42 ++++++++++++++++++++++++------------------ 1 files changed, 24 insertions(+), 18 deletions(-) diff --git a/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/service/impl/ActProcessDefinitionServiceImpl.java b/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/service/impl/ActProcessDefinitionServiceImpl.java index bbdc4bf..77fb257 100644 --- a/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/service/impl/ActProcessDefinitionServiceImpl.java +++ b/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/service/impl/ActProcessDefinitionServiceImpl.java @@ -9,6 +9,7 @@ import cn.hutool.core.util.StrUtil; import lombok.RequiredArgsConstructor; import lombok.SneakyThrows; +import lombok.extern.slf4j.Slf4j; import org.dromara.common.core.exception.ServiceException; import org.dromara.common.core.utils.StreamUtils; import org.dromara.common.core.utils.StringUtils; @@ -36,6 +37,7 @@ import org.flowable.engine.history.HistoricProcessInstance; import org.flowable.engine.impl.bpmn.deployer.ResourceNameUtil; import org.flowable.engine.repository.*; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.web.multipart.MultipartFile; @@ -55,16 +57,19 @@ * * @author may */ +@Slf4j @RequiredArgsConstructor @Service public class ActProcessDefinitionServiceImpl implements IActProcessDefinitionService { - private final RepositoryService repositoryService; - private final ProcessMigrationService processMigrationService; + @Autowired(required = false) + private RepositoryService repositoryService; + @Autowired(required = false) + private ProcessMigrationService processMigrationService; private final IWfCategoryService wfCategoryService; - private final IWfDefinitionConfigService iWfDefinitionConfigService; + private final IWfDefinitionConfigService wfDefinitionConfigService; private final WfDefinitionConfigMapper wfDefinitionConfigMapper; - private final IWfNodeConfigService iWfNodeConfigService; + private final IWfNodeConfigService wfNodeConfigService; /** * 鍒嗛〉鏌ヨ @@ -95,7 +100,7 @@ } if (CollUtil.isNotEmpty(definitionList)) { List<String> ids = StreamUtils.toList(definitionList, ProcessDefinition::getId); - List<WfDefinitionConfigVo> wfDefinitionConfigVos = iWfDefinitionConfigService.queryList(ids); + List<WfDefinitionConfigVo> wfDefinitionConfigVos = wfDefinitionConfigService.queryList(ids); for (ProcessDefinition processDefinition : definitionList) { ProcessDefinitionVo processDefinitionVo = BeanUtil.toBean(processDefinition, ProcessDefinitionVo.class); if (CollUtil.isNotEmpty(deploymentList)) { @@ -135,7 +140,7 @@ } if (CollUtil.isNotEmpty(definitionList)) { List<String> ids = StreamUtils.toList(definitionList, ProcessDefinition::getId); - List<WfDefinitionConfigVo> wfDefinitionConfigVos = iWfDefinitionConfigService.queryList(ids); + List<WfDefinitionConfigVo> wfDefinitionConfigVos = wfDefinitionConfigService.queryList(ids); for (ProcessDefinition processDefinition : definitionList) { ProcessDefinitionVo processDefinitionVo = BeanUtil.toBean(processDefinition, ProcessDefinitionVo.class); if (CollUtil.isNotEmpty(deploymentList)) { @@ -203,12 +208,12 @@ repositoryService.deleteDeployment(deploymentId); } //鍒犻櫎娴佺▼瀹氫箟閰嶇疆 - iWfDefinitionConfigService.deleteByDefIds(processDefinitionIds); + wfDefinitionConfigService.deleteByDefIds(processDefinitionIds); //鍒犻櫎鑺傜偣閰嶇疆 - iWfNodeConfigService.deleteByDefIds(processDefinitionIds); + wfNodeConfigService.deleteByDefIds(processDefinitionIds); return true; } catch (Exception e) { - e.printStackTrace(); + log.error(e.getMessage(), e); throw new ServiceException(e.getMessage()); } } @@ -233,7 +238,7 @@ } return true; } catch (Exception e) { - e.printStackTrace(); + log.error(e.getMessage(), e); throw new ServiceException("鎿嶄綔澶辫触:" + e.getMessage()); } } @@ -262,6 +267,7 @@ .migrateProcessInstances(fromProcessDefinitionId); return true; } catch (Exception e) { + log.error(e.getMessage(), e); throw new ServiceException(e.getMessage()); } } @@ -285,13 +291,14 @@ Model modelData = repositoryService.newModel(); modelData.setKey(pd.getKey()); modelData.setName(pd.getName()); + modelData.setCategory(pd.getCategory()); modelData.setTenantId(pd.getTenantId()); repositoryService.saveModel(modelData); repositoryService.addModelEditorSource(modelData.getId(), IoUtil.readBytes(inputStream)); } return true; } catch (Exception e) { - e.printStackTrace(); + log.error(e.getMessage(), e); throw new ServiceException(e.getMessage()); } } @@ -347,8 +354,7 @@ initWfDefConfig(); } else { String originalFilename = file.getOriginalFilename(); - String bpmnResourceSuffix = ResourceNameUtil.BPMN_RESOURCE_SUFFIXES[0]; - if (originalFilename.contains(bpmnResourceSuffix)) { + if (StringUtils.containsAny(originalFilename, ResourceNameUtil.BPMN_RESOURCE_SUFFIXES)) { // 鏂囦欢鍚� = 娴佺▼鍚嶇О-娴佺▼key String[] splitFilename = originalFilename.substring(0, originalFilename.lastIndexOf(".")).split("-"); if (splitFilename.length < 2) { @@ -387,7 +393,7 @@ wfDefinitionConfigBo.setProcessKey(processDefinition.getKey()); wfDefinitionConfigBo.setTableName("test_leave"); wfDefinitionConfigBo.setVersion(processDefinition.getVersion()); - iWfDefinitionConfigService.saveOrUpdate(wfDefinitionConfigBo); + wfDefinitionConfigService.saveOrUpdate(wfDefinitionConfigBo); } } @@ -402,16 +408,16 @@ private void setWfConfig(ProcessDefinition oldProcessDefinition, ProcessDefinition definition) { //鏇存柊娴佺▼瀹氫箟琛ㄥ崟 if (oldProcessDefinition != null) { - WfDefinitionConfigVo definitionVo = iWfDefinitionConfigService.getByDefId(oldProcessDefinition.getId()); + WfDefinitionConfigVo definitionVo = wfDefinitionConfigService.getByDefId(oldProcessDefinition.getId()); if (definitionVo != null) { - iWfDefinitionConfigService.deleteByDefIds(Collections.singletonList(oldProcessDefinition.getId())); + wfDefinitionConfigService.deleteByDefIds(Collections.singletonList(oldProcessDefinition.getId())); WfDefinitionConfigBo wfDefinitionConfigBo = new WfDefinitionConfigBo(); wfDefinitionConfigBo.setDefinitionId(definition.getId()); wfDefinitionConfigBo.setProcessKey(definition.getKey()); wfDefinitionConfigBo.setTableName(definitionVo.getTableName()); wfDefinitionConfigBo.setVersion(definition.getVersion()); wfDefinitionConfigBo.setRemark(definitionVo.getRemark()); - iWfDefinitionConfigService.saveOrUpdate(wfDefinitionConfigBo); + wfDefinitionConfigService.saveOrUpdate(wfDefinitionConfigBo); } } //鏇存柊娴佺▼鑺傜偣閰嶇疆琛ㄥ崟 @@ -432,7 +438,7 @@ } } if (CollUtil.isNotEmpty(wfNodeConfigList)) { - iWfNodeConfigService.saveOrUpdate(wfNodeConfigList); + wfNodeConfigService.saveOrUpdate(wfNodeConfigList); } } } -- Gitblit v1.9.3