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=361491afd7ca8e226f25f3b698acf3b2305a6e9b;hpb=a05efb7b7b3cfc77f5e3fda11e8434834829f56a;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 361491a..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,47 +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.core.Context; +import javax.ws.rs.QueryParam; 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.aaf.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; @@ -89,15 +62,19 @@ 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() { + public Response getFeeds( + @QueryParam("feedName") String feedName, + @QueryParam("version") String version, + @QueryParam("match") String match + ) { ApiService resp = new ApiService(); FeedService feedService = new FeedService(); - List nfeeds = feedService.getAllFeeds(); + List nfeeds = feedService.getAllFeeds( feedName, version, match ); GenericEntity> list = new GenericEntity>(nfeeds) { }; return resp.success(list); @@ -110,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(); @@ -129,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 ) { @@ -141,7 +120,8 @@ public class FeedResource extends BaseLoggingClass { return resp.error(); } } else if ( nfeed.getStatus() == DmaapObject_Status.DELETED ) { - nfeed = feedService.updateFeed(nfeed, resp.getErr()); + feed.setFeedId( nfeed.getFeedId()); + nfeed = feedService.updateFeed(feed, resp.getErr()); if ( nfeed != null ) { return resp.success(nfeed); } else { @@ -149,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()); @@ -160,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}") @@ -205,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}")