Validate that the site Short Name isn't too long during creation, and throw a helpful exception if it is. (Site Short Names get used in Authority Names, which are limited by the DB model to 100 characters)

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@38101 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Nick Burch
2012-06-20 23:06:09 +00:00
parent ae19fb057e
commit 428f8ddbbc
2 changed files with 12 additions and 0 deletions

View File

@@ -132,6 +132,7 @@ public class SiteServiceImpl extends AbstractLifecycleBean implements SiteServic
/** Messages */
private static final String MSG_UNABLE_TO_CREATE = "site_service.unable_to_create";
private static final String MSG_SITE_SHORT_NAME_TOO_LONG = "site_service.short_name_too_long";
private static final String MSG_VISIBILITY_GROUP_MISSING = "site_service.visibility_group_missing";
private static final String MSG_CAN_NOT_UPDATE = "site_service.can_not_update";
private static final String MSG_CAN_NOT_DELETE = "site_service.can_not_delete";
@@ -453,6 +454,16 @@ public class SiteServiceImpl extends AbstractLifecycleBean implements SiteServic
// Throw an exception since we have a duplicate site name
throw new SiteServiceException(MSG_UNABLE_TO_CREATE, new Object[]{shortName});
}
// Check that the site name isn't too long
// Authorities are limited to 100 characters by the PermissionService
int maximumPermisionGroupLength = 100;
if (getSiteGroup(shortName, true).length() > maximumPermisionGroupLength)
{
throw new SiteServiceException(MSG_SITE_SHORT_NAME_TOO_LONG, new Object[] {
shortName, maximumPermisionGroupLength - getSiteGroup("", true).length()
});
}
// Get the site parent node reference
final NodeRef siteParent = getSiteParent(shortName);