diff options
Diffstat (limited to 'aai-traversal/src')
4 files changed, 160 insertions, 21 deletions
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 |