Search in sources :

Example 6 with ReplicationDefinition

use of org.alfresco.service.cmr.replication.ReplicationDefinition in project alfresco-remote-api by Alfresco.

the class ReplicationRestApiTest method testReplicationDefinitionGet.

public void testReplicationDefinitionGet() throws Exception {
    Response response;
    // Not allowed if you're not an admin
    AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getGuestUserName());
    response = sendRequest(new GetRequest(URL_DEFINITION + "madeup"), Status.STATUS_UNAUTHORIZED);
    assertEquals(Status.STATUS_UNAUTHORIZED, response.getStatus());
    AuthenticationUtil.setFullyAuthenticatedUser(USER_NORMAL);
    response = sendRequest(new GetRequest(URL_DEFINITION + "madeup"), Status.STATUS_UNAUTHORIZED);
    assertEquals(Status.STATUS_UNAUTHORIZED, response.getStatus());
    // If an invalid name is given, you get a 404
    AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName());
    response = sendRequest(new GetRequest(URL_DEFINITION + "madeup"), 404);
    assertEquals(Status.STATUS_NOT_FOUND, response.getStatus());
    // Add a definition, it should show up
    ReplicationDefinition rd = replicationService.createReplicationDefinition("Test1", "Testing");
    replicationService.saveReplicationDefinition(rd);
    response = sendRequest(new GetRequest(URL_DEFINITION + "Test1"), 200);
    assertEquals(Status.STATUS_OK, response.getStatus());
    String jsonStr = response.getContentAsString();
    JSONObject json = new JSONObject(jsonStr).getJSONObject("data");
    assertNotNull(json);
    // Check
    assertEquals("Test1", json.get("name"));
    assertEquals("Testing", json.get("description"));
    assertEquals("New", json.get("status"));
    assertEquals(JSONObject.NULL, json.get("startedAt"));
    assertEquals(JSONObject.NULL, json.get("endedAt"));
    assertEquals(JSONObject.NULL, json.get("failureMessage"));
    assertEquals(JSONObject.NULL, json.get("executionDetails"));
    assertEquals(JSONObject.NULL, json.get("transferLocalReport"));
    assertEquals(JSONObject.NULL, json.get("transferRemoteReport"));
    assertEquals(true, json.get("enabled"));
    assertEquals(JSONObject.NULL, json.get("targetName"));
    // Payload is empty
    assertEquals(0, json.getJSONArray("payload").length());
    // Ensure we didn't get any unexpected data back
    JSONArray keys = json.names();
    for (int i = 0; i < keys.length(); i++) {
        String key = keys.getString(0);
        if (key.equals("name") || key.equals("description") || key.equals("status") || key.equals("startedAt") || key.equals("endedAt") || key.equals("failureMessage") || key.equals("executionDetails") || key.equals("payload") || key.equals("transferLocalReport") || key.equals("transferRemoteReport") || key.equals("enabled") || key.equals("targetName") || key.equals("schedule")) {
        // All good
        } else {
            fail("Unexpected key '" + key + "' found in json, raw json is\n" + jsonStr);
        }
    }
    // Mark it as pending, and check
    actionTrackingService.recordActionPending(rd);
    String actionId = rd.getId();
    int instanceId = ((ActionImpl) rd).getExecutionInstance();
    response = sendRequest(new GetRequest(URL_DEFINITION + "Test1"), 200);
    assertEquals(Status.STATUS_OK, response.getStatus());
    jsonStr = response.getContentAsString();
    json = new JSONObject(jsonStr).getJSONObject("data");
    assertEquals("Test1", json.get("name"));
    assertEquals("Testing", json.get("description"));
    assertEquals("Pending", json.get("status"));
    assertEquals(JSONObject.NULL, json.get("startedAt"));
    assertEquals(JSONObject.NULL, json.get("endedAt"));
    assertEquals(JSONObject.NULL, json.get("failureMessage"));
    assertEquals("/" + URL_RUNNING_ACTION + "replicationActionExecutor=" + actionId + "=" + instanceId, json.get("executionDetails"));
    assertEquals(JSONObject.NULL, json.get("transferLocalReport"));
    assertEquals(JSONObject.NULL, json.get("transferRemoteReport"));
    assertEquals(true, json.get("enabled"));
    assertEquals(JSONObject.NULL, json.get("targetName"));
    // Payload is empty
    assertEquals(0, json.getJSONArray("payload").length());
    // Change the status to running, and re-check
    actionTrackingService.recordActionExecuting(rd);
    assertEquals(actionId, rd.getId());
    assertEquals(instanceId, ((ActionImpl) rd).getExecutionInstance());
    String startedAt = ISO8601DateFormat.format(rd.getExecutionStartDate());
    response = sendRequest(new GetRequest(URL_DEFINITION + "Test1"), 200);
    assertEquals(Status.STATUS_OK, response.getStatus());
    jsonStr = response.getContentAsString();
    json = new JSONObject(jsonStr).getJSONObject("data");
    assertEquals("Test1", json.get("name"));
    assertEquals("Testing", json.get("description"));
    assertEquals("Running", json.get("status"));
    assertEquals(startedAt, json.getJSONObject("startedAt").get("iso8601"));
    assertEquals(JSONObject.NULL, json.get("endedAt"));
    assertEquals(JSONObject.NULL, json.get("failureMessage"));
    assertEquals("/" + URL_RUNNING_ACTION + "replicationActionExecutor=" + actionId + "=" + instanceId, json.get("executionDetails"));
    assertEquals(JSONObject.NULL, json.get("transferLocalReport"));
    assertEquals(JSONObject.NULL, json.get("transferRemoteReport"));
    assertEquals(true, json.get("enabled"));
    assertEquals(JSONObject.NULL, json.get("targetName"));
    // Payload is empty
    assertEquals(0, json.getJSONArray("payload").length());
    // Cancel it
    actionTrackingService.requestActionCancellation(rd);
    response = sendRequest(new GetRequest(URL_DEFINITION + "Test1"), 200);
    assertEquals(Status.STATUS_OK, response.getStatus());
    jsonStr = response.getContentAsString();
    json = new JSONObject(jsonStr).getJSONObject("data");
    assertEquals("Test1", json.get("name"));
    assertEquals("Testing", json.get("description"));
    assertEquals("CancelRequested", json.get("status"));
    assertEquals(startedAt, json.getJSONObject("startedAt").get("iso8601"));
    assertEquals(JSONObject.NULL, json.get("endedAt"));
    assertEquals(JSONObject.NULL, json.get("failureMessage"));
    assertEquals("/" + URL_RUNNING_ACTION + "replicationActionExecutor=" + actionId + "=" + instanceId, json.get("executionDetails"));
    assertEquals(JSONObject.NULL, json.get("transferLocalReport"));
    assertEquals(JSONObject.NULL, json.get("transferRemoteReport"));
    assertEquals(true, json.get("enabled"));
    assertEquals(JSONObject.NULL, json.get("targetName"));
    // Payload is empty
    assertEquals(0, json.getJSONArray("payload").length());
    // Add some payload details, ensure that they get expanded
    // as they should be
    rd.getPayload().add(repositoryHelper.getCompanyHome());
    rd.getPayload().add(dataDictionary);
    replicationService.saveReplicationDefinition(rd);
    response = sendRequest(new GetRequest(URL_DEFINITION + "Test1"), 200);
    assertEquals(Status.STATUS_OK, response.getStatus());
    jsonStr = response.getContentAsString();
    json = new JSONObject(jsonStr).getJSONObject("data");
    assertEquals("Test1", json.get("name"));
    assertEquals("Testing", json.get("description"));
    assertEquals("CancelRequested", json.get("status"));
    assertEquals(startedAt, json.getJSONObject("startedAt").get("iso8601"));
    assertEquals(JSONObject.NULL, json.get("endedAt"));
    assertEquals(JSONObject.NULL, json.get("failureMessage"));
    assertEquals("/" + URL_RUNNING_ACTION + "replicationActionExecutor=" + actionId + "=" + instanceId, json.get("executionDetails"));
    assertEquals(JSONObject.NULL, json.get("transferLocalReport"));
    assertEquals(JSONObject.NULL, json.get("transferRemoteReport"));
    assertEquals(true, json.get("enabled"));
    assertEquals(JSONObject.NULL, json.get("targetName"));
    // Check Payload
    assertEquals(2, json.getJSONArray("payload").length());
    JSONObject payload = json.getJSONArray("payload").getJSONObject(0);
    assertEquals(repositoryHelper.getCompanyHome().toString(), payload.get("nodeRef"));
    assertEquals(true, payload.get("isFolder"));
    assertEquals("Company Home", payload.get("name"));
    assertEquals("/Company Home", payload.get("path"));
    payload = json.getJSONArray("payload").getJSONObject(1);
    assertEquals(dataDictionary.toString(), payload.get("nodeRef"));
    assertEquals(true, payload.get("isFolder"));
    assertEquals("Data Dictionary", payload.get("name"));
    assertEquals("/Company Home/Data Dictionary", payload.get("path"));
    // Add a deleted NodeRef too, will be silently ignored
    // by the webscript layer
    UserTransaction txn = transactionService.getUserTransaction();
    txn.begin();
    NodeRef deleted = nodeService.createNode(dataDictionary, ContentModel.ASSOC_CONTAINS, QName.createQName("IwillBEdeleted"), ContentModel.TYPE_CONTENT).getChildRef();
    nodeService.deleteNode(deleted);
    txn.commit();
    rd.getPayload().add(deleted);
    replicationService.saveReplicationDefinition(rd);
    response = sendRequest(new GetRequest(URL_DEFINITION + "Test1"), 200);
    assertEquals(Status.STATUS_OK, response.getStatus());
    jsonStr = response.getContentAsString();
    json = new JSONObject(jsonStr).getJSONObject("data");
    assertEquals("Test1", json.get("name"));
    assertEquals("Testing", json.get("description"));
    assertEquals("CancelRequested", json.get("status"));
    assertEquals(startedAt, json.getJSONObject("startedAt").get("iso8601"));
    assertEquals(JSONObject.NULL, json.get("endedAt"));
    assertEquals(JSONObject.NULL, json.get("failureMessage"));
    assertEquals("/" + URL_RUNNING_ACTION + "replicationActionExecutor=" + actionId + "=" + instanceId, json.get("executionDetails"));
    assertEquals(JSONObject.NULL, json.get("transferLocalReport"));
    assertEquals(JSONObject.NULL, json.get("transferRemoteReport"));
    assertEquals(true, json.get("enabled"));
    assertEquals(JSONObject.NULL, json.get("targetName"));
    // Check Payload
    assertEquals(2, json.getJSONArray("payload").length());
    payload = json.getJSONArray("payload").getJSONObject(0);
    assertEquals("Company Home", payload.get("name"));
    payload = json.getJSONArray("payload").getJSONObject(1);
    assertEquals("Data Dictionary", payload.get("name"));
    // Add a 2nd and 3rd definition
    rd = replicationService.createReplicationDefinition("Test2", "2nd Testing");
    replicationService.saveReplicationDefinition(rd);
    rd = replicationService.createReplicationDefinition("Test3", "3rd Testing");
    rd.setLocalTransferReport(repositoryHelper.getRootHome());
    rd.setRemoteTransferReport(repositoryHelper.getCompanyHome());
    rd.setEnabled(false);
    // Have the 3rd one flagged as having failed
    txn = transactionService.getUserTransaction();
    txn.begin();
    replicationService.saveReplicationDefinition(rd);
    actionTrackingService.recordActionExecuting(rd);
    actionTrackingService.recordActionFailure(rd, new Exception("Test Failure"));
    txn.commit();
    Thread.sleep(50);
    replicationService.saveReplicationDefinition(rd);
    // Original one comes back unchanged
    response = sendRequest(new GetRequest(URL_DEFINITION + "Test1"), 200);
    assertEquals(Status.STATUS_OK, response.getStatus());
    jsonStr = response.getContentAsString();
    json = new JSONObject(jsonStr).getJSONObject("data");
    assertEquals("Test1", json.get("name"));
    assertEquals("Testing", json.get("description"));
    assertEquals("CancelRequested", json.get("status"));
    assertEquals(startedAt, json.getJSONObject("startedAt").get("iso8601"));
    assertEquals(JSONObject.NULL, json.get("endedAt"));
    assertEquals(JSONObject.NULL, json.get("failureMessage"));
    assertEquals("/" + URL_RUNNING_ACTION + "replicationActionExecutor=" + actionId + "=" + instanceId, json.get("executionDetails"));
    assertEquals(JSONObject.NULL, json.get("transferLocalReport"));
    assertEquals(JSONObject.NULL, json.get("transferRemoteReport"));
    assertEquals(true, json.get("enabled"));
    assertEquals(JSONObject.NULL, json.get("targetName"));
    // Check Payload
    assertEquals(2, json.getJSONArray("payload").length());
    payload = json.getJSONArray("payload").getJSONObject(0);
    assertEquals(repositoryHelper.getCompanyHome().toString(), payload.get("nodeRef"));
    assertEquals(true, payload.get("isFolder"));
    assertEquals("Company Home", payload.get("name"));
    assertEquals("/Company Home", payload.get("path"));
    payload = json.getJSONArray("payload").getJSONObject(1);
    assertEquals(dataDictionary.toString(), payload.get("nodeRef"));
    assertEquals(true, payload.get("isFolder"));
    assertEquals("Data Dictionary", payload.get("name"));
    assertEquals("/Company Home/Data Dictionary", payload.get("path"));
    // They show up things as expected
    response = sendRequest(new GetRequest(URL_DEFINITION + "Test2"), 200);
    assertEquals(Status.STATUS_OK, response.getStatus());
    jsonStr = response.getContentAsString();
    json = new JSONObject(jsonStr).getJSONObject("data");
    assertEquals("Test2", json.get("name"));
    assertEquals("2nd Testing", json.get("description"));
    assertEquals("New", json.get("status"));
    assertEquals(JSONObject.NULL, json.get("startedAt"));
    assertEquals(JSONObject.NULL, json.get("endedAt"));
    assertEquals(JSONObject.NULL, json.get("failureMessage"));
    assertEquals(JSONObject.NULL, json.get("executionDetails"));
    assertEquals(JSONObject.NULL, json.get("transferLocalReport"));
    assertEquals(JSONObject.NULL, json.get("transferRemoteReport"));
    assertEquals(true, json.get("enabled"));
    assertEquals(JSONObject.NULL, json.get("targetName"));
    assertEquals(0, json.getJSONArray("payload").length());
    // And the 3rd one, which is failed
    response = sendRequest(new GetRequest(URL_DEFINITION + "Test3"), 200);
    assertEquals(Status.STATUS_OK, response.getStatus());
    jsonStr = response.getContentAsString();
    json = new JSONObject(jsonStr).getJSONObject("data");
    startedAt = ISO8601DateFormat.format(rd.getExecutionStartDate());
    String endedAt = ISO8601DateFormat.format(rd.getExecutionEndDate());
    assertEquals("Test3", json.get("name"));
    assertEquals("3rd Testing", json.get("description"));
    assertEquals("Failed", json.get("status"));
    assertEquals(startedAt, json.getJSONObject("startedAt").get("iso8601"));
    assertEquals(endedAt, json.getJSONObject("endedAt").get("iso8601"));
    assertEquals("Test Failure", json.get("failureMessage"));
    assertEquals(JSONObject.NULL, json.get("executionDetails"));
    assertEquals(repositoryHelper.getRootHome().toString(), json.get("transferLocalReport"));
    assertEquals(repositoryHelper.getCompanyHome().toString(), json.get("transferRemoteReport"));
    assertEquals(false, json.get("enabled"));
    assertEquals(JSONObject.NULL, json.get("targetName"));
    assertEquals(0, json.getJSONArray("payload").length());
    // When pending/running, the previous end time, transfer reports and
    // failure details are hidden
    rd = replicationService.loadReplicationDefinition("Test3");
    assertEquals(0, actionTrackingService.getExecutingActions(rd).size());
    actionTrackingService.recordActionPending(rd);
    assertEquals(1, actionTrackingService.getExecutingActions(rd).size());
    instanceId = ((ActionImpl) rd).getExecutionInstance();
    actionId = rd.getId();
    response = sendRequest(new GetRequest(URL_DEFINITION + "Test3"), 200);
    assertEquals(Status.STATUS_OK, response.getStatus());
    jsonStr = response.getContentAsString();
    json = new JSONObject(jsonStr).getJSONObject("data");
    assertEquals("Test3", json.get("name"));
    assertEquals("3rd Testing", json.get("description"));
    assertEquals("Pending", json.get("status"));
    assertEquals(JSONObject.NULL, json.get("startedAt"));
    assertEquals(JSONObject.NULL, json.get("endedAt"));
    assertEquals(JSONObject.NULL, json.get("failureMessage"));
    assertEquals("/" + URL_RUNNING_ACTION + "replicationActionExecutor=" + actionId + "=" + instanceId, json.get("executionDetails"));
    assertEquals(JSONObject.NULL, json.get("transferLocalReport"));
    assertEquals(JSONObject.NULL, json.get("transferRemoteReport"));
    assertEquals(false, json.get("enabled"));
    assertEquals(JSONObject.NULL, json.get("targetName"));
    assertEquals(0, json.getJSONArray("payload").length());
    actionTrackingService.recordActionExecuting(rd);
    response = sendRequest(new GetRequest(URL_DEFINITION + "Test3"), 200);
    assertEquals(Status.STATUS_OK, response.getStatus());
    jsonStr = response.getContentAsString();
    json = new JSONObject(jsonStr).getJSONObject("data");
    startedAt = ISO8601DateFormat.format(rd.getExecutionStartDate());
    assertEquals("Test3", json.get("name"));
    assertEquals("3rd Testing", json.get("description"));
    assertEquals("Running", json.get("status"));
    assertEquals(startedAt, json.getJSONObject("startedAt").get("iso8601"));
    assertEquals(JSONObject.NULL, json.get("endedAt"));
    assertEquals(JSONObject.NULL, json.get("failureMessage"));
    assertEquals("/" + URL_RUNNING_ACTION + "replicationActionExecutor=" + actionId + "=" + instanceId, json.get("executionDetails"));
    assertEquals(JSONObject.NULL, json.get("transferLocalReport"));
    assertEquals(JSONObject.NULL, json.get("transferRemoteReport"));
    assertEquals(false, json.get("enabled"));
    assertEquals(JSONObject.NULL, json.get("targetName"));
    assertEquals(0, json.getJSONArray("payload").length());
    actionTrackingService.requestActionCancellation(rd);
    response = sendRequest(new GetRequest(URL_DEFINITION + "Test3"), 200);
    assertEquals(Status.STATUS_OK, response.getStatus());
    jsonStr = response.getContentAsString();
    json = new JSONObject(jsonStr).getJSONObject("data");
    startedAt = ISO8601DateFormat.format(rd.getExecutionStartDate());
    assertEquals("Test3", json.get("name"));
    assertEquals("3rd Testing", json.get("description"));
    assertEquals("CancelRequested", json.get("status"));
    assertEquals(startedAt, json.getJSONObject("startedAt").get("iso8601"));
    assertEquals(JSONObject.NULL, json.get("endedAt"));
    assertEquals(JSONObject.NULL, json.get("failureMessage"));
    assertEquals("/" + URL_RUNNING_ACTION + "replicationActionExecutor=" + actionId + "=" + instanceId, json.get("executionDetails"));
    assertEquals(JSONObject.NULL, json.get("transferLocalReport"));
    assertEquals(JSONObject.NULL, json.get("transferRemoteReport"));
    assertEquals(false, json.get("enabled"));
    assertEquals(JSONObject.NULL, json.get("targetName"));
    assertEquals(0, json.getJSONArray("payload").length());
    // These show up again when no longer running
    txn = transactionService.getUserTransaction();
    txn.begin();
    actionTrackingService.recordActionComplete(rd);
    txn.commit();
    response = sendRequest(new GetRequest(URL_DEFINITION + "Test3"), 200);
    assertEquals(Status.STATUS_OK, response.getStatus());
    jsonStr = response.getContentAsString();
    json = new JSONObject(jsonStr).getJSONObject("data");
    startedAt = ISO8601DateFormat.format(rd.getExecutionStartDate());
    endedAt = ISO8601DateFormat.format(rd.getExecutionEndDate());
    assertEquals("Test3", json.get("name"));
    assertEquals("3rd Testing", json.get("description"));
    assertEquals("Completed", json.get("status"));
    assertEquals(startedAt, json.getJSONObject("startedAt").get("iso8601"));
    assertEquals(endedAt, json.getJSONObject("endedAt").get("iso8601"));
    assertEquals(JSONObject.NULL, json.get("failureMessage"));
    assertEquals(JSONObject.NULL, json.get("executionDetails"));
    assertEquals(repositoryHelper.getRootHome().toString(), json.get("transferLocalReport"));
    assertEquals(repositoryHelper.getCompanyHome().toString(), json.get("transferRemoteReport"));
    assertEquals(false, json.get("enabled"));
    assertEquals(JSONObject.NULL, json.get("targetName"));
    assertEquals(0, json.getJSONArray("payload").length());
}
Also used : Response(org.springframework.extensions.webscripts.TestWebScriptServer.Response) UserTransaction(javax.transaction.UserTransaction) NodeRef(org.alfresco.service.cmr.repository.NodeRef) JSONObject(org.json.JSONObject) ReplicationDefinition(org.alfresco.service.cmr.replication.ReplicationDefinition) GetRequest(org.springframework.extensions.webscripts.TestWebScriptServer.GetRequest) JSONArray(org.json.JSONArray) ActionImpl(org.alfresco.repo.action.ActionImpl)

Example 7 with ReplicationDefinition

use of org.alfresco.service.cmr.replication.ReplicationDefinition in project alfresco-remote-api by Alfresco.

the class ReplicationRestApiTest method testReplicationDefinitionsPost.

public void testReplicationDefinitionsPost() throws Exception {
    Response response;
    // Not allowed if you're not an admin
    AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getGuestUserName());
    response = sendRequest(new PostRequest(URL_DEFINITIONS, "", JSON), Status.STATUS_UNAUTHORIZED);
    assertEquals(Status.STATUS_UNAUTHORIZED, response.getStatus());
    AuthenticationUtil.setFullyAuthenticatedUser(USER_NORMAL);
    response = sendRequest(new PostRequest(URL_DEFINITIONS, "", JSON), Status.STATUS_UNAUTHORIZED);
    assertEquals(Status.STATUS_UNAUTHORIZED, response.getStatus());
    // Ensure there aren't any to start with
    AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName());
    assertEquals(0, replicationService.loadReplicationDefinitions().size());
    // If you don't give it name + description, it won't like you
    JSONObject json = new JSONObject();
    response = sendRequest(new PostRequest(URL_DEFINITIONS, json.toString(), JSON), Status.STATUS_BAD_REQUEST);
    assertEquals(Status.STATUS_BAD_REQUEST, response.getStatus());
    json.put("name", "New Definition");
    response = sendRequest(new PostRequest(URL_DEFINITIONS, json.toString(), JSON), Status.STATUS_BAD_REQUEST);
    assertEquals(Status.STATUS_BAD_REQUEST, response.getStatus());
    // If it has both, it'll work
    json.put("description", "Testing");
    response = sendRequest(new PostRequest(URL_DEFINITIONS, json.toString(), JSON), Status.STATUS_OK);
    assertEquals(Status.STATUS_OK, response.getStatus());
    // Check we got the right information back
    String jsonStr = response.getContentAsString();
    json = new JSONObject(jsonStr).getJSONObject("data");
    assertNotNull(json);
    assertEquals("New Definition", json.get("name"));
    assertEquals("Testing", json.get("description"));
    assertEquals("New", json.get("status"));
    assertEquals(JSONObject.NULL, json.get("startedAt"));
    assertEquals(JSONObject.NULL, json.get("endedAt"));
    assertEquals(JSONObject.NULL, json.get("failureMessage"));
    assertEquals(JSONObject.NULL, json.get("executionDetails"));
    assertEquals(JSONObject.NULL, json.get("transferLocalReport"));
    assertEquals(JSONObject.NULL, json.get("transferRemoteReport"));
    assertEquals(true, json.get("enabled"));
    assertEquals(JSONObject.NULL, json.get("targetName"));
    assertEquals(0, json.getJSONArray("payload").length());
    // Check that the right stuff ended up in the repository
    ReplicationDefinition rd = replicationService.loadReplicationDefinition("New Definition");
    assertEquals("New Definition", rd.getReplicationName());
    assertEquals("Testing", rd.getDescription());
    assertEquals(ActionStatus.New, rd.getExecutionStatus());
    assertEquals(null, rd.getExecutionStartDate());
    assertEquals(null, rd.getExecutionEndDate());
    assertEquals(null, rd.getExecutionFailureMessage());
    assertEquals(null, rd.getLocalTransferReport());
    assertEquals(null, rd.getRemoteTransferReport());
    assertEquals(null, rd.getTargetName());
    assertEquals(0, rd.getPayload().size());
    assertEquals(true, rd.isEnabled());
    // Post with the full set of options
    json = new JSONObject();
    json.put("name", "Test");
    json.put("description", "Test Description");
    json.put("targetName", "Target");
    json.put("enabled", false);
    JSONArray payloadRefs = new JSONArray();
    payloadRefs.put(repositoryHelper.getCompanyHome().toString());
    payloadRefs.put(dataDictionary.toString());
    json.put("payload", payloadRefs);
    response = sendRequest(new PostRequest(URL_DEFINITIONS, json.toString(), JSON), Status.STATUS_OK);
    assertEquals(Status.STATUS_OK, response.getStatus());
    // Check the response for this
    jsonStr = response.getContentAsString();
    json = new JSONObject(jsonStr).getJSONObject("data");
    assertNotNull(json);
    assertEquals("Test", json.get("name"));
    assertEquals("Test Description", json.get("description"));
    assertEquals("New", json.get("status"));
    assertEquals(JSONObject.NULL, json.get("startedAt"));
    assertEquals(JSONObject.NULL, json.get("endedAt"));
    assertEquals(JSONObject.NULL, json.get("failureMessage"));
    assertEquals(JSONObject.NULL, json.get("executionDetails"));
    assertEquals(JSONObject.NULL, json.get("transferLocalReport"));
    assertEquals(JSONObject.NULL, json.get("transferRemoteReport"));
    assertEquals(false, json.get("enabled"));
    assertEquals("Target", json.get("targetName"));
    assertEquals(2, json.getJSONArray("payload").length());
    JSONObject payload = json.getJSONArray("payload").getJSONObject(0);
    assertEquals(repositoryHelper.getCompanyHome().toString(), payload.get("nodeRef"));
    assertEquals(true, payload.get("isFolder"));
    assertEquals("Company Home", payload.get("name"));
    assertEquals("/Company Home", payload.get("path"));
    payload = json.getJSONArray("payload").getJSONObject(1);
    assertEquals(dataDictionary.toString(), payload.get("nodeRef"));
    assertEquals(true, payload.get("isFolder"));
    assertEquals("Data Dictionary", payload.get("name"));
    assertEquals("/Company Home/Data Dictionary", payload.get("path"));
    // Check the database for this
    rd = replicationService.loadReplicationDefinition("Test");
    assertEquals("Test", rd.getReplicationName());
    assertEquals("Test Description", rd.getDescription());
    assertEquals(ActionStatus.New, rd.getExecutionStatus());
    assertEquals(null, rd.getExecutionStartDate());
    assertEquals(null, rd.getExecutionEndDate());
    assertEquals(null, rd.getExecutionFailureMessage());
    assertEquals(null, rd.getLocalTransferReport());
    assertEquals(null, rd.getRemoteTransferReport());
    assertEquals("Target", rd.getTargetName());
    assertEquals(false, rd.isEnabled());
    assertEquals(2, rd.getPayload().size());
    assertEquals(repositoryHelper.getCompanyHome(), rd.getPayload().get(0));
    assertEquals(dataDictionary, rd.getPayload().get(1));
    // Ensure that the original one wasn't changed by anything
    rd = replicationService.loadReplicationDefinition("New Definition");
    assertEquals("New Definition", rd.getReplicationName());
    assertEquals("Testing", rd.getDescription());
    assertEquals(ActionStatus.New, rd.getExecutionStatus());
    assertEquals(null, rd.getExecutionStartDate());
    assertEquals(null, rd.getExecutionEndDate());
    assertEquals(null, rd.getExecutionFailureMessage());
    assertEquals(null, rd.getLocalTransferReport());
    assertEquals(null, rd.getRemoteTransferReport());
    assertEquals(null, rd.getTargetName());
    assertEquals(0, rd.getPayload().size());
    assertEquals(true, rd.isEnabled());
    // Ensure we can't create with a duplicate name
    json = new JSONObject();
    json.put("name", "Test");
    json.put("description", "New Duplicate");
    json.put("targetName", "New Duplicate Target");
    response = sendRequest(new PostRequest(URL_DEFINITIONS, json.toString(), JSON), Status.STATUS_BAD_REQUEST);
    assertEquals(Status.STATUS_BAD_REQUEST, response.getStatus());
    // Ensure that even though we got BAD REQUEST back, nothing changed
    rd = replicationService.loadReplicationDefinition("New Definition");
    assertEquals("New Definition", rd.getReplicationName());
    assertEquals("Testing", rd.getDescription());
    assertEquals(ActionStatus.New, rd.getExecutionStatus());
    assertEquals(null, rd.getExecutionStartDate());
    assertEquals(null, rd.getExecutionEndDate());
    assertEquals(null, rd.getExecutionFailureMessage());
    assertEquals(null, rd.getLocalTransferReport());
    assertEquals(null, rd.getRemoteTransferReport());
    assertEquals(null, rd.getTargetName());
    assertEquals(0, rd.getPayload().size());
    assertEquals(true, rd.isEnabled());
}
Also used : Response(org.springframework.extensions.webscripts.TestWebScriptServer.Response) PostRequest(org.springframework.extensions.webscripts.TestWebScriptServer.PostRequest) JSONObject(org.json.JSONObject) ReplicationDefinition(org.alfresco.service.cmr.replication.ReplicationDefinition) JSONArray(org.json.JSONArray)

Example 8 with ReplicationDefinition

use of org.alfresco.service.cmr.replication.ReplicationDefinition in project alfresco-remote-api by Alfresco.

the class ReplicationRestApiTest method testReplicationDefinitionPut.

public void testReplicationDefinitionPut() throws Exception {
    Response response;
    // Not allowed if you're not an admin
    AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getGuestUserName());
    response = sendRequest(new PutRequest(URL_DEFINITION + "MadeUp", "", JSON), Status.STATUS_UNAUTHORIZED);
    assertEquals(Status.STATUS_UNAUTHORIZED, response.getStatus());
    AuthenticationUtil.setFullyAuthenticatedUser(USER_NORMAL);
    response = sendRequest(new PutRequest(URL_DEFINITION + "MadeUp", "", JSON), Status.STATUS_UNAUTHORIZED);
    assertEquals(Status.STATUS_UNAUTHORIZED, response.getStatus());
    // Ensure there aren't any to start with
    AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName());
    assertEquals(0, replicationService.loadReplicationDefinitions().size());
    // You need to specify a real definition
    response = sendRequest(new PutRequest(URL_DEFINITION + "MadeUp", "", JSON), Status.STATUS_NOT_FOUND);
    assertEquals(Status.STATUS_NOT_FOUND, response.getStatus());
    // Create one, and change it
    ReplicationDefinition rd = replicationService.createReplicationDefinition("Test", "Testing");
    replicationService.saveReplicationDefinition(rd);
    response = sendRequest(new PutRequest(URL_DEFINITION + "Test", "{}", JSON), Status.STATUS_OK);
    assertEquals(Status.STATUS_OK, response.getStatus());
    // Check we got the right information back on it
    String jsonStr = response.getContentAsString();
    JSONObject json = new JSONObject(jsonStr).getJSONObject("data");
    assertNotNull(json);
    assertEquals("Test", json.get("name"));
    assertEquals("Testing", json.get("description"));
    assertEquals("New", json.get("status"));
    assertEquals(JSONObject.NULL, json.get("startedAt"));
    assertEquals(JSONObject.NULL, json.get("endedAt"));
    assertEquals(JSONObject.NULL, json.get("failureMessage"));
    assertEquals(JSONObject.NULL, json.get("executionDetails"));
    assertEquals(JSONObject.NULL, json.get("transferLocalReport"));
    assertEquals(JSONObject.NULL, json.get("transferRemoteReport"));
    assertEquals(true, json.get("enabled"));
    assertEquals(JSONObject.NULL, json.get("targetName"));
    assertEquals(0, json.getJSONArray("payload").length());
    // Ensure we didn't get any unexpected data back
    JSONArray keys = json.names();
    for (int i = 0; i < keys.length(); i++) {
        String key = keys.getString(0);
        if (key.equals("name") || key.equals("description") || key.equals("status") || key.equals("startedAt") || key.equals("endedAt") || key.equals("failureMessage") || key.equals("executionDetails") || key.equals("payload") || key.equals("transferLocalReport") || key.equals("transferRemoteReport") || key.equals("enabled") || key.equals("targetName") || key.equals("schedule")) {
        // All good
        } else {
            fail("Unexpected key '" + key + "' found in json, raw json is\n" + jsonStr);
        }
    }
    // Change some details, and see them updated in both
    // the JSON and on the object in the repo
    json = new JSONObject();
    json.put("description", "Updated Description");
    json.put("enabled", false);
    response = sendRequest(new PutRequest(URL_DEFINITION + "Test", json.toString(), JSON), Status.STATUS_OK);
    assertEquals(Status.STATUS_OK, response.getStatus());
    jsonStr = response.getContentAsString();
    json = new JSONObject(jsonStr).getJSONObject("data");
    assertNotNull(json);
    assertEquals("Test", json.get("name"));
    assertEquals("Updated Description", json.get("description"));
    assertEquals("New", json.get("status"));
    assertEquals(JSONObject.NULL, json.get("startedAt"));
    assertEquals(JSONObject.NULL, json.get("endedAt"));
    assertEquals(JSONObject.NULL, json.get("failureMessage"));
    assertEquals(JSONObject.NULL, json.get("executionDetails"));
    assertEquals(JSONObject.NULL, json.get("transferLocalReport"));
    assertEquals(JSONObject.NULL, json.get("transferRemoteReport"));
    assertEquals(false, json.get("enabled"));
    assertEquals(JSONObject.NULL, json.get("targetName"));
    assertEquals(0, json.getJSONArray("payload").length());
    rd = replicationService.loadReplicationDefinition("Test");
    assertEquals("Test", rd.getReplicationName());
    assertEquals("Updated Description", rd.getDescription());
    assertEquals(ActionStatus.New, rd.getExecutionStatus());
    assertEquals(null, rd.getExecutionStartDate());
    assertEquals(null, rd.getExecutionEndDate());
    assertEquals(null, rd.getExecutionFailureMessage());
    assertEquals(null, rd.getLocalTransferReport());
    assertEquals(null, rd.getRemoteTransferReport());
    assertEquals(null, rd.getTargetName());
    assertEquals(0, rd.getPayload().size());
    assertEquals(false, rd.isEnabled());
    // Create a 2nd definition, and check that the correct
    // one gets updated
    rd = replicationService.createReplicationDefinition("Test2", "Testing2");
    rd.setTargetName("Target");
    replicationService.saveReplicationDefinition(rd);
    json = new JSONObject();
    json.put("description", "Updated Description 2");
    json.put("enabled", false);
    response = sendRequest(new PutRequest(URL_DEFINITION + "Test2", json.toString(), JSON), Status.STATUS_OK);
    assertEquals(Status.STATUS_OK, response.getStatus());
    // Check the response we got
    jsonStr = response.getContentAsString();
    json = new JSONObject(jsonStr).getJSONObject("data");
    assertNotNull(json);
    assertEquals("Test2", json.get("name"));
    assertEquals("Updated Description 2", json.get("description"));
    assertEquals("New", json.get("status"));
    assertEquals(JSONObject.NULL, json.get("startedAt"));
    assertEquals(JSONObject.NULL, json.get("endedAt"));
    assertEquals(JSONObject.NULL, json.get("failureMessage"));
    assertEquals(JSONObject.NULL, json.get("executionDetails"));
    assertEquals(JSONObject.NULL, json.get("transferLocalReport"));
    assertEquals(JSONObject.NULL, json.get("transferRemoteReport"));
    assertEquals(false, json.get("enabled"));
    assertEquals("Target", json.get("targetName"));
    assertEquals(0, json.getJSONArray("payload").length());
    // Check the 1st definition
    rd = replicationService.loadReplicationDefinition("Test");
    assertEquals("Test", rd.getReplicationName());
    assertEquals("Updated Description", rd.getDescription());
    assertEquals(ActionStatus.New, rd.getExecutionStatus());
    assertEquals(null, rd.getExecutionStartDate());
    assertEquals(null, rd.getExecutionEndDate());
    assertEquals(null, rd.getExecutionFailureMessage());
    assertEquals(null, rd.getLocalTransferReport());
    assertEquals(null, rd.getRemoteTransferReport());
    assertEquals(null, rd.getTargetName());
    assertEquals(0, rd.getPayload().size());
    assertEquals(false, rd.isEnabled());
    // Check the 2nd definition
    rd = replicationService.loadReplicationDefinition("Test2");
    assertEquals("Test2", rd.getReplicationName());
    assertEquals("Updated Description 2", rd.getDescription());
    assertEquals(ActionStatus.New, rd.getExecutionStatus());
    assertEquals(null, rd.getExecutionStartDate());
    assertEquals(null, rd.getExecutionEndDate());
    assertEquals(null, rd.getExecutionFailureMessage());
    assertEquals(null, rd.getLocalTransferReport());
    assertEquals(null, rd.getRemoteTransferReport());
    assertEquals("Target", rd.getTargetName());
    assertEquals(0, rd.getPayload().size());
    assertEquals(false, rd.isEnabled());
    // Mark it as running, then change some details and
    // see it change as expected
    rd = replicationService.loadReplicationDefinition("Test");
    actionTrackingService.recordActionExecuting(rd);
    replicationService.saveReplicationDefinition(rd);
    String startedAt = ISO8601DateFormat.format(rd.getExecutionStartDate());
    String actionId = rd.getId();
    int instanceId = ((ActionImpl) rd).getExecutionInstance();
    json = new JSONObject();
    json.put("enabled", true);
    json.put("targetName", "Another Target");
    response = sendRequest(new PutRequest(URL_DEFINITION + "Test", json.toString(), JSON), Status.STATUS_OK);
    assertEquals(Status.STATUS_OK, response.getStatus());
    jsonStr = response.getContentAsString();
    json = new JSONObject(jsonStr).getJSONObject("data");
    assertNotNull(json);
    assertEquals("Test", json.get("name"));
    assertEquals("Updated Description", json.get("description"));
    assertEquals("Running", json.get("status"));
    assertEquals(startedAt, json.getJSONObject("startedAt").get("iso8601"));
    assertEquals(JSONObject.NULL, json.get("endedAt"));
    assertEquals(JSONObject.NULL, json.get("failureMessage"));
    assertEquals("/" + URL_RUNNING_ACTION + "replicationActionExecutor=" + actionId + "=" + instanceId, json.get("executionDetails"));
    assertEquals(JSONObject.NULL, json.get("transferLocalReport"));
    assertEquals(JSONObject.NULL, json.get("transferRemoteReport"));
    assertEquals(true, json.get("enabled"));
    assertEquals("Another Target", json.get("targetName"));
    assertEquals(0, json.getJSONArray("payload").length());
    // Change the payload, and see the right information in
    // the response JSON for it
    JSONArray payloadRefs = new JSONArray();
    payloadRefs.put(repositoryHelper.getCompanyHome().toString());
    payloadRefs.put(dataDictionary.toString());
    json = new JSONObject();
    json.put("payload", payloadRefs);
    response = sendRequest(new PutRequest(URL_DEFINITION + "Test", json.toString(), JSON), Status.STATUS_OK);
    assertEquals(Status.STATUS_OK, response.getStatus());
    jsonStr = response.getContentAsString();
    json = new JSONObject(jsonStr).getJSONObject("data");
    assertNotNull(json);
    assertEquals("Test", json.get("name"));
    assertEquals("Updated Description", json.get("description"));
    assertEquals("Running", json.get("status"));
    assertEquals(startedAt, json.getJSONObject("startedAt").get("iso8601"));
    assertEquals(JSONObject.NULL, json.get("endedAt"));
    assertEquals(JSONObject.NULL, json.get("failureMessage"));
    assertEquals("/" + URL_RUNNING_ACTION + "replicationActionExecutor=" + actionId + "=" + instanceId, json.get("executionDetails"));
    assertEquals(JSONObject.NULL, json.get("transferLocalReport"));
    assertEquals(JSONObject.NULL, json.get("transferRemoteReport"));
    assertEquals(true, json.get("enabled"));
    assertEquals("Another Target", json.get("targetName"));
    assertEquals(2, json.getJSONArray("payload").length());
    JSONObject payload = json.getJSONArray("payload").getJSONObject(0);
    assertEquals(repositoryHelper.getCompanyHome().toString(), payload.get("nodeRef"));
    assertEquals(true, payload.get("isFolder"));
    assertEquals("Company Home", payload.get("name"));
    assertEquals("/Company Home", payload.get("path"));
    payload = json.getJSONArray("payload").getJSONObject(1);
    assertEquals(dataDictionary.toString(), payload.get("nodeRef"));
    assertEquals(true, payload.get("isFolder"));
    assertEquals("Data Dictionary", payload.get("name"));
    assertEquals("/Company Home/Data Dictionary", payload.get("path"));
    // Remove the payload again
    json = new JSONObject();
    payloadRefs = new JSONArray();
    json.put("payload", payloadRefs);
    response = sendRequest(new PutRequest(URL_DEFINITION + "Test", json.toString(), JSON), Status.STATUS_OK);
    assertEquals(Status.STATUS_OK, response.getStatus());
    jsonStr = response.getContentAsString();
    json = new JSONObject(jsonStr).getJSONObject("data");
    assertNotNull(json);
    assertEquals("Test", json.get("name"));
    assertEquals("Updated Description", json.get("description"));
    assertEquals("Running", json.get("status"));
    assertEquals(startedAt, json.getJSONObject("startedAt").get("iso8601"));
    assertEquals(JSONObject.NULL, json.get("endedAt"));
    assertEquals(JSONObject.NULL, json.get("failureMessage"));
    assertEquals("/" + URL_RUNNING_ACTION + "replicationActionExecutor=" + actionId + "=" + instanceId, json.get("executionDetails"));
    assertEquals(JSONObject.NULL, json.get("transferLocalReport"));
    assertEquals(JSONObject.NULL, json.get("transferRemoteReport"));
    assertEquals(true, json.get("enabled"));
    assertEquals("Another Target", json.get("targetName"));
    assertEquals(0, json.getJSONArray("payload").length());
    // Rename to a taken name, won't be allowed
    json = new JSONObject();
    json.put("name", "Test2");
    response = sendRequest(new PutRequest(URL_DEFINITION + "Test", json.toString(), JSON), Status.STATUS_BAD_REQUEST);
    assertEquals(Status.STATUS_BAD_REQUEST, response.getStatus());
    // Rename to a spare name, will be updated
    json = new JSONObject();
    json.put("name", "Renamed");
    response = sendRequest(new PutRequest(URL_DEFINITION + "Test", json.toString(), JSON), Status.STATUS_OK);
    assertEquals(Status.STATUS_OK, response.getStatus());
    jsonStr = response.getContentAsString();
    json = new JSONObject(jsonStr).getJSONObject("data");
    assertNotNull(json);
    assertEquals("Renamed", json.get("name"));
    assertEquals("Updated Description", json.get("description"));
    assertEquals("Running", json.get("status"));
    assertEquals(startedAt, json.getJSONObject("startedAt").get("iso8601"));
    assertEquals(JSONObject.NULL, json.get("endedAt"));
    assertEquals(JSONObject.NULL, json.get("failureMessage"));
    assertEquals("/" + URL_RUNNING_ACTION + "replicationActionExecutor=" + actionId + "=" + instanceId, json.get("executionDetails"));
    assertEquals(JSONObject.NULL, json.get("transferLocalReport"));
    assertEquals(JSONObject.NULL, json.get("transferRemoteReport"));
    assertEquals(true, json.get("enabled"));
    assertEquals("Another Target", json.get("targetName"));
    assertEquals(0, json.getJSONArray("payload").length());
    // Check the repo too
    assertEquals(null, replicationService.loadReplicationDefinition("Test"));
    assertNotNull(replicationService.loadReplicationDefinition("Renamed"));
    // Rename can both rename + change details
    json = new JSONObject();
    json.put("name", "Renamed Again");
    json.put("description", "Was Renamed");
    json.put("targetName", "New Target");
    response = sendRequest(new PutRequest(URL_DEFINITION + "Renamed", json.toString(), JSON), Status.STATUS_OK);
    assertEquals(Status.STATUS_OK, response.getStatus());
    jsonStr = response.getContentAsString();
    json = new JSONObject(jsonStr).getJSONObject("data");
    assertNotNull(json);
    assertEquals("Renamed Again", json.get("name"));
    assertEquals("Was Renamed", json.get("description"));
    assertEquals("Running", json.get("status"));
    assertEquals(startedAt, json.getJSONObject("startedAt").get("iso8601"));
    assertEquals(JSONObject.NULL, json.get("endedAt"));
    assertEquals(JSONObject.NULL, json.get("failureMessage"));
    assertEquals("/" + URL_RUNNING_ACTION + "replicationActionExecutor=" + actionId + "=" + instanceId, json.get("executionDetails"));
    assertEquals(JSONObject.NULL, json.get("transferLocalReport"));
    assertEquals(JSONObject.NULL, json.get("transferRemoteReport"));
    assertEquals(true, json.get("enabled"));
    assertEquals("New Target", json.get("targetName"));
    assertEquals(0, json.getJSONArray("payload").length());
}
Also used : Response(org.springframework.extensions.webscripts.TestWebScriptServer.Response) JSONObject(org.json.JSONObject) ReplicationDefinition(org.alfresco.service.cmr.replication.ReplicationDefinition) JSONArray(org.json.JSONArray) ActionImpl(org.alfresco.repo.action.ActionImpl) PutRequest(org.springframework.extensions.webscripts.TestWebScriptServer.PutRequest)

Example 9 with ReplicationDefinition

use of org.alfresco.service.cmr.replication.ReplicationDefinition in project alfresco-remote-api by Alfresco.

the class ReplicationRestApiTest method setUp.

@Override
protected void setUp() throws Exception {
    super.setUp();
    ApplicationContext appContext = getServer().getApplicationContext();
    nodeService = (NodeService) appContext.getBean("NodeService");
    replicationService = (ReplicationService) appContext.getBean("ReplicationService");
    actionTrackingService = (ActionTrackingService) appContext.getBean("actionTrackingService");
    repositoryHelper = (Repository) appContext.getBean("repositoryHelper");
    transactionService = (TransactionService) appContext.getBean("transactionService");
    MutableAuthenticationService authenticationService = (MutableAuthenticationService) appContext.getBean("AuthenticationService");
    PersonService personService = (PersonService) appContext.getBean("PersonService");
    personManager = new TestPersonManager(authenticationService, personService, nodeService);
    UserTransaction txn = transactionService.getUserTransaction();
    txn.begin();
    personManager.createPerson(USER_NORMAL);
    // Ensure we start with no replication definitions
    // (eg another test left them behind)
    AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName());
    for (ReplicationDefinition rd : replicationService.loadReplicationDefinitions()) {
        replicationService.deleteReplicationDefinition(rd);
    }
    txn.commit();
    // Grab a reference to the data dictionary
    dataDictionary = nodeService.getChildByName(repositoryHelper.getCompanyHome(), ContentModel.ASSOC_CONTAINS, "Data Dictionary");
    AuthenticationUtil.clearCurrentSecurityContext();
}
Also used : TestPersonManager(org.alfresco.repo.security.person.TestPersonManager) UserTransaction(javax.transaction.UserTransaction) ApplicationContext(org.springframework.context.ApplicationContext) ReplicationDefinition(org.alfresco.service.cmr.replication.ReplicationDefinition) PersonService(org.alfresco.service.cmr.security.PersonService) MutableAuthenticationService(org.alfresco.service.cmr.security.MutableAuthenticationService)

Example 10 with ReplicationDefinition

use of org.alfresco.service.cmr.replication.ReplicationDefinition in project alfresco-remote-api by Alfresco.

the class ReplicationDefinitionGet method buildModel.

@Override
protected Map<String, Object> buildModel(ReplicationModelBuilder modelBuilder, WebScriptRequest req, Status status, Cache cache) {
    // Which definition did they ask for?
    String replicationDefinitionName = req.getServiceMatch().getTemplateVars().get("replication_definition_name");
    ReplicationDefinition replicationDefinition = replicationService.loadReplicationDefinition(replicationDefinitionName);
    // Does it exist?
    if (replicationDefinition == null) {
        throw new WebScriptException(Status.STATUS_NOT_FOUND, "No Replication Definition found with that name");
    }
    // Have it turned into simple models
    return modelBuilder.buildDetails(replicationDefinition);
}
Also used : WebScriptException(org.springframework.extensions.webscripts.WebScriptException) ReplicationDefinition(org.alfresco.service.cmr.replication.ReplicationDefinition)

Aggregations

ReplicationDefinition (org.alfresco.service.cmr.replication.ReplicationDefinition)22 JSONObject (org.json.JSONObject)12 UserTransaction (javax.transaction.UserTransaction)11 Response (org.springframework.extensions.webscripts.TestWebScriptServer.Response)11 JSONArray (org.json.JSONArray)7 GetRequest (org.springframework.extensions.webscripts.TestWebScriptServer.GetRequest)6 WebScriptException (org.springframework.extensions.webscripts.WebScriptException)5 ActionImpl (org.alfresco.repo.action.ActionImpl)4 IOException (java.io.IOException)3 ExecutionSummary (org.alfresco.service.cmr.action.ExecutionSummary)3 JSONException (org.json.JSONException)3 JSONTokener (org.json.JSONTokener)3 PostRequest (org.springframework.extensions.webscripts.TestWebScriptServer.PostRequest)3 TestPersonManager (org.alfresco.repo.security.person.TestPersonManager)2 ExecutionDetails (org.alfresco.service.cmr.action.ExecutionDetails)2 MutableAuthenticationService (org.alfresco.service.cmr.security.MutableAuthenticationService)2 PersonService (org.alfresco.service.cmr.security.PersonService)2 ApplicationContext (org.springframework.context.ApplicationContext)2 DeleteRequest (org.springframework.extensions.webscripts.TestWebScriptServer.DeleteRequest)2 ArrayList (java.util.ArrayList)1