diff --git a/src/main/java/de/jeyp91/App.java b/src/main/java/de/jeyp91/App.java index e3ec4f6..8117c03 100644 --- a/src/main/java/de/jeyp91/App.java +++ b/src/main/java/de/jeyp91/App.java @@ -18,7 +18,7 @@ public class App { private static int season; private static int league; private static String configFile; - private static Logger logger = LogManager.getLogger(App.class); + private static final Logger logger = LogManager.getLogger(App.class); public static void main(String[] args) throws Exception { initOptions(args); diff --git a/src/main/java/de/jeyp91/tippliga/TLWMatchesUpdaterFootball.java b/src/main/java/de/jeyp91/tippliga/TLWMatchesUpdaterFootball.java index 84b32e5..7a2e9f0 100644 --- a/src/main/java/de/jeyp91/tippliga/TLWMatchesUpdaterFootball.java +++ b/src/main/java/de/jeyp91/tippliga/TLWMatchesUpdaterFootball.java @@ -1,9 +1,12 @@ package de.jeyp91.tippliga; import com.google.api.client.util.DateTime; +import de.jeyp91.App; import de.jeyp91.TeamIDMatcher; import de.jeyp91.apifootball.APIFootballMatch; import de.jeyp91.apifootball.APIFootballMatchesProvider; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.json.simple.JSONArray; import org.json.simple.JSONObject; @@ -13,11 +16,12 @@ import java.util.ArrayList; import java.util.Date; public class TLWMatchesUpdaterFootball extends TLWMatchesManagerBase { + private static Logger logger = LogManager.getLogger(App.class); ArrayList tlwMatchesOriginal; ArrayList tlwMatchesUpdated; - public TLWMatchesUpdaterFootball(int season, int league, String configFileName) throws Exception { + public TLWMatchesUpdaterFootball(int season, int league, String configFileName) { this.season = season; this.league = league; @@ -29,7 +33,7 @@ public class TLWMatchesUpdaterFootball extends TLWMatchesManagerBase { this.initUpdates(); } - private void initUpdates() throws Exception { + private void initUpdates() { APIFootballMatchesProvider apiFootballMatchesProvider = new APIFootballMatchesProvider(this.season); TippligaSQLConnector tippligaSQLConnector = new TippligaSQLConnector(); @@ -44,7 +48,7 @@ public class TLWMatchesUpdaterFootball extends TLWMatchesManagerBase { for (TLWMatch match : tlwMatchesOriginalMatchday) tlwMatchesUpdatedMatchday.add(new TLWMatch(match)); if (apiFootballMatches.size() > tlwMatchesUpdatedMatchday.size()) { - throw new Exception("Not matching config!"); + logger.error("Not matching config!"); } addMissingMatches(tlwMatchesUpdatedMatchday, apiFootballMatches); @@ -105,7 +109,7 @@ public class TLWMatchesUpdaterFootball extends TLWMatchesManagerBase { } private void addMissingMatches(ArrayList tlwMatches, - ArrayList apiFootballMatches) throws Exception { + ArrayList apiFootballMatches) { ArrayList missingMatches = new ArrayList<>(); @@ -125,14 +129,14 @@ public class TLWMatchesUpdaterFootball extends TLWMatchesManagerBase { } } if(!done) { - throw new Exception("Could not add missing match"); + logger.error("Could not add missing match"); } } } private void updateMatchDateTimes( ArrayList tlwMatches, - ArrayList apiFootballMatches) throws Exception + ArrayList apiFootballMatches) { for(APIFootballMatch apiFootballMatch : apiFootballMatches) { TLWMatch tlwMatch = getMatchingMatch(apiFootballMatch, tlwMatches); @@ -155,7 +159,7 @@ public class TLWMatchesUpdaterFootball extends TLWMatchesManagerBase { } } - private TLWMatch getMatchingMatch(APIFootballMatch apiFootballMatch, ArrayList tlwMatches) throws Exception { + private TLWMatch getMatchingMatch(APIFootballMatch apiFootballMatch, ArrayList tlwMatches) { int foundMatches = 0; TLWMatch matchingMatch = null; for(TLWMatch match : tlwMatches) { @@ -170,7 +174,7 @@ public class TLWMatchesUpdaterFootball extends TLWMatchesManagerBase { } } if(foundMatches > 1) { - throw new Exception("Found more than one matching matches"); + logger.error("Found more than one matching matches"); } return matchingMatch; }