X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Forg%2Fonap%2Fdmaap%2Fdbcapi%2Fservice%2FDmaapService.java;h=e2bc379da925e30ec159a2364a80bbc1563ea77e;hb=378d55bf699e9a3d6c5a1f1a5e47bdbde9594abc;hp=03410f3957e8c384fcd33441517ed76b52bafa3b;hpb=0bff051a842b164b680bc938f4a56db435dd5841;p=dmaap%2Fdbcapi.git 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 03410f3..e2bc379 100644 --- a/src/main/java/org/onap/dmaap/dbcapi/service/DmaapService.java +++ b/src/main/java/org/onap/dmaap/dbcapi/service/DmaapService.java @@ -36,6 +36,7 @@ import org.onap.dmaap.dbcapi.aaf.DmaapGrant; import org.onap.dmaap.dbcapi.aaf.DmaapPerm; import org.onap.dmaap.dbcapi.aaf.AafService.ServiceType; import org.onap.dmaap.dbcapi.authentication.ApiPerms; +import org.onap.dmaap.dbcapi.authentication.ApiPolicy; import org.onap.dmaap.dbcapi.database.DatabaseClass; import org.onap.dmaap.dbcapi.logging.BaseLoggingClass; import org.onap.dmaap.dbcapi.logging.DmaapbcLogMessageEnum; @@ -51,13 +52,13 @@ public class DmaapService extends BaseLoggingClass { private Singleton dmaapholder = DatabaseClass.getDmaap(); + private static String noEnvironmentPrefix; + - // TODO put these in properties file String topicFactory; // = "org.openecomp.dcae.dmaap.topicFactory"; String topicMgrRole; // = "org.openecomp.dmaapBC.TopicMgr"; - - // TODO confirm this is equivalent to dmaap.getTopicNsRoot() so we can retire it String dcaeTopicNs; // = "org.openecomp.dcae.dmaap"; + private boolean multiSite; public DmaapService() { @@ -65,6 +66,16 @@ public class DmaapService extends BaseLoggingClass { 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 + ); } @@ -83,9 +94,16 @@ public class DmaapService extends BaseLoggingClass { dmaapholder.update(nd); AafService aaf = new AafService( ServiceType.AAF_Admin); - ApiPerms p = new ApiPerms(); - p.setEnvMap(); - boolean anythingWrong = setTopicMgtPerms( nd, aaf ) || createMmaTopic(); + ApiPolicy apiPolicy = new ApiPolicy(); + if ( apiPolicy.getUseAuthClass() ) { + ApiPerms p = new ApiPerms(); + p.setEnvMap(); + } + boolean anythingWrong = false; + + if ( multiSite ) { + anythingWrong = setTopicMgtPerms( nd, aaf ) || createMmaTopic(); + } if ( anythingWrong ) { dmaap.setStatus(DmaapObject_Status.INVALID); @@ -118,10 +136,15 @@ 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. - ApiPerms p = new ApiPerms(); - p.setEnvMap(); + ApiPolicy apiPolicy = new ApiPolicy(); + if ( apiPolicy.getUseAuthClass()) { + ApiPerms p = new ApiPerms(); + p.setEnvMap(); + } AafService aaf = new AafService( ServiceType.AAF_Admin); - anythingWrong = setTopicMgtPerms( nd, aaf ) || createMmaTopic(); + if ( multiSite ) { + anythingWrong = setTopicMgtPerms( nd, aaf ) || createMmaTopic(); + } } if ( anythingWrong ) { @@ -142,7 +165,15 @@ public class DmaapService extends BaseLoggingClass { } public String getTopicPerm( String val ) { Dmaap dmaap = dmaapholder.get(); - return dmaap.getTopicNsRoot() + "." + val + ".mr.topic"; + String nsRoot = dmaap.getTopicNsRoot(); + String t; + // in ONAP Casablanca, we assume no distinction of environments reflected in topic namespace + if ( nsRoot.startsWith(noEnvironmentPrefix) ) { + t = nsRoot + ".mr.topic"; + } else { + t = nsRoot + "." + val + ".mr.topic"; + } + return t; } public String getBridgeAdminFqtn(){