X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=appc-config%2Fappc-data-services%2Fprovider%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Fappc%2Fdata%2Fservices%2Fnode%2FConfigResourceNode.java;fp=appc-config%2Fappc-data-services%2Fprovider%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Fappc%2Fdata%2Fservices%2Fnode%2FConfigResourceNode.java;h=856648210d87d5e8a7b79b7a830dba38da89c55b;hb=84919d3230ad04b6a78f52e37449ba5d34c9a033;hp=c0580b43beb830b08db6c834fb427aefe0471d13;hpb=91057d811d2c43013d789ad85dd3ac175c0e98dd;p=appc.git diff --git a/appc-config/appc-data-services/provider/src/main/java/org/onap/appc/data/services/node/ConfigResourceNode.java b/appc-config/appc-data-services/provider/src/main/java/org/onap/appc/data/services/node/ConfigResourceNode.java index c0580b43b..856648210 100644 --- a/appc-config/appc-data-services/provider/src/main/java/org/onap/appc/data/services/node/ConfigResourceNode.java +++ b/appc-config/appc-data-services/provider/src/main/java/org/onap/appc/data/services/node/ConfigResourceNode.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP : APPC * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Copyright (C) 2017 Amdocs * ============================================================================= @@ -190,6 +190,7 @@ public class ConfigResourceNode implements SvcLogicJavaPlugin { String responsePrefix = inParams.get(AppcDataServiceConstant.INPUT_PARAM_RESPONSE_PREFIX); String fileCategory = inParams.get(AppcDataServiceConstant.INPUT_PARAM_FILE_CATEGORY); String templateName = ctx.getAttribute("template-name"); + String templateModelId = ctx.getAttribute("template-model-id"); QueryStatus status; String responsePrefix1 = ""; @@ -200,22 +201,51 @@ public class ConfigResourceNode implements SvcLogicJavaPlugin { log.info("RESPONSEPREFIX1 : " + responsePrefix1); if (StringUtils.isBlank(templateName)) { + if (StringUtils.isNotBlank(templateModelId)) { + status = db.getTemplateWithTemplateModelId(ctx, responsePrefix, fileCategory,templateModelId); + if (status == QueryStatus.FAILURE) { + throw new QueryException(UNABLE_TO_READ_STR + fileCategory); + } + if (!(status == QueryStatus.NOT_FOUND) ) { + ctx.setAttribute(responsePrefix1 + AppcDataServiceConstant.OUTPUT_PARAM_STATUS, + AppcDataServiceConstant.OUTPUT_STATUS_SUCCESS); + log.info("GetTemplate Successful "); + return; + } + } status = db.getTemplate(ctx, responsePrefix, fileCategory); if (status == QueryStatus.FAILURE) { throw new QueryException(UNABLE_TO_READ_STR + fileCategory); } if (status == QueryStatus.NOT_FOUND) { + if (StringUtils.isNotBlank(templateModelId)) { + status = db.getTemplateByVnfTypeNActionWithTemplateModelId(ctx, responsePrefix, fileCategory,templateModelId); + if (status == QueryStatus.FAILURE) { + throw new QueryException(UNABLE_TO_READ_STR + fileCategory); + } + if (!(status == QueryStatus.NOT_FOUND) ) { + ctx.setAttribute(responsePrefix1 + AppcDataServiceConstant.OUTPUT_PARAM_STATUS, + AppcDataServiceConstant.OUTPUT_STATUS_SUCCESS); + log.info("GetTemplate Successful "); + return; + } + } + if (status == QueryStatus.NOT_FOUND) { - status = db.getTemplateByVnfTypeNAction(ctx, responsePrefix, fileCategory); - if (status == QueryStatus.FAILURE) { - throw new QueryException(UNABLE_TO_READ_STR + fileCategory); - } + status = db.getTemplateByVnfTypeNAction(ctx, responsePrefix, fileCategory); - if (status == QueryStatus.NOT_FOUND) { - throw new QueryException(UNABLE_TO_READ_STR + fileCategory); + if (status == QueryStatus.FAILURE) { + throw new QueryException(UNABLE_TO_READ_STR + fileCategory); + } + + if (status == QueryStatus.NOT_FOUND) { + throw new QueryException(UNABLE_TO_READ_STR + fileCategory); + } } + + } } else { @@ -629,20 +659,33 @@ public class ConfigResourceNode implements SvcLogicJavaPlugin { log.info("Received getVnfcReference call with params : " + inParams); String responsePrefix = inParams.get(AppcDataServiceConstant.INPUT_PARAM_RESPONSE_PREFIX); - QueryStatus status; + String templateModelId = ctx.getAttribute("template-model-id"); + log.info("getVnfcReference():::"+templateModelId); + QueryStatus status = null; try { if (!StringUtils.isBlank(ctx.getAttribute("vnfc-type"))) { + + status = db.getVnfcReferenceByVnfcTypeNAction(ctx, responsePrefix); if (status == QueryStatus.FAILURE) { throw new QueryException("Unable to Read vnfc-reference"); } + } - status = db.getVnfcReferenceByVnfTypeNAction(ctx, responsePrefix); + if (StringUtils.isNotBlank(templateModelId)) { + status = db.getVnfcReferenceByVnfTypeNActionWithTemplateModelId(ctx, responsePrefix,templateModelId); + if (status == QueryStatus.FAILURE) { + throw new QueryException("Unable to Read vnfc-reference with template-model-id"); + } + } + if (StringUtils.isBlank(templateModelId) || (StringUtils.isNotBlank(templateModelId) && (status == QueryStatus.NOT_FOUND))) { + status = db.getVnfcReferenceByVnfTypeNAction(ctx, responsePrefix); - if (status == QueryStatus.NOT_FOUND || status == QueryStatus.FAILURE) { - throw new QueryException("Unable to Read vnfc reference"); + if (status == QueryStatus.NOT_FOUND || status == QueryStatus.FAILURE) { + throw new QueryException("Unable to Read vnfc reference"); + } } responsePrefix = StringUtils.isNotBlank(responsePrefix) ? (responsePrefix + ".") : ""; @@ -794,4 +837,5 @@ public class ConfigResourceNode implements SvcLogicJavaPlugin { } return capabilityCheckNeeded; } -} \ No newline at end of file + +}