From fef8f6d4af95dad57fe5e009133ac5c4338e2be3 Mon Sep 17 00:00:00 2001 From: Likitha Shetty Date: Mon, 27 Aug 2012 15:45:55 -0700 Subject: [PATCH] CS-15703: EC2 tag support, improve error handling. Component: AWSAPI. Handle exceptions thrown when invalid syntax is used to create or delete tags. --- awsapi/src/com/cloud/bridge/service/EC2SoapServiceImpl.java | 4 ++++ .../cloud/bridge/service/exception/EC2ServiceException.java | 1 + 2 files changed, 5 insertions(+) diff --git a/awsapi/src/com/cloud/bridge/service/EC2SoapServiceImpl.java b/awsapi/src/com/cloud/bridge/service/EC2SoapServiceImpl.java index 38f80c815fc..c23a11d6740 100644 --- a/awsapi/src/com/cloud/bridge/service/EC2SoapServiceImpl.java +++ b/awsapi/src/com/cloud/bridge/service/EC2SoapServiceImpl.java @@ -259,6 +259,10 @@ public class EC2SoapServiceImpl implements AmazonEC2SkeletonInterface { List resourceTypeList = new ArrayList(); if (items != null) { for( int i=0; i < items.length; i++ ) { + if (!items[i].getResourceId().contains(":") || items[i].getResourceId().split(":").length != 2) { + throw new EC2ServiceException( ClientError.InvalidResourceId_Format, + "Invalid Format. ResourceId format is resource-type:resource-uuid"); + } String resourceType = items[i].getResourceId().split(":")[0]; if (resourceTypeList.isEmpty()) resourceTypeList.add(resourceType); diff --git a/awsapi/src/com/cloud/bridge/service/exception/EC2ServiceException.java b/awsapi/src/com/cloud/bridge/service/exception/EC2ServiceException.java index f40278d25e2..e1f515ad2c0 100644 --- a/awsapi/src/com/cloud/bridge/service/exception/EC2ServiceException.java +++ b/awsapi/src/com/cloud/bridge/service/exception/EC2ServiceException.java @@ -78,6 +78,7 @@ public class EC2ServiceException extends RuntimeException { InvalidPermission_Malformed("Client.InvalidPermission.Malformed", 400), InvalidReservationID_Malformed("Client.InvalidReservationID.Malformed", 400), InvalidReservationID_NotFound("Client.InvalidReservationID.NotFound", 400), + InvalidResourceId_Format("Client.InvalidResourceId.Format", 400), InvalidSnapshotID_Malformed("Client.InvalidSnapshotID.Malformed", 400), InvalidSnapshot_NotFound("Client.InvalidSnapshot.NotFound", 400), InvalidUserID_Malformed("Client.InvalidUserID.Malformed", 400),