diff --git a/config/alfresco/messages/site-service.properties b/config/alfresco/messages/site-service.properties index 89d1a4f697..9836723b3d 100644 --- a/config/alfresco/messages/site-service.properties +++ b/config/alfresco/messages/site-service.properties @@ -1,6 +1,7 @@ # 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.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.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. diff --git a/source/java/org/alfresco/repo/site/SiteServiceImpl.java b/source/java/org/alfresco/repo/site/SiteServiceImpl.java index c85ef42406..69327127c2 100644 --- a/source/java/org/alfresco/repo/site/SiteServiceImpl.java +++ b/source/java/org/alfresco/repo/site/SiteServiceImpl.java @@ -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);