X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Forg%2Fonap%2Fdmaap%2Fdbcapi%2Fservice%2FDmaapService.java;h=92455cdf3e3843cbfb1313f43ac1c9e7379e8b88;hb=bf91de122a24dbfc9a0158556e290df21472240b;hp=5c2c8a3494dc7e291d1e7cb49830ad6b943430a8;hpb=30f5f28cdd17eb94ca70db6dbf027cc330bb59e7;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 5c2c8a3..92455cd 100644 --- a/src/main/java/org/onap/dmaap/dbcapi/service/DmaapService.java +++ b/src/main/java/org/onap/dmaap/dbcapi/service/DmaapService.java @@ -3,6 +3,8 @@ * org.onap.dmaap * ================================================================================ * 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. @@ -21,17 +23,8 @@ package org.onap.dmaap.dbcapi.service; import java.util.ArrayList; - - - - - - - - - - import org.onap.dmaap.dbcapi.aaf.AafService; +import org.onap.dmaap.dbcapi.aaf.AafServiceImpl; import org.onap.dmaap.dbcapi.aaf.DmaapGrant; import org.onap.dmaap.dbcapi.aaf.DmaapPerm; import org.onap.dmaap.dbcapi.aaf.AafService.ServiceType; @@ -43,7 +36,6 @@ import org.onap.dmaap.dbcapi.logging.DmaapbcLogMessageEnum; import org.onap.dmaap.dbcapi.model.ApiError; import org.onap.dmaap.dbcapi.model.Dmaap; import org.onap.dmaap.dbcapi.model.MR_Client; -import org.onap.dmaap.dbcapi.model.ReplicationType; import org.onap.dmaap.dbcapi.model.Topic; import org.onap.dmaap.dbcapi.model.DmaapObject.DmaapObject_Status; import org.onap.dmaap.dbcapi.util.DmaapConfig; @@ -58,7 +50,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 +58,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,10 +85,10 @@ public class DmaapService extends BaseLoggingClass { nd.setLastMod(); dmaapholder.update(nd); - - AafService aaf = new AafService( ServiceType.AAF_Admin); + + AafService aaf = new AafServiceImpl( ServiceType.AAF_Admin); ApiPolicy apiPolicy = new ApiPolicy(); - if ( apiPolicy.getUseAuthClass() ) { + if ( apiPolicy.isPermissionClassSet() ) { ApiPerms p = new ApiPerms(); p.setEnvMap(); } @@ -137,13 +129,13 @@ 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()) { + if ( apiPolicy.isPermissionClassSet()) { ApiPerms p = new ApiPerms(); p.setEnvMap(); } - AafService aaf = new AafService( ServiceType.AAF_Admin); + AafService aaf = new AafServiceImpl( ServiceType.AAF_Admin); if ( multiSite ) { anythingWrong = setTopicMgtPerms( nd, aaf ) || createMmaTopic(); } @@ -168,6 +160,8 @@ public class DmaapService extends BaseLoggingClass { public String getTopicPerm( String val ) { Dmaap dmaap = dmaapholder.get(); String nsRoot = dmaap.getTopicNsRoot(); + if ( nsRoot == null ) { return null; } + String t; // in ONAP Casablanca, we assume no distinction of environments reflected in topic namespace if ( nsRoot.startsWith(noEnvironmentPrefix) ) { @@ -192,7 +186,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 ) { @@ -212,7 +206,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 = "*";