summaryrefslogtreecommitdiffstats
path: root/aai-traversal
diff options
context:
space:
mode:
authorVenkata Harish K Kajur <vk250x@att.com>2017-06-16 17:04:44 -0400
committerVenkata Harish K Kajur <vk250x@att.com>2017-06-16 17:19:03 -0400
commitc87550c395bcb26bc9e6b4716cd2a25ae97694eb (patch)
treee2ae64762dc4973a860aab9d8257f5f8ef2753b4 /aai-traversal
parent4d0bc004f38567750fb31f407fc495c0dee28b29 (diff)
[AAI-ONAP] Add missing named queries fix model del
Add the missing thunderbolt named queries Fix model-based delete functionality Change-Id: Ib49f7a50cefff3a402eed1bfbfc716052ba91538 Signed-off-by: Venkata Harish K Kajur <vk250x@att.com>
Diffstat (limited to 'aai-traversal')
-rw-r--r--aai-traversal/bundleconfig-local/etc/appprops/error.properties2
-rw-r--r--aai-traversal/bundleconfig-local/etc/scriptdata/named-query-json/closed-loop-named-query-1.0.json24
-rw-r--r--aai-traversal/bundleconfig-local/etc/scriptdata/named-query-json/getServiceInstanceModel-1.0.json51
-rw-r--r--aai-traversal/bundleconfig-local/etc/scriptdata/named-query-json/getVserver-1.0.json65
-rw-r--r--aai-traversal/src/main/config/ajsc-jetty.xml9
-rw-r--r--aai-traversal/src/main/java/org/openecomp/aai/dbgraphgen/ModelBasedProcessing.java6
-rw-r--r--aai-traversal/src/main/java/org/openecomp/aai/dbgraphmap/SearchGraph.java34
-rw-r--r--aai-traversal/src/main/scripts/deleteTool.sh132
8 files changed, 253 insertions, 70 deletions
diff --git a/aai-traversal/bundleconfig-local/etc/appprops/error.properties b/aai-traversal/bundleconfig-local/etc/appprops/error.properties
index 20827e6..0599bf2 100644
--- a/aai-traversal/bundleconfig-local/etc/appprops/error.properties
+++ b/aai-traversal/bundleconfig-local/etc/appprops/error.properties
@@ -28,6 +28,8 @@ AAI_3007=5:6:INFO:3007:410:3007:This version (%1) of the API is retired, please
AAI_3008=5:6:ERROR:3008:400:3008:URI is not encoded in UTF-8
AAI_3009=5:6:ERROR:3009:400:3002:Malformed URL
AAI_3010=5:6:ERROR:3010:400:3002:Cannot write via this URL
+AAI_3011=5:6:ERROR:3011:400:3000:Unknown XML namespace used in payload
+AAI_3012=5:6:ERROR:3012:400:3012:Unrecognized A&AI function
# pol errors
AAI_3100=5:1:WARN:3100:400:3100:Unsupported operation %1
AAI_3101=5:1:WARN:3101:403:3101:Attempt by client %1 to execute API %2
diff --git a/aai-traversal/bundleconfig-local/etc/scriptdata/named-query-json/closed-loop-named-query-1.0.json b/aai-traversal/bundleconfig-local/etc/scriptdata/named-query-json/closed-loop-named-query-1.0.json
index c9b463e..2ff66f8 100644
--- a/aai-traversal/bundleconfig-local/etc/scriptdata/named-query-json/closed-loop-named-query-1.0.json
+++ b/aai-traversal/bundleconfig-local/etc/scriptdata/named-query-json/closed-loop-named-query-1.0.json
@@ -13,8 +13,8 @@
"relationship" : [ {
"related-to" : "model",
"relationship-data" : [ {
- "relationship-key" : "model.model-name-version-id",
- "relationship-value" : "2a160989-b202-47dd-874b-4a0f275998f7"
+ "relationship-key" : "model.model-invariant-id",
+ "relationship-value" : "425b2158-e51d-4509-9945-dad4556474a3"
} ]
} ]
}
@@ -24,8 +24,8 @@
"relationship" : [ {
"related-to" : "model",
"relationship-data" : [ {
- "relationship-key" : "model.model-name-version-id",
- "relationship-value" : "abcc54bc-bb74-49dc-9043-7f7171707545"
+ "relationship-key" : "model.model-invariant-id",
+ "relationship-value" : "97c26c99-6870-44c1-8a07-1d900d3f4ce6"
} ]
} ]
}
@@ -36,8 +36,8 @@
"relationship" : [ {
"related-to" : "model",
"relationship-data" : [ {
- "relationship-key" : "model.model-name-version-id",
- "relationship-value" : "c00563ae-812b-4e62-8330-7c4d0f47088a"
+ "relationship-key" : "model.model-invariant-id",
+ "relationship-value" : "ef86f9c5-2165-44f3-8fc3-96018b609ea5"
} ]
} ]
}
@@ -46,8 +46,8 @@
"relationship" : [ {
"related-to" : "model",
"relationship-data" : [ {
- "relationship-key" : "model.model-name-version-id",
- "relationship-value" : "46b92144-923a-4d20-b85a-3cbd847668a9"
+ "relationship-key" : "model.model-invariant-id",
+ "relationship-value" : "82194af1-3c2c-485a-8f44-420e22a9eaa4"
} ]
} ]
}
@@ -57,8 +57,8 @@
"relationship" : [ {
"related-to" : "model",
"relationship-data" : [ {
- "relationship-key" : "model.model-name-version-id",
- "relationship-value" : "93a6166f-b3d5-4f06-b4ba-aed48d009ad9"
+ "relationship-key" : "model.model-invariant-id",
+ "relationship-value" : "acc6edd8-a8d4-4b93-afaa-0994068be14c"
} ]
} ]
}
@@ -68,8 +68,8 @@
"relationship" : [ {
"related-to" : "model",
"relationship-data" : [ {
- "relationship-key" : "model.model-name-version-id",
- "relationship-value" : "8ecb2c5d-7176-4317-a255-26274edfdd53"
+ "relationship-key" : "model.model-invariant-id",
+ "relationship-value" : "ff69d4e0-a8e8-4108-bdb0-dd63217e63c7"
} ]
} ]
}
diff --git a/aai-traversal/bundleconfig-local/etc/scriptdata/named-query-json/getServiceInstanceModel-1.0.json b/aai-traversal/bundleconfig-local/etc/scriptdata/named-query-json/getServiceInstanceModel-1.0.json
index aaee8d9..035dc8c 100644
--- a/aai-traversal/bundleconfig-local/etc/scriptdata/named-query-json/getServiceInstanceModel-1.0.json
+++ b/aai-traversal/bundleconfig-local/etc/scriptdata/named-query-json/getServiceInstanceModel-1.0.json
@@ -12,18 +12,25 @@
"related-lookups" : {
"related-lookup" : [ {
"source-node-type" : "vf-module",
- "source-node-property" : "persona-model-id",
+ "source-node-property" : "model-invariant-id-local",
"target-node-type" : "model",
- "target-node-property" : "model-id",
- "property-collect-list" : [ "model-name-version-id", "model-type", "model-name", "model-id", "model-version" ]
+ "target-node-property" : "model-invariant-id",
+ "property-collect-list" : [ "model-invariant-id", "model-type" ]
+ },
+ {
+ "source-node-type" : "vf-module",
+ "source-node-property" : "model-version-id-local",
+ "target-node-type" : "model-ver",
+ "target-node-property" : "model-version-id",
+ "property-collect-list" : [ "model-name", "model-version-id", "model-version" ]
} ]
},
"relationship-list" : {
"relationship" : [ {
"related-to" : "model",
"relationship-data" : [ {
- "relationship-key" : "model.model-name-version-id",
- "relationship-value" : "c00563ae-812b-4e62-8330-7c4d0f47088a"
+ "relationship-key" : "model.model-invariant-id",
+ "relationship-value" : "ef86f9c5-2165-44f3-8fc3-96018b609ea5"
} ]
} ]
}
@@ -32,18 +39,25 @@
"related-lookups" : {
"related-lookup" : [ {
"source-node-type" : "generic-vnf",
- "source-node-property" : "persona-model-id",
+ "source-node-property" : "model-invariant-id-local",
"target-node-type" : "model",
- "target-node-property" : "model-id",
- "property-collect-list" : [ "model-name-version-id", "model-type", "model-name", "model-id", "model-version" ]
+ "target-node-property" : "model-invariant-id",
+ "property-collect-list" : [ "model-invariant-id", "model-type" ]
+ },
+ {
+ "source-node-type" : "generic-vnf",
+ "source-node-property" : "model-version-id-local",
+ "target-node-type" : "model-ver",
+ "target-node-property" : "model-version-id",
+ "property-collect-list" : [ "model-name", "model-version-id", "model-version" ]
} ]
},
"relationship-list" : {
"relationship" : [ {
"related-to" : "model",
"relationship-data" : [ {
- "relationship-key" : "model.model-name-version-id",
- "relationship-value" : "93a6166f-b3d5-4f06-b4ba-aed48d009ad9"
+ "relationship-key" : "model.model-invariant-id",
+ "relationship-value" : "acc6edd8-a8d4-4b93-afaa-0994068be14c"
} ]
} ]
}
@@ -52,18 +66,25 @@
"related-lookups" : {
"related-lookup" : [ {
"source-node-type" : "service-instance",
- "source-node-property" : "persona-model-id",
+ "source-node-property" : "model-invariant-id-local",
+ "target-node-type" : "model",
+ "target-node-property" : "model-invariant-id",
+ "property-collect-list" : [ "model-invariant-id", "model-type" ]
+ },
+ {
+ "source-node-type" : "service-instance",
+ "source-node-property" : "model-invariant-id-local",
"target-node-type" : "model",
- "target-node-property" : "model-id",
- "property-collect-list" : [ "model-name-version-id", "model-type", "model-name", "model-id", "model-version" ]
+ "target-node-property" : "model-invariant-id",
+ "property-collect-list" : [ "model-name", "model-version-id", "model-version" ]
} ]
},
"relationship-list" : {
"relationship" : [ {
"related-to" : "model",
"relationship-data" : [ {
- "relationship-key" : "model.model-name-version-id",
- "relationship-value" : "46b92144-923a-4d20-b85a-3cbd847668a9"
+ "relationship-key" : "model.model-invariant-id",
+ "relationship-value" : "82194af1-3c2c-485a-8f44-420e22a9eaa4"
} ]
} ]
}
diff --git a/aai-traversal/bundleconfig-local/etc/scriptdata/named-query-json/getVserver-1.0.json b/aai-traversal/bundleconfig-local/etc/scriptdata/named-query-json/getVserver-1.0.json
index 624a4ec..2107523 100644
--- a/aai-traversal/bundleconfig-local/etc/scriptdata/named-query-json/getVserver-1.0.json
+++ b/aai-traversal/bundleconfig-local/etc/scriptdata/named-query-json/getVserver-1.0.json
@@ -13,8 +13,8 @@
"relationship" : [ {
"related-to" : "model",
"relationship-data" : [ {
- "relationship-key" : "model.model-name-version-id",
- "relationship-value" : "2a160989-b202-47dd-874b-4a0f275998f7"
+ "relationship-key" : "model.model-invariant-id",
+ "relationship-value" : "425b2158-e51d-4509-9945-dad4556474a3"
} ]
} ]
}
@@ -24,8 +24,8 @@
"relationship" : [ {
"related-to" : "model",
"relationship-data" : [ {
- "relationship-key" : "model.model-name-version-id",
- "relationship-value" : "abcc54bc-bb74-49dc-9043-7f7171707545"
+ "relationship-key" : "model.model-invariant-id",
+ "relationship-value" : "97c26c99-6870-44c1-8a07-1d900d3f4ce6"
} ]
} ]
}
@@ -35,18 +35,25 @@
"related-lookups" : {
"related-lookup" : [ {
"source-node-type" : "vf-module",
- "source-node-property" : "persona-model-id",
+ "source-node-property" : "model-invariant-id-local",
"target-node-type" : "model",
- "target-node-property" : "model-id",
- "property-collect-list" : [ "model-name-version-id", "model-type", "model-name", "model-id", "model-version" ]
+ "target-node-property" : "model-invariant-id",
+ "property-collect-list" : [ "model-invariant-id", "model-type" ]
+ },
+ {
+ "source-node-type" : "vf-module",
+ "source-node-property" : "model-version-id-local",
+ "target-node-type" : "model-ver",
+ "target-node-property" : "model-version-id",
+ "property-collect-list" : ["model-name", "model-version-id", "model-version" ]
} ]
},
"relationship-list" : {
"relationship" : [ {
"related-to" : "model",
"relationship-data" : [ {
- "relationship-key" : "model.model-name-version-id",
- "relationship-value" : "c00563ae-812b-4e62-8330-7c4d0f47088a"
+ "relationship-key" : "model.model-invariant-id",
+ "relationship-value" : "ef86f9c5-2165-44f3-8fc3-96018b609ea5"
} ]
} ]
}
@@ -54,18 +61,25 @@
"related-lookups" : {
"related-lookup" : [ {
"source-node-type" : "service-instance",
- "source-node-property" : "persona-model-id",
+ "source-node-property" : "model-invariant-id-local",
"target-node-type" : "model",
- "target-node-property" : "model-id",
- "property-collect-list" : [ "model-name-version-id", "model-type", "model-name", "model-id", "model-version" ]
- } ]
+ "target-node-property" : "model-invariant-id",
+ "property-collect-list" : [ "model-invariant-id", "model-type" ]
+ },
+ {
+ "source-node-type" : "service-instance",
+ "source-node-property" : "model-version-id-local",
+ "target-node-type" : "model-ver",
+ "target-node-property" : "model-version-id",
+ "property-collect-list" : [ "model-name", "model-version-id", "model-version" ]
+ }]
},
"relationship-list" : {
"relationship" : [ {
"related-to" : "model",
"relationship-data" : [ {
- "relationship-key" : "model.model-name-version-id",
- "relationship-value" : "46b92144-923a-4d20-b85a-3cbd847668a9"
+ "relationship-key" : "model.model-invariant-id",
+ "relationship-value" : "82194af1-3c2c-485a-8f44-420e22a9eaa4"
} ]
} ]
}
@@ -74,18 +88,25 @@
"related-lookups" : {
"related-lookup" : [ {
"source-node-type" : "generic-vnf",
- "source-node-property" : "persona-model-id",
+ "source-node-property" : "model-invariant-id-local",
"target-node-type" : "model",
- "target-node-property" : "model-id",
- "property-collect-list" : [ "model-name-version-id", "model-type", "model-name", "model-id", "model-version" ]
+ "target-node-property" : "model-invariant-id",
+ "property-collect-list" : [ "model-invariant-id", "model-type" ]
+ },
+ {
+ "source-node-type" : "generic-vnf",
+ "source-node-property" : "model-version-id-local",
+ "target-node-type" : "model-ver",
+ "target-node-property" : "model-version-id",
+ "property-collect-list" : [ "model-name", "model-version-id", "model-version" ]
} ]
},
"relationship-list" : {
"relationship" : [ {
"related-to" : "model",
"relationship-data" : [ {
- "relationship-key" : "model.model-name-version-id",
- "relationship-value" : "93a6166f-b3d5-4f06-b4ba-aed48d009ad9"
+ "relationship-key" : "model.model-invariant-id",
+ "relationship-value" : "acc6edd8-a8d4-4b93-afaa-0994068be14c"
} ]
} ]
}
@@ -95,8 +116,8 @@
"relationship" : [ {
"related-to" : "model",
"relationship-data" : [ {
- "relationship-key" : "model.model-name-version-id",
- "relationship-value" : "8ecb2c5d-7176-4317-a255-26274edfdd53"
+ "relationship-key" : "model.model-invariant-id",
+ "relationship-value" : "ff69d4e0-a8e8-4108-bdb0-dd63217e63c7"
} ]
} ]
}
diff --git a/aai-traversal/src/main/config/ajsc-jetty.xml b/aai-traversal/src/main/config/ajsc-jetty.xml
index d7e60ed..b74b071 100644
--- a/aai-traversal/src/main/config/ajsc-jetty.xml
+++ b/aai-traversal/src/main/config/ajsc-jetty.xml
@@ -111,6 +111,15 @@
</Call>
</Set>
<Set name="needClientAuth">false</Set>
+ <Set name="ExcludeProtocols">
+ <Array type="java.lang.String">
+ <Item>SSL</Item>
+ <Item>SSLv2</Item>
+ <Item>SSLv2Hello</Item>
+ <Item>SSLv3</Item>
+ <Item>TLSv1</Item>
+ </Array>
+ </Set>
</New>
</Arg>
</New>
diff --git a/aai-traversal/src/main/java/org/openecomp/aai/dbgraphgen/ModelBasedProcessing.java b/aai-traversal/src/main/java/org/openecomp/aai/dbgraphgen/ModelBasedProcessing.java
index da1fc1e..d3b44a3 100644
--- a/aai-traversal/src/main/java/org/openecomp/aai/dbgraphgen/ModelBasedProcessing.java
+++ b/aai-traversal/src/main/java/org/openecomp/aai/dbgraphgen/ModelBasedProcessing.java
@@ -2593,10 +2593,10 @@ public class ModelBasedProcessing{
String emsg = " Unrecognized nodeType bb [" + nodeTypeB + "]\n";
throw new AAIException("AAI_6115", emsg);
}
- } else {
- String msg = " No Edge Rule found for this pair of nodeTypes (order does not matter) ["
+
+ String msg = " No Edge Rule found for this pair of nodeTypes (order does not matter) ["
+ nodeTypeA + "], [" + nodeTypeB + "].";
- throw new AAIException("AAI_6120", msg);
+ throw new AAIException("AAI_6120", msg);
}
diff --git a/aai-traversal/src/main/java/org/openecomp/aai/dbgraphmap/SearchGraph.java b/aai-traversal/src/main/java/org/openecomp/aai/dbgraphmap/SearchGraph.java
index d9e40c4..8821f07 100644
--- a/aai-traversal/src/main/java/org/openecomp/aai/dbgraphmap/SearchGraph.java
+++ b/aai-traversal/src/main/java/org/openecomp/aai/dbgraphmap/SearchGraph.java
@@ -453,7 +453,7 @@ public class SearchGraph {
boolean isParallel = stream.isParallel();
stream.forEach(v -> {
String nodeType = v.<String>property(AAIProperties.NODE_TYPE).orElse(null);
-
+
String thisNodeURL;
try {
thisNodeURL = urlBuilder.pathed(v);
@@ -471,7 +471,7 @@ public class SearchGraph {
} catch (AAIException | AAIFormatVertexException e) {
throw new RuntimeException(e);
}
-
+
});
return searchResults;
}
@@ -667,7 +667,7 @@ public class SearchGraph {
}
DynamicEntity modelAndNamedQuerySearch = (DynamicEntity)loader.unmarshal("ModelAndNamedQuerySearch", queryParameters, mediaType).getUnderlyingObject();
- if (modelAndNamedQuerySearch == null) {
+ if (modelAndNamedQuerySearch == null) {
throw new AAIException("AAI_5105");
}
if (modelAndNamedQuerySearch == null) {
@@ -758,6 +758,13 @@ public class SearchGraph {
ResultSet rs = resultSet.get(0);
TitanVertex firstVert = rs.getVert();
+ String restURI = serializer.getURIForVertex(firstVert).toString();
+ String notificationVersion = AAIProperties.LATEST.toString();
+ if (restURI.startsWith("/")) {
+ restURI = "/aai/" + notificationVersion + restURI;
+ } else {
+ restURI = "/aai/" + notificationVersion + "/" + restURI;
+ }
Map<String,String> delResult = processor.runDeleteByModel( transId, fromAppId,
modelVersionId, topNodeType, startNodeFilterHash.get(0), aaiExtMap.getApiVersion(), resourceVersion );
@@ -768,25 +775,16 @@ public class SearchGraph {
}
resultStr.trim();
- DynamicEntity inventoryItems = jaxbContext.newDynamicEntity("inventory.aai.openecomp.org." + aaiExtMap.getApiVersion() + ".InventoryResponseItems");
+ DynamicEntity inventoryItems = jaxbContext.newDynamicEntity("inventory.aai.att.com." + aaiExtMap.getApiVersion() + ".InventoryResponseItems");
DynamicEntity topInvItem = remapInventoryItems((DynamicEntity)invItemList.get(0), jaxbContext, delResult, objectToVertMap, aaiExtMap);
-
List<DynamicEntity> newInvItemList = new ArrayList<DynamicEntity>();
+
newInvItemList.add(topInvItem);
inventoryItems.set("inventoryResponseItem", newInvItemList);
- String notificationVersion = AAIProperties.LATEST.toString();
-
- String restURI = serializer.getURIForVertex(firstVert).toString();
- if (restURI.startsWith("/")) {
- restURI = "/aai/" + notificationVersion + restURI;
- } else {
- restURI = "/aai/" + notificationVersion + "/" + restURI;
- }
DynamicEntity notificationHeader = (DynamicEntity) loader.introspectorFromName("notification-event-header").getUnderlyingObject();
notificationHeader.set("entityLink", restURI);
- notificationHeader.set("action", "DELETE");
-
+ notificationHeader.set("action", "DELETE");
notificationHeader.set("entityType", "inventory-response-items");
notificationHeader.set("topEntityType", "inventory-response-items");
notificationHeader.set("sourceName", aaiExtMap.getFromAppId());
@@ -945,7 +943,7 @@ public class SearchGraph {
Map<String,String> includeTheseVertices, Map<Object,String> objectToVertMap, AAIExtensionMap aaiExtMap) {
- DynamicEntity inventoryItem = jaxbContext.newDynamicEntity("inventory.aai.openecomp.org." + aaiExtMap.getApiVersion() + ".InventoryResponseItem");
+ DynamicEntity inventoryItem = jaxbContext.newDynamicEntity("inventory.aai.att.com." + aaiExtMap.getApiVersion() + ".InventoryResponseItem");
Object item = invResultItem.get("item");
inventoryItem.set("modelName", invResultItem.get("modelName"));
inventoryItem.set("item", item);
@@ -960,7 +958,7 @@ public class SearchGraph {
if (includeTheseVertices.containsKey(vertexId)) {
if (invResultItem.isSet("inventoryResponseItems")) {
List<DynamicEntity> invItemList = new ArrayList<DynamicEntity>();
- DynamicEntity inventoryItems = jaxbContext.newDynamicEntity("inventory.aai.openecomp.org." + aaiExtMap.getApiVersion() + ".InventoryResponseItems");
+ DynamicEntity inventoryItems = jaxbContext.newDynamicEntity("inventory.aai.att.com." + aaiExtMap.getApiVersion() + ".InventoryResponseItems");
DynamicEntity subInventoryResponseItems = invResultItem.get("inventoryResponseItems");
List<DynamicEntity> subInventoryResponseItemList = subInventoryResponseItems.get("inventoryResponseItem");
for (DynamicEntity ent : subInventoryResponseItemList) {
@@ -1016,7 +1014,7 @@ public class SearchGraph {
String aaiNodeType = vert.<String>property("aai-node-type").orElse(null);
-
+
if (aaiNodeType != null) {
Introspector thisObj = loader.introspectorFromName(aaiNodeType);
diff --git a/aai-traversal/src/main/scripts/deleteTool.sh b/aai-traversal/src/main/scripts/deleteTool.sh
new file mode 100644
index 0000000..02b72b0
--- /dev/null
+++ b/aai-traversal/src/main/scripts/deleteTool.sh
@@ -0,0 +1,132 @@
+#!/bin/ksh
+
+###
+# ============LICENSE_START=======================================================
+# org.openecomp.aai
+# ================================================================================
+# Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+# ================================================================================
+# 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.
+# ============LICENSE_END=========================================================
+###
+
+#
+# The script is called with a resource to be deleted.
+# Uses aaiconfig.properties for authorization type and url.
+# It invokes a GET on the resource using curl and parses the resource-version.
+# If found, prompts the user to continue and invokes DELETE using curl.
+# responses in the range of 200 to 299 are considered successful
+#
+
+# remove leading slash when present
+RESOURCE=`echo $1 | sed "s,^/,,"`
+if [ -z $RESOURCE ]; then
+ echo "resource parameter is missing"
+ echo "usage: $0 resource"
+ exit 1
+fi
+echo `date` " Starting $0 for resource $RESOURCE"
+
+XFROMAPPID="AAI-TOOLS"
+XTRANSID=`uuidgen`
+XTRANSID1=`uuidgen`
+
+userid=$( id | cut -f2 -d"(" | cut -f1 -d")" )
+if [ "${userid}" != "aaiadmin" ]; then
+ echo "You must be aaiadmin to run $0. The id used $userid."
+ exit 1
+fi
+
+. /etc/profile.d/aai.sh
+PROJECT_HOME=/opt/app/aai-traversal
+prop_file=$PROJECT_HOME/bundleconfig/etc/appprops/aaiconfig.properties
+log_dir=$PROJECT_HOME/logs/misc
+today=$(date +\%Y-\%m-\%d)
+
+MISSING_PROP=false
+RESTURL=`grep ^aai.server.url= $prop_file |cut -d'=' -f2 |tr -d "\015"`
+if [ -z $RESTURL ]; then
+ echo "Property [aai.server.url] not found in file $prop_file"
+ MISSING_PROP=true
+fi
+USEBASICAUTH=false
+BASICENABLE=`grep ^aai.tools.enableBasicAuth $prop_file |cut -d'=' -f2 |tr -d "\015"`
+if [ -z $BASICENABLE ]; then
+ USEBASICAUTH=false
+else
+ USEBASICAUTH=true
+ CURLUSER=`grep ^aai.tools.username $prop_file |cut -d'=' -f2 |tr -d "\015"`
+ if [ -z $CURLUSER ]; then
+ echo "Property [aai.tools.username] not found in file $prop_file"
+ MISSING_PROP=true
+ fi
+ CURLPASSWORD=`grep ^aai.tools.password $prop_file |cut -d'=' -f2 |tr -d "\015"`
+ if [ -z $CURLPASSWORD ]; then
+ echo "Property [aai.tools.password] not found in file $prop_file"
+ MISSING_PROP=true
+ fi
+fi
+
+if [ $MISSING_PROP = false ]; then
+ if [ $USEBASICAUTH = false ]; then
+ AUTHSTRING="--cert $PROJECT_HOME/bundleconfig/etc/auth/aaiClientPublicCert.pem --key $PROJECT_HOME/bundleconfig/etc/auth/aaiClientPrivateKey.pem"
+ else
+ AUTHSTRING="-u $CURLUSER:$CURLPASSWORD"
+ fi
+ RESOURCEVERSION=`curl --request GET -sL -k $AUTHSTRING -H "X-FromAppId: $XFROMAPPID" -H "X-TransactionId: $XTRANSID1" -H "Accept: application/json" $RESTURL$RESOURCE|awk -F"\"resource-version\":\"" '{print $2}' | cut -d\" -f1`
+ echo "resource-version is" $RESOURCEVERSION
+ if [ -z $RESOURCEVERSION ]; then
+ echo "failed to get resource-version for $RESOURCE"
+ echo `date` " Done $0, returning -1"
+ exit -1
+ fi
+ echo "Are you sure you would like to delete $RESOURCE? (y, n)"
+ read USERINPUT
+ if [ "$USERINPUT" != "y" ]; then
+ echo "user chose to exit before delete"
+ echo `date` " Done $0, returning -1"
+ exit -1
+ fi
+
+ result=`curl --request DELETE -sL -w "%{http_code}" -o /dev/null -k $AUTHSTRING -H "X-FromAppId: $XFROMAPPID" -H "X-TransactionId: $XTRANSID" -H "Accept: application/json" $RESTURL$RESOURCE?resource-version=$RESOURCEVERSION`
+ echo "result is $result."
+ RC=0;
+ if [ $? -eq 0 ]; then
+ case $result in
+ +([0-9])?)
+ if [[ "$result" -ge 200 && $result -lt 300 ]]
+ then
+ echo "DELETE result is OK, $result"
+ else
+ echo "failed DELETE request, response code was $result"
+ RC=$result
+ fi
+ ;;
+ *)
+ echo "DELETE request failed, response was $result"
+ RC=-1
+ ;;
+
+ esac
+ else
+ echo "FAILED to send request to $RESTURL"
+ RC=-1
+ fi
+else
+ echo "usage: $0 resource"
+ RC=-1
+fi
+
+echo
+echo `date` " Done $0, returning $RC"
+exit $RC