mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-21 18:09:20 +00:00
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:
@@ -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>
|
||||||
|
@@ -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);
|
||||||
|
@@ -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)
|
||||||
{
|
{
|
||||||
|
@@ -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)
|
||||||
{
|
{
|
||||||
|
@@ -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
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user