diff options
author | Seshu Kumar M <seshu.kumar.m@huawei.com> | 2017-08-10 06:52:09 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2017-08-10 06:52:09 +0000 |
commit | 59a326947cb83a4ac1b7bef7793982b5ed653654 (patch) | |
tree | 3b6563439f5cf2d42f732b5e8841be7e7f0ffd9e /mso-api-handlers | |
parent | 7255957aa5015de4daae554730ed15158c28abe6 (diff) | |
parent | 49f38ff32c2323f5460e18ee300eff015bbd8772 (diff) |
Merge "fixed for defect SO-70 - recipe lookup mechanism doesn't allow to define default recipe mapping for any 'source' at level of 'service' and 'network' resources."
Diffstat (limited to 'mso-api-handlers')
-rw-r--r-- | mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/ServiceInstances.java | 65 |
1 files changed, 39 insertions, 26 deletions
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/ServiceInstances.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/ServiceInstances.java index 317859da0e..988d72cc6f 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/ServiceInstances.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/ServiceInstances.java @@ -654,33 +654,35 @@ public class ServiceInstances { // SERVICE REQUEST // Construct the default service name // TODO need to make this a configurable property - String defaultServiceName = msoRequest.getRequestInfo().getSource() + "_DEFAULT"; + String sourceDefaultServiceName = msoRequest.getRequestInfo().getSource() + "_DEFAULT"; + String defaultService = "*"; Service serviceRecord = null; - if(msoRequest.getALaCarteFlag()){ - serviceRecord = db.getServiceByName(defaultServiceName); - }else{ - serviceRecord = db.getServiceByVersionAndInvariantId(msoRequest.getModelInfo().getModelInvariantId(), msoRequest.getModelInfo().getModelVersion()); - } int serviceId; ServiceRecipe recipe = null; - if(serviceRecord !=null){ - serviceId = serviceRecord.getId(); - recipe = db.getServiceRecipe(serviceId, action.name()); + + //if an aLaCarte flag was Not sent in the request, look first if there is a custom recipe for the specific model version + if(!msoRequest.getALaCarteFlag()){ + serviceRecord = db.getServiceByVersionAndInvariantId(msoRequest.getModelInfo().getModelInvariantId(), msoRequest.getModelInfo().getModelVersion()); + if(serviceRecord !=null){ + serviceId = serviceRecord.getId(); + recipe = db.getServiceRecipe(serviceId, action.name()); + } } - //if an aLaCarte flag was sent in the request, throw an error if the recipe was not found - RequestParameters reqParam = msoRequest.getServiceInstancesRequest().getRequestDetails().getRequestParameters(); - if(reqParam!=null && reqParam.isALaCarteSet() && recipe==null){ - return null; - }else if (recipe == null) { //aLaCarte wasn't sent, so we'll try the default - serviceRecord = db.getServiceByName(defaultServiceName); - serviceId = serviceRecord.getId(); - recipe = db.getServiceRecipe(serviceId, action.name()); + + if (recipe == null) { + //find source(initiator) default recipe + recipe = db.getServiceRecipeByServiceNameAndAction(sourceDefaultServiceName, action.name()); + } + if (recipe == null) { + //find default recipe + recipe = db.getServiceRecipeByServiceNameAndAction(defaultService, action.name()); } if(recipe==null){ return null; } return new RecipeLookupResult (recipe.getOrchestrationUri (), recipe.getRecipeTimeout ()); + } @@ -787,27 +789,38 @@ public class ServiceInstances { private RecipeLookupResult getNetworkUri (CatalogDatabase db, MsoRequest msoRequest, Action action) throws Exception { - String defaultNetworkType = msoRequest.getRequestInfo().getSource() + "_DEFAULT"; + String sourceDefaultNetworkType = msoRequest.getRequestInfo().getSource() + "_DEFAULT"; + String defaultNetworkType = "*"; String modelName = msoRequest.getModelInfo().getModelName(); Recipe recipe = null; - if(msoRequest.getALaCarteFlag()){ - recipe = db.getNetworkRecipe(defaultNetworkType, action.name()); - }else{ + //if an aLaCarte flag was Not sent in the request, look first if there is a custom recipe for the specific ModelCustomizationId + if(!msoRequest.getALaCarteFlag()){ + String networkType = null; + if(msoRequest.getModelInfo().getModelCustomizationId()!=null){ NetworkResource networkResource = db.getNetworkResourceByModelCustUuid(msoRequest.getModelInfo().getModelCustomizationId()); if(networkResource!=null){ - recipe = db.getNetworkRecipe(networkResource.getNetworkType(), action.name()); + networkType = networkResource.getNetworkType(); }else{ throw new ValidationException("no catalog entry found"); } }else{ //ok for version < 3 - recipe = db.getNetworkRecipe(modelName, action.name()); - } - if(recipe == null){ - recipe = db.getNetworkRecipe(defaultNetworkType, action.name()); + networkType = modelName; } + + //find latest version Recipe for the given networkType and action + recipe = db.getNetworkRecipe(networkType, action.name()); + } + + if(recipe == null){ + //find source(initiator) default recipe + recipe = db.getNetworkRecipe(sourceDefaultNetworkType, action.name()); + } + if(recipe == null){ + //find default recipe + recipe = db.getNetworkRecipe(defaultNetworkType, action.name()); } if (recipe == null) { return null; |