当前位置: 首页>>代码示例>>Java>>正文


Java ReplicationDefinition.setEnabled方法代码示例

本文整理汇总了Java中org.alfresco.service.cmr.replication.ReplicationDefinition.setEnabled方法的典型用法代码示例。如果您正苦于以下问题:Java ReplicationDefinition.setEnabled方法的具体用法?Java ReplicationDefinition.setEnabled怎么用?Java ReplicationDefinition.setEnabled使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.alfresco.service.cmr.replication.ReplicationDefinition的用法示例。


在下文中一共展示了ReplicationDefinition.setEnabled方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testEditing

import org.alfresco.service.cmr.replication.ReplicationDefinition; //导入方法依赖的package包/类
/**
 * Ensures that we can create, save, edit, save
 *  load, edit, save, load etc, all without
 *  problems, and without creating duplicates
 */
public void testEditing() throws Exception
{
   ReplicationDefinition rdTT = replicationService.createReplicationDefinition(ACTION_NAME, "Test");
   rdTT.setTargetName("TestTarget");
   replicationService.saveReplicationDefinition(rdTT);
   
   // Load, and check it hasn't changed
   rdTT = replicationService.loadReplicationDefinition(ACTION_NAME);
   assertEquals(ACTION_NAME, rdTT.getReplicationName());
   assertEquals("Test", rdTT.getDescription());
   assertEquals("TestTarget", rdTT.getTargetName());
   assertEquals(true, rdTT.isEnabled());
   assertEquals(0, rdTT.getPayload().size());
   
   // Save and re-load without changes
   replicationService.saveReplicationDefinition(rdTT);
   rdTT = replicationService.loadReplicationDefinition(ACTION_NAME);
   assertEquals(ACTION_NAME, rdTT.getReplicationName());
   assertEquals("Test", rdTT.getDescription());
   assertEquals("TestTarget", rdTT.getTargetName());
   assertEquals(true, rdTT.isEnabled());
   assertEquals(0, rdTT.getPayload().size());
   
   // Make some small changes
   rdTT.setDescription("Test Description");
   rdTT.getPayload().add(folder2a);
   rdTT.setEnabled(false);
   
   // Check we see them on save/load
   replicationService.saveReplicationDefinition(rdTT);
   rdTT = replicationService.loadReplicationDefinition(ACTION_NAME);
   assertEquals(ACTION_NAME, rdTT.getReplicationName());
   assertEquals("Test Description", rdTT.getDescription());
   assertEquals("TestTarget", rdTT.getTargetName());
   assertEquals(false, rdTT.isEnabled());
   assertEquals(1, rdTT.getPayload().size());
   assertEquals(folder2a, rdTT.getPayload().get(0));
   
   // And some more changes
   rdTT.setDescription("Another One");
   rdTT.getPayload().clear();
   rdTT.getPayload().add(folder1);
   rdTT.getPayload().add(folder2b);
   assertEquals(2, rdTT.getPayload().size());
   
   // Ensure these also come with save/load
   replicationService.saveReplicationDefinition(rdTT);
   rdTT = replicationService.loadReplicationDefinition(ACTION_NAME);
   assertEquals(ACTION_NAME, rdTT.getReplicationName());
   assertEquals("Another One", rdTT.getDescription());
   assertEquals("TestTarget", rdTT.getTargetName());
   assertEquals(false, rdTT.isEnabled());
   assertEquals(2, rdTT.getPayload().size());
   assertEquals(folder1, rdTT.getPayload().get(0));
   assertEquals(folder2b, rdTT.getPayload().get(1));
   
   // And more payload changes
   rdTT.getPayload().clear();
   rdTT.getPayload().add(content1_1);
   assertEquals(1, rdTT.getPayload().size());
   rdTT.setEnabled(true);
   
   replicationService.saveReplicationDefinition(rdTT);
   rdTT = replicationService.loadReplicationDefinition(ACTION_NAME);
   assertEquals(ACTION_NAME, rdTT.getReplicationName());
   assertEquals("Another One", rdTT.getDescription());
   assertEquals("TestTarget", rdTT.getTargetName());
   assertEquals(true, rdTT.isEnabled());
   assertEquals(1, rdTT.getPayload().size());
   assertEquals(content1_1, rdTT.getPayload().get(0));
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:77,代码来源:ReplicationServiceIntegrationTest.java

示例2: 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);
   }
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:77,代码来源:AbstractReplicationWebscript.java


注:本文中的org.alfresco.service.cmr.replication.ReplicationDefinition.setEnabled方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。