mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-14 17:58:59 +00:00
ALF-4408 - prevent creation of duplicate named replication definitions, and update the unit tests to properly test this, not just almost test it...
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@21986 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -55,9 +55,16 @@ public class ReplicationDefinitionsPost extends AbstractReplicationWebscript
|
||||
if(! json.has("description"))
|
||||
throw new WebScriptException(Status.STATUS_BAD_REQUEST, "description is required but wasn't supplied");
|
||||
|
||||
// Create
|
||||
// Ensure one doesn't already exist with that name
|
||||
String name = json.getString("name");
|
||||
if(replicationService.loadReplicationDefinition(name) != null)
|
||||
{
|
||||
throw new WebScriptException(Status.STATUS_BAD_REQUEST, "A replication definition already exists with that name");
|
||||
}
|
||||
|
||||
// Create the definition
|
||||
replicationDefinition = replicationService.createReplicationDefinition(
|
||||
json.getString("name"), json.getString("description")
|
||||
name, json.getString("description")
|
||||
);
|
||||
|
||||
// Set the extra parts
|
||||
|
@@ -818,9 +818,25 @@ public class ReplicationRestApiTest extends BaseWebScriptTest
|
||||
// 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());
|
||||
}
|
||||
|
||||
public void testReplicationDefinitionPut() throws Exception
|
||||
|
Reference in New Issue
Block a user