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

@@ -1,6 +1,7 @@
# Site service externalised display strings # Site service externalised display strings
site_service.unable_to_create=Unable to create site because the site short name {0} is already in use. Site short names must be unique. site_service.unable_to_create=Unable to create site because the site short name {0} is already in use. Site short names must be unique.
site_service.short_name_too_long=Unable to create site because the site short name {0} is too long. Site short names can be no longer than {1} characters.
site_service.visibility_group_missing=Unable to create site because the visibility group {0} does not exist. site_service.visibility_group_missing=Unable to create site because the visibility group {0} does not exist.
site_service.can_not_update=Cannot update site {0} because it does not exist. site_service.can_not_update=Cannot update site {0} because it does not exist.
site_service.can_not_delete=Cannot delete site {0} because it does not exist. site_service.can_not_delete=Cannot delete site {0} because it does not exist.

View File

@@ -132,6 +132,7 @@ public class SiteServiceImpl extends AbstractLifecycleBean implements SiteServic
/** Messages */ /** Messages */
private static final String MSG_UNABLE_TO_CREATE = "site_service.unable_to_create"; 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_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_UPDATE = "site_service.can_not_update";
private static final String MSG_CAN_NOT_DELETE = "site_service.can_not_delete"; 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 an exception since we have a duplicate site name
throw new SiteServiceException(MSG_UNABLE_TO_CREATE, new Object[]{shortName}); 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 // Get the site parent node reference
final NodeRef siteParent = getSiteParent(shortName); final NodeRef siteParent = getSiteParent(shortName);