volume upload: fixed the error message incase of wrong image format
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/4f35d361 Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/4f35d361 Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/4f35d361 Branch: refs/heads/master Commit: 4f35d3611a60c64a252f7ce2e233f228101774d0 Parents: d5bb2f1 Author: Rajani Karuturi <rajanikarut...@gmail.com> Authored: Thu Apr 16 17:34:29 2015 +0530 Committer: Rajani Karuturi <rajanikarut...@gmail.com> Committed: Thu Apr 16 17:43:46 2015 +0530 ---------------------------------------------------------------------- server/src/com/cloud/storage/VolumeApiServiceImpl.java | 8 +++++--- server/src/com/cloud/template/TemplateAdapterBase.java | 9 ++++++--- 2 files changed, 11 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4f35d361/server/src/com/cloud/storage/VolumeApiServiceImpl.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/storage/VolumeApiServiceImpl.java b/server/src/com/cloud/storage/VolumeApiServiceImpl.java index 533f6fa..2022dde 100644 --- a/server/src/com/cloud/storage/VolumeApiServiceImpl.java +++ b/server/src/com/cloud/storage/VolumeApiServiceImpl.java @@ -385,9 +385,11 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic _resourceLimitMgr.checkResourceLimit(_accountMgr.getAccount(ownerId), ResourceType.secondary_storage); } - ImageFormat imgfmt = ImageFormat.valueOf(format.toUpperCase()); - if (imgfmt == null) { - throw new IllegalArgumentException("Image format is incorrect " + format + ". Supported formats are " + EnumUtils.listValues(ImageFormat.values())); + try { + ImageFormat.valueOf(format.toUpperCase()); + } catch (IllegalArgumentException e) { + s_logger.debug("ImageFormat IllegalArgumentException: " + e.getMessage()); + throw new IllegalArgumentException("Image format: " + format + " is incorrect. Supported formats are " + EnumUtils.listValues(ImageFormat.values())); } // Check that the the disk offering specified is valid http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4f35d361/server/src/com/cloud/template/TemplateAdapterBase.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/template/TemplateAdapterBase.java b/server/src/com/cloud/template/TemplateAdapterBase.java index 8bb93dd..c5d0c5b 100755 --- a/server/src/com/cloud/template/TemplateAdapterBase.java +++ b/server/src/com/cloud/template/TemplateAdapterBase.java @@ -198,9 +198,12 @@ public abstract class TemplateAdapterBase extends AdapterBase implements Templat featured = Boolean.FALSE; } - ImageFormat imgfmt = ImageFormat.valueOf(format.toUpperCase()); - if (imgfmt == null) { - throw new IllegalArgumentException("Image format is incorrect " + format + ". Supported formats are " + EnumUtils.listValues(ImageFormat.values())); + ImageFormat imgfmt; + try { + imgfmt = ImageFormat.valueOf(format.toUpperCase()); + } catch (IllegalArgumentException e) { + s_logger.debug("ImageFormat IllegalArgumentException: " + e.getMessage()); + throw new IllegalArgumentException("Image format: " + format + " is incorrect. Supported formats are " + EnumUtils.listValues(ImageFormat.values())); } // Check that the resource limit for templates/ISOs won't be exceeded