import org.onap.dmaap.dbcapi.model.ApiError;
import org.onap.dmaap.dbcapi.model.DR_Pub;
import org.onap.dmaap.dbcapi.model.ReplicationType;
+import org.onap.dmaap.dbcapi.model.FqtnType;
import org.onap.dmaap.dbcapi.model.Topic;
import org.onap.dmaap.dbcapi.service.ApiService;
import org.onap.dmaap.dbcapi.service.TopicService;
+import org.onap.dmaap.dbcapi.util.DmaapConfig;
@Path("/topics")
@Api( value= "topics", description = "Endpoint for retreiving MR Topics" )
@Produces(MediaType.APPLICATION_JSON)
@Authorization
public class TopicResource extends BaseLoggingClass {
-
+ private static FqtnType defaultTopicStyle;
TopicService mr_topicService = new TopicService();
+
+ public TopicResource() {
+ DmaapConfig p = (DmaapConfig)DmaapConfig.getConfig();
+ defaultTopicStyle = FqtnType.Validator( p.getProperty("MR.topicStyle", "FQTN_LEGACY_FORMAT"));
+ logger.info( "Setting defaultTopicStyle=" + defaultTopicStyle );
+ }
@GET
@ApiOperation( value = "return Topic details",
public Response addTopic(
Topic topic
) {
- logger.info( "addTopic request: " + String.valueOf(topic) );
+ logger.info( "addTopic request: " + topic );
ApiService check = new ApiService();
try {
check.required( "topicDescription", topic.getTopicDescription(), "" );
check.required( "owner", topic.getOwner(), "" );
} catch( RequiredFieldException rfe ) {
+ logger.error("Error", rfe);
return check.error();
}
- //String repReq = topic.getReplicationRequest();
ReplicationType t = topic.getReplicationCase();
if ( t == null || t == ReplicationType.REPLICATION_NOT_SPECIFIED ) {
topic.setReplicationCase( mr_topicService.reviewTopic(topic));
}
-
+ FqtnType ft = topic.getFqtnStyle();
+ if ( ft == null || ft == FqtnType.FQTN_NOT_SPECIFIED ) {
+ logger.info( "setting defaultTopicStyle=" + defaultTopicStyle + " for topic " + topic.getTopicName() );
+ topic.setFqtnStyle( defaultTopicStyle );
+ }
topic.setLastMod();
Topic mrc = mr_topicService.addTopic(topic, check.getErr());
- if ( mrc != null && mrc.isStatusValid() ) {
+ if ( mrc != null && check.getErr().is2xx() ) {
return check.success(Status.CREATED.getStatusCode(), mrc);
}
return check.error();
try {
check.required( "fqtn", id, "" );
} catch( RequiredFieldException rfe ) {
+ logger.error("Error", rfe);
return check.error();
}
try {
check.required( "topicName", id, "^\\S+$" ); //no white space allowed in topicName
} catch( RequiredFieldException rfe ) {
+ logger.error("Error", rfe);
return check.error();
}
Topic mrc = mr_topicService.getTopic( id, check.getErr() );