diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/replication/replication-definition.lib.ftl b/config/alfresco/templates/webscripts/org/alfresco/repository/replication/replication-definition.lib.ftl index 47529af1d1..ececf794d8 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/repository/replication/replication-definition.lib.ftl +++ b/config/alfresco/templates/webscripts/org/alfresco/repository/replication/replication-definition.lib.ftl @@ -38,7 +38,9 @@ "targetName": <#if replicationDefinition.targetName??>"${replicationDefinition.targetName}"<#else>null, "schedule": <#if replicationDefinition.scheduleEnabled> { - "start": "${replicationDefinition.scheduleStart}", + "start": { + "iso8601": "${replicationDefinition.scheduleStart}" + }, "intervalPeriod": <#if replicationDefinition.scheduleIntervalPeriod??>"${replicationDefinition.scheduleIntervalPeriod}"<#else>null, "intervalCount": <#if replicationDefinition.scheduleIntervalCount??>${replicationDefinition.scheduleIntervalCount}<#else>null }<#else>null diff --git a/source/java/org/alfresco/repo/web/scripts/replication/AbstractReplicationWebscript.java b/source/java/org/alfresco/repo/web/scripts/replication/AbstractReplicationWebscript.java index 856146b66d..42f8649316 100644 --- a/source/java/org/alfresco/repo/web/scripts/replication/AbstractReplicationWebscript.java +++ b/source/java/org/alfresco/repo/web/scripts/replication/AbstractReplicationWebscript.java @@ -102,15 +102,10 @@ public abstract class AbstractReplicationWebscript extends DeclarativeWebScript ); } } - } - - /** - * Updates the schedule related properties, based on the - * JSON, and has these persisted as required. - */ - protected void updateDefinitionScheduling(ReplicationDefinition replicationDefinition, JSONObject json) - throws JSONException - { + + + // Now for the scheduling parts + if(json.has("schedule") && !json.isNull("schedule")) { // Turn on scheduling, if not already enabled replicationService.enableScheduling(replicationDefinition); @@ -119,9 +114,13 @@ public abstract class AbstractReplicationWebscript extends DeclarativeWebScript JSONObject schedule = json.getJSONObject("schedule"); if(schedule.has("start") && !schedule.isNull("start")) { - replicationDefinition.setScheduleStart( - ISO8601DateFormat.parse(schedule.getString("start")) - ); + // Look for start:.... or start:{"iso8601":....} + String startDate = schedule.getString("start"); + if(schedule.get("start") instanceof JSONObject) { + startDate = schedule.getJSONObject("start").getString("iso8601"); + } + + replicationDefinition.setScheduleStart( ISO8601DateFormat.parse(startDate) ); } else { replicationDefinition.setScheduleStart(null); } @@ -141,9 +140,6 @@ public abstract class AbstractReplicationWebscript extends DeclarativeWebScript } else { replicationDefinition.setScheduleIntervalCount(null); } - - // Ensure the scheduling is saved - replicationService.saveReplicationDefinition(replicationDefinition); } else { // Disable scheduling replicationService.disableScheduling(replicationDefinition); diff --git a/source/java/org/alfresco/repo/web/scripts/replication/ReplicationDefinitionPut.java b/source/java/org/alfresco/repo/web/scripts/replication/ReplicationDefinitionPut.java index a75d98baf6..1327e9d0cd 100644 --- a/source/java/org/alfresco/repo/web/scripts/replication/ReplicationDefinitionPut.java +++ b/source/java/org/alfresco/repo/web/scripts/replication/ReplicationDefinitionPut.java @@ -85,9 +85,6 @@ public class ReplicationDefinitionPut extends AbstractReplicationWebscript // Save the changes replicationService.saveReplicationDefinition(replicationDefinition); - - // Now do the scheduling - updateDefinitionScheduling(replicationDefinition, json); } catch (IOException iox) { diff --git a/source/java/org/alfresco/repo/web/scripts/replication/ReplicationDefinitionsPost.java b/source/java/org/alfresco/repo/web/scripts/replication/ReplicationDefinitionsPost.java index a2d1708ed6..266be95845 100644 --- a/source/java/org/alfresco/repo/web/scripts/replication/ReplicationDefinitionsPost.java +++ b/source/java/org/alfresco/repo/web/scripts/replication/ReplicationDefinitionsPost.java @@ -72,9 +72,6 @@ public class ReplicationDefinitionsPost extends AbstractReplicationWebscript // Save the changes replicationService.saveReplicationDefinition(replicationDefinition); - - // Now do the scheduling - updateDefinitionScheduling(replicationDefinition, json); } catch (IOException iox) { diff --git a/source/java/org/alfresco/repo/web/scripts/replication/ReplicationRestApiTest.java b/source/java/org/alfresco/repo/web/scripts/replication/ReplicationRestApiTest.java index e406e49073..109d42d90e 100644 --- a/source/java/org/alfresco/repo/web/scripts/replication/ReplicationRestApiTest.java +++ b/source/java/org/alfresco/repo/web/scripts/replication/ReplicationRestApiTest.java @@ -50,6 +50,8 @@ import org.springframework.extensions.webscripts.TestWebScriptServer.Response; /** * Tests for the Replication Webscripts * @author Nick Burch + * + * TODO - Scheduling parts */ public class ReplicationRestApiTest extends BaseWebScriptTest {