From d9669d9870154165349e8d2ee2fb51bed76d580b Mon Sep 17 00:00:00 2001 From: masumcse1 Date: Sat, 15 Apr 2023 16:58:45 +0600 Subject: [PATCH 01/41] remove symbolic link --- .../impl/MavenConfigurationService.java | 26 ++++--------------- 1 file changed, 5 insertions(+), 21 deletions(-) diff --git a/meveo-admin-ejbs/src/main/java/org/meveo/service/config/impl/MavenConfigurationService.java b/meveo-admin-ejbs/src/main/java/org/meveo/service/config/impl/MavenConfigurationService.java index a80c5923f..f0c7f8da7 100644 --- a/meveo-admin-ejbs/src/main/java/org/meveo/service/config/impl/MavenConfigurationService.java +++ b/meveo-admin-ejbs/src/main/java/org/meveo/service/config/impl/MavenConfigurationService.java @@ -303,8 +303,11 @@ public void generatePom(String message, MeveoModule module,GitRepository reposit //TODO: Avoid this code when module just got uninstalled File gitRepo = GitHelper.getRepositoryDir(currentUser.get(), module.getGitRepository()); - Paths.get(gitRepo.getPath(), "facets", "maven").toFile().mkdirs(); - + Paths.get(gitRepo.getPath(), "facets", "maven").toFile().mkdirs(); + + Path source = Paths.get(gitRepo.getPath(), "facets", "java"); + source.toFile().mkdirs(); + log.debug("Generating pom.xml file"); File pomFile = this.moduleService.findPom(module); @@ -321,25 +324,6 @@ public void generatePom(String message, MeveoModule module,GitRepository reposit model.setBuild(new Build()); } - // Create symlink for java folder - Path source = Paths.get(gitRepo.getPath(), "facets", "java"); - source.toFile().mkdirs(); - - Path link = Paths.get(gitRepo.getPath(), "facets", "maven", "src", "main", "java"); - Path relativeSrc = link.getParent().relativize(source); - - try { - - link.getParent().toFile().mkdirs(); - try { - Files.createSymbolicLink(link, relativeSrc); - } catch (FileAlreadyExistsException e) { - //NOOP - } - } catch (IOException e1) { - log.error("Failed to create symbolic link for java source", e1); - } - // Create .gitignore file Path gitIgnore = Paths.get(gitRepo.getPath(), "facets", "maven", ".gitignore"); List ignoredPatterns = List.of( From 5a75f27e3c2b3f9c1c6c3c2b343add375056abdc Mon Sep 17 00:00:00 2001 From: masumcse1 Date: Sat, 15 Apr 2023 17:01:50 +0600 Subject: [PATCH 02/41] create parent pom --- .../org/meveo/service/admin/impl/MeveoModuleService.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/meveo-admin-ejbs/src/main/java/org/meveo/service/admin/impl/MeveoModuleService.java b/meveo-admin-ejbs/src/main/java/org/meveo/service/admin/impl/MeveoModuleService.java index fa073e2ba..71ae5bd76 100644 --- a/meveo-admin-ejbs/src/main/java/org/meveo/service/admin/impl/MeveoModuleService.java +++ b/meveo-admin-ejbs/src/main/java/org/meveo/service/admin/impl/MeveoModuleService.java @@ -969,6 +969,15 @@ public File findPom(MeveoModule module) { .resolve("pom.xml") .toFile(); } + + + public File findParentPom(MeveoModule module) { + return GitHelper.getRepositoryDir(null, module.getGitRepository()) + .toPath() + .resolve("facets") + .resolve("pom.xml") + .toFile(); + } @Override public void addFilesToModule(MeveoModule entity, MeveoModule module) throws BusinessException { From 3241424c5b495950bd536337b8710e09a85c0331 Mon Sep 17 00:00:00 2001 From: masumcse1 Date: Sat, 15 Apr 2023 17:25:56 +0600 Subject: [PATCH 03/41] create parent & child pom --- .../impl/MavenConfigurationService.java | 115 ++++++++++++------ 1 file changed, 80 insertions(+), 35 deletions(-) diff --git a/meveo-admin-ejbs/src/main/java/org/meveo/service/config/impl/MavenConfigurationService.java b/meveo-admin-ejbs/src/main/java/org/meveo/service/config/impl/MavenConfigurationService.java index f0c7f8da7..042298ebb 100644 --- a/meveo-admin-ejbs/src/main/java/org/meveo/service/config/impl/MavenConfigurationService.java +++ b/meveo-admin-ejbs/src/main/java/org/meveo/service/config/impl/MavenConfigurationService.java @@ -43,6 +43,7 @@ import org.apache.maven.model.Dependency; import org.apache.maven.model.DependencyManagement; import org.apache.maven.model.Model; +import org.apache.maven.model.Parent; import org.apache.maven.model.Repository; import org.apache.maven.model.RepositoryPolicy; import org.apache.maven.model.io.xpp3.MavenXpp3Writer; @@ -301,59 +302,99 @@ private void generatePom(String message, MeveoModule module) { public void generatePom(String message, MeveoModule module,GitRepository repository) { //TODO: Avoid this code when module just got uninstalled - + File gitRepo = GitHelper.getRepositoryDir(currentUser.get(), module.getGitRepository()); - Paths.get(gitRepo.getPath(), "facets", "maven").toFile().mkdirs(); - + Paths.get(gitRepo.getPath(), "facets", "maven").toFile().mkdirs(); + Path source = Paths.get(gitRepo.getPath(), "facets", "java"); source.toFile().mkdirs(); - - log.debug("Generating pom.xml file"); - - File pomFile = this.moduleService.findPom(module); - final Model model = MavenUtils.readModel(pomFile); - - model.setGroupId("org.meveo");//TODO: Add group id to module - model.setArtifactId(module.getCode()); - model.setVersion(module.getCurrentVersion()); - model.setModelVersion("4.0.0"); - model.setDependencyManagement(null); - model.setDependencies(null); - - if (model.getPomFile() == null) { - model.setBuild(new Build()); - } - + // Create .gitignore file Path gitIgnore = Paths.get(gitRepo.getPath(), "facets", "maven", ".gitignore"); List ignoredPatterns = List.of( "src/main/java/**", "target/" ); - + String gitIgnoreFile = String.join("\n", ignoredPatterns); try { MeveoFileUtils.writeAndPreserveCharset(gitIgnoreFile, gitIgnore.toFile()); } catch (IOException e1) { log.error("Failed to create gitignore", e1); } - + + log.debug("Generating pom.xml file---***"); + + generateParentPom(message,module,repository); + + generateChildPom(message,module,repository,gitIgnore); + + } + + private void generateParentPom(String message, MeveoModule module,GitRepository repository) { + log.debug("Generating pom.xml file---parents***"); + File pomFile = this.moduleService.findParentPom(module); + final Model model = MavenUtils.readModel(pomFile); + + model.setGroupId("org.meveo");//TODO: Add group id to module + model.setArtifactId("facets"); + model.setVersion(module.getCurrentVersion()); + model.setModelVersion("4.0.0"); + model.setDependencyManagement(null); + model.setDependencies(null); + model.setPackaging("pom"); + Properties properties = new Properties(); properties.setProperty("maven.compiler.target", "11"); properties.setProperty("maven.compiler.source", "11"); model.setProperties(properties); + List modules = List.of("maven"); + model.setModules(modules); + + writeToPom(model, pomFile); + + List updatedFiles = List.of(pomFile); + + if (module.isAutoCommit()) { + try { + gitClient.commitFiles(repository, updatedFiles, message); + } catch (BusinessException e) { + log.error("Can't commit pom.xml file", e); + } + } + + } + + private void generateChildPom (String message, MeveoModule module,GitRepository repository,Path file) { + log.debug("Generating pom.xml file---childs***"); + File pomFile = this.moduleService.findPom(module); + final Model model = MavenUtils.readModel(pomFile); + + Parent parent = new Parent(); + parent.setArtifactId("facets"); + parent.setGroupId("org.meveo"); + parent.setVersion("1.0.0"); + model.setParent(parent); + + model.setGroupId("org.meveo");//TODO: Add group id to module + model.setArtifactId(module.getCode()); + model.setVersion(module.getCurrentVersion()); + model.setModelVersion("4.0.0"); + model.setDependencyManagement(null); + model.setDependencies(null); + List remoteRepositories = remoteRepositoryService.list(); if (CollectionUtils.isNotEmpty(remoteRepositories)) { for (RemoteRepository remoteRepository : remoteRepositories) { MavenUtils.addRepository(model, remoteRepository); } } - + // Include meveo bom DependencyManagement dependencyManagement = new DependencyManagement(); model.setDependencyManagement(dependencyManagement); - + Dependency meveoBom = new Dependency(); meveoBom.setGroupId("org.meveo"); meveoBom.setArtifactId("meveo"); @@ -361,7 +402,7 @@ public void generatePom(String message, MeveoModule module,GitRepository reposit meveoBom.setScope("import"); meveoBom.setVersion(System.getProperty("meveo.version", Version.appVersion)); MavenUtils.addOrUpdateDependency(dependencyManagement, meveoBom); - + Dependency wildflyBom = new Dependency(); wildflyBom.setGroupId("org.wildfly.bom"); wildflyBom.setArtifactId("wildfly-jakartaee8-with-tools"); @@ -369,7 +410,7 @@ public void generatePom(String message, MeveoModule module,GitRepository reposit wildflyBom.setScope("import"); wildflyBom.setVersion("18.0.1.Final"); MavenUtils.addOrUpdateDependency(dependencyManagement, wildflyBom); - + Dependency wildflyBom2 = new Dependency(); wildflyBom2.setGroupId("org.wildfly.bom"); wildflyBom2.setArtifactId("wildfly-jakartaee8"); @@ -377,7 +418,7 @@ public void generatePom(String message, MeveoModule module,GitRepository reposit wildflyBom2.setScope("import"); wildflyBom2.setVersion("18.0.1.Final"); MavenUtils.addOrUpdateDependency(dependencyManagement, wildflyBom2); - + Dependency wildflyBom3 = new Dependency(); wildflyBom3.setGroupId("org.wildfly"); wildflyBom3.setArtifactId("wildfly-feature-pack"); @@ -385,7 +426,7 @@ public void generatePom(String message, MeveoModule module,GitRepository reposit wildflyBom3.setScope("import"); wildflyBom3.setVersion("18.0.1.Final"); MavenUtils.addOrUpdateDependency(dependencyManagement, wildflyBom3); - + // Use maven pkg repo before meveo instance repo Repository githubRepo = new Repository(); githubRepo.setId("github"); @@ -403,14 +444,14 @@ public void generatePom(String message, MeveoModule module,GitRepository reposit } ownInstance.setUrl(baseUrl + System.getProperty("meveo.moduleName", "meveo") + "/maven"); MavenUtils.addRepository(model, ownInstance); - + Dependency meveoDependency = new Dependency(); meveoDependency.setGroupId("org.meveo"); meveoDependency.setArtifactId("meveo-api"); meveoDependency.setVersion(System.getProperty("meveo.version", Version.appVersion)); meveoDependency.setScope("import"); MavenUtils.addOrUpdateDependency(dependencyManagement, meveoDependency); - + module.getModuleDependencies().forEach(meveoModuleDependency -> { Dependency dependency = new Dependency(); dependency.setGroupId("org.meveo"); @@ -434,10 +475,14 @@ public void generatePom(String message, MeveoModule module,GitRepository reposit log.error("Error retrieving maven dependencies", e); } - List updatedFiles = List.of(pomFile, gitIgnore.toFile(), link.toFile()); - - writeToPom(model, pomFile); - + Build build = new Build(); + build.setSourceDirectory("../java"); + model.setBuild(build); + + List updatedFiles = List.of(pomFile, file.toFile()); + + writeToPom(model, pomFile); + if (module.isAutoCommit()) { try { gitClient.commitFiles(repository, updatedFiles, message); @@ -446,7 +491,7 @@ public void generatePom(String message, MeveoModule module,GitRepository reposit } } - } + } private void writeToPom(Model model, File pomFile) { try { From ac232031b9a14746d1762efdb1ff598815e1744b Mon Sep 17 00:00:00 2001 From: masumcse1 Date: Sat, 15 Apr 2023 20:12:58 +0600 Subject: [PATCH 04/41] create pom file. --- .../service/config/impl/MavenConfigurationService.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/meveo-admin-ejbs/src/main/java/org/meveo/service/config/impl/MavenConfigurationService.java b/meveo-admin-ejbs/src/main/java/org/meveo/service/config/impl/MavenConfigurationService.java index 042298ebb..4a73316e6 100644 --- a/meveo-admin-ejbs/src/main/java/org/meveo/service/config/impl/MavenConfigurationService.java +++ b/meveo-admin-ejbs/src/main/java/org/meveo/service/config/impl/MavenConfigurationService.java @@ -323,7 +323,7 @@ public void generatePom(String message, MeveoModule module,GitRepository reposit log.error("Failed to create gitignore", e1); } - log.debug("Generating pom.xml file---***"); + log.debug("Generating pom.xml file---"); generateParentPom(message,module,repository); @@ -332,7 +332,7 @@ public void generatePom(String message, MeveoModule module,GitRepository reposit } private void generateParentPom(String message, MeveoModule module,GitRepository repository) { - log.debug("Generating pom.xml file---parents***"); + File pomFile = this.moduleService.findParentPom(module); final Model model = MavenUtils.readModel(pomFile); @@ -367,7 +367,7 @@ private void generateParentPom(String message, MeveoModule module,GitRepository } private void generateChildPom (String message, MeveoModule module,GitRepository repository,Path file) { - log.debug("Generating pom.xml file---childs***"); + File pomFile = this.moduleService.findPom(module); final Model model = MavenUtils.readModel(pomFile); From 47372a27e1377b5161995a9306c164d093514405 Mon Sep 17 00:00:00 2001 From: masumcse1 Date: Sat, 15 Apr 2023 21:09:14 +0600 Subject: [PATCH 05/41] correction. --- .../meveo/service/config/impl/MavenConfigurationService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meveo-admin-ejbs/src/main/java/org/meveo/service/config/impl/MavenConfigurationService.java b/meveo-admin-ejbs/src/main/java/org/meveo/service/config/impl/MavenConfigurationService.java index 4a73316e6..468de2625 100644 --- a/meveo-admin-ejbs/src/main/java/org/meveo/service/config/impl/MavenConfigurationService.java +++ b/meveo-admin-ejbs/src/main/java/org/meveo/service/config/impl/MavenConfigurationService.java @@ -374,7 +374,7 @@ private void generateChildPom (String message, MeveoModule module,GitRepository Parent parent = new Parent(); parent.setArtifactId("facets"); parent.setGroupId("org.meveo"); - parent.setVersion("1.0.0"); + parent.setVersion(module.getCurrentVersion()); model.setParent(parent); model.setGroupId("org.meveo");//TODO: Add group id to module From 238ae3a657eaf8b2c2a567a775ba05acdb152818 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Bareth-Desgranges?= Date: Tue, 25 Apr 2023 12:19:01 +0200 Subject: [PATCH 06/41] [FIX] Neo4j persistence only : case when node not found by uuid --- .../persistence/neo4j/service/Neo4jService.java | 12 ++++++++++-- .../org/meveo/persistence/scheduler/EntityRef.java | 6 ++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/meveo-admin-ejbs/src/main/java/org/meveo/persistence/neo4j/service/Neo4jService.java b/meveo-admin-ejbs/src/main/java/org/meveo/persistence/neo4j/service/Neo4jService.java index 49f3d4ee3..1cb8f1d66 100644 --- a/meveo-admin-ejbs/src/main/java/org/meveo/persistence/neo4j/service/Neo4jService.java +++ b/meveo-admin-ejbs/src/main/java/org/meveo/persistence/neo4j/service/Neo4jService.java @@ -424,7 +424,8 @@ public PersistenceActionResult addCetNode(String neo4JConfiguration, CustomEntit final List labels = getAdditionalLabels(cet); if (applicableConstraints.isEmpty()) { var existingNode = neo4jDao.findNodeById(neo4JConfiguration, cet.getCode(), uuid); - if (uniqueFields.isEmpty() && (existingNode == null || existingNode.isEmpty())) { + boolean nodeNotFound = (existingNode == null || existingNode.isEmpty()); + if (uniqueFields.isEmpty() && nodeNotFound) { String nodeId = neo4jDao.createNode(neo4JConfiguration, cet.getCode(), fields, labels, uuid); if(nodeId != null) { @@ -435,7 +436,14 @@ public PersistenceActionResult addCetNode(String neo4JConfiguration, CustomEntit } else { Map editableFields = getEditableFields(cetFields, fields); // Pass an empty map as unique fields to force merge using only the uuid as merge key - String nodeId = neo4jDao.mergeNode(neo4JConfiguration, cet.getCode(), Map.of(), fields, editableFields, labels, uuid); + String nodeId = neo4jDao.mergeNode( + neo4JConfiguration, + cet.getCode(), + nodeNotFound ? uniqueFields : Map.of(), + fields, + editableFields, + labels, + uuid); if(nodeId != null) { persistedEntities.add(new EntityRef(nodeId, cet.getCode())); diff --git a/meveo-admin-ejbs/src/main/java/org/meveo/persistence/scheduler/EntityRef.java b/meveo-admin-ejbs/src/main/java/org/meveo/persistence/scheduler/EntityRef.java index 16c082318..d83b09945 100644 --- a/meveo-admin-ejbs/src/main/java/org/meveo/persistence/scheduler/EntityRef.java +++ b/meveo-admin-ejbs/src/main/java/org/meveo/persistence/scheduler/EntityRef.java @@ -122,4 +122,10 @@ public boolean equals(Object o) { public int hashCode() { return Objects.hashCode(uuid); } + + @Override + public String toString() { + return "EntityRef [uuid=" + uuid + ", label=" + label + "]"; + } + } From 50ab2bd300ab4773df7158cdc0d010902791c1b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Bareth-Desgranges?= Date: Thu, 27 Apr 2023 16:44:41 +0200 Subject: [PATCH 07/41] Use input stream to send response --- .../technicalservice/EndpointServlet.java | 8 +++----- .../impl/EndpointResponse.java | 20 ++++++++++++------- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/meveo-admin-web/src/main/java/org/meveo/api/rest/technicalservice/EndpointServlet.java b/meveo-admin-web/src/main/java/org/meveo/api/rest/technicalservice/EndpointServlet.java index 962db7e52..67d4f04cc 100644 --- a/meveo-admin-web/src/main/java/org/meveo/api/rest/technicalservice/EndpointServlet.java +++ b/meveo-admin-web/src/main/java/org/meveo/api/rest/technicalservice/EndpointServlet.java @@ -383,7 +383,7 @@ private void doRequest(EndpointExecution endpointExecution, boolean cancel) thro log.error("Error while executing request", e); returnError(endpointExecution.getResp(), HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Error while executing request", e.getMessage(), e.toString()); } finally { - if(endpointExecution.getResponse().getOutput() == null) { + if(endpointExecution.getResponse().getInputStream() == null) { endpointExecution.getResp().getWriter().flush(); endpointExecution.getResp().getWriter().close(); } @@ -488,15 +488,13 @@ private void setReponse(String transformedResult, EndpointExecution endpointExec // Body of the response String errorMessage = response.getErrorMessage(); - byte[] output = response.getOutput(); if (!StringUtils.isBlank(errorMessage)) { // Priority to error message servletResponse.getWriter().print(errorMessage); - } else if (output != null) { // Output has been set - ByteArrayInputStream in = new ByteArrayInputStream(output); + } else if (response.getInputStream() != null) { // Output has been set ServletOutputStream out = servletResponse.getOutputStream(); byte[] buffer = new byte[1024]; int len = 0; - while ((len = in.read(buffer)) != -1) { + while ((len = response.getInputStream().read(buffer)) != -1) { out.write(buffer, 0, len); } out.flush(); diff --git a/meveo-api/src/main/java/org/meveo/api/rest/technicalservice/impl/EndpointResponse.java b/meveo-api/src/main/java/org/meveo/api/rest/technicalservice/impl/EndpointResponse.java index 0703c6ead..02434676d 100644 --- a/meveo-api/src/main/java/org/meveo/api/rest/technicalservice/impl/EndpointResponse.java +++ b/meveo-api/src/main/java/org/meveo/api/rest/technicalservice/impl/EndpointResponse.java @@ -16,7 +16,9 @@ package org.meveo.api.rest.technicalservice.impl; +import java.io.ByteArrayInputStream; import java.io.IOException; +import java.io.InputStream; import java.util.HashMap; import java.util.Map; @@ -40,9 +42,9 @@ public class EndpointResponse { private HttpServletResponse httpServletResponse; /** - * Content to write on the servlet response + * Input stream to copy on servlet response */ - private byte[] output; + private InputStream is; /** * If error, content to write on the servlet response @@ -110,12 +112,16 @@ public void setDateHeader(String headerName, long value) { this.dateHeaders.put(headerName, value); } - public byte[] getOutput() { - return output; - } - public void setOutput(byte[] output) throws IOException { - this.output = output; + this.is = new ByteArrayInputStream(output); + } + + public void setInputStream(InputStream is) { + this.is = is; + } + + public InputStream getInputStream() { + return this.is; } public String getErrorMessage() { From 5477e25eb9a73ca1243c3e1b49138c9ddae3f2b3 Mon Sep 17 00:00:00 2001 From: Gulam Samdani Date: Fri, 28 Apr 2023 22:08:47 +0600 Subject: [PATCH 08/41] Remote encrypted Password set (#713) --- .../action/storage/GitRepositoryBean.java | 30 ++++++++++++++++--- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/meveo-admin-web/src/main/java/org/meveo/admin/action/storage/GitRepositoryBean.java b/meveo-admin-web/src/main/java/org/meveo/admin/action/storage/GitRepositoryBean.java index c73af249e..768a36a57 100644 --- a/meveo-admin-web/src/main/java/org/meveo/admin/action/storage/GitRepositoryBean.java +++ b/meveo-admin-web/src/main/java/org/meveo/admin/action/storage/GitRepositoryBean.java @@ -32,6 +32,7 @@ import org.meveo.model.git.GitRepository; import org.meveo.model.module.MeveoModule; import org.meveo.model.storage.Repository; +import org.meveo.security.PasswordUtils; import org.meveo.service.admin.impl.MeveoModuleService; import org.meveo.service.base.local.IPersistenceService; import org.meveo.service.git.GitClient; @@ -134,8 +135,13 @@ public List getBranchList(String query) { public String saveOrUpdateGit() throws BusinessException, ELException { if (entity.getId() == null && entity.getRemoteOrigin() != null) { + + if(this.password.equals(entity.getDefaultRemotePassword())) { + password = PasswordUtils.decrypt(entity.getSalt(), password); + } + try { - gitRepositoryService.create(entity, false, this.getUsername(), this.getPassword()); + gitRepositoryService.create(entity, false, username,password); } catch (Exception e) { return MessagesHelper.error(messages, e); } @@ -152,7 +158,10 @@ public String saveOrUpdateGit() throws BusinessException, ELException { public void pushRemote() { try { - gitClient.push(entity, this.getUsername(), this.getPassword()); + if(this.password.equals(entity.getDefaultRemotePassword())) { + password = PasswordUtils.decrypt(entity.getSalt(), password); + } + gitClient.push(entity,username, password); initEntity(entity.getId()); messages.info(new BundleKey("messages", "gitRepositories.push.successful")); } catch (Exception e) { @@ -201,7 +210,10 @@ public void discard() throws BusinessException { public void fetchRemote() { try { - gitClient.fetch(entity, this.getUsername(), this.getPassword()); + if(this.password.equals(entity.getDefaultRemotePassword())) { + password = PasswordUtils.decrypt(entity.getSalt(), password); + } + gitClient.fetch(entity, username, password); initEntity(entity.getId()); messages.info(new BundleKey("messages", "gitRepositories.pull.successful")); } catch (Exception e) { @@ -212,7 +224,10 @@ public void fetchRemote() { public void pullRemote() { try { - gitClient.pull(entity, this.getUsername(), this.getPassword()); + if(this.password.equals(entity.getDefaultRemotePassword())) { + password = PasswordUtils.decrypt(entity.getSalt(), password); + } + gitClient.pull(entity, username, password); initEntity(entity.getId()); messages.info(new BundleKey("messages", "gitRepositories.pull.successful")); } catch (Exception e) { @@ -298,6 +313,9 @@ public void setUsername(String username) { } public String getPassword() { + if (entity.getId() != null && entity.getRemoteOrigin() != null) { + password = entity.getDefaultRemotePassword(); + } return password; } @@ -333,6 +351,10 @@ public boolean isModuleInstalled() { public String installMissingDependencies() { try { + + if(this.password.equals(entity.getDefaultRemotePassword())) { + password = PasswordUtils.decrypt(entity.getSalt(), password); + } LinkedHashMap gitRepos = moduleApi.retrieveModuleDependencies(missingDependencies, username, password); this.missingDependencies = new ArrayList<>(gitRepos.values()); From afe3e29edc4bc6b60aec0123cacc127f18c50a52 Mon Sep 17 00:00:00 2001 From: smichea Date: Mon, 8 May 2023 05:46:29 +0200 Subject: [PATCH 09/41] fix #714 use dynamic columns --- .../custom/CustomEntityDataTableColumn.java | 16 ++++++++++++++++ .../custom/CustomEntityInstanceListBean.java | 2 ++ .../admin/customEntities/customEntities.xhtml | 15 +++++++-------- 3 files changed, 25 insertions(+), 8 deletions(-) create mode 100644 meveo-admin-web/src/main/java/org/meveo/admin/action/admin/custom/CustomEntityDataTableColumn.java diff --git a/meveo-admin-web/src/main/java/org/meveo/admin/action/admin/custom/CustomEntityDataTableColumn.java b/meveo-admin-web/src/main/java/org/meveo/admin/action/admin/custom/CustomEntityDataTableColumn.java new file mode 100644 index 000000000..3e1fff7a9 --- /dev/null +++ b/meveo-admin-web/src/main/java/org/meveo/admin/action/admin/custom/CustomEntityDataTableColumn.java @@ -0,0 +1,16 @@ +package org.meveo.admin.action.admin.custom; + +public class CustomEntityDataTableColumn { + private String header; + private String property; + public CustomEntityDataTableColumn(String header, String property) { + this.header = header; + this.property = property; + } + public String getHeader() { + return header; + } + public String getProperty() { + return property; + } +} diff --git a/meveo-admin-web/src/main/java/org/meveo/admin/action/admin/custom/CustomEntityInstanceListBean.java b/meveo-admin-web/src/main/java/org/meveo/admin/action/admin/custom/CustomEntityInstanceListBean.java index 4ee2e04e5..e37989c48 100644 --- a/meveo-admin-web/src/main/java/org/meveo/admin/action/admin/custom/CustomEntityInstanceListBean.java +++ b/meveo-admin-web/src/main/java/org/meveo/admin/action/admin/custom/CustomEntityInstanceListBean.java @@ -49,6 +49,7 @@ public class CustomEntityInstanceListBean extends CustomEntityInstanceBean { private LazyDataModel> nativeDataModel; private List> selectedValues; + private List dataTableColumns = new ArrayList(); public void initialize() { @@ -77,6 +78,7 @@ public void initialize() { if(groupedCustomField.getData() instanceof CustomFieldTemplate) { CustomFieldTemplate cft = (CustomFieldTemplate) groupedCustomField.getData(); list.add(cft); + dataTableColumns.add(new CustomEntityDataTableColumn(cft.getDescription(), cft.getCode())); } } i++; diff --git a/meveo-admin-web/src/main/webapp/pages/admin/customEntities/customEntities.xhtml b/meveo-admin-web/src/main/webapp/pages/admin/customEntities/customEntities.xhtml index f85e0eba3..cb099edf9 100644 --- a/meveo-admin-web/src/main/webapp/pages/admin/customEntities/customEntities.xhtml +++ b/meveo-admin-web/src/main/webapp/pages/admin/customEntities/customEntities.xhtml @@ -204,13 +204,13 @@ - - + + + - - + + + - - + From 71b60e963a58b04a61cf2d014ef0a91430e50d0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Bareth-Desgranges?= Date: Tue, 9 May 2023 17:14:59 +0200 Subject: [PATCH 10/41] Set current module to null while installing a module This is to avoid the installation script to be attached to the current selected module Thus, it makes sense that there is no current module during a module installation --- .../src/main/java/org/meveo/api/module/MeveoModuleApi.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/meveo-api/src/main/java/org/meveo/api/module/MeveoModuleApi.java b/meveo-api/src/main/java/org/meveo/api/module/MeveoModuleApi.java index 62e64deda..c89422b15 100644 --- a/meveo-api/src/main/java/org/meveo/api/module/MeveoModuleApi.java +++ b/meveo-api/src/main/java/org/meveo/api/module/MeveoModuleApi.java @@ -281,6 +281,8 @@ public void installData(MeveoModule module, Repository repository) throws Busine * @return the installation summary */ public ModuleInstallResult install(List repositories, MeveoModuleDto moduleDto, OnDuplicate onDuplicate) throws MeveoApiException, BusinessException { + currentUser.setCurrentModule(null); + List missingModules = checkModuleDependencies(moduleDto); if (!missingModules.isEmpty()) { throw new MissingModuleException(missingModules); @@ -307,7 +309,7 @@ public ModuleInstallResult install(List repositories, MeveoModuleDto mod try { var installResult = meveoModuleItemInstaller.install(meveoModule, moduleDto, onDuplicate); - + currentUser.setCurrentModule(meveoModule.getCode()); return installResult; } catch (ModuleInstallFail e) { throw e.getException(); From a0187370e71fb443e4d2e1e2a4b9a7043e38cef7 Mon Sep 17 00:00:00 2001 From: Quentin Tixier Date: Wed, 10 May 2023 17:21:33 +0200 Subject: [PATCH 11/41] update CustomRelationshipTemplate getCRTForCache named query --- .../persistence/CrossStorageService.java | 1 + .../persistence/CrossStorageTransaction.java | 7 ++++--- .../neo4j/service/graphql/GraphQLService.java | 7 ++++--- .../service/crm/impl/JSONSchemaGenerator.java | 2 +- .../impl/JSONSchemaIntoTemplateParser.java | 6 ++++-- .../service/storage/RepositoryService.java | 3 ++- .../custom/CustomEntityTemplateBean.java | 3 ++- .../CustomRelationshipTemplateBean.java | 3 ++- .../action/crm/CustomFieldTemplateBean.java | 3 ++- .../api/dto/CustomEntityTemplateDto.java | 8 +++++--- .../dto/CustomRelationshipTemplateDto.java | 8 +++++--- .../org/meveo/api/CustomFieldTemplateApi.java | 3 ++- .../customEntities/CustomEntityTemplate.java | 10 +++++----- .../customEntities/CustomModelObject.java | 3 ++- .../CustomRelationshipTemplate.java | 19 ++++++++++++++----- 15 files changed, 55 insertions(+), 31 deletions(-) diff --git a/meveo-admin-ejbs/src/main/java/org/meveo/persistence/CrossStorageService.java b/meveo-admin-ejbs/src/main/java/org/meveo/persistence/CrossStorageService.java index 294acc633..51d38af14 100644 --- a/meveo-admin-ejbs/src/main/java/org/meveo/persistence/CrossStorageService.java +++ b/meveo-admin-ejbs/src/main/java/org/meveo/persistence/CrossStorageService.java @@ -656,6 +656,7 @@ public PersistenceActionResult createOrUpdate(Repository repository, CustomEntit var intermediateResults = impl.createOrUpdate(repository, storageConf, ceiAfterPreEvents, customFieldTemplates, foundId); if (intermediateResults != null) { results = intermediateResults; + persistedEntities.addAll(results.getPersistedEntities()); } } if (results != null) { diff --git a/meveo-admin-ejbs/src/main/java/org/meveo/persistence/CrossStorageTransaction.java b/meveo-admin-ejbs/src/main/java/org/meveo/persistence/CrossStorageTransaction.java index deb60a2f8..1df605b32 100644 --- a/meveo-admin-ejbs/src/main/java/org/meveo/persistence/CrossStorageTransaction.java +++ b/meveo-admin-ejbs/src/main/java/org/meveo/persistence/CrossStorageTransaction.java @@ -3,6 +3,7 @@ */ package org.meveo.persistence; +import java.util.Collection; import java.util.List; import java.util.stream.Collectors; @@ -57,7 +58,7 @@ private void postConstruct() { storages.forEach(StorageImpl::init); } - public void beginTransaction(Repository repository, List storages) { + public void beginTransaction(Repository repository, Collection storages) { for (var storage : storages) { var impl = provider.findImplementation(storage); for (var storageConf : repository.getStorageConfigurations(storage)) { @@ -77,7 +78,7 @@ public T beginTransaction(Repository repository, DBStorageType storage) { } - public void commitTransaction(Repository repository, List storages) { + public void commitTransaction(Repository repository, Collection storages) { stackedCalls--; if(stackedCalls == 0) { @@ -90,7 +91,7 @@ public void commitTransaction(Repository repository, List storage } } - public void rollbackTransaction(Exception exception, List storages) { + public void rollbackTransaction(Exception exception, Collection storages) { log.warn("Transaction rolled back : ", exception); stackedCalls--; diff --git a/meveo-admin-ejbs/src/main/java/org/meveo/persistence/neo4j/service/graphql/GraphQLService.java b/meveo-admin-ejbs/src/main/java/org/meveo/persistence/neo4j/service/graphql/GraphQLService.java index 61559d00c..011b8d46a 100644 --- a/meveo-admin-ejbs/src/main/java/org/meveo/persistence/neo4j/service/graphql/GraphQLService.java +++ b/meveo-admin-ejbs/src/main/java/org/meveo/persistence/neo4j/service/graphql/GraphQLService.java @@ -21,6 +21,7 @@ import java.util.ArrayList; import java.util.Collection; import java.util.Collections; +import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Optional; @@ -311,9 +312,9 @@ private Collection getEntities(Neo4JConfiguration neo4jConfigurat final CustomEntityTemplate startNode = relationshipTemplate.getStartNode(); // IF either the relation, the start entity or the end entity is not configured to be stored in Neo4J, don't include it in the generated graphql - final List relationStorages = relationshipTemplate.getAvailableStorages() != null ? relationshipTemplate.getAvailableStorages() : new ArrayList<>(); - final List endNodeStorages = endNode.getAvailableStorages() != null ? endNode.getAvailableStorages() : new ArrayList<>(); - final List startNodeStorages = startNode.getAvailableStorages() != null ? startNode.getAvailableStorages() : new ArrayList<>(); + final Set relationStorages = relationshipTemplate.getAvailableStorages() != null ? relationshipTemplate.getAvailableStorages() : new HashSet<>(); + final Set endNodeStorages = endNode.getAvailableStorages() != null ? endNode.getAvailableStorages() : new HashSet<>(); + final Set startNodeStorages = startNode.getAvailableStorages() != null ? startNode.getAvailableStorages() : new HashSet<>(); if (!relationStorages.contains(DBStorageType.NEO4J) || !endNodeStorages.contains(DBStorageType.NEO4J) || !startNodeStorages.contains(DBStorageType.NEO4J)) { continue; diff --git a/meveo-admin-ejbs/src/main/java/org/meveo/service/crm/impl/JSONSchemaGenerator.java b/meveo-admin-ejbs/src/main/java/org/meveo/service/crm/impl/JSONSchemaGenerator.java index 07cff0f60..aaab15b24 100644 --- a/meveo-admin-ejbs/src/main/java/org/meveo/service/crm/impl/JSONSchemaGenerator.java +++ b/meveo-admin-ejbs/src/main/java/org/meveo/service/crm/impl/JSONSchemaGenerator.java @@ -703,7 +703,7 @@ private ReferenceViewSchema createReference_obsolete(CustomEntityTemplate node, }; } - private List buildDBStorageType(List dbStorageTypes) { + private List buildDBStorageType(Collection dbStorageTypes) { List dbStorageTypeAsString = new ArrayList<>(); if (dbStorageTypes != null) { for (DBStorageType dbStorageType : dbStorageTypes) { diff --git a/meveo-admin-ejbs/src/main/java/org/meveo/service/crm/impl/JSONSchemaIntoTemplateParser.java b/meveo-admin-ejbs/src/main/java/org/meveo/service/crm/impl/JSONSchemaIntoTemplateParser.java index 8f68683e5..d9aabb672 100644 --- a/meveo-admin-ejbs/src/main/java/org/meveo/service/crm/impl/JSONSchemaIntoTemplateParser.java +++ b/meveo-admin-ejbs/src/main/java/org/meveo/service/crm/impl/JSONSchemaIntoTemplateParser.java @@ -14,8 +14,10 @@ import java.nio.file.Files; import java.util.ArrayList; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Set; public class JSONSchemaIntoTemplateParser { @@ -73,7 +75,7 @@ private void parseDescription(Map jsonMap, CustomEntityTemplateD private void parseStorage(Map jsonMap, CustomEntityTemplateDto customEntityTemplateDto) { if (jsonMap.containsKey("storages")) { List storages = (List) jsonMap.get("storages"); - List storageTypeList = new ArrayList<>(); + Set storageTypeList = new HashSet<>(); for (String storage : storages) { storageTypeList.add(DBStorageType.valueOf(storage)); } @@ -223,7 +225,7 @@ private void parseDescriptionCRT(Map jsonMap, CustomRelationship private void parseStorageCRT(Map jsonMap, CustomRelationshipTemplateDto customRelationshipTemplateDto) { if (jsonMap.containsKey("storages")) { List storages = (List) jsonMap.get("storages"); - List storageTypeList = new ArrayList<>(); + Set storageTypeList = new HashSet<>(); for (String storage : storages) { storageTypeList.add(DBStorageType.valueOf(storage)); } diff --git a/meveo-admin-ejbs/src/main/java/org/meveo/service/storage/RepositoryService.java b/meveo-admin-ejbs/src/main/java/org/meveo/service/storage/RepositoryService.java index 70141b546..445ba1d55 100644 --- a/meveo-admin-ejbs/src/main/java/org/meveo/service/storage/RepositoryService.java +++ b/meveo-admin-ejbs/src/main/java/org/meveo/service/storage/RepositoryService.java @@ -2,6 +2,7 @@ import java.util.ArrayList; import java.util.List; +import java.util.Set; import java.util.stream.Collectors; import javax.ejb.Stateless; @@ -141,7 +142,7 @@ public List listByCetByUserLevel(CustomEntityTemplate cet) { @SuppressWarnings("unchecked") public List listByCet(CustomEntityTemplate cet, UserHierarchyLevel userLevel) { - List storageTypes = cet.getAvailableStorages(); + Set storageTypes = cet.getAvailableStorages(); boolean withCustomTable = false; withCustomTable = storageTypes.contains(DBStorageType.SQL) && cet.getSqlStorageConfigurationNullSafe().isStoreAsTable(); diff --git a/meveo-admin-web/src/main/java/org/meveo/admin/action/admin/custom/CustomEntityTemplateBean.java b/meveo-admin-web/src/main/java/org/meveo/admin/action/admin/custom/CustomEntityTemplateBean.java index 0cc92dd95..1506ebdd0 100644 --- a/meveo-admin-web/src/main/java/org/meveo/admin/action/admin/custom/CustomEntityTemplateBean.java +++ b/meveo-admin-web/src/main/java/org/meveo/admin/action/admin/custom/CustomEntityTemplateBean.java @@ -4,6 +4,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.stream.Collectors; @@ -386,7 +387,7 @@ public void onChangeAvailableStorages() { getEntity().getAvailableStorages().clear(); getEntity().getAvailableStorages().addAll(availableStoragesDM.getTarget()); } else { - getEntity().setAvailableStorages(availableStoragesDM.getTarget()); + getEntity().setAvailableStorages(new HashSet<>(availableStoragesDM.getTarget())); } } diff --git a/meveo-admin-web/src/main/java/org/meveo/admin/action/admin/custom/CustomRelationshipTemplateBean.java b/meveo-admin-web/src/main/java/org/meveo/admin/action/admin/custom/CustomRelationshipTemplateBean.java index aa6114221..d70b55e06 100644 --- a/meveo-admin-web/src/main/java/org/meveo/admin/action/admin/custom/CustomRelationshipTemplateBean.java +++ b/meveo-admin-web/src/main/java/org/meveo/admin/action/admin/custom/CustomRelationshipTemplateBean.java @@ -3,6 +3,7 @@ import java.io.Serializable; import java.util.ArrayList; import java.util.Comparator; +import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.stream.Collectors; @@ -110,7 +111,7 @@ public void onChangeAvailableStorages() { getEntity().getAvailableStorages().clear(); getEntity().getAvailableStorages().addAll(availableStoragesDM.getTarget()); } else { - getEntity().setAvailableStorages(availableStoragesDM.getTarget()); + getEntity().setAvailableStorages(new HashSet<>(availableStoragesDM.getTarget())); } } diff --git a/meveo-admin-web/src/main/java/org/meveo/admin/action/crm/CustomFieldTemplateBean.java b/meveo-admin-web/src/main/java/org/meveo/admin/action/crm/CustomFieldTemplateBean.java index 0b8a248f5..5ed0f452f 100644 --- a/meveo-admin-web/src/main/java/org/meveo/admin/action/crm/CustomFieldTemplateBean.java +++ b/meveo-admin-web/src/main/java/org/meveo/admin/action/crm/CustomFieldTemplateBean.java @@ -4,6 +4,7 @@ import java.util.Arrays; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.TreeMap; import java.util.stream.Collectors; @@ -764,7 +765,7 @@ public void createRelationsip() { relationshipToCreate.setStartEntity(source); relationshipToCreate.setEndEntity(target); - relationshipToCreate.setAvailableStorages(List.of(DBStorageType.NEO4J)); + relationshipToCreate.setAvailableStorages(Set.of(DBStorageType.NEO4J)); try { customRelationshipTemplateService.create(relationshipToCreate); diff --git a/meveo-api-dto/src/main/java/org/meveo/api/dto/CustomEntityTemplateDto.java b/meveo-api-dto/src/main/java/org/meveo/api/dto/CustomEntityTemplateDto.java index 9796f489c..dbf109d08 100644 --- a/meveo-api-dto/src/main/java/org/meveo/api/dto/CustomEntityTemplateDto.java +++ b/meveo-api-dto/src/main/java/org/meveo/api/dto/CustomEntityTemplateDto.java @@ -1,7 +1,9 @@ package org.meveo.api.dto; import java.util.ArrayList; +import java.util.Collection; import java.util.List; +import java.util.Set; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; @@ -92,7 +94,7 @@ public class CustomEntityTemplateDto extends BaseEntityDto { */ @XmlElement() @ApiModelProperty("List of storages where cfts can be stored") - private List availableStorages; + private Set availableStorages; @XmlElement @ApiModelProperty("Neo4J storage configuration information") @@ -161,7 +163,7 @@ public CustomEntityTemplateDto() { super(); } - public List getAvailableStorages() { + public Set getAvailableStorages() { return availableStorages; } @@ -179,7 +181,7 @@ public void setCrudEventListenerScript(String crudEventListenerScript) { this.crudEventListenerScript = crudEventListenerScript; } - public void setAvailableStorages(List availableStorages) { + public void setAvailableStorages(Set availableStorages) { this.availableStorages = availableStorages; } diff --git a/meveo-api-dto/src/main/java/org/meveo/api/dto/CustomRelationshipTemplateDto.java b/meveo-api-dto/src/main/java/org/meveo/api/dto/CustomRelationshipTemplateDto.java index d0900f3f9..2c5d76fc4 100644 --- a/meveo-api-dto/src/main/java/org/meveo/api/dto/CustomRelationshipTemplateDto.java +++ b/meveo-api-dto/src/main/java/org/meveo/api/dto/CustomRelationshipTemplateDto.java @@ -2,7 +2,9 @@ import java.util.ArrayList; import java.util.Collection; +import java.util.HashSet; import java.util.List; +import java.util.Set; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; @@ -80,7 +82,7 @@ public class CustomRelationshipTemplateDto extends BaseEntityDto { */ @XmlAttribute() @ApiModelProperty("List of available storages where the custom relationship instances should be stored") - private List availableStorages = new ArrayList<>(); + private Set availableStorages = new HashSet<>(); /** * Name of the field that will be added to the source entity to refer the most recent target entity @@ -147,11 +149,11 @@ public String getGraphQlTypeName() { return graphQlTypeName; } - public List getAvailableStorages() { + public Set getAvailableStorages() { return availableStorages; } - public void setAvailableStorages(List availableStorages) { + public void setAvailableStorages(Set availableStorages) { this.availableStorages = availableStorages; } diff --git a/meveo-api/src/main/java/org/meveo/api/CustomFieldTemplateApi.java b/meveo-api/src/main/java/org/meveo/api/CustomFieldTemplateApi.java index ee2ccf7e6..d338b67da 100644 --- a/meveo-api/src/main/java/org/meveo/api/CustomFieldTemplateApi.java +++ b/meveo-api/src/main/java/org/meveo/api/CustomFieldTemplateApi.java @@ -3,6 +3,7 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; +import java.util.Set; import javax.ejb.Stateless; import javax.ejb.TransactionAttribute; @@ -598,7 +599,7 @@ protected CustomFieldTemplate fromDTO(CustomFieldTemplateDto dto, String applies cft.setHasReferenceJpaEntity(dto.hasReferenceJpaEntity()); // A cft can't be stored in a db that is not available for its cet - List storageTypes = null; + Set storageTypes = null; if(cft.getAppliesTo().startsWith(CustomEntityTemplate.CFT_PREFIX)) { String cetCode = CustomEntityTemplate.getCodeFromAppliesTo(cft.getAppliesTo()); CustomEntityTemplate cet = customEntityTemplateService.findByCode(cetCode); diff --git a/meveo-model/src/main/java/org/meveo/model/customEntities/CustomEntityTemplate.java b/meveo-model/src/main/java/org/meveo/model/customEntities/CustomEntityTemplate.java index b5e99fcbc..a9be0e13e 100644 --- a/meveo-model/src/main/java/org/meveo/model/customEntities/CustomEntityTemplate.java +++ b/meveo-model/src/main/java/org/meveo/model/customEntities/CustomEntityTemplate.java @@ -18,7 +18,9 @@ package org.meveo.model.customEntities; import java.util.ArrayList; +import java.util.HashSet; import java.util.List; +import java.util.Set; import javax.persistence.Cacheable; import javax.persistence.Column; @@ -39,8 +41,6 @@ import javax.validation.constraints.NotNull; import javax.validation.constraints.Size; -import org.hibernate.annotations.Fetch; -import org.hibernate.annotations.FetchMode; import org.hibernate.annotations.GenericGenerator; import org.hibernate.annotations.Parameter; import org.hibernate.annotations.Type; @@ -138,7 +138,7 @@ public class CustomEntityTemplate extends BusinessEntity implements Comparable availableStorages = new ArrayList<>(); + private Set availableStorages = new HashSet<>(); @Type(type = "numeric_boolean") @Column(name = "audited") @@ -319,7 +319,7 @@ public void setSqlStorageConfiguration(SQLStorageConfiguration sqlStorageConfigu * * @return the list of storages where the custom fields can be stored */ - public List getAvailableStorages() { + public Set getAvailableStorages() { return availableStorages; } @@ -328,7 +328,7 @@ public List getAvailableStorages() { * * @param availableStorages the new list of storages where the custom fields can be stored */ - public void setAvailableStorages(List availableStorages) { + public void setAvailableStorages(Set availableStorages) { this.availableStorages = availableStorages; } diff --git a/meveo-model/src/main/java/org/meveo/model/customEntities/CustomModelObject.java b/meveo-model/src/main/java/org/meveo/model/customEntities/CustomModelObject.java index fb9105290..149c9287a 100644 --- a/meveo-model/src/main/java/org/meveo/model/customEntities/CustomModelObject.java +++ b/meveo-model/src/main/java/org/meveo/model/customEntities/CustomModelObject.java @@ -1,6 +1,7 @@ package org.meveo.model.customEntities; import java.util.List; +import java.util.Set; import org.meveo.model.persistence.DBStorageType; import org.meveo.model.storage.Repository; @@ -15,6 +16,6 @@ public interface CustomModelObject { List getRepositories(); - List getAvailableStorages(); + Set getAvailableStorages(); } diff --git a/meveo-model/src/main/java/org/meveo/model/customEntities/CustomRelationshipTemplate.java b/meveo-model/src/main/java/org/meveo/model/customEntities/CustomRelationshipTemplate.java index 0a0b033b9..f2c88b5db 100644 --- a/meveo-model/src/main/java/org/meveo/model/customEntities/CustomRelationshipTemplate.java +++ b/meveo-model/src/main/java/org/meveo/model/customEntities/CustomRelationshipTemplate.java @@ -18,7 +18,9 @@ package org.meveo.model.customEntities; import java.util.ArrayList; +import java.util.HashSet; import java.util.List; +import java.util.Set; import javax.persistence.Column; import javax.persistence.Entity; @@ -68,7 +70,14 @@ parameters = {@org.hibernate.annotations.Parameter(name = "sequence_name", value = "CUST_CRT_SEQ")} ) @NamedQueries({ - @NamedQuery(name = "CustomRelationshipTemplate.getCRTForCache", query = "SELECT crt from CustomRelationshipTemplate crt JOIN FETCH crt.availableStorages where crt.disabled=false "), + @NamedQuery(name = "CustomRelationshipTemplate.getCRTForCache", query = "SELECT crt " + + "FROM CustomRelationshipTemplate crt " + + "JOIN FETCH crt.availableStorages " + + "JOIN FETCH crt.startNode startNode " + + " JOIN FETCH startNode.availableStorages " + + "JOIN FETCH crt.endNode endNode " + + " JOIN FETCH endNode.availableStorages " + + "WHERE crt.disabled=false"), @NamedQuery(name = "CustomRelationshipTemplate.findByStartEndAndName", query = "SELECT crt from CustomRelationshipTemplate crt " + "WHERE crt.startNode.code = :startCode " + "AND crt.endNode.code = :endCode " + @@ -103,7 +112,7 @@ public class CustomRelationshipTemplate extends BusinessEntity implements Compar // @Type(type = JsonTypes.JSON_LIST) @ManyToMany @JoinTable(name = "crt_db_storage", inverseJoinColumns = @JoinColumn(name = "db_storage_code"), joinColumns = @JoinColumn(name = "crt_id")) - private List availableStorages; + private Set availableStorages; /** * Json list type. ex : ["firstName","lastName","birthDate"] @@ -207,8 +216,8 @@ public String getRelationshipsFieldTarget() { * * @return the available storages */ - public List getAvailableStorages() { - return availableStorages != null ? availableStorages : new ArrayList<>(); + public Set getAvailableStorages() { + return availableStorages != null ? availableStorages : new HashSet<>(); } public void addStorage(DBStorageType e) { @@ -221,7 +230,7 @@ public void addStorage(DBStorageType e) { * * @param availableStorages the new available storages */ - public void setAvailableStorages(List availableStorages) { + public void setAvailableStorages(Set availableStorages) { this.availableStorages = availableStorages; } From 90473af55182c3f208e0d147709c866951446307 Mon Sep 17 00:00:00 2001 From: smichea Date: Fri, 19 May 2023 02:35:16 +0200 Subject: [PATCH 12/41] fix #716 --- .../main/java/org/meveo/persistence/CrossStorageService.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/meveo-admin-ejbs/src/main/java/org/meveo/persistence/CrossStorageService.java b/meveo-admin-ejbs/src/main/java/org/meveo/persistence/CrossStorageService.java index 1495daafb..ea1ef98fb 100644 --- a/meveo-admin-ejbs/src/main/java/org/meveo/persistence/CrossStorageService.java +++ b/meveo-admin-ejbs/src/main/java/org/meveo/persistence/CrossStorageService.java @@ -928,7 +928,10 @@ private Map createEntityReferences(Repository repository, Map Date: Fri, 19 May 2023 06:51:37 +0200 Subject: [PATCH 13/41] fix #717 --- .../api/module/MeveoModuleItemInstaller.java | 30 +++++++++---------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/meveo-api/src/main/java/org/meveo/api/module/MeveoModuleItemInstaller.java b/meveo-api/src/main/java/org/meveo/api/module/MeveoModuleItemInstaller.java index 95a4f3071..db3343f52 100644 --- a/meveo-api/src/main/java/org/meveo/api/module/MeveoModuleItemInstaller.java +++ b/meveo-api/src/main/java/org/meveo/api/module/MeveoModuleItemInstaller.java @@ -755,22 +755,20 @@ private void unpackAndInstallModuleItems(ModuleInstallResult result, MeveoModule throw new BusinessException(e); } } - - for (MeveoModuleItemDto moduleItemDto : sortedModuleItems) { - if (moduleItemDto.getDtoClassName().equals(CustomEntityTemplateDto.class.getName())) { - try { - Class dtoClass = (Class) Class.forName(moduleItemDto.getDtoClassName()); - CustomEntityTemplateDto cetDto = (CustomEntityTemplateDto) JacksonUtil.convert(moduleItemDto.getDtoData(), dtoClass); - if (!StringUtils.isBlank(cetDto.getTransientCrudEventListenerScript())) { - CustomEntityTemplate cet = customEntityTemplateService.findByCode(cetDto.getCode()); - ScriptInstance si = scriptInstanceService.findByCode(cetDto.getTransientCrudEventListenerScript()); - if (si != null) { - cet.setCrudEventListenerScript(si); - customEntityTemplateService.update(cet); - } - } - } catch (ClassNotFoundException e) { - log.error("Cannot find dto class", e); + } + + //finally we store crudScript of custom entities that have been put temporarily in transientCrudEventListenerScript + for (MeveoModuleItemDto moduleItemDto : moduleDto.getModuleItems()) { + if (moduleItemDto.getDtoClassName().equals(CustomEntityTemplateDto.class.getName())) { + CustomEntityTemplateDto cetDto = (CustomEntityTemplateDto) moduleItemDto.getDtoData(); + if (!StringUtils.isBlank(cetDto.getTransientCrudEventListenerScript())) { + CustomEntityTemplate cet = customEntityTemplateService.findByCode(cetDto.getCode()); + ScriptInstance si = scriptInstanceService.findByCode(cetDto.getTransientCrudEventListenerScript()); + if (si != null) { + cet.setCrudEventListenerScript(si); + customEntityTemplateService.update(cet); + } else { + throw new BusinessException("cannot find crusdScript "+cetDto.getTransientCrudEventListenerScript()+" of entity "+cetDto.getCode()); } } } From 6c0a55c8ad7caadd793577d8205c7cdb6edbcc55 Mon Sep 17 00:00:00 2001 From: smichea Date: Sat, 20 May 2023 05:12:01 +0200 Subject: [PATCH 14/41] fix side effect of #717 fix --- .../org/meveo/api/module/MeveoModuleItemInstaller.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/meveo-api/src/main/java/org/meveo/api/module/MeveoModuleItemInstaller.java b/meveo-api/src/main/java/org/meveo/api/module/MeveoModuleItemInstaller.java index db3343f52..b8cdb7c0c 100644 --- a/meveo-api/src/main/java/org/meveo/api/module/MeveoModuleItemInstaller.java +++ b/meveo-api/src/main/java/org/meveo/api/module/MeveoModuleItemInstaller.java @@ -760,7 +760,13 @@ private void unpackAndInstallModuleItems(ModuleInstallResult result, MeveoModule //finally we store crudScript of custom entities that have been put temporarily in transientCrudEventListenerScript for (MeveoModuleItemDto moduleItemDto : moduleDto.getModuleItems()) { if (moduleItemDto.getDtoClassName().equals(CustomEntityTemplateDto.class.getName())) { - CustomEntityTemplateDto cetDto = (CustomEntityTemplateDto) moduleItemDto.getDtoData(); + CustomEntityTemplateDto cetDto =null; + if(moduleItemDto.getDtoData() instanceof CustomEntityTemplateDto){ + cetDto = (CustomEntityTemplateDto) moduleItemDto.getDtoData(); + } else { + Class dtoClass = (Class) Class.forName(moduleItemDto.getDtoClassName()); + cetDto = (CustomEntityTemplateDto) JacksonUtil.convert(moduleItemDto.getDtoData(), dtoClass); + } if (!StringUtils.isBlank(cetDto.getTransientCrudEventListenerScript())) { CustomEntityTemplate cet = customEntityTemplateService.findByCode(cetDto.getCode()); ScriptInstance si = scriptInstanceService.findByCode(cetDto.getTransientCrudEventListenerScript()); From 9f744123005e5c376feab707aee10ceb12bfde1a Mon Sep 17 00:00:00 2001 From: smichea Date: Sat, 20 May 2023 05:16:25 +0200 Subject: [PATCH 15/41] refix #717 --- .../api/module/MeveoModuleItemInstaller.java | 36 +++++++++++-------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/meveo-api/src/main/java/org/meveo/api/module/MeveoModuleItemInstaller.java b/meveo-api/src/main/java/org/meveo/api/module/MeveoModuleItemInstaller.java index b8cdb7c0c..260fa8f68 100644 --- a/meveo-api/src/main/java/org/meveo/api/module/MeveoModuleItemInstaller.java +++ b/meveo-api/src/main/java/org/meveo/api/module/MeveoModuleItemInstaller.java @@ -760,23 +760,29 @@ private void unpackAndInstallModuleItems(ModuleInstallResult result, MeveoModule //finally we store crudScript of custom entities that have been put temporarily in transientCrudEventListenerScript for (MeveoModuleItemDto moduleItemDto : moduleDto.getModuleItems()) { if (moduleItemDto.getDtoClassName().equals(CustomEntityTemplateDto.class.getName())) { - CustomEntityTemplateDto cetDto =null; - if(moduleItemDto.getDtoData() instanceof CustomEntityTemplateDto){ - cetDto = (CustomEntityTemplateDto) moduleItemDto.getDtoData(); - } else { - Class dtoClass = (Class) Class.forName(moduleItemDto.getDtoClassName()); - cetDto = (CustomEntityTemplateDto) JacksonUtil.convert(moduleItemDto.getDtoData(), dtoClass); - } - if (!StringUtils.isBlank(cetDto.getTransientCrudEventListenerScript())) { - CustomEntityTemplate cet = customEntityTemplateService.findByCode(cetDto.getCode()); - ScriptInstance si = scriptInstanceService.findByCode(cetDto.getTransientCrudEventListenerScript()); - if (si != null) { - cet.setCrudEventListenerScript(si); - customEntityTemplateService.update(cet); + CustomEntityTemplateDto cetDto =null; + if(moduleItemDto.getDtoData() instanceof CustomEntityTemplateDto){ + cetDto = (CustomEntityTemplateDto) moduleItemDto.getDtoData(); } else { - throw new BusinessException("cannot find crusdScript "+cetDto.getTransientCrudEventListenerScript()+" of entity "+cetDto.getCode()); + try { + Class dtoClass = (Class) Class.forName(moduleItemDto.getDtoClassName()); + cetDto = (CustomEntityTemplateDto) JacksonUtil.convert(moduleItemDto.getDtoData(), dtoClass); + } catch (ClassNotFoundException e) { + log.error("Cannot find dto class", e); + throw new BusinessException("cannot find crusdScript class "+moduleItemDto.getDtoClassName()); + } } - } + if (!StringUtils.isBlank(cetDto.getTransientCrudEventListenerScript())) { + CustomEntityTemplate cet = customEntityTemplateService.findByCode(cetDto.getCode()); + ScriptInstance si = scriptInstanceService.findByCode(cetDto.getTransientCrudEventListenerScript()); + if (si != null) { + cet.setCrudEventListenerScript(si); + customEntityTemplateService.update(cet); + } else { + throw new BusinessException("cannot find crusdScript "+cetDto.getTransientCrudEventListenerScript()+" of entity "+cetDto.getCode()); + } + } + } } } From 12b55eef2cccdd4925da4b7c945ef41fd038ba8c Mon Sep 17 00:00:00 2001 From: smichea Date: Sat, 20 May 2023 10:26:00 +0200 Subject: [PATCH 16/41] fix #718 --- .../src/main/java/org/meveo/model/persistence/CEIUtils.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/meveo-model/src/main/java/org/meveo/model/persistence/CEIUtils.java b/meveo-model/src/main/java/org/meveo/model/persistence/CEIUtils.java index 3a6b3d35e..990cb0bd8 100644 --- a/meveo-model/src/main/java/org/meveo/model/persistence/CEIUtils.java +++ b/meveo-model/src/main/java/org/meveo/model/persistence/CEIUtils.java @@ -75,12 +75,13 @@ public static String getHash(CustomEntityInstance cei, Map { if (e.getValue() instanceof Instant) { e.setValue(((Instant) e.getValue()).toEpochMilli()); - } + } }); cfts.values().stream() .sorted((cft1, cft2) -> cft1.getCode().compareTo(cft2.getCode())) .filter(cft -> !cft.getFieldType().equals(CustomFieldTypeEnum.SECRET)) .map(cft -> values.get(cft.getCode())) + .map(val -> (val instanceof EntityReferenceWrapper)?(((EntityReferenceWrapper)val).getId()==null)?null:(((EntityReferenceWrapper)val).getId()):val) .filter(java.util.Objects::nonNull) .forEach(objectsToHash::add); From 3d0bb77c267bc7a91938026443b6ab764023fad4 Mon Sep 17 00:00:00 2001 From: smichea Date: Sat, 20 May 2023 10:28:40 +0200 Subject: [PATCH 17/41] fix #719 --- .../persistence/CrossStorageService.java | 83 ++++++++++--------- 1 file changed, 42 insertions(+), 41 deletions(-) diff --git a/meveo-admin-ejbs/src/main/java/org/meveo/persistence/CrossStorageService.java b/meveo-admin-ejbs/src/main/java/org/meveo/persistence/CrossStorageService.java index ea1ef98fb..e0824c673 100644 --- a/meveo-admin-ejbs/src/main/java/org/meveo/persistence/CrossStorageService.java +++ b/meveo-admin-ejbs/src/main/java/org/meveo/persistence/CrossStorageService.java @@ -565,7 +565,7 @@ public PersistenceActionResult createOrUpdate(Repository repository, CustomEntit // Create referenced entities and set UUIDs in the values Map tmpValues = ceiToSave.getCfValuesAsValues() != null ? new HashMap<>(ceiToSave.getCfValuesAsValues()) : new HashMap<>(); - Map entityValues = createEntityReferences(repository, tmpValues, cet); + Map entityValues = createEntityReferences(repository, tmpValues, cet,customFieldTemplates); customFieldInstanceService.setCfValues(cei, entityValues); String uuid = null; @@ -573,13 +573,6 @@ public PersistenceActionResult createOrUpdate(Repository repository, CustomEntit // First check if data exist, in order to synchronize UUID across all storages String foundId; - List secretFields = customFieldTemplates.values() - .stream() - .filter(cft -> cft.getFieldType() == CustomFieldTypeEnum.SECRET) - .filter(cft -> cei.get(cft.getCode()) != null) - .map(CustomFieldTemplate::getCode) - .collect(Collectors.toList()); - try { if (ceiToSave.getUuid() != null && exists(repository, cet, ceiToSave.getUuid())) { foundId = ceiToSave.getUuid(); @@ -590,37 +583,7 @@ public PersistenceActionResult createOrUpdate(Repository repository, CustomEntit // It's no problem if we can't retrieve record using values - we consider it does not exist foundId = null; } - - if (foundId != null) { - cei.setUuid(foundId); - // Handle secret fields - if(!secretFields.isEmpty()) { - var foundCei = CEIUtils.pojoToCei(find(repository, cet, foundId, false)); - String oldCeiHash = CEIUtils.getHash(foundCei, customFieldTemplates); - secretFields.forEach(secretField -> { - // Secret field has not changed, decrypt it so it will be correctly re-encrypted - if(cei.get(secretField).equals(foundCei.get(secretField))) { - String decryptedValue = PasswordUtils.decryptNoSecret(oldCeiHash, cei.get(secretField)); - cei.getCfValues().setValue(secretField, decryptedValue); - entityValues.put(secretField, decryptedValue); - } - }); - } - } - - // Encrypt secret fields - if(!secretFields.isEmpty()) { - String ceiHash = CEIUtils.getHash(cei, customFieldTemplates); - secretFields.forEach(secretField -> { - String secretValue = cei.get(secretField); - if(!secretValue.startsWith("🔒")) { // Value is already encrypted - String encryptedValue = PasswordUtils.encryptNoSecret(ceiHash, secretValue); - cei.getCfValues().setValue(secretField, encryptedValue); - entityValues.put(secretField, encryptedValue); - } - }); - } - + var listener = customEntityTemplateService.loadCrudEventListener(cei.getCet()); CustomEntity cetClassInstance = null; @@ -643,11 +606,50 @@ public PersistenceActionResult createOrUpdate(Repository repository, CustomEntit ceiAfterPreEvents = CEIUtils.pojoToCei(cetClassInstance); // Handle case where entity was modified ceiAfterPreEvents.setCet(cei.getCet()); + ceiAfterPreEvents.setFieldTemplates(customFieldTemplates); } } catch (Exception e) { throw new RuntimeException(e); } + + List secretFields = new ArrayList<>(); + for( CustomFieldTemplate cft :customFieldTemplates.values()){ + if(ceiAfterPreEvents.get(cft.getCode()) != null && cft.getFieldType() == CustomFieldTypeEnum.SECRET){ + secretFields.add(cft.getCode()); + } + } + + if (foundId != null) { + ceiAfterPreEvents.setUuid(foundId); + // Handle secret fields + if(!secretFields.isEmpty()) { + var foundCei = CEIUtils.pojoToCei(find(repository, cet, foundId, false)); + String oldCeiHash = CEIUtils.getHash(foundCei, customFieldTemplates); + for(String secretField:secretFields) { + // Secret field has not changed, decrypt it so it will be correctly re-encrypted + if(ceiAfterPreEvents.get(secretField).equals(foundCei.get(secretField))) { + String decryptedValue = PasswordUtils.decryptNoSecret(oldCeiHash, ceiAfterPreEvents.get(secretField)); + cei.getCfValues().setValue(secretField, decryptedValue); + entityValues.put(secretField, decryptedValue); + } + }; + } + } + + // Encrypt secret fields + if(!secretFields.isEmpty()) { + String ceiHash = CEIUtils.getHash(ceiAfterPreEvents, customFieldTemplates); + for(String secretField:secretFields) { + String secretValue = ceiAfterPreEvents.get(secretField); + if(!secretValue.startsWith("🔒")) { // Value is already encrypted + String encryptedValue = PasswordUtils.encryptNoSecret(ceiHash, secretValue); + ceiAfterPreEvents.getCfValues().setValue(secretField, encryptedValue); + entityValues.put(secretField, encryptedValue); + } + }; + } + try { @@ -909,10 +911,9 @@ public void setBinaries(Repository repository, CustomEntityTemplate cet, CustomF } } - private Map createEntityReferences(Repository repository, Map entityValues, CustomEntityTemplate cet) throws BusinessException, IOException, BusinessApiException, EntityDoesNotExistsException { + private Map createEntityReferences(Repository repository, Map entityValues, CustomEntityTemplate cet,Map cfts) throws BusinessException, IOException, BusinessApiException, EntityDoesNotExistsException { Map updatedValues = new HashMap<>(entityValues); - Map cfts = customFieldTemplateService.getCftsWithInheritedFields(cet); List cetFields = updatedValues.keySet() .stream() .map(cfts::get) From 8ac7aa63443a58ef305856521be55422357e82c9 Mon Sep 17 00:00:00 2001 From: smichea Date: Sat, 20 May 2023 14:06:17 +0200 Subject: [PATCH 18/41] remove entity references in salt computation #719 --- .../src/main/java/org/meveo/model/persistence/CEIUtils.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/meveo-model/src/main/java/org/meveo/model/persistence/CEIUtils.java b/meveo-model/src/main/java/org/meveo/model/persistence/CEIUtils.java index 990cb0bd8..efcb19254 100644 --- a/meveo-model/src/main/java/org/meveo/model/persistence/CEIUtils.java +++ b/meveo-model/src/main/java/org/meveo/model/persistence/CEIUtils.java @@ -72,6 +72,7 @@ public static String getHash(CustomEntityInstance cei, Map { if (e.getValue() instanceof Instant) { e.setValue(((Instant) e.getValue()).toEpochMilli()); @@ -81,7 +82,7 @@ public static String getHash(CustomEntityInstance cei, Map cft1.getCode().compareTo(cft2.getCode())) .filter(cft -> !cft.getFieldType().equals(CustomFieldTypeEnum.SECRET)) .map(cft -> values.get(cft.getCode())) - .map(val -> (val instanceof EntityReferenceWrapper)?(((EntityReferenceWrapper)val).getId()==null)?null:(((EntityReferenceWrapper)val).getId()):val) + .map(val -> !(val instanceof EntityReferenceWrapper)) .filter(java.util.Objects::nonNull) .forEach(objectsToHash::add); From c6fc3c2262e4f75142e4f9c5223861b3c9411369 Mon Sep 17 00:00:00 2001 From: Gulam Samdani Date: Thu, 25 May 2023 07:18:49 +0600 Subject: [PATCH 19/41] fix nullpointerexception issue when getting files from local meveo maven (#722) --- .../main/java/org/meveo/admin/web/servlet/MavenFileServlet.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meveo-admin-web/src/main/java/org/meveo/admin/web/servlet/MavenFileServlet.java b/meveo-admin-web/src/main/java/org/meveo/admin/web/servlet/MavenFileServlet.java index 3987a98d7..10d2cfff5 100644 --- a/meveo-admin-web/src/main/java/org/meveo/admin/web/servlet/MavenFileServlet.java +++ b/meveo-admin-web/src/main/java/org/meveo/admin/web/servlet/MavenFileServlet.java @@ -170,7 +170,7 @@ private void processRequest(HttpServletRequest request, HttpServletResponse resp String artifactName = requestedFileName.substring(0, indexOf); String version = requestedFileName.substring(indexOf + 1); module = moduleService.findByCode(artifactName); - if (!module.getCurrentVersion().equalsIgnoreCase(version)) { + if (module !=null && !module.getCurrentVersion().equalsIgnoreCase(version)) { module = null; } } From eba59336ca5c4e36ee575352f7fcc1e07771263b Mon Sep 17 00:00:00 2001 From: Gulam Samdani Date: Thu, 25 May 2023 07:53:42 +0600 Subject: [PATCH 20/41] Code revert for adding symbolic link in module (#721) --- .../admin/impl/MeveoModuleService.java | 9 -- .../impl/MavenConfigurationService.java | 123 +++++++----------- 2 files changed, 47 insertions(+), 85 deletions(-) diff --git a/meveo-admin-ejbs/src/main/java/org/meveo/service/admin/impl/MeveoModuleService.java b/meveo-admin-ejbs/src/main/java/org/meveo/service/admin/impl/MeveoModuleService.java index 71ae5bd76..fa073e2ba 100644 --- a/meveo-admin-ejbs/src/main/java/org/meveo/service/admin/impl/MeveoModuleService.java +++ b/meveo-admin-ejbs/src/main/java/org/meveo/service/admin/impl/MeveoModuleService.java @@ -969,15 +969,6 @@ public File findPom(MeveoModule module) { .resolve("pom.xml") .toFile(); } - - - public File findParentPom(MeveoModule module) { - return GitHelper.getRepositoryDir(null, module.getGitRepository()) - .toPath() - .resolve("facets") - .resolve("pom.xml") - .toFile(); - } @Override public void addFilesToModule(MeveoModule entity, MeveoModule module) throws BusinessException { diff --git a/meveo-admin-ejbs/src/main/java/org/meveo/service/config/impl/MavenConfigurationService.java b/meveo-admin-ejbs/src/main/java/org/meveo/service/config/impl/MavenConfigurationService.java index 468de2625..a80c5923f 100644 --- a/meveo-admin-ejbs/src/main/java/org/meveo/service/config/impl/MavenConfigurationService.java +++ b/meveo-admin-ejbs/src/main/java/org/meveo/service/config/impl/MavenConfigurationService.java @@ -43,7 +43,6 @@ import org.apache.maven.model.Dependency; import org.apache.maven.model.DependencyManagement; import org.apache.maven.model.Model; -import org.apache.maven.model.Parent; import org.apache.maven.model.Repository; import org.apache.maven.model.RepositoryPolicy; import org.apache.maven.model.io.xpp3.MavenXpp3Writer; @@ -302,99 +301,75 @@ private void generatePom(String message, MeveoModule module) { public void generatePom(String message, MeveoModule module,GitRepository repository) { //TODO: Avoid this code when module just got uninstalled - + File gitRepo = GitHelper.getRepositoryDir(currentUser.get(), module.getGitRepository()); Paths.get(gitRepo.getPath(), "facets", "maven").toFile().mkdirs(); + log.debug("Generating pom.xml file"); + + File pomFile = this.moduleService.findPom(module); + final Model model = MavenUtils.readModel(pomFile); + + model.setGroupId("org.meveo");//TODO: Add group id to module + model.setArtifactId(module.getCode()); + model.setVersion(module.getCurrentVersion()); + model.setModelVersion("4.0.0"); + model.setDependencyManagement(null); + model.setDependencies(null); + + if (model.getPomFile() == null) { + model.setBuild(new Build()); + } + + // Create symlink for java folder Path source = Paths.get(gitRepo.getPath(), "facets", "java"); source.toFile().mkdirs(); + + Path link = Paths.get(gitRepo.getPath(), "facets", "maven", "src", "main", "java"); + Path relativeSrc = link.getParent().relativize(source); + + try { + link.getParent().toFile().mkdirs(); + try { + Files.createSymbolicLink(link, relativeSrc); + } catch (FileAlreadyExistsException e) { + //NOOP + } + } catch (IOException e1) { + log.error("Failed to create symbolic link for java source", e1); + } + // Create .gitignore file Path gitIgnore = Paths.get(gitRepo.getPath(), "facets", "maven", ".gitignore"); List ignoredPatterns = List.of( "src/main/java/**", "target/" ); - + String gitIgnoreFile = String.join("\n", ignoredPatterns); try { MeveoFileUtils.writeAndPreserveCharset(gitIgnoreFile, gitIgnore.toFile()); } catch (IOException e1) { log.error("Failed to create gitignore", e1); } - - log.debug("Generating pom.xml file---"); - - generateParentPom(message,module,repository); - - generateChildPom(message,module,repository,gitIgnore); - - } - - private void generateParentPom(String message, MeveoModule module,GitRepository repository) { - File pomFile = this.moduleService.findParentPom(module); - final Model model = MavenUtils.readModel(pomFile); - - model.setGroupId("org.meveo");//TODO: Add group id to module - model.setArtifactId("facets"); - model.setVersion(module.getCurrentVersion()); - model.setModelVersion("4.0.0"); - model.setDependencyManagement(null); - model.setDependencies(null); - model.setPackaging("pom"); - Properties properties = new Properties(); properties.setProperty("maven.compiler.target", "11"); properties.setProperty("maven.compiler.source", "11"); model.setProperties(properties); - List modules = List.of("maven"); - model.setModules(modules); - - writeToPom(model, pomFile); - - List updatedFiles = List.of(pomFile); - - if (module.isAutoCommit()) { - try { - gitClient.commitFiles(repository, updatedFiles, message); - } catch (BusinessException e) { - log.error("Can't commit pom.xml file", e); - } - } - - } - - private void generateChildPom (String message, MeveoModule module,GitRepository repository,Path file) { - - File pomFile = this.moduleService.findPom(module); - final Model model = MavenUtils.readModel(pomFile); - - Parent parent = new Parent(); - parent.setArtifactId("facets"); - parent.setGroupId("org.meveo"); - parent.setVersion(module.getCurrentVersion()); - model.setParent(parent); - - model.setGroupId("org.meveo");//TODO: Add group id to module - model.setArtifactId(module.getCode()); - model.setVersion(module.getCurrentVersion()); - model.setModelVersion("4.0.0"); - model.setDependencyManagement(null); - model.setDependencies(null); - List remoteRepositories = remoteRepositoryService.list(); if (CollectionUtils.isNotEmpty(remoteRepositories)) { for (RemoteRepository remoteRepository : remoteRepositories) { MavenUtils.addRepository(model, remoteRepository); } } - + // Include meveo bom DependencyManagement dependencyManagement = new DependencyManagement(); model.setDependencyManagement(dependencyManagement); - + Dependency meveoBom = new Dependency(); meveoBom.setGroupId("org.meveo"); meveoBom.setArtifactId("meveo"); @@ -402,7 +377,7 @@ private void generateChildPom (String message, MeveoModule module,GitRepository meveoBom.setScope("import"); meveoBom.setVersion(System.getProperty("meveo.version", Version.appVersion)); MavenUtils.addOrUpdateDependency(dependencyManagement, meveoBom); - + Dependency wildflyBom = new Dependency(); wildflyBom.setGroupId("org.wildfly.bom"); wildflyBom.setArtifactId("wildfly-jakartaee8-with-tools"); @@ -410,7 +385,7 @@ private void generateChildPom (String message, MeveoModule module,GitRepository wildflyBom.setScope("import"); wildflyBom.setVersion("18.0.1.Final"); MavenUtils.addOrUpdateDependency(dependencyManagement, wildflyBom); - + Dependency wildflyBom2 = new Dependency(); wildflyBom2.setGroupId("org.wildfly.bom"); wildflyBom2.setArtifactId("wildfly-jakartaee8"); @@ -418,7 +393,7 @@ private void generateChildPom (String message, MeveoModule module,GitRepository wildflyBom2.setScope("import"); wildflyBom2.setVersion("18.0.1.Final"); MavenUtils.addOrUpdateDependency(dependencyManagement, wildflyBom2); - + Dependency wildflyBom3 = new Dependency(); wildflyBom3.setGroupId("org.wildfly"); wildflyBom3.setArtifactId("wildfly-feature-pack"); @@ -426,7 +401,7 @@ private void generateChildPom (String message, MeveoModule module,GitRepository wildflyBom3.setScope("import"); wildflyBom3.setVersion("18.0.1.Final"); MavenUtils.addOrUpdateDependency(dependencyManagement, wildflyBom3); - + // Use maven pkg repo before meveo instance repo Repository githubRepo = new Repository(); githubRepo.setId("github"); @@ -444,14 +419,14 @@ private void generateChildPom (String message, MeveoModule module,GitRepository } ownInstance.setUrl(baseUrl + System.getProperty("meveo.moduleName", "meveo") + "/maven"); MavenUtils.addRepository(model, ownInstance); - + Dependency meveoDependency = new Dependency(); meveoDependency.setGroupId("org.meveo"); meveoDependency.setArtifactId("meveo-api"); meveoDependency.setVersion(System.getProperty("meveo.version", Version.appVersion)); meveoDependency.setScope("import"); MavenUtils.addOrUpdateDependency(dependencyManagement, meveoDependency); - + module.getModuleDependencies().forEach(meveoModuleDependency -> { Dependency dependency = new Dependency(); dependency.setGroupId("org.meveo"); @@ -475,14 +450,10 @@ private void generateChildPom (String message, MeveoModule module,GitRepository log.error("Error retrieving maven dependencies", e); } - Build build = new Build(); - build.setSourceDirectory("../java"); - model.setBuild(build); - - List updatedFiles = List.of(pomFile, file.toFile()); - - writeToPom(model, pomFile); - + List updatedFiles = List.of(pomFile, gitIgnore.toFile(), link.toFile()); + + writeToPom(model, pomFile); + if (module.isAutoCommit()) { try { gitClient.commitFiles(repository, updatedFiles, message); @@ -491,7 +462,7 @@ private void generateChildPom (String message, MeveoModule module,GitRepository } } - } + } private void writeToPom(Model model, File pomFile) { try { From 2714d35c558079afb174d8adc7fcc5eb3b67c851 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Bareth-Desgranges?= Date: Fri, 26 May 2023 16:22:50 +0200 Subject: [PATCH 21/41] [FIX] Set up cet on entity ref create Fix #724 --- .../src/main/java/org/meveo/persistence/CrossStorageService.java | 1 + 1 file changed, 1 insertion(+) diff --git a/meveo-admin-ejbs/src/main/java/org/meveo/persistence/CrossStorageService.java b/meveo-admin-ejbs/src/main/java/org/meveo/persistence/CrossStorageService.java index e0824c673..47933578f 100644 --- a/meveo-admin-ejbs/src/main/java/org/meveo/persistence/CrossStorageService.java +++ b/meveo-admin-ejbs/src/main/java/org/meveo/persistence/CrossStorageService.java @@ -1109,6 +1109,7 @@ protected PersistenceActionResult createReferencedEntity(Repository repository, CustomEntityInstance cei = new CustomEntityInstance(); cei.setCetCode(customFieldTemplate.getEntityClazzCetCode()); cei.setCode((String) values.get("code")); + cei.setCet(customEntityTemplateService.findByCode(customFieldTemplate.getEntityClazzCetCode())); cei.setRepository(repository); String uuid = (String) values.get("uuid"); if (uuid != null) { From 6ec090afb212e72695e95b497dc2bc1aa2784551 Mon Sep 17 00:00:00 2001 From: smichea Date: Sat, 27 May 2023 00:11:43 +0200 Subject: [PATCH 22/41] include authentication in meveo maven github repo --- .../meveo/service/config/impl/MavenConfigurationService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meveo-admin-ejbs/src/main/java/org/meveo/service/config/impl/MavenConfigurationService.java b/meveo-admin-ejbs/src/main/java/org/meveo/service/config/impl/MavenConfigurationService.java index a80c5923f..7d36d061c 100644 --- a/meveo-admin-ejbs/src/main/java/org/meveo/service/config/impl/MavenConfigurationService.java +++ b/meveo-admin-ejbs/src/main/java/org/meveo/service/config/impl/MavenConfigurationService.java @@ -405,7 +405,7 @@ public void generatePom(String message, MeveoModule module,GitRepository reposit // Use maven pkg repo before meveo instance repo Repository githubRepo = new Repository(); githubRepo.setId("github"); - githubRepo.setUrl("https://maven.pkg.github.com/meveo-org/meveo"); + githubRepo.setUrl("https://smichea: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@maven.pkg.github.com/meveo-org/meveo"); RepositoryPolicy policy = new RepositoryPolicy(); policy.setEnabled(true); githubRepo.setSnapshots(policy); From 7c72188543cc7ed83206d507c3f83bf06845a93d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Bareth?= Date: Thu, 1 Jun 2023 18:48:23 +0200 Subject: [PATCH 23/41] Cache .m2 & compiled classes to speed up image building --- Dockerfile | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index b501a7e08..9faa0f801 100644 --- a/Dockerfile +++ b/Dockerfile @@ -18,7 +18,20 @@ COPY . . # Download all dependencies using docker cache #RUN mvn dependency:go-offline -RUN mvn clean package -Dscm.url=${SCM} -DskipTests +RUN --mount=type=cache,target=/root/.m2 \ + --mount=type=cache,target=/usr/src/meveo/target/classes \ + --mount=type=cache,target=/usr/src/meveo/meveo-admin-ejbs/target/classes \ + --mount=type=cache,target=/usr/src/meveo/meveo-admin-web/target/classes \ + --mount=type=cache,target=/usr/src/meveo/meveo-annotations/target/classes \ + --mount=type=cache,target=/usr/src/meveo/meveo-api/target/classes \ + --mount=type=cache,target=/usr/src/meveo/meveo-api-dto/target/classes \ + --mount=type=cache,target=/usr/src/meveo/meveo-el-resolver/target/classes \ + --mount=type=cache,target=/usr/src/meveo/meveo-json-schema/target/classes \ + --mount=type=cache,target=/usr/src/meveo/meveo-model/target/classes \ + --mount=type=cache,target=/usr/src/meveo/meveo-reporting/target/classes \ + --mount=type=cache,target=/usr/src/meveo/meveo-security/target/classes \ + --mount=type=cache,target=/usr/src/meveo/meveo-ws/target/classes \ + mvn package -Dscm.url=${SCM} -DskipTests -Dmaven.test.skip=true ################################################################## ##### Build meveo docker image ##### From 614b63833eb0d5a60ef5a6a3986bc6e69288bc5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Bareth?= Date: Thu, 1 Jun 2023 18:51:15 +0200 Subject: [PATCH 24/41] Add default timeout setting --- docker/README.md | 3 ++- docker/configs/cli/standalone-configuration.cli | 1 + docker/configs/cli/transactions.cli | 2 ++ 3 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 docker/configs/cli/transactions.cli diff --git a/docker/README.md b/docker/README.md index ac4c48842..433fd6da3 100644 --- a/docker/README.md +++ b/docker/README.md @@ -70,7 +70,8 @@ The following environment variables can be redefined for meveo service |WILDFLY_LOG_FILE_LEVEL |INFO |Wildfly server log level (means server.log file) | |WILDFLY_LOG_MEVEO_LEVEL |INFO |Meveo source log level | |WILDFLY_DEBUG_ENABLE |"false" |Add a debug option to Wildfly startup command ("true" or "false"). debug_enable could not be used with `JAVA_OPTS` together. If this value is `true`, `JAVA_OPTS` should be commented.| -|WILDFLY_DEBUG_PORT |9999 |Wildfly debug port | +|WILDFLY_DEBUG_PORT |9999 |Wildfly debug port +|DEFAULT_TX_TIMEOUT |300 | Default EJB transaction timeout | |JAVA_OPTS |Many parameters.
Need to look at code|This variable can override default settings for wildfly java application. If this value is defined, WILDFLY_CUSTOM_XMS and WILDFLY_CUSTOM_XMX are ignored. | |JAVA_EXTRA_OPTS |- |The extra options to add to the default jvm options. |### APM for Meveo wildfly diff --git a/docker/configs/cli/standalone-configuration.cli b/docker/configs/cli/standalone-configuration.cli index 31bad21cf..9936015b9 100644 --- a/docker/configs/cli/standalone-configuration.cli +++ b/docker/configs/cli/standalone-configuration.cli @@ -8,4 +8,5 @@ run-batch --file=/opt/jboss/wildfly/cli/email.cli run-batch --file=/opt/jboss/wildfly/cli/logging.cli run-batch --file=/opt/jboss/wildfly/cli/reverse-proxy.cli run-batch --file=/opt/jboss/wildfly/cli/deploy-scanner.cli +run-batch --file=/opt/jboss/wildfly/cli/transactions.cli stop-embedded-server \ No newline at end of file diff --git a/docker/configs/cli/transactions.cli b/docker/configs/cli/transactions.cli new file mode 100644 index 000000000..1253087c7 --- /dev/null +++ b/docker/configs/cli/transactions.cli @@ -0,0 +1,2 @@ +# Change transaction timeout +/subsystem=transactions/:write-attribute(name=default-timeout,value="${env.DEFAULT_TX_TIMEOUT:300}") \ No newline at end of file From 5ea5231daf99ff960445cfb6a6b5e14d7720ffd1 Mon Sep 17 00:00:00 2001 From: Gulam Samdani Date: Tue, 6 Jun 2023 03:57:46 +0600 Subject: [PATCH 25/41] module pom update . (#725) * module pom update . * repository name update. --- .../impl/MavenConfigurationService.java | 45 +++++++------------ 1 file changed, 15 insertions(+), 30 deletions(-) diff --git a/meveo-admin-ejbs/src/main/java/org/meveo/service/config/impl/MavenConfigurationService.java b/meveo-admin-ejbs/src/main/java/org/meveo/service/config/impl/MavenConfigurationService.java index 7d36d061c..7c35ba39d 100644 --- a/meveo-admin-ejbs/src/main/java/org/meveo/service/config/impl/MavenConfigurationService.java +++ b/meveo-admin-ejbs/src/main/java/org/meveo/service/config/impl/MavenConfigurationService.java @@ -357,6 +357,7 @@ public void generatePom(String message, MeveoModule module,GitRepository reposit Properties properties = new Properties(); properties.setProperty("maven.compiler.target", "11"); properties.setProperty("maven.compiler.source", "11"); + properties.setProperty("jakartaee-version", "8.0.0"); model.setProperties(properties); List remoteRepositories = remoteRepositoryService.list(); @@ -366,9 +367,8 @@ public void generatePom(String message, MeveoModule module,GitRepository reposit } } - // Include meveo bom - DependencyManagement dependencyManagement = new DependencyManagement(); - model.setDependencyManagement(dependencyManagement); + List dependencies = new ArrayList<>(); + model.setDependencies(dependencies); Dependency meveoBom = new Dependency(); meveoBom.setGroupId("org.meveo"); @@ -376,35 +376,20 @@ public void generatePom(String message, MeveoModule module,GitRepository reposit meveoBom.setType("pom"); meveoBom.setScope("import"); meveoBom.setVersion(System.getProperty("meveo.version", Version.appVersion)); - MavenUtils.addOrUpdateDependency(dependencyManagement, meveoBom); + dependencies.add(meveoBom); - Dependency wildflyBom = new Dependency(); - wildflyBom.setGroupId("org.wildfly.bom"); - wildflyBom.setArtifactId("wildfly-jakartaee8-with-tools"); - wildflyBom.setType("pom"); - wildflyBom.setScope("import"); - wildflyBom.setVersion("18.0.1.Final"); - MavenUtils.addOrUpdateDependency(dependencyManagement, wildflyBom); - - Dependency wildflyBom2 = new Dependency(); - wildflyBom2.setGroupId("org.wildfly.bom"); - wildflyBom2.setArtifactId("wildfly-jakartaee8"); - wildflyBom2.setType("pom"); - wildflyBom2.setScope("import"); - wildflyBom2.setVersion("18.0.1.Final"); - MavenUtils.addOrUpdateDependency(dependencyManagement, wildflyBom2); - - Dependency wildflyBom3 = new Dependency(); - wildflyBom3.setGroupId("org.wildfly"); - wildflyBom3.setArtifactId("wildfly-feature-pack"); - wildflyBom3.setType("pom"); - wildflyBom3.setScope("import"); - wildflyBom3.setVersion("18.0.1.Final"); - MavenUtils.addOrUpdateDependency(dependencyManagement, wildflyBom3); + Dependency jakartaplatform = new Dependency(); + jakartaplatform.setGroupId("jakarta.platform"); + jakartaplatform.setArtifactId("jakarta.jakartaee-api"); + jakartaplatform.setVersion(properties.getProperty("jakartaee-version")); + jakartaplatform.setScope("provided"); + jakartaplatform.setOptional(true); + dependencies.add(jakartaplatform); // Use maven pkg repo before meveo instance repo Repository githubRepo = new Repository(); githubRepo.setId("github"); + githubRepo.setName("meveo github"); githubRepo.setUrl("https://smichea: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@maven.pkg.github.com/meveo-org/meveo"); RepositoryPolicy policy = new RepositoryPolicy(); policy.setEnabled(true); @@ -424,8 +409,8 @@ public void generatePom(String message, MeveoModule module,GitRepository reposit meveoDependency.setGroupId("org.meveo"); meveoDependency.setArtifactId("meveo-api"); meveoDependency.setVersion(System.getProperty("meveo.version", Version.appVersion)); - meveoDependency.setScope("import"); - MavenUtils.addOrUpdateDependency(dependencyManagement, meveoDependency); + meveoDependency.setOptional(true); + dependencies.add(meveoDependency); module.getModuleDependencies().forEach(meveoModuleDependency -> { Dependency dependency = new Dependency(); @@ -433,7 +418,7 @@ public void generatePom(String message, MeveoModule module,GitRepository reposit dependency.setArtifactId(meveoModuleDependency.getCode()); dependency.setVersion(meveoModuleDependency.getCurrentVersion()); dependency.setScope("compile"); - MavenUtils.addOrUpdateDependency(dependencyManagement, dependency); + dependencies.add(dependency); }); try { From 11dc93682d8639bf383c3aa5d3abfa4fdd9f3561 Mon Sep 17 00:00:00 2001 From: Gulam Samdani Date: Tue, 6 Jun 2023 04:00:14 +0600 Subject: [PATCH 26/41] resolved dependency issue from remote repo (#727) --- .../service/script/CustomScriptService.java | 49 +++++++++++++------ 1 file changed, 33 insertions(+), 16 deletions(-) diff --git a/meveo-admin-ejbs/src/main/java/org/meveo/service/script/CustomScriptService.java b/meveo-admin-ejbs/src/main/java/org/meveo/service/script/CustomScriptService.java index 2e8e9064a..9669154cc 100644 --- a/meveo-admin-ejbs/src/main/java/org/meveo/service/script/CustomScriptService.java +++ b/meveo-admin-ejbs/src/main/java/org/meveo/service/script/CustomScriptService.java @@ -777,7 +777,7 @@ public List addMavenLibrariesToClassPath(Collection getMavenDependencies(MavenDependency e, List remoteRepositories) { Set result = null; staticLogger.info("Resolving artifacts for {}", e); - List artifacts; + List artifacts = null; DefaultArtifact rootArtifact = new DefaultArtifact(e.getGroupId(), e.getArtifactId(), e.getClassifier(), "jar", e.getVersion()); DependencyFilter classpathFlter = DependencyFilterUtils.classpathFilter(JavaScopes.COMPILE); @@ -795,25 +795,30 @@ private Set getMavenDependencies(MavenDependency e, List mavenremoterepo = new ArrayList<>(); + mavenremoterepo.add(remoterepository); + collectRequestRemote.setRepositories(mavenremoterepo); + + DependencyRequest theDependencyRequest = new DependencyRequest(collectRequestRemote, classpathFlter); + DependencyResult dependencyResult = collectDependencies(theDependencyRequest); + if(dependencyResult != null) { + artifacts = dependencyResult.getArtifactResults(); + break; + } + } + + if (artifacts == null){ + staticLogger.error("Fail downloading dependencies {}"); + return null; + } } - staticLogger.debug("Found {} artifacts for dependency {}", artifacts.size(), e); result = artifacts.stream().filter(Objects::nonNull).map(artifact -> { @@ -822,6 +827,18 @@ private Set getMavenDependencies(MavenDependency e, List Date: Wed, 7 Jun 2023 06:00:59 +0600 Subject: [PATCH 27/41] module Clone Url correction (#729) --- .../java/org/meveo/admin/action/storage/GitRepositoryBean.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/meveo-admin-web/src/main/java/org/meveo/admin/action/storage/GitRepositoryBean.java b/meveo-admin-web/src/main/java/org/meveo/admin/action/storage/GitRepositoryBean.java index 768a36a57..eab232659 100644 --- a/meveo-admin-web/src/main/java/org/meveo/admin/action/storage/GitRepositoryBean.java +++ b/meveo-admin-web/src/main/java/org/meveo/admin/action/storage/GitRepositoryBean.java @@ -448,12 +448,14 @@ public String getGitCloneUrl() { try { ParamBean paramBean = ParamBean.getInstance(); String baseUrlConfig = paramBean.getProperty("meveo.admin.baseUrl", "http://localhost:8080/meveo"); + String webContext = paramBean.getProperty("meveo.admin.webContext","meveo"); URL baseUrl = new URL(baseUrlConfig); return baseUrl.getProtocol() + "://" + currentUser.getUserName() + ":@" + baseUrlConfig.replace(baseUrl.getProtocol() + "://","") + + webContext + "/git/" + this.entity.getCode(); } From fad00a07223c5c9f98f52bb83e162b17e12af1da Mon Sep 17 00:00:00 2001 From: Arthur Grenier Date: Thu, 8 Jun 2023 10:52:47 +0200 Subject: [PATCH 28/41] Retreive field with inheritance except for crt --- .../crm/impl/CustomFieldTemplateService.java | 7 +++++++ .../api/technicalservice/DescriptionApi.java | 16 ++++++++-------- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/meveo-admin-ejbs/src/main/java/org/meveo/service/crm/impl/CustomFieldTemplateService.java b/meveo-admin-ejbs/src/main/java/org/meveo/service/crm/impl/CustomFieldTemplateService.java index 28edf7c48..e3c867241 100644 --- a/meveo-admin-ejbs/src/main/java/org/meveo/service/crm/impl/CustomFieldTemplateService.java +++ b/meveo-admin-ejbs/src/main/java/org/meveo/service/crm/impl/CustomFieldTemplateService.java @@ -161,6 +161,13 @@ public Map findByAppliesTo(ICustomFieldEntity entit } } + public CustomFieldTemplate find(String code, CustomModelObject modelObj) { + if (modelObj instanceof CustomEntityTemplate) { + return find(code, (CustomEntityTemplate) modelObj); + } + return this.findByCodeAndAppliesTo(code, modelObj.getAppliesTo()); + } + /** * Retrieve cft by code, in the fields of the given cet or its ancestors * diff --git a/meveo-api/src/main/java/org/meveo/api/technicalservice/DescriptionApi.java b/meveo-api/src/main/java/org/meveo/api/technicalservice/DescriptionApi.java index 0e0cf4389..c9a82c82a 100644 --- a/meveo-api/src/main/java/org/meveo/api/technicalservice/DescriptionApi.java +++ b/meveo-api/src/main/java/org/meveo/api/technicalservice/DescriptionApi.java @@ -31,6 +31,7 @@ import org.meveo.api.exception.EntityDoesNotExistsException; import org.meveo.model.crm.CustomFieldTemplate; import org.meveo.model.customEntities.CustomEntityTemplate; +import org.meveo.model.customEntities.CustomModelObject; import org.meveo.model.customEntities.CustomRelationshipTemplate; import org.meveo.model.technicalservice.Description; import org.meveo.model.technicalservice.InputMeveoProperty; @@ -115,7 +116,7 @@ public InputMeveoProperty fromInputPropertyDto(String serviceCode, InputProperty public Description toDescription(TechnicalService technicalService, InputOutputDescription dto) throws EntityDoesNotExistsException { Description description; String code; - String appliesTo; + CustomModelObject modelObj; if (dto instanceof ProcessEntityDescription) { description = new MeveoEntityDescription(); ((MeveoEntityDescription) description).setName(dto.getName()); @@ -125,7 +126,7 @@ public Description toDescription(TechnicalService technicalService, InputOutputD } ((MeveoEntityDescription) description).setType(customEntityTemplate); code = customEntityTemplate.getCode(); - appliesTo = customEntityTemplate.getAppliesTo(); + modelObj = customEntityTemplate; } else { description = new RelationDescription(); ((RelationDescription) description).setSource(((ProcessRelationDescription) dto).getSource()); @@ -136,12 +137,11 @@ public Description toDescription(TechnicalService technicalService, InputOutputD } ((RelationDescription) description).setType(customRelationshipTemplate); code = customRelationshipTemplate.getCode(); - appliesTo = customRelationshipTemplate.getAppliesTo(); + modelObj = customRelationshipTemplate; } description.setInherited(dto.isInherited()); description.setService(technicalService); - Map customFields = customFieldTemplateService.findByAppliesToNoCache(appliesTo); description.setInput(dto.isInput()); description.setOutput(dto.isOutput()); description.setName(dto.getName()); @@ -149,10 +149,10 @@ public Description toDescription(TechnicalService technicalService, InputOutputD final List outputProperties = new ArrayList<>(); for (InputPropertyDto p : dto.getInputProperties()) { InputMeveoProperty inputProperty = new InputMeveoProperty(); - CustomFieldTemplate property = customFields.get(p.getProperty()); + CustomFieldTemplate property = customFieldTemplateService.find(code, modelObj); if (property == null) { LOGGER.error("No custom field template for property {} of custom template {}", p.getProperty(), code); - throw new EntityDoesNotExistsException(CustomRelationshipTemplate.class, p.getProperty()); + throw new EntityDoesNotExistsException(CustomFieldTemplate.class, p.getProperty()); } inputProperty.setDescription(description); inputProperty.setProperty(property); @@ -166,9 +166,9 @@ public Description toDescription(TechnicalService technicalService, InputOutputD description.setInputProperties(inputProperties); for (OutputPropertyDto p : dto.getOutputProperties()) { OutputMeveoProperty outputProperty = new OutputMeveoProperty(); - CustomFieldTemplate property = customFields.get(p.getProperty()); + CustomFieldTemplate property = customFieldTemplateService.find(code, modelObj); if (property == null) { - throw new EntityDoesNotExistsException(CustomRelationshipTemplate.class, p.getProperty()); + throw new EntityDoesNotExistsException(CustomFieldTemplate.class, p.getProperty()); } outputProperty.setProperty(property); outputProperty.setDescription(description); From f0238fe59732d546e3c5736fda787dd510c9f652 Mon Sep 17 00:00:00 2001 From: Gulam Samdani Date: Sun, 11 Jun 2023 08:28:22 +0600 Subject: [PATCH 29/41] UUID field max length increase for Sha512 (#732) --- meveo-model/src/main/java/org/meveo/model/BusinessCFEntity.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meveo-model/src/main/java/org/meveo/model/BusinessCFEntity.java b/meveo-model/src/main/java/org/meveo/model/BusinessCFEntity.java index e3ecada07..4d9b1fcaf 100644 --- a/meveo-model/src/main/java/org/meveo/model/BusinessCFEntity.java +++ b/meveo-model/src/main/java/org/meveo/model/BusinessCFEntity.java @@ -35,7 +35,7 @@ public abstract class BusinessCFEntity extends BusinessEntity implements ICustom private static final long serialVersionUID = -6054446440106807337L; @Column(name = "uuid", nullable = false, updatable = false, length = 60) - @Size(max = 60) + @Size(max = 128) @NotNull private String uuid = UUID.randomUUID().toString(); From dce10141817af56d9993230292f76e705a995bb6 Mon Sep 17 00:00:00 2001 From: Gulam Samdani Date: Mon, 12 Jun 2023 04:18:38 +0600 Subject: [PATCH 30/41] remote push issue solved. (#734) * remote push issue solved. * thrown exception for each push status other than ok & up to date. * set unique message for each push status --- .../java/org/meveo/service/git/GitClient.java | 47 +++++++++++++++++-- 1 file changed, 43 insertions(+), 4 deletions(-) diff --git a/meveo-admin-ejbs/src/main/java/org/meveo/service/git/GitClient.java b/meveo-admin-ejbs/src/main/java/org/meveo/service/git/GitClient.java index c3a753e7d..59152e15b 100644 --- a/meveo-admin-ejbs/src/main/java/org/meveo/service/git/GitClient.java +++ b/meveo-admin-ejbs/src/main/java/org/meveo/service/git/GitClient.java @@ -69,6 +69,8 @@ import org.eclipse.jgit.revwalk.RevWalk; import org.eclipse.jgit.storage.file.WindowCacheConfig; import org.eclipse.jgit.transport.CredentialsProvider; +import org.eclipse.jgit.transport.PushResult; +import org.eclipse.jgit.transport.RemoteRefUpdate; import org.eclipse.jgit.transport.URIish; import org.eclipse.jgit.util.io.DisabledOutputStream; import org.meveo.admin.exception.BusinessException; @@ -412,17 +414,18 @@ public void push(GitRepository gitRepository, String username, String password) } final File repositoryDir = GitHelper.getRepositoryDir(user, gitRepository); - keyLock.lock(gitRepository.getCode()); try (Git git = Git.open(repositoryDir)) { final PushCommand push = git.push(); if(gitRepository.getRemoteOrigin().startsWith("http")) { - CredentialsProvider usernamePasswordCredentialsProvider = GitHelper.getCredentialsProvider(gitRepository, username, password, user); - push.setCredentialsProvider(usernamePasswordCredentialsProvider).call(); + CredentialsProvider usernamePasswordCredentialsProvider = GitHelper.getCredentialsProvider(gitRepository, username, password, user); + Iterable pushResults = push.setCredentialsProvider(usernamePasswordCredentialsProvider).call(); + getPushUpdateStatus(pushResults); } else { SshTransportConfigCallback sshTransportConfigCallback = new SshTransportConfigCallback(user.getSshPrivateKey(), user.getSshPublicKey(), password); - push.setTransportConfigCallback(sshTransportConfigCallback).call(); + Iterable pushResults = push.setTransportConfigCallback(sshTransportConfigCallback).call(); + getPushUpdateStatus(pushResults); } } catch (IOException e) { @@ -1163,5 +1166,41 @@ protected void createGitMeveoFolder(GitRepository gitRepository, File repoDir) t keyLock.unlock(gitRepository.getCode()); } } + + /* + * Represent remote update status of a push + * @throws BusinessException if repository cannot be opened or if a problem happen during the push + */ + private void getPushUpdateStatus(Iterable pushResults)throws BusinessException { + for (PushResult pushresult : pushResults) { + for(RemoteRefUpdate remoteRef : pushresult.getRemoteUpdates()) { + if(remoteRef.getStatus() != RemoteRefUpdate.Status.OK && remoteRef.getStatus() != RemoteRefUpdate.Status.UP_TO_DATE) { + + if(remoteRef.getStatus() == RemoteRefUpdate.Status.REJECTED_NONFASTFORWARD) { + throw new BusinessException("Updates were rejected because the remote contains work that you do not have locally."); + } + if(remoteRef.getStatus() == RemoteRefUpdate.Status.NOT_ATTEMPTED) { + throw new BusinessException("Push process hasn't yet attempted to update this ref."); + } + if(remoteRef.getStatus() == RemoteRefUpdate.Status.REJECTED_NODELETE) { + throw new BusinessException("Remote ref update was rejected, because remote side doesn't support/allow deleting refs."); + } + if(remoteRef.getStatus() == RemoteRefUpdate.Status.REJECTED_REMOTE_CHANGED) { + throw new BusinessException("Remote ref update was rejected, because old object id on remote repository wasn't the same as defined expected old object."); + } + if(remoteRef.getStatus() == RemoteRefUpdate.Status.REJECTED_OTHER_REASON) { + throw new BusinessException("Remote ref update was rejected " +remoteRef.getMessage()); + } + if(remoteRef.getStatus() == RemoteRefUpdate.Status.NON_EXISTING) { + throw new BusinessException("Remote ref didn't exist."); + } + if(remoteRef.getStatus() == RemoteRefUpdate.Status.AWAITING_REPORT) { + throw new BusinessException("Push process is awaiting update report from remote repository."); + } + + } + } + } + } } From 009ea051c90226c01c09a5201f7d7070eff4a70a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Bareth-Desgranges?= Date: Wed, 21 Jun 2023 16:22:38 +0200 Subject: [PATCH 31/41] Always check if child template is stored as table before deletion --- .../service/base/NativePersistenceService.java | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/meveo-admin-ejbs/src/main/java/org/meveo/service/base/NativePersistenceService.java b/meveo-admin-ejbs/src/main/java/org/meveo/service/base/NativePersistenceService.java index 9ba96bee1..629e41af6 100644 --- a/meveo-admin-ejbs/src/main/java/org/meveo/service/base/NativePersistenceService.java +++ b/meveo-admin-ejbs/src/main/java/org/meveo/service/base/NativePersistenceService.java @@ -952,7 +952,11 @@ public void remove(String sqlConnectionCode, CustomEntityTemplate template) thro // Remove records in children tables var subTemplates = customEntityTemplateService.getSubTemplates(template); - subTemplates.forEach(subT -> doUpdate(sqlConnectionCode, "delete from " + tableName(subT), (ps) -> {})); + subTemplates.forEach(subT -> { + if (subT.isStoreAsTable()) { + doUpdate(sqlConnectionCode, "delete from " + tableName(subT), (ps) -> {}); + } + }); // Gather uuids to delete List uuids = getEntityManager(sqlConnectionCode) @@ -981,7 +985,11 @@ public void remove(String sqlConnectionCode, CustomEntityTemplate template) thro public void remove(String sqlConnectionCode, CustomEntityTemplate template, Collection ids) throws BusinessException { // Remove record in children tables var subTemplates = customEntityTemplateService.getSubTemplates(template); - subTemplates.forEach(subT -> removeRecords(sqlConnectionCode, tableName(subT), ids)); + subTemplates.forEach(subT -> { + if (subT.isStoreAsTable()) { + removeRecords(sqlConnectionCode, tableName(subT), ids); + } + }); // Remove in own table removeRecords(sqlConnectionCode, tableName(template), ids); @@ -1030,7 +1038,11 @@ private void removeRecords(String sqlConnectionCode, String tableName, Collectio public void remove(String sqlConnectionCode, CustomEntityTemplate template, String uuid) throws BusinessException { // Remove record in children tables var subTemplates = customEntityTemplateService.getSubTemplates(template); - subTemplates.forEach(subT -> removeRecord(sqlConnectionCode, uuid, tableName(subT))); + subTemplates.forEach(subT -> { + if (subT.isStoreAsTable()) { + removeRecord(sqlConnectionCode, uuid, tableName(subT)); + } + }); // Remove in own table removeRecord(sqlConnectionCode, uuid, tableName(template)); From 54b14660bdd012f02d275b300ea4f97337c5241c Mon Sep 17 00:00:00 2001 From: Arthur Grenier Date: Fri, 9 Jun 2023 17:30:08 +0200 Subject: [PATCH 32/41] fix extractor import outputProperties and creation --- .../service/crm/impl/CustomFieldTemplateService.java | 9 +++++++++ .../org/meveo/api/technicalservice/DescriptionApi.java | 4 ++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/meveo-admin-ejbs/src/main/java/org/meveo/service/crm/impl/CustomFieldTemplateService.java b/meveo-admin-ejbs/src/main/java/org/meveo/service/crm/impl/CustomFieldTemplateService.java index e3c867241..1a3d658a8 100644 --- a/meveo-admin-ejbs/src/main/java/org/meveo/service/crm/impl/CustomFieldTemplateService.java +++ b/meveo-admin-ejbs/src/main/java/org/meveo/service/crm/impl/CustomFieldTemplateService.java @@ -336,6 +336,15 @@ public CustomFieldTemplate findByCodeAndAppliesToNoCache(String code, String app return null; } } + + public CustomFieldTemplate find(String cftCode, String appliesTo) { + if (appliesTo.startsWith(CustomRelationshipTemplate.CRT_PREFIX)) { + return this.findByCodeAndAppliesTo(cftCode, appliesTo); + } else { + CustomEntityTemplate cet = customEntityTemplateService.findByCode(CustomEntityTemplate.getCodeFromAppliesTo(appliesTo)); + return this.find(cftCode, cet); + } + } @Override public void create(CustomFieldTemplate cft) throws BusinessException { diff --git a/meveo-api/src/main/java/org/meveo/api/technicalservice/DescriptionApi.java b/meveo-api/src/main/java/org/meveo/api/technicalservice/DescriptionApi.java index c9a82c82a..947f21304 100644 --- a/meveo-api/src/main/java/org/meveo/api/technicalservice/DescriptionApi.java +++ b/meveo-api/src/main/java/org/meveo/api/technicalservice/DescriptionApi.java @@ -149,7 +149,7 @@ public Description toDescription(TechnicalService technicalService, InputOutputD final List outputProperties = new ArrayList<>(); for (InputPropertyDto p : dto.getInputProperties()) { InputMeveoProperty inputProperty = new InputMeveoProperty(); - CustomFieldTemplate property = customFieldTemplateService.find(code, modelObj); + CustomFieldTemplate property = customFieldTemplateService.find(p.getProperty(), modelObj); if (property == null) { LOGGER.error("No custom field template for property {} of custom template {}", p.getProperty(), code); throw new EntityDoesNotExistsException(CustomFieldTemplate.class, p.getProperty()); @@ -166,7 +166,7 @@ public Description toDescription(TechnicalService technicalService, InputOutputD description.setInputProperties(inputProperties); for (OutputPropertyDto p : dto.getOutputProperties()) { OutputMeveoProperty outputProperty = new OutputMeveoProperty(); - CustomFieldTemplate property = customFieldTemplateService.find(code, modelObj); + CustomFieldTemplate property = customFieldTemplateService.find(p.getProperty(), modelObj); if (property == null) { throw new EntityDoesNotExistsException(CustomFieldTemplate.class, p.getProperty()); } From f48d050104e3c5aa9cf0b418282486b142cbd683 Mon Sep 17 00:00:00 2001 From: smichea Date: Thu, 22 Jun 2023 13:28:44 +0200 Subject: [PATCH 33/41] fix #736 --- .../org/meveo/model/persistence/CEIUtils.java | 37 +++++++++++++------ .../org/meveo/security/PasswordUtils.java | 13 ++++--- 2 files changed, 32 insertions(+), 18 deletions(-) diff --git a/meveo-model/src/main/java/org/meveo/model/persistence/CEIUtils.java b/meveo-model/src/main/java/org/meveo/model/persistence/CEIUtils.java index efcb19254..82633ffda 100644 --- a/meveo-model/src/main/java/org/meveo/model/persistence/CEIUtils.java +++ b/meveo-model/src/main/java/org/meveo/model/persistence/CEIUtils.java @@ -80,9 +80,8 @@ public static String getHash(CustomEntityInstance cei, Map cft1.getCode().compareTo(cft2.getCode())) - .filter(cft -> !cft.getFieldType().equals(CustomFieldTypeEnum.SECRET)) + .filter(cft -> !(cft.getFieldType().equals(CustomFieldTypeEnum.SECRET)||cft.getFieldType().equals(CustomFieldTypeEnum.ENTITY))) .map(cft -> values.get(cft.getCode())) - .map(val -> !(val instanceof EntityReferenceWrapper)) .filter(java.util.Objects::nonNull) .forEach(objectsToHash::add); @@ -528,6 +527,11 @@ public static CustomEntityInstance pojoToCei(Object pojo) { // Convert to EntityReferenceWrapper var reference = new EntityReferenceWrapper((BusinessEntity) e.getValue()); pojoAsMap.put(e.getKey(), reference); + } else if (e.getValue() instanceof BaseEntity) { + // Convert to EntityReferenceWrapper + BaseEntity entity = (BaseEntity)e.getValue(); + var reference = new EntityReferenceWrapper(entity.getClass().getName(), CustomFieldTemplate.retrieveCetCode(entity.getClass().getName()), null, entity.getId()); + pojoAsMap.put(e.getKey(), reference); } else { pojoAsMap.put(e.getKey(), getIdValue(e.getValue())); } @@ -600,14 +604,14 @@ private static void setUUIDField(Object object, String value) { private static Object getIdValue(Object object) { return ReflectionUtils.getAllFields(new ArrayList<>(), object.getClass()).stream().filter(f -> f.getAnnotation(Id.class) != null).findFirst().map(f -> { - try { - f.setAccessible(true); - return f.get(object); - } catch (IllegalArgumentException | IllegalAccessException e) { - throw new RuntimeException(e); - } - }).orElse(null); - } + try { + f.setAccessible(true); + return f.get(object); + } catch (IllegalArgumentException | IllegalAccessException e) { + throw new RuntimeException(e); + } + }).orElse(null); + } public static String serialize(CustomEntityInstance entity) { Map values = entity.getCfValuesAsValues(); @@ -621,8 +625,12 @@ public static String serialize(CustomEntityInstance entity) { // Serialize references values.entrySet().forEach(entry -> { if (entry.getValue() instanceof EntityReferenceWrapper) { - entry.setValue(((EntityReferenceWrapper) entry.getValue()).getUuid()); - } + if(((EntityReferenceWrapper) entry.getValue()).getUuid()!=null){ + entry.setValue(((EntityReferenceWrapper) entry.getValue()).getUuid()); + } else { + entry.setValue(((EntityReferenceWrapper) entry.getValue()).getId()); + } + } }); return JacksonUtil.toStringPrettyPrinted(values); @@ -671,6 +679,11 @@ public static T deserialize(Map value, Class clazz) throw try { if (entry.getValue() instanceof BaseEntity || entry.getValue() instanceof ICustomFieldEntity) { setter.invoke(instance, entry.getValue()); + } else if (entry.getValue() instanceof EntityReferenceWrapper) { + lazyInitInstance = paramType.getDeclaredConstructor().newInstance(); + setIdField(lazyInitInstance, ((EntityReferenceWrapper ) entry.getValue()).getId()); + setter.invoke(instance, lazyInitInstance); + } else { var type = setter.getParameters()[0].getParameterizedType(); var jacksonType = TypeFactory.defaultInstance().constructType(type); diff --git a/meveo-model/src/main/java/org/meveo/security/PasswordUtils.java b/meveo-model/src/main/java/org/meveo/security/PasswordUtils.java index c734b079d..6c48c22a2 100644 --- a/meveo-model/src/main/java/org/meveo/security/PasswordUtils.java +++ b/meveo-model/src/main/java/org/meveo/security/PasswordUtils.java @@ -46,7 +46,7 @@ public static String getSalt(Object... values) { String stringValues = StringUtils.join(values); byte[] encodedhash = digest.digest(stringValues.getBytes(StandardCharsets.UTF_8)); - return new String(encodedhash, StandardCharsets.UTF_8); + return Base64.getEncoder().encodeToString(encodedhash); } /** @@ -116,21 +116,22 @@ public static String encryptNoSecret(String salt, String value) { * @throws Exception if error occurs */ public static String decryptNoSecret(String salt, String encrypted) { - if(encrypted.startsWith(SECRET_PREFIX)) { // Don't include this special char when decrypting - encrypted = encrypted.substring(SECRET_PREFIX.length()); - } else { + if(!encrypted.startsWith(SECRET_PREFIX)) { // Don't include this special char when decrypting // Consider the string is not encrypted return encrypted; } + String encryptedWithoutPrefix = encrypted.substring(SECRET_PREFIX.length()); try { Cipher cipher = initCipherNoSecret(salt, Cipher.DECRYPT_MODE); - byte[] decodedBytes = Base64.getDecoder().decode(encrypted); + byte[] decodedBytes = Base64.getDecoder().decode(encryptedWithoutPrefix); byte[] original = cipher.doFinal(decodedBytes); byte[] originalWithoutIv = Arrays.copyOfRange(original, 16, original.length); return new String(originalWithoutIv); } catch (Exception e) { - throw new RuntimeException(e); + e.printStackTrace(); + //we failed to decrypt but should not interrupt execution + return encrypted; } } From b5a4dae0ed0e04f74f359e4c93dab61c30bc5052 Mon Sep 17 00:00:00 2001 From: smichea Date: Fri, 23 Jun 2023 08:47:38 +0200 Subject: [PATCH 34/41] add bouncycastle dependency --- .../src/main/webapp/WEB-INF/jboss-deployment-structure.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/meveo-admin-web/src/main/webapp/WEB-INF/jboss-deployment-structure.xml b/meveo-admin-web/src/main/webapp/WEB-INF/jboss-deployment-structure.xml index 4826cc9cb..b310efc8b 100644 --- a/meveo-admin-web/src/main/webapp/WEB-INF/jboss-deployment-structure.xml +++ b/meveo-admin-web/src/main/webapp/WEB-INF/jboss-deployment-structure.xml @@ -24,6 +24,7 @@ + \ No newline at end of file From a9f4a8f8170e4d1809e92baeee1be6f53169bb33 Mon Sep 17 00:00:00 2001 From: Gulam Samdani Date: Tue, 27 Jun 2023 05:06:59 +0600 Subject: [PATCH 35/41] Grid column data loading when User a ref entity (#737) * Grid column data loaded when User a ref entity * Grid column data loaded when Provider a ref entity * Correction. * Get id expect CET Person provider type class * remove items for Classname combo box --- .../action/crm/CustomFieldTemplateBean.java | 7 +++++++ .../converter/EntityReferenceConverter.java | 20 ++++++++++++++++++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/meveo-admin-web/src/main/java/org/meveo/admin/action/crm/CustomFieldTemplateBean.java b/meveo-admin-web/src/main/java/org/meveo/admin/action/crm/CustomFieldTemplateBean.java index 5ed0f452f..443e760c5 100644 --- a/meveo-admin-web/src/main/java/org/meveo/admin/action/crm/CustomFieldTemplateBean.java +++ b/meveo-admin-web/src/main/java/org/meveo/admin/action/crm/CustomFieldTemplateBean.java @@ -359,6 +359,13 @@ public List autocompleteClassNames(String query) { filter.setIncludeParentClassesOnly(false); List entities = customizedEntityService.getCustomizedEntities(filter); + entities.removeIf(e ->e.getEntityClass().getName().contains("org.meveo.admin.job")); + entities.removeIf(e ->e.getEntityClass().getName().contains("org.meveo.model.storage.BinaryStorageConfiguration")); + entities.removeIf(e ->e.getEntityClass().getName().contains("org.meveo.model.filter.Filter")); + entities.removeIf(e ->e.getEntityClass().getName().contains("org.meveo.model.admin.MvCredential")); + entities.removeIf(e ->e.getEntityClass().getName().contains("org.meveo.model.neo4j.Neo4JConfiguration")); + entities.removeIf(e ->e.getEntityClass().getName().contains("org.meveo.model.sql.SqlConfiguration")); + entities.removeIf(e ->e.getEntityClass().getName().contains("org.meveo.model.storage.StorageConfiguration")); for (CustomizedEntity customizedEntity : entities) { clazzNames.add(customizedEntity.getClassnameToDisplay()); diff --git a/meveo-admin-web/src/main/java/org/meveo/admin/jsf/converter/EntityReferenceConverter.java b/meveo-admin-web/src/main/java/org/meveo/admin/jsf/converter/EntityReferenceConverter.java index efdc46970..e5da206d0 100644 --- a/meveo-admin-web/src/main/java/org/meveo/admin/jsf/converter/EntityReferenceConverter.java +++ b/meveo-admin-web/src/main/java/org/meveo/admin/jsf/converter/EntityReferenceConverter.java @@ -15,11 +15,15 @@ import javax.inject.Inject; import javax.inject.Named; +import org.meveo.model.admin.User; import org.meveo.model.crm.CustomFieldTemplate; import org.meveo.model.crm.EntityReferenceWrapper; +import org.meveo.model.crm.Provider; import org.meveo.model.crm.custom.CustomFieldTypeEnum; import org.meveo.model.storage.Repository; +import org.meveo.service.admin.impl.UserService; import org.meveo.service.crm.impl.CustomFieldTemplateService; +import org.meveo.service.crm.impl.ProviderService; import org.meveo.service.custom.CustomTableService; import com.google.common.cache.CacheBuilder; @@ -42,6 +46,12 @@ public class EntityReferenceConverter implements Converter, Serializable @Inject private CustomFieldTemplateService customFieldTemplateService; + + @Inject + private UserService userService; + + @Inject + private ProviderService providerService; private volatile Map> cacheMap = new HashMap<>(); @@ -66,6 +76,14 @@ public String getAsString(FacesContext context, UIComponent component, Object uu return null; } + if (field.getEntityClazz().equals(User.class.getName())) { + User user = userService.findById(Long.parseLong(String.valueOf(uuid))); + return user.getNameOrUsername(); + }else if (field.getEntityClazz().equals(Provider.class.getName())) { + Provider provider = providerService.findById(Long.parseLong(String.valueOf(uuid))); + return provider.getCode(); + } + String stringUuid = null; if (uuid instanceof EntityReferenceWrapper) { EntityReferenceWrapper entityReferenceWrapper = (EntityReferenceWrapper) uuid; @@ -101,7 +119,7 @@ public String getAsString(FacesContext context, UIComponent component, Object uu } } - return null; + return String.valueOf(uuid); } private class FieldRepresentationLoader extends CacheLoader { From 0eebb529598d8a70c4e761ef71d6f0386db89aab Mon Sep 17 00:00:00 2001 From: smichea Date: Tue, 27 Jun 2023 01:29:45 +0200 Subject: [PATCH 36/41] upgrade maven --- Dockerfile.dev | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile.dev b/Dockerfile.dev index cf8725464..52a602520 100644 --- a/Dockerfile.dev +++ b/Dockerfile.dev @@ -193,8 +193,8 @@ RUN apt-get update \ && apt-get autoremove -y && rm -rf /var/lib/apt/lists/* # Install maven -ARG MAVEN_VERSION=3.6.3 -ARG SHA=c35a1803a6e70a126e80b2b3ae33eed961f83ed74d18fcd16909b2d44d7dada3203f1ffe726c17ef8dcca2dcaa9fca676987befeadc9b9f759967a8cb77181c0 +ARG MAVEN_VERSION=3.9.3 +ARG SHA=400fc5b6d000c158d5ee7937543faa06b6bda8408caa2444a9c947c21472fde0f0b64ac452b8cec8855d528c0335522ed5b6c8f77085811c7e29e1bedbb5daa2 ARG BASE_URL=https://apache.osuosl.org/maven/maven-3/${MAVEN_VERSION}/binaries RUN mkdir -p /usr/share/maven /usr/share/maven/ref \ From fcd65f0dd9f079eba354616c7039852ab02ffa92 Mon Sep 17 00:00:00 2001 From: Quentin Tixier Date: Tue, 27 Jun 2023 17:34:12 +0200 Subject: [PATCH 37/41] Add current user in EndpointScript params When executing an asyncronous endpoint the current user wasn't fetched correctly --- .../org/meveo/api/rest/technicalservice/EndpointScript.java | 2 ++ .../org/meveo/api/technicalservice/endpoint/EndpointApi.java | 1 + 2 files changed, 3 insertions(+) diff --git a/meveo-api/src/main/java/org/meveo/api/rest/technicalservice/EndpointScript.java b/meveo-api/src/main/java/org/meveo/api/rest/technicalservice/EndpointScript.java index 71ee558c1..dd41cd964 100644 --- a/meveo-api/src/main/java/org/meveo/api/rest/technicalservice/EndpointScript.java +++ b/meveo-api/src/main/java/org/meveo/api/rest/technicalservice/EndpointScript.java @@ -15,6 +15,8 @@ public abstract class EndpointScript extends Script { * Will always be null if endpoint is asychronous */ protected EndpointResponse endpointResponse; + + public final static String CURRENT_MEVEO_USER_KEY = "currentMeveoUser"; @JsonIgnore public void setEndpointRequest(EndpointRequest endpointRequest) { diff --git a/meveo-api/src/main/java/org/meveo/api/technicalservice/endpoint/EndpointApi.java b/meveo-api/src/main/java/org/meveo/api/technicalservice/endpoint/EndpointApi.java index 4c017d456..ffe898b01 100644 --- a/meveo-api/src/main/java/org/meveo/api/technicalservice/endpoint/EndpointApi.java +++ b/meveo-api/src/main/java/org/meveo/api/technicalservice/endpoint/EndpointApi.java @@ -145,6 +145,7 @@ public PendingResult executeAsync(Endpoint endpoint, EndpointExecution endpointE service = functionService.findById(service.getId()); Map parameterMap = new HashMap<>(endpointExecution.getParameters()); + parameterMap.put(EndpointScript.CURRENT_MEVEO_USER_KEY, currentUser.unProxy()); final ScriptInterface executionEngine = getEngine(endpoint, endpointExecution, service, functionService, parameterMap); CompletableFuture future = CompletableFuture.supplyAsync(() -> { From d861e74df1d0b1a94a9d392b92da4d38dda6a39f Mon Sep 17 00:00:00 2001 From: Quentin Tixier Date: Wed, 28 Jun 2023 11:10:43 +0200 Subject: [PATCH 38/41] also add current user in synchronous endpoint execution --- .../org/meveo/api/technicalservice/endpoint/EndpointApi.java | 1 + 1 file changed, 1 insertion(+) diff --git a/meveo-api/src/main/java/org/meveo/api/technicalservice/endpoint/EndpointApi.java b/meveo-api/src/main/java/org/meveo/api/technicalservice/endpoint/EndpointApi.java index ffe898b01..38da7cc20 100644 --- a/meveo-api/src/main/java/org/meveo/api/technicalservice/endpoint/EndpointApi.java +++ b/meveo-api/src/main/java/org/meveo/api/technicalservice/endpoint/EndpointApi.java @@ -183,6 +183,7 @@ public EndpointExecutionResult execute(Endpoint endpoint, EndpointExecution exec var functionService = concreteFunctionService.getFunctionService(service.getCode()); service = functionService.findById(service.getId()); Map parameterMap = new HashMap<>(execution.getParameters()); + parameterMap.put(EndpointScript.CURRENT_MEVEO_USER_KEY, currentUser.unProxy()); final ScriptInterface executionEngine = getEngine(endpoint, execution, service, functionService, parameterMap); From 4079271d414c07f672d15b3232b96f246925e1ae Mon Sep 17 00:00:00 2001 From: Quentin Tixier Date: Wed, 28 Jun 2023 11:10:58 +0200 Subject: [PATCH 39/41] add doc for current user in endpoint params --- .../java/org/meveo/service/technicalservice/endpoint/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/meveo-admin-ejbs/src/main/java/org/meveo/service/technicalservice/endpoint/README.md b/meveo-admin-ejbs/src/main/java/org/meveo/service/technicalservice/endpoint/README.md index 227a45284..9a31490bc 100644 --- a/meveo-admin-ejbs/src/main/java/org/meveo/service/technicalservice/endpoint/README.md +++ b/meveo-admin-ejbs/src/main/java/org/meveo/service/technicalservice/endpoint/README.md @@ -58,6 +58,7 @@ There are several headers that was defined to modify the default behavior of the To retrieve the result of an asynchronous request, call the servlet “/rest/” followed by the id previously returned +Also, for all endpoint execution, the currentUser can be accessed from the endpoint script parameters (key is EndpointScript.CURRENT_MEVEO_USER_KEY). ## Examples For the following examples, let’s consider that we have three setters defined, and therefore three inputs named companyName, year and location and that companyName has been defined as a path parameter. From f52570adbbc38d125dac51be2bc52745dffd489d Mon Sep 17 00:00:00 2001 From: Gulam Samdani Date: Wed, 19 Jul 2023 22:48:40 +0600 Subject: [PATCH 40/41] fix #739 (#741) --- .../meveo/api/CustomEntityTemplateApi.java | 5 ++- .../org/meveo/api/module/MeveoModuleApi.java | 5 +++ .../api/module/MeveoModuleItemInstaller.java | 31 +++++++++++++++++++ 3 files changed, 38 insertions(+), 3 deletions(-) diff --git a/meveo-api/src/main/java/org/meveo/api/CustomEntityTemplateApi.java b/meveo-api/src/main/java/org/meveo/api/CustomEntityTemplateApi.java index 06f4df2bd..529db5f1f 100644 --- a/meveo-api/src/main/java/org/meveo/api/CustomEntityTemplateApi.java +++ b/meveo-api/src/main/java/org/meveo/api/CustomEntityTemplateApi.java @@ -643,9 +643,8 @@ private CustomEntityTemplate fromDTO(CustomEntityTemplateDto dto, CustomEntityTe if(dto.getCrudEventListenerScript() != null) { var crudListenerScript = scriptInstanceService.findByCode(dto.getCrudEventListenerScript()); - cet.setCrudEventListenerScript(crudListenerScript); - if(crudListenerScript == null) { - throw new IllegalArgumentException("Script " + dto.getCrudEventListenerScript() + " does not exists"); + if(crudListenerScript != null) { + cet.setCrudEventListenerScript(crudListenerScript); } } diff --git a/meveo-api/src/main/java/org/meveo/api/module/MeveoModuleApi.java b/meveo-api/src/main/java/org/meveo/api/module/MeveoModuleApi.java index c89422b15..a6eb79f2f 100644 --- a/meveo-api/src/main/java/org/meveo/api/module/MeveoModuleApi.java +++ b/meveo-api/src/main/java/org/meveo/api/module/MeveoModuleApi.java @@ -1761,6 +1761,11 @@ public void applyChanges(MeveoModule module, Set installItem meveoModuleItemInstaller.uninstallItem(options, null, item); } + // update CET + for (var itemDto : meveoModuleItemInstaller.getSortedModuleItems(installItems)) { + meveoModuleItemInstaller.updateCetforCrudEventListenerScript(itemDto); + } + moduleCtx.end(); meveoModuleService.update(module); diff --git a/meveo-api/src/main/java/org/meveo/api/module/MeveoModuleItemInstaller.java b/meveo-api/src/main/java/org/meveo/api/module/MeveoModuleItemInstaller.java index 260fa8f68..b69d9476a 100644 --- a/meveo-api/src/main/java/org/meveo/api/module/MeveoModuleItemInstaller.java +++ b/meveo-api/src/main/java/org/meveo/api/module/MeveoModuleItemInstaller.java @@ -818,6 +818,37 @@ private void addCftToModuleItem(CustomRelationshipTemplateDto dto, MeveoModule m } } } + + public void updateCetforCrudEventListenerScript (MeveoModuleItemDto moduleItemDto) throws BusinessException { + + if (moduleItemDto.getDtoClassName().equals(CustomEntityTemplateDto.class.getName())) { + CustomEntityTemplateDto cetDto =null; + if(moduleItemDto.getDtoData() instanceof CustomEntityTemplateDto){ + cetDto = (CustomEntityTemplateDto) moduleItemDto.getDtoData(); + } else { + try { + Class dtoClass = (Class) Class.forName(moduleItemDto.getDtoClassName()); + cetDto = (CustomEntityTemplateDto) JacksonUtil.convert(moduleItemDto.getDtoData(), dtoClass); + } catch (ClassNotFoundException e) { + log.error("Cannot find dto class", e); + throw new BusinessException("cannot find crusdScript class "+moduleItemDto.getDtoClassName()); + } + } + if (cetDto.getCrudEventListenerScript() != null) { + CustomEntityTemplate cet = customEntityTemplateService.findByCode(cetDto.getCode()); + ScriptInstance si = scriptInstanceService.findByCode(cetDto.getCrudEventListenerScript()); + if (si != null) { + cet.setCrudEventListenerScript(si); + customEntityTemplateService.update(cet); + } else { + throw new BusinessException("cannot find crusdScript "+cetDto.getTransientCrudEventListenerScript()+" of entity "+cetDto.getCode()); + } + } + + } + +} + } \ No newline at end of file From 3d5127c3d4c98dfa78ffad9226df383172bae620 Mon Sep 17 00:00:00 2001 From: Gulam Samdani Date: Wed, 19 Jul 2023 22:51:17 +0600 Subject: [PATCH 41/41] fix #740 (#742) --- .../src/main/java/org/meveo/api/CustomEntityTemplateApi.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/meveo-api/src/main/java/org/meveo/api/CustomEntityTemplateApi.java b/meveo-api/src/main/java/org/meveo/api/CustomEntityTemplateApi.java index 529db5f1f..210ad367d 100644 --- a/meveo-api/src/main/java/org/meveo/api/CustomEntityTemplateApi.java +++ b/meveo-api/src/main/java/org/meveo/api/CustomEntityTemplateApi.java @@ -318,9 +318,7 @@ public CustomEntityTemplate updateEntityTemplate(CustomEntityTemplateDto dto, bo } cet = customEntityTemplateService.update(cet); - - synchronizeCustomFieldsAndActions(cet.getAppliesTo(), dto.getFields(), dto.getActions(), withData); - + } catch (Exception e) { throw e;