diff --git a/server/src/com/cloud/template/TemplateManagerImpl.java b/server/src/com/cloud/template/TemplateManagerImpl.java index a1fb6f0dae7..2c35646ead5 100755 --- a/server/src/com/cloud/template/TemplateManagerImpl.java +++ b/server/src/com/cloud/template/TemplateManagerImpl.java @@ -317,10 +317,6 @@ public class TemplateManagerImpl implements TemplateManager { { throw new InvalidParameterValueException("Template name should be less than 32 characters"); } - - if (!name.matches("^[\\p{Alnum} ._-]+")) { - throw new InvalidParameterValueException("Only alphanumeric, dot, dashes and underscore characters allowed for the parameter 'name'"); - } ImageFormat imgfmt = ImageFormat.valueOf(format.toUpperCase()); if (imgfmt == null) { @@ -1241,7 +1237,7 @@ public class TemplateManagerImpl implements TemplateManager { // FIXME: if template/ISO owner is null we probably need to throw some kind of exception if (template != null) { - Account templateOwner = _accountDao.findById(template.getId()); + Account templateOwner = _accountDao.findById(template.getAccountId()); if ((templateOwner != null) && !_domainDao.isChildDomain(account.getDomainId(), templateOwner.getDomainId())) { throw new PermissionDeniedException(msg + ". Permission denied."); } diff --git a/server/src/com/cloud/vm/UserVmManagerImpl.java b/server/src/com/cloud/vm/UserVmManagerImpl.java index b6ba08dcb4b..fda232e6d13 100755 --- a/server/src/com/cloud/vm/UserVmManagerImpl.java +++ b/server/src/com/cloud/vm/UserVmManagerImpl.java @@ -2532,10 +2532,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, VirtualM if ((name == null) || (name.length() > 32)) { throw new InvalidParameterValueException("Template name cannot be null and should be less than 32 characters"); } - - if (!name.matches("^[\\p{Alnum} ._-]+")) { - throw new InvalidParameterValueException("Only alphanumeric, space, dot, dashes and underscore characters allowed"); - } + String uniqueName = Long.valueOf((userId == null)?1:userId).toString() + Long.valueOf(volumeId).toString() + UUID.nameUUIDFromBytes(name.getBytes()).toString(); VMTemplateVO existingTemplate = _templateDao.findByTemplateNameAccountId(name, volume.getAccountId());