mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-14 17:58:59 +00:00
ALF-4346 & ALF-4348 - More work on schedulable actions, and start to expose this through to the replication service
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@22019 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -35,7 +35,13 @@
|
|||||||
"transferLocalReport": <#if replicationDefinition.transferLocalReport??>"${replicationDefinition.transferLocalReport.nodeRef}"<#else>null</#if>,
|
"transferLocalReport": <#if replicationDefinition.transferLocalReport??>"${replicationDefinition.transferLocalReport.nodeRef}"<#else>null</#if>,
|
||||||
"transferRemoteReport": <#if replicationDefinition.transferRemoteReport??>"${replicationDefinition.transferRemoteReport.nodeRef}"<#else>null</#if>,
|
"transferRemoteReport": <#if replicationDefinition.transferRemoteReport??>"${replicationDefinition.transferRemoteReport.nodeRef}"<#else>null</#if>,
|
||||||
"enabled": ${replicationDefinition.enabled?string},
|
"enabled": ${replicationDefinition.enabled?string},
|
||||||
"targetName": <#if replicationDefinition.targetName??>"${replicationDefinition.targetName}"<#else>null</#if>
|
"targetName": <#if replicationDefinition.targetName??>"${replicationDefinition.targetName}"<#else>null</#if>,
|
||||||
|
"schedule": <#if replicationDefinition.scheduleEnabled>
|
||||||
|
{
|
||||||
|
"start": "${replicationDefinition.scheduleStart}",
|
||||||
|
"intervalPeriod": <#if replicationDefinition.scheduleIntervalPeriod??>"${replicationDefinition.scheduleIntervalPeriod}"<#else>null</#if>,
|
||||||
|
"intervalCount": <#if replicationDefinition.scheduleIntervalCount??>${replicationDefinition.scheduleIntervalCount}<#else>null</#if>
|
||||||
|
}<#else>null</#if>
|
||||||
}
|
}
|
||||||
</#escape>
|
</#escape>
|
||||||
</#macro>
|
</#macro>
|
||||||
|
@@ -21,10 +21,12 @@ package org.alfresco.repo.web.scripts.replication;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.alfresco.service.cmr.action.ActionTrackingService;
|
import org.alfresco.service.cmr.action.ActionTrackingService;
|
||||||
|
import org.alfresco.service.cmr.action.scheduled.SchedulableAction.IntervalPeriod;
|
||||||
import org.alfresco.service.cmr.replication.ReplicationDefinition;
|
import org.alfresco.service.cmr.replication.ReplicationDefinition;
|
||||||
import org.alfresco.service.cmr.replication.ReplicationService;
|
import org.alfresco.service.cmr.replication.ReplicationService;
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
import org.alfresco.service.cmr.repository.NodeService;
|
import org.alfresco.service.cmr.repository.NodeService;
|
||||||
|
import org.alfresco.util.ISO8601DateFormat;
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
@@ -102,6 +104,52 @@ 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
|
||||||
|
{
|
||||||
|
if(json.has("schedule") && !json.isNull("schedule")) {
|
||||||
|
// Turn on scheduling, if not already enabled
|
||||||
|
replicationService.enableScheduling(replicationDefinition);
|
||||||
|
|
||||||
|
// Update the properties
|
||||||
|
JSONObject schedule = json.getJSONObject("schedule");
|
||||||
|
|
||||||
|
if(schedule.has("start") && !schedule.isNull("start")) {
|
||||||
|
replicationDefinition.setScheduleStart(
|
||||||
|
ISO8601DateFormat.parse(schedule.getString("start"))
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
replicationDefinition.setScheduleStart(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(schedule.has("intervalPeriod") && !schedule.isNull("intervalPeriod")) {
|
||||||
|
replicationDefinition.setScheduleIntervalPeriod(
|
||||||
|
IntervalPeriod.valueOf(schedule.getString("intervalPeriod"))
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
replicationDefinition.setScheduleIntervalPeriod(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(schedule.has("intervalCount") && !schedule.isNull("intervalCount")) {
|
||||||
|
replicationDefinition.setScheduleIntervalCount(
|
||||||
|
schedule.getInt("intervalCount")
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
replicationDefinition.setScheduleIntervalCount(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ensure the scheduling is saved
|
||||||
|
replicationService.saveReplicationDefinition(replicationDefinition);
|
||||||
|
} else {
|
||||||
|
// Disable scheduling
|
||||||
|
replicationService.disableScheduling(replicationDefinition);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected abstract Map<String, Object> buildModel(
|
protected abstract Map<String, Object> buildModel(
|
||||||
ReplicationModelBuilder modelBuilder,
|
ReplicationModelBuilder modelBuilder,
|
||||||
WebScriptRequest req,
|
WebScriptRequest req,
|
||||||
|
@@ -85,6 +85,9 @@ 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,6 +72,9 @@ 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)
|
||||||
{
|
{
|
||||||
|
@@ -60,6 +60,11 @@ public class ReplicationModelBuilder
|
|||||||
protected static final String DEFINITION_ENABLED = "enabled";
|
protected static final String DEFINITION_ENABLED = "enabled";
|
||||||
protected static final String DEFINITION_TARGET_NAME = "targetName";
|
protected static final String DEFINITION_TARGET_NAME = "targetName";
|
||||||
|
|
||||||
|
protected static final String DEFINITION_SCHEDULE_ENABLED = "scheduleEnabled";
|
||||||
|
protected static final String DEFINITION_SCHEDULE_START = "scheduleStart";
|
||||||
|
protected static final String DEFINITION_SCHEDULE_PERIOD = "scheduleIntervalPeriod";
|
||||||
|
protected static final String DEFINITION_SCHEDULE_COUNT = "scheduleIntervalCount";
|
||||||
|
|
||||||
protected NodeService nodeService;
|
protected NodeService nodeService;
|
||||||
protected ReplicationService replicationService;
|
protected ReplicationService replicationService;
|
||||||
protected ActionTrackingService actionTrackingService;
|
protected ActionTrackingService actionTrackingService;
|
||||||
@@ -191,6 +196,20 @@ public class ReplicationModelBuilder
|
|||||||
rdm.put(DEFINITION_ENABLED, rd.isEnabled());
|
rdm.put(DEFINITION_ENABLED, rd.isEnabled());
|
||||||
rdm.put(DEFINITION_TARGET_NAME, rd.getTargetName());
|
rdm.put(DEFINITION_TARGET_NAME, rd.getTargetName());
|
||||||
|
|
||||||
|
// Set the scheduling details
|
||||||
|
rdm.put(DEFINITION_SCHEDULE_ENABLED, rd.isSchedulingEnabled());
|
||||||
|
if(rd.isSchedulingEnabled())
|
||||||
|
{
|
||||||
|
rdm.put(DEFINITION_SCHEDULE_START, ISO8601DateFormat.format(rd.getScheduleStart()));
|
||||||
|
|
||||||
|
rdm.put(DEFINITION_SCHEDULE_COUNT, rd.getScheduleIntervalCount());
|
||||||
|
if(rd.getScheduleIntervalPeriod() != null) {
|
||||||
|
rdm.put(DEFINITION_SCHEDULE_PERIOD, rd.getScheduleIntervalPeriod().toString());
|
||||||
|
} else {
|
||||||
|
rdm.put(DEFINITION_SCHEDULE_PERIOD, null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Do the status
|
// Do the status
|
||||||
// Includes start+end times, and running action details
|
// Includes start+end times, and running action details
|
||||||
setStatus(rd, rdm);
|
setStatus(rd, rdm);
|
||||||
|
Reference in New Issue
Block a user