This is an automated email from the ASF dual-hosted git repository.
benjobs pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/incubator-streampark.git
The following commit(s) were added to refs/heads/dev by this push:
new bdcf4c820 [Improve] project src path improvements and Check project
name add team query condition (#3650)
bdcf4c820 is described below
commit bdcf4c82032a8227e40cc7aa64782dd7cfbe4552
Author: Cancai Cai <[email protected]>
AuthorDate: Mon Apr 1 17:10:09 2024 +0800
[Improve] project src path improvements and Check project name add team
query condition (#3650)
---
.../streampark/console/core/entity/Project.java | 37 ++++++++++++++--------
.../core/service/impl/ProjectServiceImpl.java | 4 ++-
2 files changed, 27 insertions(+), 14 deletions(-)
diff --git
a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/entity/Project.java
b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/entity/Project.java
index 8efaa0eee..40439be42 100644
---
a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/entity/Project.java
+++
b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/entity/Project.java
@@ -107,27 +107,38 @@ public class Project implements Serializable {
private transient String dateTo;
- /** project source */
- private transient String appSource;
-
/** get project source */
@JsonIgnore
public File getAppSource() {
- if (StringUtils.isBlank(appSource)) {
- appSource = Workspace.PROJECT_LOCAL_PATH();
- }
- File sourcePath = new File(appSource);
+ File sourcePath = new File(Workspace.PROJECT_LOCAL_PATH());
if (!sourcePath.exists()) {
sourcePath.mkdirs();
+ } else if (sourcePath.isFile()) {
+ throw new IllegalArgumentException(
+ "[StreamPark] project source base path: "
+ + sourcePath.getAbsolutePath()
+ + " must be directory");
}
- if (sourcePath.isFile()) {
- throw new IllegalArgumentException("[StreamPark] sourcePath must be
directory");
+
+ String sourceDir = getSourceDirName();
+ File srcFile =
+ new File(String.format("%s/%s/%s", sourcePath.getAbsolutePath(), name,
sourceDir));
+ String newPath = String.format("%s/%s", sourcePath.getAbsolutePath(), id);
+ if (srcFile.exists()) {
+ File newFile = new File(newPath);
+ if (!newFile.exists()) {
+ newFile.mkdirs();
+ }
+ // old project path move to new path
+ srcFile.getParentFile().renameTo(newFile);
}
- String branches = StringUtils.isBlank(this.getBranches()) ? "main" :
this.getBranches();
+ return new File(newPath, sourceDir);
+ }
+
+ private String getSourceDirName() {
+ String branches = this.getBranches() == null ? "main" : this.getBranches();
String rootName = url.replaceAll(".*/|\\.git|\\.svn", "");
- String fullName = rootName.concat("-").concat(branches);
- String path = String.format("%s/%s/%s", sourcePath.getAbsolutePath(),
getName(), fullName);
- return new File(path);
+ return rootName.concat("-").concat(branches);
}
@JsonIgnore
diff --git
a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/impl/ProjectServiceImpl.java
b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/impl/ProjectServiceImpl.java
index 1bc047830..13f5a137b 100644
---
a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/impl/ProjectServiceImpl.java
+++
b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/service/impl/ProjectServiceImpl.java
@@ -315,7 +315,9 @@ public class ProjectServiceImpl extends
ServiceImpl<ProjectMapper, Project>
}
}
LambdaQueryWrapper<Project> queryWrapper =
- new LambdaQueryWrapper<Project>().eq(Project::getName,
project.getName());
+ new LambdaQueryWrapper<Project>()
+ .eq(Project::getName, project.getName())
+ .eq(Project::getTeamId, project.getTeamId());
return this.baseMapper.selectCount(queryWrapper) > 0;
}