ALF-4348 - More replication job scheduling work

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@22021 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Nick Burch
2010-08-26 13:56:44 +00:00
parent ce1f57c3b9
commit eb4b8fd94e
5 changed files with 16 additions and 22 deletions

View File

@@ -38,7 +38,9 @@
"targetName": <#if replicationDefinition.targetName??>"${replicationDefinition.targetName}"<#else>null</#if>, "targetName": <#if replicationDefinition.targetName??>"${replicationDefinition.targetName}"<#else>null</#if>,
"schedule": <#if replicationDefinition.scheduleEnabled> "schedule": <#if replicationDefinition.scheduleEnabled>
{ {
"start": "${replicationDefinition.scheduleStart}", "start": {
"iso8601": "${replicationDefinition.scheduleStart}"
},
"intervalPeriod": <#if replicationDefinition.scheduleIntervalPeriod??>"${replicationDefinition.scheduleIntervalPeriod}"<#else>null</#if>, "intervalPeriod": <#if replicationDefinition.scheduleIntervalPeriod??>"${replicationDefinition.scheduleIntervalPeriod}"<#else>null</#if>,
"intervalCount": <#if replicationDefinition.scheduleIntervalCount??>${replicationDefinition.scheduleIntervalCount}<#else>null</#if> "intervalCount": <#if replicationDefinition.scheduleIntervalCount??>${replicationDefinition.scheduleIntervalCount}<#else>null</#if>
}<#else>null</#if> }<#else>null</#if>

View File

@@ -102,15 +102,10 @@ public abstract class AbstractReplicationWebscript extends DeclarativeWebScript
); );
} }
} }
}
/**
* Updates the schedule related properties, based on the // Now for the scheduling parts
* JSON, and has these persisted as required.
*/
protected void updateDefinitionScheduling(ReplicationDefinition replicationDefinition, JSONObject json)
throws JSONException
{
if(json.has("schedule") && !json.isNull("schedule")) { if(json.has("schedule") && !json.isNull("schedule")) {
// Turn on scheduling, if not already enabled // Turn on scheduling, if not already enabled
replicationService.enableScheduling(replicationDefinition); replicationService.enableScheduling(replicationDefinition);
@@ -119,9 +114,13 @@ public abstract class AbstractReplicationWebscript extends DeclarativeWebScript
JSONObject schedule = json.getJSONObject("schedule"); JSONObject schedule = json.getJSONObject("schedule");
if(schedule.has("start") && !schedule.isNull("start")) { if(schedule.has("start") && !schedule.isNull("start")) {
replicationDefinition.setScheduleStart( // Look for start:.... or start:{"iso8601":....}
ISO8601DateFormat.parse(schedule.getString("start")) String startDate = schedule.getString("start");
); if(schedule.get("start") instanceof JSONObject) {
startDate = schedule.getJSONObject("start").getString("iso8601");
}
replicationDefinition.setScheduleStart( ISO8601DateFormat.parse(startDate) );
} else { } else {
replicationDefinition.setScheduleStart(null); replicationDefinition.setScheduleStart(null);
} }
@@ -141,9 +140,6 @@ public abstract class AbstractReplicationWebscript extends DeclarativeWebScript
} else { } else {
replicationDefinition.setScheduleIntervalCount(null); replicationDefinition.setScheduleIntervalCount(null);
} }
// Ensure the scheduling is saved
replicationService.saveReplicationDefinition(replicationDefinition);
} else { } else {
// Disable scheduling // Disable scheduling
replicationService.disableScheduling(replicationDefinition); replicationService.disableScheduling(replicationDefinition);

View File

@@ -85,9 +85,6 @@ public class ReplicationDefinitionPut extends AbstractReplicationWebscript
// Save the changes // Save the changes
replicationService.saveReplicationDefinition(replicationDefinition); replicationService.saveReplicationDefinition(replicationDefinition);
// Now do the scheduling
updateDefinitionScheduling(replicationDefinition, json);
} }
catch (IOException iox) catch (IOException iox)
{ {

View File

@@ -72,9 +72,6 @@ public class ReplicationDefinitionsPost extends AbstractReplicationWebscript
// Save the changes // Save the changes
replicationService.saveReplicationDefinition(replicationDefinition); replicationService.saveReplicationDefinition(replicationDefinition);
// Now do the scheduling
updateDefinitionScheduling(replicationDefinition, json);
} }
catch (IOException iox) catch (IOException iox)
{ {

View File

@@ -50,6 +50,8 @@ import org.springframework.extensions.webscripts.TestWebScriptServer.Response;
/** /**
* Tests for the Replication Webscripts * Tests for the Replication Webscripts
* @author Nick Burch * @author Nick Burch
*
* TODO - Scheduling parts
*/ */
public class ReplicationRestApiTest extends BaseWebScriptTest public class ReplicationRestApiTest extends BaseWebScriptTest
{ {