X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;ds=sidebyside;f=src%2Fmain%2Fjava%2Forg%2Fonap%2Fdmaap%2Fdbcapi%2Fservice%2FTopicService.java;h=eed502268474372dbdb7c0b88e22f9663be08caa;hb=8f54f37825746cf82b33a21ff356950eb682d290;hp=244fe37be916bc3961c11c6bf6b11e80b53e7f3c;hpb=a05efb7b7b3cfc77f5e3fda11e8434834829f56a;p=dmaap%2Fdbcapi.git diff --git a/src/main/java/org/onap/dmaap/dbcapi/service/TopicService.java b/src/main/java/org/onap/dmaap/dbcapi/service/TopicService.java index 244fe37..eed5022 100644 --- a/src/main/java/org/onap/dmaap/dbcapi/service/TopicService.java +++ b/src/main/java/org/onap/dmaap/dbcapi/service/TopicService.java @@ -31,7 +31,7 @@ import javax.ws.rs.core.Response.Status; import org.onap.dmaap.dbcapi.aaf.AafService; import org.onap.dmaap.dbcapi.aaf.DmaapPerm; import org.onap.dmaap.dbcapi.aaf.AafService.ServiceType; -import org.onap.dmaap.dbcapi.aaf.database.DatabaseClass; +import org.onap.dmaap.dbcapi.database.DatabaseClass; import org.onap.dmaap.dbcapi.logging.BaseLoggingClass; import org.onap.dmaap.dbcapi.logging.DmaapbcLogMessageEnum; import org.onap.dmaap.dbcapi.model.ApiError; @@ -43,6 +43,7 @@ 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; +import org.onap.dmaap.dbcapi.util.Fqdn; import org.onap.dmaap.dbcapi.util.Graph; public class TopicService extends BaseLoggingClass { @@ -94,7 +95,9 @@ public class TopicService extends BaseLoggingClass { public Topic addTopic( Topic topic, ApiError err ) { logger.info( "Entry: addTopic"); - String nFqtn = Topic.genFqtn( topic.getTopicName() ); + logger.info( "Topic name=" + topic.getTopicName() + " fqtnStyle=" + topic.getFqtnStyle() ); + String nFqtn = topic.genFqtn(); + logger.info( "FQTN=" + nFqtn ); if ( getTopic( nFqtn, err ) != null ) { String t = "topic already exists: " + nFqtn; logger.info( t ); @@ -104,7 +107,7 @@ public class TopicService extends BaseLoggingClass { return null; } err.reset(); // err filled with NOT_FOUND is expected case, but don't want to litter... - logger.info( "fqtn: " + nFqtn ); + topic.setFqtn( nFqtn ); AafService aaf = new AafService(ServiceType.AAF_TopicMgr); @@ -122,6 +125,20 @@ public class TopicService extends BaseLoggingClass { return null; } } + if ( topic.getReplicationCase().involvesGlobal() ) { + if ( topic.getGlobalMrURL() == null ) { + topic.setGlobalMrURL(defaultGlobalMrHost); + } + if ( ! Fqdn.isValid( topic.getGlobalMrURL())) { + logger.error( "GlobalMR FQDN not valid: " + topic.getGlobalMrURL()); + topic.setStatus( DmaapObject_Status.INVALID); + err.setCode(500); + err.setMessage("Value is not a valid FQDN:" + topic.getGlobalMrURL() ); + err.setFields("globalMrURL"); + + return null; + } + } if ( topic.getNumClients() > 0 ) { @@ -144,11 +161,7 @@ public class TopicService extends BaseLoggingClass { topic.setClients(clients2); } - if ( topic.getReplicationCase().involvesGlobal() ) { - if ( topic.getGlobalMrURL() == null ) { - topic.setGlobalMrURL(defaultGlobalMrHost); - } - } + Topic ntopic = checkForBridge( topic, err ); if ( ntopic == null ) { topic.setStatus( DmaapObject_Status.INVALID);