本文整理汇总了Java中org.alfresco.service.cmr.replication.ReplicationDefinition.setScheduleIntervalCount方法的典型用法代码示例。如果您正苦于以下问题:Java ReplicationDefinition.setScheduleIntervalCount方法的具体用法?Java ReplicationDefinition.setScheduleIntervalCount怎么用?Java ReplicationDefinition.setScheduleIntervalCount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.alfresco.service.cmr.replication.ReplicationDefinition
的用法示例。
在下文中一共展示了ReplicationDefinition.setScheduleIntervalCount方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updateDefinitionProperties
import org.alfresco.service.cmr.replication.ReplicationDefinition; //导入方法依赖的package包/类
/**
* Updates properties on the definition, based on the JSON.
* Doesn't save the definition
* Doesn't change the name
*/
protected void updateDefinitionProperties(ReplicationDefinition replicationDefinition, JSONObject json)
throws JSONException
{
if(json.has("description")) {
String description = json.getString("description");
replicationDefinition.setDescription(description);
}
if(json.has("targetName")) {
String targetName = json.getString("targetName");
replicationDefinition.setTargetName(targetName);
}
if(json.has("enabled")) {
boolean enabled = json.getBoolean("enabled");
replicationDefinition.setEnabled(enabled);
}
if(json.has("payload")) {
replicationDefinition.getPayload().clear();
JSONArray payload = json.getJSONArray("payload");
for(int i=0; i<payload.length(); i++) {
String node = payload.getString(i);
replicationDefinition.getPayload().add(
new NodeRef(node)
);
}
}
// Now for the scheduling parts
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")) {
// 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);
}
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);
}
} else {
// Disable scheduling
replicationService.disableScheduling(replicationDefinition);
}
}