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;
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 {
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 );
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);
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 ) {
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);