Fix Model based delete failing bug 87/8287/1
authorVenkata Harish K Kajur <vk250x@att.com>
Tue, 22 Aug 2017 14:13:14 +0000 (10:13 -0400)
committerVenkata Harish K Kajur <vk250x@att.com>
Tue, 22 Aug 2017 14:13:21 +0000 (10:13 -0400)
Issue-ID: AAI-206

Change-Id: If69f34b9527e4e21a4ddacd32d3591f3f591da05
Signed-off-by: Venkata Harish K Kajur <vk250x@att.com>
aai-traversal/src/main/java/org/openecomp/aai/dbgraphgen/ModelBasedProcessing.java
aai-traversal/src/main/java/org/openecomp/aai/dbgraphmap/SearchGraph.java

index 282f5d3..9b65ca1 100644 (file)
@@ -828,20 +828,32 @@ public class ModelBasedProcessing{
                String thisNT = "";
                String thisGuyStr = "";
                
+               Boolean gotVtxOK = false;
                try {
-                       if( thisVtx != null){
+                       if( thisVtx != null ){
                                thisGuyId = thisVtx.id().toString();
                                thisNT = thisVtx.<String>property(AAIProperties.NODE_TYPE).orElse(null);
                                thisGuyStr = thisGuyId + "[" + thisNT + " found at:" + resSet.getLocationInModelSubGraph() + "]";
+                               
+                               // NOTE -- will try to set the NodeType to itself to see if the node has been deleted already in 
+                               //       this transaction. It lets you get properties from nodes being deleted where the 
+                               //       delete hasn't been committed yet.  This check used to be accomplished with a call to 
+                               //       "vtx.isRemoved()" but that was a Titan-only feature and is not available anymore since
+                               //       we no longer use Titan vertices.
+                               // If we don't do this check, we get errors later when we try to delete the node.
+                               thisVtx.property(AAIProperties.NODE_TYPE, thisNT); 
+                               gotVtxOK = true;
                        }
                }
                catch (Exception ex) {
                        // Sometimes things have already been deleted by the time we get to them - just log it.
-                       LOGGER.warn("Exception when deleting " + thisGuyStr + ".  msg = " + ex.getMessage(), ex);
+                       LOGGER.warn("Exception when trying to delete: " + thisGuyStr + ".  msg = " + ex.getMessage(), ex);
                }
                
-               if( thisGuyId.equals("") ){
+               if( !gotVtxOK ){
                        // The vertex must have already been removed.   Just return.
+                       // Note - We need to catch this because the DB sometimes can still have the vtx 
+                       // and be able to get its ID but it is flagged internally as removed already.
                        return retHash;
                }
                else {
index 58c4d1d..b8581d1 100644 (file)
@@ -757,7 +757,7 @@ public class SearchGraph {
                                } else {
                                        restURI = "/aai/" + notificationVersion + "/" + restURI;
                                }
-
+                               
                                Map<String,String> delResult = processor.runDeleteByModel( transId, fromAppId,
                                                modelVersionId, topNodeType, startNodeFilterHash.get(0), aaiExtMap.getApiVersion(), resourceVersion );
 
@@ -767,24 +767,7 @@ public class SearchGraph {
                                }
                                resultStr.trim();
 
-                               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);
-
-                               DynamicEntity notificationHeader = (DynamicEntity) loader.introspectorFromName("notification-event-header").getUnderlyingObject();
-                               notificationHeader.set("entityLink", restURI);
-                               notificationHeader.set("action", "DELETE");
-                               notificationHeader.set("entityType", "inventory-response-items");
-                               notificationHeader.set("topEntityType", "inventory-response-items");
-                               notificationHeader.set("sourceName", aaiExtMap.getFromAppId());
-                               notificationHeader.set("version", notificationVersion);
-
-                               StoreNotificationEvent sne = new StoreNotificationEvent(transId, fromAppId);
-
-                               sne.storeDynamicEvent(loader.getJAXBContext(), notificationVersion, notificationHeader, inventoryItems);
+                               // Note - notifications are now done down in the individual "remove" calls done in runDeleteByModel() above.
 
                                response = Response.ok(resultStr).build();