aboutsummaryrefslogtreecommitdiffstats
path: root/catalog/packages/biz
diff options
context:
space:
mode:
authorhongyuzhao <zhao.hongyu@zte.com.cn>2020-04-08 11:50:53 +0800
committerhongyuzhao <zhao.hongyu@zte.com.cn>2020-04-08 15:28:34 +0800
commit3fcd9e6adf5833688b0007983aab00db312e433e (patch)
tree8276ad08790b71ee3bad427713875b7cbb2bff57 /catalog/packages/biz
parent613fed546242f8d7f50e9322ef58617402c075bc (diff)
fix bug for ETSI Catalog Manager needs to raise 303 exception for the same callback_uri and the same filter
Change-Id: Ie577540d2c4bb25299059869ce967422610f5785 Issue-ID: MODELING-353 Signed-off-by: hongyu zhao <zhao.hongyu@zte.com.cn>
Diffstat (limited to 'catalog/packages/biz')
-rw-r--r--catalog/packages/biz/nsdm_subscription.py11
-rw-r--r--catalog/packages/biz/vnf_pkg_subscription.py20
2 files changed, 16 insertions, 15 deletions
diff --git a/catalog/packages/biz/nsdm_subscription.py b/catalog/packages/biz/nsdm_subscription.py
index d111bc2..84bacde 100644
--- a/catalog/packages/biz/nsdm_subscription.py
+++ b/catalog/packages/biz/nsdm_subscription.py
@@ -26,6 +26,7 @@ from catalog.pub.database.models import NsdmSubscriptionModel
from catalog.pub.exceptions import CatalogException, \
NsdmBadRequestException, NsdmDuplicateSubscriptionException, SubscriptionDoesNotExistsException
from catalog.pub.utils.values import ignore_case_get
+from catalog.pub.config.config import MSB_SERVICE_IP, MSB_SERVICE_PORT
logger = logging.getLogger(__name__)
@@ -185,13 +186,15 @@ class NsdmSubscription:
subscriptions = \
NsdmSubscriptionModel.objects.filter(
callback_uri=self.callback_uri)
- if not subscriptions.exists():
- return
+
for subscription in subscriptions:
if self.check_filter_exists(subscription):
- raise NsdmDuplicateSubscriptionException(
+ links = json.loads(subscription.links)
+ logger.error(
"Subscription has already existed with the "
- "same callbackUri and filter")
+ "same callbackUri and filter:%s" % links)
+ raise NsdmDuplicateSubscriptionException(
+ "https://%s:%s/%s" % (MSB_SERVICE_IP, MSB_SERVICE_PORT, links["self"]["href"]))
def save_db(self):
logger.debug("Create Subscription --> Saving the subscription "
diff --git a/catalog/packages/biz/vnf_pkg_subscription.py b/catalog/packages/biz/vnf_pkg_subscription.py
index a98fe12..d059365 100644
--- a/catalog/packages/biz/vnf_pkg_subscription.py
+++ b/catalog/packages/biz/vnf_pkg_subscription.py
@@ -27,6 +27,7 @@ from catalog.pub.database.models import VnfPkgSubscriptionModel
from catalog.pub.exceptions import VnfPkgSubscriptionException, \
VnfPkgDuplicateSubscriptionException, SubscriptionDoesNotExistsException
from catalog.pub.utils.values import ignore_case_get
+from catalog.pub.config.config import MSB_SERVICE_IP, MSB_SERVICE_PORT
logger = logging.getLogger(__name__)
@@ -44,7 +45,6 @@ def is_filter_type_equal(new_filter, existing_filter):
class CreateSubscription(object):
-
def __init__(self, data):
self.data = data
self.filter = ignore_case_get(self.data, "filter", {})
@@ -104,11 +104,10 @@ class CreateSubscription(object):
def check_valid_auth_info(self):
logger.debug("SubscribeNotification--post::> Validating Auth "
"details if provided")
- if self.authentication.get("paramsBasic", {}) and \
- const.BASIC not in self.authentication.get("authType"):
+ if self.authentication.get("paramsBasic", {}) and const.BASIC not in self.authentication.get("authType"):
raise VnfPkgSubscriptionException('Auth type should be ' + const.BASIC)
- if self.authentication.get("paramsOauth2ClientCredentials", {}) and \
- const.OAUTH2_CLIENT_CREDENTIALS not in self.authentication.get("authType"):
+ if self.authentication.get("paramsOauth2ClientCredentials", {}) \
+ and const.OAUTH2_CLIENT_CREDENTIALS not in self.authentication.get("authType"):
raise VnfPkgSubscriptionException('Auth type should be ' + const.OAUTH2_CLIENT_CREDENTIALS)
def check_filter_exists(self, sub):
@@ -125,16 +124,17 @@ class CreateSubscription(object):
return True
def check_valid(self):
+ links = ""
logger.debug("SubscribeNotification--post::> Checking DB if "
"callbackUri already exists")
subscriptions = VnfPkgSubscriptionModel.objects.filter(callback_uri=self.callback_uri)
- if not subscriptions.exists():
- return True
for subscription in subscriptions:
if self.check_filter_exists(subscription):
+ links = json.loads(subscription.links)
+ logger.error("Subscriptions has already exists with the same callbackUri and filter:%s" % links)
raise VnfPkgDuplicateSubscriptionException(
- "Already Subscription (%s) exists with the "
- "same callbackUri and filter" % subscription.subscription_id)
+ "https://%s:%s/%s" % (MSB_SERVICE_IP, MSB_SERVICE_PORT, links["self"]["href"]))
+
return True
def save_db(self):
@@ -160,7 +160,6 @@ class CreateSubscription(object):
class QuerySubscription(object):
-
def query_multi_subscriptions(self, params):
query_data = {}
logger.debug("QuerySubscription--get--multi--subscriptions--biz::> Check "
@@ -190,7 +189,6 @@ class QuerySubscription(object):
class TerminateSubscription(object):
-
def terminate(self, subscription_id):
logger.debug("TerminateSubscriptions--delete--biz::> "
"ID: %s" % subscription_id)