X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Forg%2Fonap%2Fdmaap%2Fdbcapi%2Fservice%2FDR_NodeService.java;h=918115430ac7c9ded845b81bdf7f0c7dc47bea86;hb=e2e2bcd054957077817b4e9f441ca069ad452d2d;hp=f2476a879eb195a5c422d342f65d522782f967d3;hpb=503da874ce876dbe463bcc1a03f63ea0f48fe650;p=dmaap%2Fdbcapi.git diff --git a/src/main/java/org/onap/dmaap/dbcapi/service/DR_NodeService.java b/src/main/java/org/onap/dmaap/dbcapi/service/DR_NodeService.java index f2476a8..9181154 100644 --- a/src/main/java/org/onap/dmaap/dbcapi/service/DR_NodeService.java +++ b/src/main/java/org/onap/dmaap/dbcapi/service/DR_NodeService.java @@ -3,6 +3,8 @@ * org.onap.dcae * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * Modifications Copyright (C) 2019 IBM. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,12 +29,14 @@ import java.util.Map; import javax.ws.rs.core.Response.Status; import org.apache.log4j.Logger; -import org.onap.dmaap.dbcapi.aaf.client.DrProvConnection; -import org.onap.dmaap.dbcapi.aaf.database.DatabaseClass; +import org.onap.dmaap.dbcapi.client.DrProvConnection; +import org.onap.dmaap.dbcapi.database.DatabaseClass; import org.onap.dmaap.dbcapi.logging.BaseLoggingClass; import org.onap.dmaap.dbcapi.model.ApiError; import org.onap.dmaap.dbcapi.model.DR_Node; import org.onap.dmaap.dbcapi.model.DmaapObject.DmaapObject_Status; +import org.onap.dmaap.dbcapi.util.DmaapConfig; + public class DR_NodeService extends BaseLoggingClass { private class DrProv { @@ -56,7 +60,7 @@ public class DR_NodeService extends BaseLoggingClass { private void setX( String X, String list, ApiError apiError ) { DrProvConnection prov = new DrProvConnection(); prov.makeNodesConnection( X, list ); - String resp = prov.doPutNodes( apiError ); + prov.doPutNodes( apiError ); } private String removeFromList( String aNode, String aList ) { @@ -141,6 +145,10 @@ public class DR_NodeService extends BaseLoggingClass { setX( "STATIC_ROUTING_NODES", currentStaticNodes, apiError ); } } + + DmaapConfig p = (DmaapConfig)DmaapConfig.getConfig(); + String unit_test = p.getProperty( "UnitTest", "No" ); + private Map dr_nodes = DatabaseClass.getDr_nodes(); public Map getDr_Nodes() { @@ -182,7 +190,7 @@ public class DR_NodeService extends BaseLoggingClass { drProv.addNode( node.getFqdn(), apiError ); } logger.info( "templog:addDr_Node at" + " 20" ); - if ( ! apiError.is2xx()) { + if ( ! apiError.is2xx() && ! unit_test.equals( "Yes" ) ) { return null; } logger.info( "templog:addDr_Node at" + " 30" ); @@ -193,7 +201,7 @@ public class DR_NodeService extends BaseLoggingClass { } } logger.info( "templog:addDr_Node at" + " 40" ); - if ( ! apiError.is2xx()) { + if ( ! apiError.is2xx() && ! unit_test.equals("Yes") ) { return null; } @@ -207,11 +215,11 @@ public class DR_NodeService extends BaseLoggingClass { } public DR_Node updateDr_Node( DR_Node node, ApiError apiError ) { - DR_Node old = dr_nodes.get( node ); + DR_Node old = dr_nodes.get( node.getFqdn() ); if ( old == null ) { apiError.setCode(Status.NOT_FOUND.getStatusCode()); apiError.setFields( "fqdn"); - apiError.setMessage( "Node " + node + " does not exist"); + apiError.setMessage( "Node " + node.getFqdn() + " does not exist"); return null; } node.setLastMod();