branch timebundle updated (df7f10f -> 877fc29)
This is an automated email from the git hooks/post-receive script. New change to branch timebundle in repository jtimer. See https://gitlab.nuiton.org/chorem/jtimer.git from df7f10f Refactor time bundle code into dedicated plugin. new 877fc29 Fix lastSyncDate after succesfull sync The 1 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "adds" were already present in the repository and have only been added to this reference. Detailed log of new commits: commit 877fc299dca763bf078a68101875e8a2602594c7 Author: Eric Chatellier <chatellier@codelutin.com> Date: Tue Aug 2 17:41:38 2016 +0200 Fix lastSyncDate after succesfull sync Summary of changes: pom.xml | 4 +-- .../java/org/chorem/jtimer/data/TimerCore.java | 4 ++- .../plugin/timebundle/TimeBundleSynchronizer.java | 35 ++++++++++++++++++---- 3 files changed, 34 insertions(+), 9 deletions(-) -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
This is an automated email from the git hooks/post-receive script. New commit to branch timebundle in repository jtimer. See https://gitlab.nuiton.org/chorem/jtimer.git commit 877fc299dca763bf078a68101875e8a2602594c7 Author: Eric Chatellier <chatellier@codelutin.com> Date: Tue Aug 2 17:41:38 2016 +0200 Fix lastSyncDate after succesfull sync --- pom.xml | 4 +-- .../java/org/chorem/jtimer/data/TimerCore.java | 4 ++- .../plugin/timebundle/TimeBundleSynchronizer.java | 35 ++++++++++++++++++---- 3 files changed, 34 insertions(+), 9 deletions(-) diff --git a/pom.xml b/pom.xml index 343f74c..8ef993f 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ <parent> <groupId>org.nuiton</groupId> <artifactId>chorempom</artifactId> - <version>10.1</version> + <version>10.2</version> </parent> <groupId>org.chorem</groupId> @@ -355,7 +355,7 @@ <plugin> <groupId>com.akathist.maven.plugins.launch4j</groupId> <artifactId>launch4j-maven-plugin</artifactId> - <version>1.7.10</version> + <version>1.7.11</version> <executions> <execution> <id>launch4j</id> diff --git a/src/main/java/org/chorem/jtimer/data/TimerCore.java b/src/main/java/org/chorem/jtimer/data/TimerCore.java index 44fec8a..fe5465b 100644 --- a/src/main/java/org/chorem/jtimer/data/TimerCore.java +++ b/src/main/java/org/chorem/jtimer/data/TimerCore.java @@ -94,9 +94,11 @@ public class TimerCore { //init sync synchronizer = JTimerFactory.getSynchronizer(); if (synchronizer != null) { + TimeBundleSaver saver = new TimeBundleSaver(); data.addVetoableDataEventListener(new TimeBundleVetoable()); - data.addDataEventListener(new TimeBundleSaver()); + data.addDataEventListener(saver); data.addDataEventListener(synchronizer); + synchronizer.setSaver(saver); } } diff --git a/src/main/java/org/chorem/jtimer/plugin/timebundle/TimeBundleSynchronizer.java b/src/main/java/org/chorem/jtimer/plugin/timebundle/TimeBundleSynchronizer.java index abd5fba..f27bf47 100644 --- a/src/main/java/org/chorem/jtimer/plugin/timebundle/TimeBundleSynchronizer.java +++ b/src/main/java/org/chorem/jtimer/plugin/timebundle/TimeBundleSynchronizer.java @@ -50,6 +50,8 @@ public class TimeBundleSynchronizer extends TimerTask implements DataEventListen protected Collection<TimerProject> projects; + protected TimeBundleSaver saver; + /** * TimeBundleSynchronizer constructor */ @@ -82,7 +84,15 @@ public class TimeBundleSynchronizer extends TimerTask implements DataEventListen } JsonObject syncObject = TimeBundleHelper.taskToJsonObject(timerTask, timerSync); - synchronizeTaskOnURL(syncObject); + boolean resultOk = synchronizeTaskOnURL(syncObject); + if (resultOk) { + timerSync.setLastSync(new Date()); + if (timerTask instanceof TimerProject) { + saver.modifyProject(TimerProject.class.cast(timerTask)); + } else { + saver.modifyTask(timerTask); + } + } } }); } @@ -92,8 +102,8 @@ public class TimeBundleSynchronizer extends TimerTask implements DataEventListen * @param object the object to sync * @return an int (http response code or 0 in case of a problem) */ - protected int synchronizeTaskOnURL(JsonObject object) { - int upDateValue = 0; + protected boolean synchronizeTaskOnURL(JsonObject object) { + boolean result = false; // if it's an empty object, no synchronization is possible if (!object.equals(new JsonObject())) { String updateJsonString = object.toString(); @@ -114,14 +124,17 @@ public class TimeBundleSynchronizer extends TimerTask implements DataEventListen connection.setRequestMethod("POST"); postDataBytes = updateJsonString.getBytes(charset); connection.getOutputStream().write(postDataBytes); - upDateValue = connection.getResponseCode(); + int upDateValue = connection.getResponseCode(); + if (upDateValue >= 200 && upDateValue < 300) { + result = true; + } } catch (IOException ex) { if (log.isErrorEnabled()) { - log.error("Problem with the connection " + syncURL + " Code : " + upDateValue, ex); + log.error("Problem with the connection " + syncURL, ex); } } } - return upDateValue; + return result; } /** @@ -145,4 +158,14 @@ public class TimeBundleSynchronizer extends TimerTask implements DataEventListen } } } + + /** + * Set saver. + * @param saver + * @deprecated since 1.5.1 this is ugly, need a proper centralized way to save a task modified by current class + */ + @Deprecated + public void setSaver(TimeBundleSaver saver) { + this.saver = saver; + } } -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
participants (1)
-
chorem.org scm