From: Sweidan Omar Date: Fri, 10 Dec 2021 14:03:14 +0000 (+0000) Subject: git-tfs-id: [http://tfs.userrendszerhaz.hu:8080/tfs/DefaultCollection]$/MediaCube... X-Git-Url: http://git.useribm.hu/?a=commitdiff_plain;h=b7f1d470714997e78e5d9049b57557b451c32cee;p=mediacube.git git-tfs-id: [tfs.userrendszerhaz.hu:8080/tfs/DefaultCollection]$/MediaCube;C32567 --- diff --git a/server/user.jobengine.osgi.server/src/user/jobengine/server/JobEngineConfiguration.java b/server/user.jobengine.osgi.server/src/user/jobengine/server/JobEngineConfiguration.java index af0aa582..a7bd34ab 100644 --- a/server/user.jobengine.osgi.server/src/user/jobengine/server/JobEngineConfiguration.java +++ b/server/user.jobengine.osgi.server/src/user/jobengine/server/JobEngineConfiguration.java @@ -11,12 +11,14 @@ import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.security.CodeSource; +import java.util.AbstractMap.SimpleEntry; import java.util.ArrayList; import java.util.Collections; import java.util.HashSet; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; +import java.util.Map.Entry; import java.util.Set; import java.util.function.Consumer; import java.util.function.Predicate; @@ -324,18 +326,34 @@ public class JobEngineConfiguration implements IJobEngineConfiguration { String jsonConfig = new String(Files.readAllBytes(Paths.get(configFilePath))); BasicDBObject dbo = (BasicDBObject) JSONUtil.jsonToDbObject(jsonConfig); BasicDBList scheduleJobs = NoSQLUtils.asDBList(dbo, "joblist"); + ArrayList> schedulesArraylist = new ArrayList>(); + scheduleJobs.forEach(o -> { try { + boolean keyAlreadyContained = false; BasicDBObject j = (BasicDBObject) o; String template = j.getString("template"); String xml = loadTemplateXml(template); j.put("xml", xml); - schedules.put(template, j); + + for (int index = 0; index < schedulesArraylist.size(); index++) { + if (schedulesArraylist.get(index).getKey().equals(template)) { + keyAlreadyContained = true; + throw new Exception("Key " + template + " is already contained in scheduled jobs!"); + } + } + + if (!keyAlreadyContained) { + schedulesArraylist.add(new SimpleEntry(template, j)); + } } catch (Exception e) { logger.error("Scheduled job error! {}", e.getMessage()); } - }); + + for (Entry entry : schedulesArraylist) { + schedules.put(entry.getKey(), entry.getValue()); + } } private Set getJavaFileList(Path path, String excludeFileName) {