diff options
Diffstat (limited to 'src')
3 files changed, 45 insertions, 19 deletions
diff --git a/src/main/java/org/onap/dmaap/dbcapi/database/DatabaseClass.java b/src/main/java/org/onap/dmaap/dbcapi/database/DatabaseClass.java index 11b0d15..934b7bb 100644 --- a/src/main/java/org/onap/dmaap/dbcapi/database/DatabaseClass.java +++ b/src/main/java/org/onap/dmaap/dbcapi/database/DatabaseClass.java @@ -200,22 +200,18 @@ public class DatabaseClass extends BaseLoggingClass { mirrors = new HashMap<>(); } dmaap.init(new Dmaap("0", "", "", "", "", "", "", "")); - // check for, and set up initial data, if it isn't already there + // force initial read from DB, if it exists + @SuppressWarnings("unused") Dmaap dmx = dmaap.get(); - if ("0".equals(dmx.getVersion())) { - - dmx = new Dmaap("0", "", "", "", "", "", "", ""); - dmx.setDmaapName(p.getProperty("DmaapName")); - dmx.setDrProvUrl("https://" + p.getProperty("DR.provhost", "notSet")); - dmx.setTopicNsRoot(p.getProperty("topicNsRoot")); - dmx.setBridgeAdminTopic("DCAE_MM_AGENT"); + + // old code in this spot would read from properties file as part of init. + // but all those properties are now set via /dmaap API - dmaap.update(dmx); - } } catch (Exception e) { errorLogger.error("Error", e); errorLogger.error(DmaapbcLogMessageEnum.DB_UPDATE_ERROR, e.getMessage()); } + } public static synchronized String getNextClientId() { diff --git a/src/main/java/org/onap/dmaap/dbcapi/service/DmaapService.java b/src/main/java/org/onap/dmaap/dbcapi/service/DmaapService.java index 9d9b922..48ee661 100644 --- a/src/main/java/org/onap/dmaap/dbcapi/service/DmaapService.java +++ b/src/main/java/org/onap/dmaap/dbcapi/service/DmaapService.java @@ -58,7 +58,7 @@ public class DmaapService extends BaseLoggingClass { String topicFactory; // = "org.openecomp.dcae.dmaap.topicFactory"; String topicMgrRole; // = "org.openecomp.dmaapBC.TopicMgr"; - String dcaeTopicNs; // = "org.openecomp.dcae.dmaap"; + private boolean multiSite; @@ -66,14 +66,14 @@ public class DmaapService extends BaseLoggingClass { DmaapConfig p = (DmaapConfig)DmaapConfig.getConfig(); topicFactory = p.getProperty("MR.TopicFactoryNS", "MR.topicFactoryNS.not.set"); topicMgrRole = p.getProperty("MR.TopicMgrRole", "MR.TopicMgrRole.not.set" ); - dcaeTopicNs = dmaapholder.get().getTopicNsRoot(); + multiSite = "true".equalsIgnoreCase(p.getProperty("MR.multisite", "true")); noEnvironmentPrefix = p.getProperty( "AAF.NoEnvironmentPrefix", "org.onap"); logger.info( "DmaapService settings: " + " topicFactory=" + topicFactory + " topicMgrRole=" + topicMgrRole + - " dcaeTopicNs=" + dcaeTopicNs + + " multisite=" + multiSite + " noEnvironmentPrefix=" + noEnvironmentPrefix ); @@ -93,7 +93,7 @@ public class DmaapService extends BaseLoggingClass { nd.setLastMod(); dmaapholder.update(nd); - + AafService aaf = new AafService( ServiceType.AAF_Admin); ApiPolicy apiPolicy = new ApiPolicy(); if ( apiPolicy.getUseAuthClass() ) { @@ -137,7 +137,7 @@ public class DmaapService extends BaseLoggingClass { if ( ! dmaap.isStatusValid() || ! nd.getDmaapName().equals(dmaap.getDmaapName()) || dmaap.getVersion().equals( "0") ) { nd.setLastMod(); dmaapholder.update(nd); //need to set this so the following perms will pick up any new vals. - dcaeTopicNs = dmaapholder.get().getTopicNsRoot(); + //dcaeTopicNs = dmaapholder.get().getTopicNsRoot(); ApiPolicy apiPolicy = new ApiPolicy(); if ( apiPolicy.getUseAuthClass()) { ApiPerms p = new ApiPerms(); @@ -194,7 +194,7 @@ public class DmaapService extends BaseLoggingClass { private boolean setTopicMgtPerms( Dmaap nd, AafService aaf ){ String[] actions = { "create", "destroy" }; - String instance = ":" + dcaeTopicNs + "." + nd.getDmaapName() + ".mr.topic:" + dcaeTopicNs + "." + nd.getDmaapName(); + String instance = ":" + nd.getTopicNsRoot() + "." + nd.getDmaapName() + ".mr.topic:" + nd.getTopicNsRoot() + "." + nd.getDmaapName(); for( String action : actions ) { @@ -214,7 +214,7 @@ public class DmaapService extends BaseLoggingClass { } } - String t = dcaeTopicNs +"." + nd.getDmaapName() + ".mr.topic"; + String t = nd.getTopicNsRoot() +"." + nd.getDmaapName() + ".mr.topic"; String[] s = { "view", "pub", "sub" }; actions = s; instance = "*"; diff --git a/src/test/java/org/onap/dmaap/dbcapi/resources/DR_SubResourceTest.java b/src/test/java/org/onap/dmaap/dbcapi/resources/DR_SubResourceTest.java index 48d1016..917507f 100644 --- a/src/test/java/org/onap/dmaap/dbcapi/resources/DR_SubResourceTest.java +++ b/src/test/java/org/onap/dmaap/dbcapi/resources/DR_SubResourceTest.java @@ -21,6 +21,8 @@ package org.onap.dmaap.dbcapi.resources; import org.onap.dmaap.dbcapi.model.*; import org.onap.dmaap.dbcapi.service.*; +import org.onap.dmaap.dbcapi.testframework.DmaapObjectFactory; + import static org.junit.Assert.*; import org.junit.After; @@ -39,16 +41,44 @@ import javax.ws.rs.Path; import javax.ws.rs.GET; public class DR_SubResourceTest extends JerseyTest{ + + static DmaapObjectFactory factory = new DmaapObjectFactory(); @Override protected Application configure() { return new ResourceConfig() .register( DR_SubResource.class ) - .register( FeedResource.class ); + .register( FeedResource.class ) + .register( DcaeLocationResource.class ) + .register( DmaapResource.class ); } - private static final String fmt = "%24s: %s%n"; String d, un, up, f, p; + + @Before + public void preTest() throws Exception { + try { + + Dmaap dmaap = factory.genDmaap(); + Entity<Dmaap> reqEntity = Entity.entity( dmaap, MediaType.APPLICATION_JSON ); + Response resp = target( "dmaap").request().post( reqEntity, Response.class ); + System.out.println( resp.getStatus() ); + assertTrue( resp.getStatus() == 200 ); + }catch (Exception e ) { + } + try { + DcaeLocation loc = factory.genDcaeLocation( "central" ); + Entity<DcaeLocation> reqEntity = Entity.entity( loc, MediaType.APPLICATION_JSON ); + Response resp = target( "dcaeLocations").request().post( reqEntity, Response.class ); + System.out.println( "POST dcaeLocation resp=" + resp.getStatus() + " " + resp.readEntity( String.class )); + if ( resp.getStatus() != 409 ) { + assertTrue( resp.getStatus() == 201 ); + } + } catch (Exception e ) { + } + + + } /* @Before public void setUp() throws Exception { |