X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Forg%2Fonap%2Fdmaap%2Fdbcapi%2Fresources%2FFeedResource.java;h=a7b4f7374002af0ae8298e51e71bd376e1a4a338;hb=956361f657eda468d5980249db6b155c472f5f85;hp=c0fdd0d93b19ad9bed09deec6a4f611fc5714113;hpb=8f54f37825746cf82b33a21ff356950eb682d290;p=dmaap%2Fdbcapi.git diff --git a/src/main/java/org/onap/dmaap/dbcapi/resources/FeedResource.java b/src/main/java/org/onap/dmaap/dbcapi/resources/FeedResource.java index c0fdd0d..a7b4f73 100644 --- a/src/main/java/org/onap/dmaap/dbcapi/resources/FeedResource.java +++ b/src/main/java/org/onap/dmaap/dbcapi/resources/FeedResource.java @@ -31,29 +31,20 @@ import javax.jws.WebParam; import javax.ws.rs.Consumes; import javax.ws.rs.DELETE; import javax.ws.rs.GET; -import javax.ws.rs.HeaderParam; import javax.ws.rs.POST; import javax.ws.rs.PUT; 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.Context; import javax.ws.rs.core.GenericEntity; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import javax.ws.rs.core.Response.Status; -import javax.ws.rs.core.UriInfo; - -import org.apache.log4j.Logger; -import org.onap.dmaap.dbcapi.authentication.AuthenticationErrorException; 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.DR_Pub; -import org.onap.dmaap.dbcapi.model.DR_Sub; import org.onap.dmaap.dbcapi.model.Feed; -import org.onap.dmaap.dbcapi.model.Topic; import org.onap.dmaap.dbcapi.model.DmaapObject.DmaapObject_Status; import org.onap.dmaap.dbcapi.service.ApiService; import org.onap.dmaap.dbcapi.service.FeedService; @@ -71,7 +62,7 @@ public class FeedResource extends BaseLoggingClass { notes = "Returns array of `Feed` objects.", response = Feed.class) @ApiResponses( value = { - @ApiResponse( code = 200, message = "Success", response = DR_Pub.class), + @ApiResponse( code = 200, message = "Success", response = Feed.class), @ApiResponse( code = 400, message = "Error", response = ApiError.class ) }) public Response getFeeds( @@ -96,11 +87,12 @@ public class FeedResource extends BaseLoggingClass { notes = "Create a of `Feed` object.", response = Feed.class) @ApiResponses( value = { - @ApiResponse( code = 200, message = "Success", response = DR_Pub.class), + @ApiResponse( code = 200, message = "Success", response = Feed.class), @ApiResponse( code = 400, message = "Error", response = ApiError.class ) }) public Response addFeed( - @WebParam(name = "feed") Feed feed + @WebParam(name = "feed") Feed feed, + @QueryParam("useExisting") String useExisting ) { ApiService resp = new ApiService(); @@ -115,6 +107,7 @@ public class FeedResource extends BaseLoggingClass { return resp.error(); } + FeedService feedService = new FeedService(); Feed nfeed = feedService.getFeedByName( feed.getFeedName(), feed.getFeedVersion(), resp.getErr() ); if ( nfeed == null ) { @@ -136,6 +129,8 @@ public class FeedResource extends BaseLoggingClass { return resp.error(); } + } else if ( (useExisting != null) && ("true".compareToIgnoreCase( useExisting ) == 0)) { + return resp.success(nfeed); } resp.setCode(Status.CONFLICT.getStatusCode()); @@ -147,7 +142,7 @@ public class FeedResource extends BaseLoggingClass { notes = "Update a `Feed` object, specified by id.", response = Feed.class) @ApiResponses( value = { - @ApiResponse( code = 200, message = "Success", response = DR_Pub.class), + @ApiResponse( code = 200, message = "Success", response = Feed.class), @ApiResponse( code = 400, message = "Error", response = ApiError.class ) }) @Path("/{id}") @@ -192,7 +187,7 @@ public class FeedResource extends BaseLoggingClass { notes = "Delete a `Feed` object, specified by id.", response = Feed.class) @ApiResponses( value = { - @ApiResponse( code = 204, message = "Success", response = DR_Pub.class), + @ApiResponse( code = 204, message = "Success", response = Feed.class), @ApiResponse( code = 400, message = "Error", response = ApiError.class ) }) @Path("/{id}")