From ea84f3bde2ed835b615f0dbbc56619943da0af36 Mon Sep 17 00:00:00 2001 From: Kris McQueen Date: Thu, 7 Oct 2010 14:52:06 -0700 Subject: [PATCH] registerTemplate and registerIso expect the template to be returned, not the template id...fixed --- server/src/com/cloud/template/TemplateManager.java | 6 +++--- .../com/cloud/template/TemplateManagerImpl.java | 14 +++++++------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/server/src/com/cloud/template/TemplateManager.java b/server/src/com/cloud/template/TemplateManager.java index 9242f9f3eb9..d02944c7647 100755 --- a/server/src/com/cloud/template/TemplateManager.java +++ b/server/src/com/cloud/template/TemplateManager.java @@ -71,11 +71,11 @@ public interface TemplateManager extends Manager { * @param enablePassword Does the template support password change. * @param guestOSId OS that is on the template * @param bootable true if this template will represent a bootable ISO - * @return id of the template created. + * @return the template created. */ // Long create(long userId, Long zoneId, String name, String displayText, boolean isPublic, boolean featured, ImageFormat format, FileSystem fs, URI url, String chksum, boolean requiresHvm, int bits, boolean enablePassword, long guestOSId, boolean bootable); - Long registerTemplate(RegisterTemplateCmd cmd) throws InvalidParameterValueException, URISyntaxException, ResourceAllocationException; - Long registerIso(RegisterIsoCmd cmd) throws InvalidParameterValueException, IllegalArgumentException, ResourceAllocationException; + VMTemplateVO registerTemplate(RegisterTemplateCmd cmd) throws InvalidParameterValueException, URISyntaxException, ResourceAllocationException; + VMTemplateVO registerIso(RegisterIsoCmd cmd) throws InvalidParameterValueException, IllegalArgumentException, ResourceAllocationException; /** * Creates a Template * diff --git a/server/src/com/cloud/template/TemplateManagerImpl.java b/server/src/com/cloud/template/TemplateManagerImpl.java index 6edbfc0fd48..0b1fe510651 100755 --- a/server/src/com/cloud/template/TemplateManagerImpl.java +++ b/server/src/com/cloud/template/TemplateManagerImpl.java @@ -151,7 +151,7 @@ public class TemplateManagerImpl implements TemplateManager { protected SearchBuilder HostTemplateStatesSearch; @Override - public Long registerIso(RegisterIsoCmd cmd) throws InvalidParameterValueException, IllegalArgumentException, ResourceAllocationException{ + public VMTemplateVO registerIso(RegisterIsoCmd cmd) throws InvalidParameterValueException, IllegalArgumentException, ResourceAllocationException{ Account account = (Account)UserContext.current().getAccountObject(); Long userId = UserContext.current().getUserId(); String name = cmd.getName(); @@ -221,7 +221,7 @@ public class TemplateManagerImpl implements TemplateManager { } @Override - public Long registerTemplate(RegisterTemplateCmd cmd) throws InvalidParameterValueException, URISyntaxException, ResourceAllocationException{ + public VMTemplateVO registerTemplate(RegisterTemplateCmd cmd) throws InvalidParameterValueException, URISyntaxException, ResourceAllocationException{ Account account = (Account)UserContext.current().getAccountObject(); Long userId = UserContext.current().getUserId(); @@ -302,7 +302,7 @@ public class TemplateManagerImpl implements TemplateManager { } - private Long createTemplateOrIso(long userId, Long zoneId, String name, String displayText, boolean isPublic, boolean featured, String format, String diskType, String url, String chksum, boolean requiresHvm, int bits, boolean enablePassword, long guestOSId, boolean bootable) throws InvalidParameterValueException,IllegalArgumentException, ResourceAllocationException { + private VMTemplateVO createTemplateOrIso(long userId, Long zoneId, String name, String displayText, boolean isPublic, boolean featured, String format, String diskType, String url, String chksum, boolean requiresHvm, int bits, boolean enablePassword, long guestOSId, boolean bootable) throws InvalidParameterValueException,IllegalArgumentException, ResourceAllocationException { try { if (name.length() > 32) @@ -374,7 +374,7 @@ public class TemplateManagerImpl implements TemplateManager { } } - private Long create(long userId, Long zoneId, String name, String displayText, boolean isPublic, boolean featured, ImageFormat format, FileSystem fs, URI url, String chksum, boolean requiresHvm, int bits, boolean enablePassword, long guestOSId, boolean bootable) { + private VMTemplateVO create(long userId, Long zoneId, String name, String displayText, boolean isPublic, boolean featured, ImageFormat format, FileSystem fs, URI url, String chksum, boolean requiresHvm, int bits, boolean enablePassword, long guestOSId, boolean bootable) { Long id = _tmpltDao.getNextInSequence(Long.class, "id"); UserVO user = _userDao.findById(userId); @@ -403,7 +403,7 @@ public class TemplateManagerImpl implements TemplateManager { _accountMgr.incrementResourceCount(userAccount.getAccountId(), ResourceType.template); - return id; + return template; } @Override @@ -811,8 +811,8 @@ public class TemplateManagerImpl implements TemplateManager { return copiedTemplate; } - - @Override + + @Override @DB public boolean delete(long userId, long templateId, Long zoneId) throws InternalErrorException { boolean success = true; VMTemplateVO template = _tmpltDao.findById(templateId);