summaryrefslogtreecommitdiffstats
path: root/appc-inbound/appc-artifact-handler
diff options
context:
space:
mode:
Diffstat (limited to 'appc-inbound/appc-artifact-handler')
-rw-r--r--appc-inbound/appc-artifact-handler/provider/src/main/java/org/openecomp/appc/artifact/handler/dbservices/DBService.java51
-rw-r--r--appc-inbound/appc-artifact-handler/provider/src/main/java/org/openecomp/appc/artifact/handler/node/ArtifactHandlerNode.java41
-rw-r--r--appc-inbound/appc-artifact-handler/provider/src/test/java/org/openecomp/appc/artifact/handler/dbservices/DBServiceTest.java16
-rw-r--r--appc-inbound/appc-artifact-handler/provider/src/test/java/org/openecomp/appc/artifact/handler/dbservices/MockSvcLogicResource.java1
4 files changed, 80 insertions, 29 deletions
diff --git a/appc-inbound/appc-artifact-handler/provider/src/main/java/org/openecomp/appc/artifact/handler/dbservices/DBService.java b/appc-inbound/appc-artifact-handler/provider/src/main/java/org/openecomp/appc/artifact/handler/dbservices/DBService.java
index 1dcc65e34..41ff4a2f3 100644
--- a/appc-inbound/appc-artifact-handler/provider/src/main/java/org/openecomp/appc/artifact/handler/dbservices/DBService.java
+++ b/appc-inbound/appc-artifact-handler/provider/src/main/java/org/openecomp/appc/artifact/handler/dbservices/DBService.java
@@ -9,15 +9,15 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- *
+ *
* ECOMP is a trademark and service mark of AT&T Intellectual Property.
* ============LICENSE_END=========================================================
*/
@@ -35,6 +35,7 @@ import org.openecomp.appc.artifact.handler.utils.SdcArtifactHandlerConstants;
import java.sql.SQLException;
import java.util.HashMap;
+import org.apache.commons.lang.StringUtils;
public class DBService {
@@ -151,20 +152,21 @@ public class DBService {
String key = "";
QueryStatus status = null;
- if (isUpdate && SdcArtifactHandlerConstants.FILE_CATEGORY.equals(SdcArtifactHandlerConstants.CAPABILITY)) {
+ if (isUpdate && context.getAttribute(SdcArtifactHandlerConstants.FILE_CATEGORY).equals(SdcArtifactHandlerConstants.CAPABILITY)) {
+ log.info("Updating capability artifact in ASDC_REFERENCE");
key = "update " + SdcArtifactHandlerConstants.DB_SDC_REFERENCE + " set ARTIFACT_NAME = $"
- + SdcArtifactHandlerConstants.ARTIFACT_NAME + " where VNFC_TYPE = $"
- + SdcArtifactHandlerConstants.VNFC_TYPE + " and FILE_CATEGORY = $"
- + SdcArtifactHandlerConstants.FILE_CATEGORY + " and ACTION = null";
+ + SdcArtifactHandlerConstants.ARTIFACT_NAME + " where " + "FILE_CATEGORY = $"
+ + SdcArtifactHandlerConstants.FILE_CATEGORY + " and VNF_TYPE = $"
+ + SdcArtifactHandlerConstants.VNF_TYPE ;
} else if (isUpdate)
key = "update " + SdcArtifactHandlerConstants.DB_SDC_REFERENCE + " set ARTIFACT_NAME = $"
+ SdcArtifactHandlerConstants.ARTIFACT_NAME + " where VNFC_TYPE = $"
+ SdcArtifactHandlerConstants.VNFC_TYPE + " and FILE_CATEGORY = $"
+ SdcArtifactHandlerConstants.FILE_CATEGORY + " and ACTION = $"
- + SdcArtifactHandlerConstants.ACTION;
+ + SdcArtifactHandlerConstants.ACTION + " and VNF_TYPE = $" + SdcArtifactHandlerConstants.VNF_TYPE;
else {
- if (SdcArtifactHandlerConstants.FILE_CATEGORY.equals(SdcArtifactHandlerConstants.CAPABILITY)) {
+ if (context.getAttribute(SdcArtifactHandlerConstants.FILE_CATEGORY).equals(SdcArtifactHandlerConstants.CAPABILITY)) {
key = "insert into " + SdcArtifactHandlerConstants.DB_SDC_REFERENCE + " set VNFC_TYPE = null "
+ " , FILE_CATEGORY = $" + SdcArtifactHandlerConstants.FILE_CATEGORY + " , VNF_TYPE = $"
+ SdcArtifactHandlerConstants.VNF_TYPE + " , ACTION = null " + " , ARTIFACT_TYPE = null "
@@ -443,9 +445,9 @@ public class DBService {
status = serviceLogic.save("SQL", false, false, key, null, null, context);
if ((status == null) || status.toString().equals("FAILURE"))
throw new SvcLogicException("Error While processing insertProtocolReference ");
-
+
}
-
+
public boolean isProtocolReferenceUpdateRequired(SvcLogicContext context, String vnfType, String protocol,
String action, String action_level, String template) throws SvcLogicException {
SvcLogicContext localContext = new SvcLogicContext();
@@ -483,4 +485,31 @@ public class DBService {
return;
}
+ public String getDownLoadDGReference(SvcLogicContext context) throws Exception {
+ String fn = "DBService.setDownLoadDGReference";
+ String downloadConfigDg = null;
+ log.info(fn + "Setting Download DG Reference from DB");
+ String key = "";
+ QueryStatus status = null;
+ String protocol = context.getAttribute(SdcArtifactHandlerConstants.DEVICE_PROTOCOL);
+ if (StringUtils.isBlank(protocol)) {
+ log.info(fn + " :: Protocol is Blank!! Returning without querying DB");
+ throw new Exception(fn+":: Protocol is Blank!! Returning without querying DB");
+ }
+ key = "select download_config_dg from " + SdcArtifactHandlerConstants.DB_DOWNLOAD_DG_REFERENCE
+ + " where protocol = '" + protocol + "'";
+ SvcLogicContext localContext = new SvcLogicContext();
+ status = serviceLogic.query("SQL", false, null, key, null, null, localContext);
+ if (status == QueryStatus.FAILURE) {
+ log.info(fn + ":: Error retrieving download_config_dg");
+ throw new SvcLogicException("Error retrieving download_config_dg");
+ }
+ if (status == QueryStatus.NOT_FOUND) {
+ log.info(fn + ":: NOT_FOUND! No data found for download_config_dg!!");
+ throw new Exception(fn + ":: NOT_FOUND! No data found for download_config_dg!");
+ }
+ downloadConfigDg = localContext.getAttribute("download-config-dg");
+ log.info(fn + "download_config_dg::" + downloadConfigDg);
+ return downloadConfigDg;
+ }
}
diff --git a/appc-inbound/appc-artifact-handler/provider/src/main/java/org/openecomp/appc/artifact/handler/node/ArtifactHandlerNode.java b/appc-inbound/appc-artifact-handler/provider/src/main/java/org/openecomp/appc/artifact/handler/node/ArtifactHandlerNode.java
index 5df455a8e..e53247e7e 100644
--- a/appc-inbound/appc-artifact-handler/provider/src/main/java/org/openecomp/appc/artifact/handler/node/ArtifactHandlerNode.java
+++ b/appc-inbound/appc-artifact-handler/provider/src/main/java/org/openecomp/appc/artifact/handler/node/ArtifactHandlerNode.java
@@ -9,15 +9,15 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- *
+ *
* ECOMP is a trademark and service mark of AT&T Intellectual Property.
* ============LICENSE_END=========================================================
*/
@@ -246,6 +246,7 @@ public class ArtifactHandlerNode implements SvcLogicJavaPlugin {
String vnfType = null;
JSONObject contentObject = new JSONObject(contentString);
JSONArray contentArray = contentObject.getJSONArray("reference_data");
+ boolean storeCapabilityArtifact=true;
for (int a = 0; a < contentArray.length(); a++) {
JSONObject content = (JSONObject) contentArray.get(a);
@@ -276,9 +277,12 @@ public class ArtifactHandlerNode implements SvcLogicJavaPlugin {
vmActionList.put(content.getString(SdcArtifactHandlerConstants.ACTION));
}
if (scope.has(SdcArtifactHandlerConstants.VNFC_TYPE)
- && !scope.isNull(SdcArtifactHandlerConstants.VNFC_TYPE))
+ && !scope.isNull(SdcArtifactHandlerConstants.VNFC_TYPE)) {
context.setAttribute(SdcArtifactHandlerConstants.VNFC_TYPE,
scope.getString(SdcArtifactHandlerConstants.VNFC_TYPE));
+ storeCapabilityArtifact=false;
+ log.info("No capability Artifact for this reference data as it is ar VNFC level!!");
+ }
else
context.setAttribute(SdcArtifactHandlerConstants.VNFC_TYPE, null);
if (content.has(SdcArtifactHandlerConstants.DEVICE_PROTOCOL))
@@ -330,7 +334,8 @@ public class ArtifactHandlerNode implements SvcLogicJavaPlugin {
SdcArtifactHandlerConstants.DB_SDC_REFERENCE));
}
}
- if (content.getString(SdcArtifactHandlerConstants.ACTION).equals("Configure")) {
+ if (content.getString(SdcArtifactHandlerConstants.ACTION).equals("Configure")
+ || content.getString(SdcArtifactHandlerConstants.ACTION).equals("ConfigModify")) {
if (content.has(SdcArtifactHandlerConstants.DOWNLOAD_DG_REFERENCE)
&& content.getString(SdcArtifactHandlerConstants.DOWNLOAD_DG_REFERENCE).length() > 0) {
context.setAttribute(SdcArtifactHandlerConstants.DOWNLOAD_DG_REFERENCE,
@@ -338,13 +343,17 @@ public class ArtifactHandlerNode implements SvcLogicJavaPlugin {
dbservice.processDownloadDgReference(context, dbservice.isArtifactUpdateRequired(context,
SdcArtifactHandlerConstants.DB_DOWNLOAD_DG_REFERENCE));
}
-
+ if (StringUtils.isBlank(context.getAttribute(SdcArtifactHandlerConstants.DOWNLOAD_DG_REFERENCE)))
+ context.setAttribute(SdcArtifactHandlerConstants.DOWNLOAD_DG_REFERENCE,
+ dbservice.getDownLoadDGReference(context));
dbservice.processConfigActionDg(context, dbservice.isArtifactUpdateRequired(context,
SdcArtifactHandlerConstants.DB_CONFIG_ACTION_DG));
- dbservice.processDeviceInterfaceProtocol(context, dbservice.isArtifactUpdateRequired(context,
- SdcArtifactHandlerConstants.DB_DEVICE_INTERFACE_PROTOCOL));
- dbservice.processDeviceAuthentication(context, dbservice.isArtifactUpdateRequired(context,
- SdcArtifactHandlerConstants.DB_DEVICE_AUTHENTICATION));
+ if (content.getString(SdcArtifactHandlerConstants.ACTION).equals("Configure")) {
+ dbservice.processDeviceInterfaceProtocol(context, dbservice.isArtifactUpdateRequired(context,
+ SdcArtifactHandlerConstants.DB_DEVICE_INTERFACE_PROTOCOL));
+ dbservice.processDeviceAuthentication(context, dbservice.isArtifactUpdateRequired(context,
+ SdcArtifactHandlerConstants.DB_DEVICE_AUTHENTICATION));
+ }
}
@@ -391,12 +400,14 @@ public class ArtifactHandlerNode implements SvcLogicJavaPlugin {
}
- capabilities.put("vnf", vnfActionList);
- capabilities.put("vf-module", vfModuleActionList);
- capabilities.put("vnfc", vnfcActionList);
- capabilities.put("vm", vmActionList);
- processAndStoreCapablitiesArtifact(dbservice, document_information, capabilities, capabilityArtifactName,
+ if (storeCapabilityArtifact) {
+ capabilities.put("vnf", vnfActionList);
+ capabilities.put("vf-module", vfModuleActionList);
+ capabilities.put("vnfc", vnfcActionList);
+ capabilities.put("vm", vmActionList);
+ processAndStoreCapablitiesArtifact(dbservice, document_information, capabilities, capabilityArtifactName,
vnfType);
+ }
} catch (Exception e) {
e.printStackTrace();
diff --git a/appc-inbound/appc-artifact-handler/provider/src/test/java/org/openecomp/appc/artifact/handler/dbservices/DBServiceTest.java b/appc-inbound/appc-artifact-handler/provider/src/test/java/org/openecomp/appc/artifact/handler/dbservices/DBServiceTest.java
index 043283fb1..5ca6ec3f6 100644
--- a/appc-inbound/appc-artifact-handler/provider/src/test/java/org/openecomp/appc/artifact/handler/dbservices/DBServiceTest.java
+++ b/appc-inbound/appc-artifact-handler/provider/src/test/java/org/openecomp/appc/artifact/handler/dbservices/DBServiceTest.java
@@ -9,15 +9,15 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- *
+ *
* ECOMP is a trademark and service mark of AT&T Intellectual Property.
* ============LICENSE_END=========================================================
*/
@@ -30,6 +30,7 @@ import org.junit.Test;
import org.openecomp.appc.artifact.handler.utils.SdcArtifactHandlerConstants;
import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
import org.powermock.reflect.Whitebox;
+import static org.junit.Assert.assertEquals;
public class DBServiceTest {
@@ -234,6 +235,7 @@ public class DBServiceTest {
MockDBService dbService = MockDBService.initialise();
SvcLogicContext ctx = new SvcLogicContext();
ctx.setAttribute("test", "test");
+ ctx.setAttribute(SdcArtifactHandlerConstants.FILE_CATEGORY, "testCategory");
boolean isUpdate = true;
dbService.processSdcReferences(ctx, isUpdate);
}
@@ -283,5 +285,13 @@ public class DBServiceTest {
String db = "db";
dbService.getArtifactID(ctx, db);
}
+ @Test
+ public void testGetDownLoadDGReference() throws Exception {
+ MockDBService dbService = MockDBService.initialise();
+ SvcLogicContext ctx = new SvcLogicContext();
+ ctx.setAttribute("test", "test");
+ ctx.setAttribute(SdcArtifactHandlerConstants.DEVICE_PROTOCOL, "CLI");
+ assertEquals("TestDG", dbService.getDownLoadDGReference(ctx));
+ }
}
diff --git a/appc-inbound/appc-artifact-handler/provider/src/test/java/org/openecomp/appc/artifact/handler/dbservices/MockSvcLogicResource.java b/appc-inbound/appc-artifact-handler/provider/src/test/java/org/openecomp/appc/artifact/handler/dbservices/MockSvcLogicResource.java
index ae09e459c..1a07117ed 100644
--- a/appc-inbound/appc-artifact-handler/provider/src/test/java/org/openecomp/appc/artifact/handler/dbservices/MockSvcLogicResource.java
+++ b/appc-inbound/appc-artifact-handler/provider/src/test/java/org/openecomp/appc/artifact/handler/dbservices/MockSvcLogicResource.java
@@ -40,6 +40,7 @@ public class MockSvcLogicResource extends SqlResource {
ctx.setAttribute("VNF_TYPE", "testvnf");
ctx.setAttribute("maximum", "1");
ctx.setAttribute("COUNT(*)", "1");
+ ctx.setAttribute("download-config-dg", "TestDG");
return status;
}