import org.onap.dmaap.dbcapi.model.ApiError;
import org.onap.dmaap.dbcapi.model.DR_Pub;
import org.onap.dmaap.dbcapi.model.Feed;
import org.onap.dmaap.dbcapi.model.ApiError;
import org.onap.dmaap.dbcapi.model.DR_Pub;
import org.onap.dmaap.dbcapi.model.Feed;
import org.onap.dmaap.dbcapi.service.DR_PubService;
import org.onap.dmaap.dbcapi.service.FeedService;
import org.onap.dmaap.dbcapi.service.DR_PubService;
import org.onap.dmaap.dbcapi.service.FeedService;
- DR_PubService dr_pubService = new DR_PubService();
+ private DR_PubService dr_pubService = new DR_PubService();
+ private ResponseBuilder responseBuilder = new ResponseBuilder();
+ private RequiredChecker checker = new RequiredChecker();
@ApiResponse( code = 400, message = "Error", response = ApiError.class )
})
public Response getDr_Pubs() {
@ApiResponse( code = 400, message = "Error", response = ApiError.class )
})
public Response getDr_Pubs() {
logger.info( "Entry: GET /dr_pubs");
List<DR_Pub> pubs = dr_pubService.getAllDr_Pubs();
GenericEntity<List<DR_Pub>> list = new GenericEntity<List<DR_Pub>>(pubs) {
};
logger.info( "Entry: GET /dr_pubs");
List<DR_Pub> pubs = dr_pubService.getAllDr_Pubs();
GenericEntity<List<DR_Pub>> list = new GenericEntity<List<DR_Pub>>(pubs) {
};
@ApiResponse( code = 200, message = "Success", response = DR_Pub.class),
@ApiResponse( code = 400, message = "Error", response = ApiError.class )
})
@ApiResponse( code = 200, message = "Success", response = DR_Pub.class),
@ApiResponse( code = 400, message = "Error", response = ApiError.class )
})
}
// if we found a FeedName instead of a FeedId then try to look it up.
List<Feed> nfeeds = feeds.getAllFeeds( pub.getFeedName(), pub.getFeedVersion(), "equals");
if ( nfeeds.size() != 1 ) {
logger.debug( "Attempt to match "+ pub.getFeedName() + " ver="+pub.getFeedVersion() + " matched " + nfeeds.size() );
}
// if we found a FeedName instead of a FeedId then try to look it up.
List<Feed> nfeeds = feeds.getAllFeeds( pub.getFeedName(), pub.getFeedVersion(), "equals");
if ( nfeeds.size() != 1 ) {
logger.debug( "Attempt to match "+ pub.getFeedName() + " ver="+pub.getFeedVersion() + " matched " + nfeeds.size() );
- DR_Pub pnew = dr_pubService.getDr_Pub(pub.getPubId(), resp.getErr());
- return resp.success(Status.CREATED.getStatusCode(), pnew);
+ DR_Pub pnew = dr_pubService.getDr_Pub(pub.getPubId(), apiError);
+ return responseBuilder.success(Status.CREATED.getStatusCode(), pnew);
- public Response updateDr_Pub(
- @PathParam("pubId") String name,
- DR_Pub pub
- ) {
- ApiService resp = new ApiService();
-
+ public Response updateDr_Pub(@PathParam("pubId") String name, DR_Pub pub) {
- DR_Pub pub = dr_pubService.getDr_Pub( id, resp.getErr() );
- if ( ! resp.getErr().is2xx()) {
- return resp.error();
+ DR_Pub pub = dr_pubService.getDr_Pub(id, apiError);
+ if ( !apiError.is2xx()) {
+ return responseBuilder.error(apiError);
- resp.setCode(Status.BAD_REQUEST.getStatusCode());
- resp.setMessage( "Can't delete the last publisher of a feed");
- return resp.error();
+ apiError.setCode(Status.BAD_REQUEST.getStatusCode());
+ apiError.setMessage( "Can't delete the last publisher of a feed");
+ return responseBuilder.error(apiError);
- fnew = feeds.updateFeed( fnew, resp.getErr() );
- if ( ! resp.getErr().is2xx()) {
- return resp.error();
+ fnew = feeds.updateFeed(fnew,apiError);
+ if (!apiError.is2xx()) {
+ return responseBuilder.error(apiError);
- dr_pubService.removeDr_Pub(id, resp.getErr() );
- if ( ! resp.getErr().is2xx()) {
- return resp.error();
+ dr_pubService.removeDr_Pub(id, apiError);
+ if (!apiError.is2xx()) {
+ return responseBuilder.error(apiError);
- DR_Pub pub = dr_pubService.getDr_Pub( id, resp.getErr() );
- if ( ! resp.getErr().is2xx()) {
- resp.getErr();
+ DR_Pub pub = dr_pubService.getDr_Pub(id, apiError);
+ if (!apiError.is2xx()) {
+ return responseBuilder.error(apiError);