import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
import javax.ws.rs.core.GenericEntity;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import org.onap.dmaap.dbcapi.logging.BaseLoggingClass;
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;
@Authorization
public class TopicResource extends BaseLoggingClass {
private static FqtnType defaultTopicStyle;
+ private static String defaultPartitionCount;
+ private static String defaultReplicationCount;
TopicService mr_topicService = new TopicService();
public TopicResource() {
DmaapConfig p = (DmaapConfig)DmaapConfig.getConfig();
- defaultTopicStyle = FqtnType.Validator( p.getProperty("MR.topicStyle", "FQTN_LEGACY_FORMAT"));
+ defaultTopicStyle = FqtnType.Validator( p.getProperty("MR.topicStyle", "FQTN_LEGACY_FORMAT"));
+ defaultPartitionCount = p.getProperty( "MR.partitionCount", "2");
+ defaultReplicationCount = p.getProperty( "MR.replicationCount", "1");
+
logger.info( "Setting defaultTopicStyle=" + defaultTopicStyle );
}
notes = "Returns array of `Topic` objects.",
response = Topic.class)
@ApiResponses( value = {
- @ApiResponse( code = 200, message = "Success", response = DR_Pub.class),
+ @ApiResponse( code = 200, message = "Success", response = Topic.class),
@ApiResponse( code = 400, message = "Error", response = ApiError.class )
})
public Response getTopics() {
notes = "Create `Topic` object.",
response = Topic.class)
@ApiResponses( value = {
- @ApiResponse( code = 200, message = "Success", response = DR_Pub.class),
+ @ApiResponse( code = 200, message = "Success", response = Topic.class),
@ApiResponse( code = 400, message = "Error", response = ApiError.class )
})
public Response addTopic(
- Topic topic
+ Topic topic,
+ @QueryParam("useExisting") String useExisting
) {
- logger.info( "addTopic request: " + topic );
+ logger.info( "addTopic request: " + topic + " useExisting=" + useExisting );
ApiService check = new ApiService();
try {
logger.info( "setting defaultTopicStyle=" + defaultTopicStyle + " for topic " + topic.getTopicName() );
topic.setFqtnStyle( defaultTopicStyle );
}
+ String pc = topic.getPartitionCount();
+ if ( pc == null ) {
+ topic.setPartitionCount(defaultPartitionCount);
+ }
+ String rc = topic.getReplicationCount();
+ if ( rc == null ) {
+ topic.setReplicationCount(defaultReplicationCount);
+ }
topic.setLastMod();
+ Boolean flag = false;
+ if (useExisting != null) {
+ flag = "true".compareToIgnoreCase( useExisting ) == 0;
+ }
- Topic mrc = mr_topicService.addTopic(topic, check.getErr());
+ Topic mrc = mr_topicService.addTopic(topic, check.getErr(), flag);
if ( mrc != null && check.getErr().is2xx() ) {
return check.success(Status.CREATED.getStatusCode(), mrc);
}
notes = "Update a `Topic` object, identified by topicId",
response = Topic.class)
@ApiResponses( value = {
- @ApiResponse( code = 200, message = "Success", response = DR_Pub.class),
+ @ApiResponse( code = 200, message = "Success", response = Topic.class),
@ApiResponse( code = 400, message = "Error", response = ApiError.class )
})
@Path("/{topicId}")
notes = "Delete a `Topic` object, identified by topicId",
response = Topic.class)
@ApiResponses( value = {
- @ApiResponse( code = 204, message = "Success", response = DR_Pub.class),
+ @ApiResponse( code = 204, message = "Success", response = Topic.class),
@ApiResponse( code = 400, message = "Error", response = ApiError.class )
})
@Path("/{topicId}")
notes = "Retrieve a `Topic` object, identified by topicId",
response = Topic.class)
@ApiResponses( value = {
- @ApiResponse( code = 200, message = "Success", response = DR_Pub.class),
+ @ApiResponse( code = 200, message = "Success", response = Topic.class),
@ApiResponse( code = 400, message = "Error", response = ApiError.class )
})
@Path("/{topicId}")