RM-92: Prevent users from being able to create duplicate lists

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/BRANCHES/V2.0@38290 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Dave Draper
2012-06-25 13:50:08 +00:00
parent ef827f9053
commit df743e37a5
2 changed files with 32 additions and 5 deletions

View File

@@ -2,6 +2,10 @@
<#escape x as jsonUtils.encodeJSONString(x)>
{
"data": <@rmconstraintLib.constraintJSON constraint=constraint />
<#if !errorMessage??>
"data": <@rmconstraintLib.constraintJSON constraint=constraint />
<#else>
"message" : "${msg(errorMessage, title)}"
</#if>
}
</#escape>

View File

@@ -19,7 +19,7 @@ function main()
{
for (var x = 0; x < values.length(); x++)
{
allowedValues[i++] = values.get(x);
allowedValues[i++] = values.get(x);
}
}
}
@@ -38,10 +38,33 @@ function main()
title = name;
}
var constraint = caveatConfig.createConstraint(name, title, allowedValues);
var constraints = caveatConfig.allConstraints;
// Pass the constraint detail to the template
model.constraint = constraint;
// Check for existing constraint...
var alreadyExists = false;
for (var i=0; i<constraints.length; i++)
{
var currTitle = constraints[i].title;
if (currTitle + "" == title)
{
alreadyExists = true;
break;
}
}
var existingConstraint = caveatConfig.getConstraint(title);
if (!alreadyExists)
{
var constraint = caveatConfig.createConstraint(name, title, allowedValues);
model.constraint = constraint;
}
else
{
status.code = 400;
model.errorMessage = "rm.admin.list-already-exists";
model.title = title;
}
}
main();