summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorpkaras <piotr.karas@nokia.com>2019-03-26 11:20:25 +0100
committerpkaras <piotr.karas@nokia.com>2019-04-05 14:01:08 +0200
commitea44032b89d04201924f7ca1551cb33ed49b947e (patch)
tree94c7e82da17304be587711afb6f8b67c376657b3 /src
parentad7fb12850f0c9b17e32c9904f63e83ae5ee6264 (diff)
ApiService used only in AuthorizationFilter
Change-Id: If73418eaae8513611c58d945f2d39c35aa6b373d Issue-ID: DMAAP-1129 Signed-off-by: piotr.karas <piotr.karas@nokia.com>
Diffstat (limited to 'src')
-rw-r--r--src/main/java/org/onap/dmaap/dbcapi/resources/DR_NodeResource.java54
-rw-r--r--src/main/java/org/onap/dmaap/dbcapi/resources/DR_PubResource.java72
-rw-r--r--src/main/java/org/onap/dmaap/dbcapi/resources/DR_SubResource.java72
-rw-r--r--src/main/java/org/onap/dmaap/dbcapi/resources/FeedResource.java65
-rw-r--r--src/main/java/org/onap/dmaap/dbcapi/resources/MR_ClientResource.java81
-rw-r--r--src/main/java/org/onap/dmaap/dbcapi/resources/MR_ClusterResource.java43
-rw-r--r--src/main/java/org/onap/dmaap/dbcapi/resources/TopicResource.java48
-rw-r--r--src/main/java/org/onap/dmaap/dbcapi/service/ApiService.java19
8 files changed, 188 insertions, 266 deletions
diff --git a/src/main/java/org/onap/dmaap/dbcapi/resources/DR_NodeResource.java b/src/main/java/org/onap/dmaap/dbcapi/resources/DR_NodeResource.java
index d29f353..f001136 100644
--- a/src/main/java/org/onap/dmaap/dbcapi/resources/DR_NodeResource.java
+++ b/src/main/java/org/onap/dmaap/dbcapi/resources/DR_NodeResource.java
@@ -42,7 +42,6 @@ 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_Node;
-import org.onap.dmaap.dbcapi.service.ApiService;
import org.onap.dmaap.dbcapi.service.DR_NodeService;
import static javax.ws.rs.core.Response.Status.BAD_REQUEST;
@@ -83,10 +82,9 @@ public class DR_NodeResource extends BaseLoggingClass {
@ApiResponse( code = 200, message = "Success", response = DR_Node.class),
@ApiResponse( code = 400, message = "Error", response = ApiError.class )
})
- public Response addDr_Node(
- DR_Node node
- ) {
- ApiService resp = new ApiService();
+ public Response addDr_Node(DR_Node node) {
+
+ ApiError apiError = new ApiError();
try {
checker.required( "dcaeLocation", node.getDcaeLocationName());
@@ -95,11 +93,11 @@ public class DR_NodeResource extends BaseLoggingClass {
return responseBuilder.error(new ApiError(BAD_REQUEST.getStatusCode(),
"missing required field", "dcaeLocation, fqdn"));
}
- DR_Node nNode = dr_nodeService.addDr_Node(node, resp.getErr());
- if ( resp.getErr().is2xx()) {
+ DR_Node nNode = dr_nodeService.addDr_Node(node, apiError);
+ if (apiError.is2xx()) {
return responseBuilder.success(nNode);
}
- return responseBuilder.error(resp.getErr());
+ return responseBuilder.error(apiError);
}
@PUT
@@ -111,11 +109,9 @@ public class DR_NodeResource extends BaseLoggingClass {
@ApiResponse( code = 400, message = "Error", response = ApiError.class )
})
@Path("/{fqdn}")
- public Response updateDr_Node(
- @PathParam("fqdn") String name,
- DR_Node node
- ) {
- ApiService resp = new ApiService();
+ public Response updateDr_Node(@PathParam("fqdn") String name, DR_Node node) {
+
+ ApiError apiError = new ApiError();
try {
checker.required( "dcaeLocation", node.getDcaeLocationName());
@@ -125,11 +121,11 @@ public class DR_NodeResource extends BaseLoggingClass {
"missing required field", "dcaeLocation, fqdn"));
}
node.setFqdn(name);
- DR_Node nNode = dr_nodeService.updateDr_Node(node, resp.getErr());
- if ( resp.getErr().is2xx()) {
+ DR_Node nNode = dr_nodeService.updateDr_Node(node, apiError);
+ if (apiError.is2xx()) {
return responseBuilder.success(nNode);
}
- return responseBuilder.error(resp.getErr());
+ return responseBuilder.error(apiError);
}
@DELETE
@@ -142,15 +138,16 @@ public class DR_NodeResource extends BaseLoggingClass {
})
@Path("/{fqdn}")
public Response deleteDr_Node(
- @PathParam("fqdn") String name
- ){
- ApiService resp = new ApiService();
+ @PathParam("fqdn") String name){
+
- dr_nodeService.removeDr_Node(name, resp.getErr());
- if ( resp.getErr().is2xx() ) {
+ ApiError apiError = new ApiError();
+
+ dr_nodeService.removeDr_Node(name, apiError);
+ if (apiError.is2xx()) {
return responseBuilder.success(NO_CONTENT.getStatusCode(), null);
}
- return responseBuilder.error(resp.getErr());
+ return responseBuilder.error(apiError);
}
@GET
@@ -162,15 +159,14 @@ public class DR_NodeResource extends BaseLoggingClass {
@ApiResponse( code = 400, message = "Error", response = ApiError.class )
})
@Path("/{fqdn}")
- public Response get(
- @PathParam("fqdn") String name
- ) {
- ApiService resp = new ApiService();
+ public Response get(@PathParam("fqdn") String name) {
+
+ ApiError apiError = new ApiError();
- DR_Node nNode = dr_nodeService.getDr_Node( name, resp.getErr() );
- if ( resp.getErr().is2xx() ) {
+ DR_Node nNode = dr_nodeService.getDr_Node( name, apiError );
+ if (apiError.is2xx()) {
return responseBuilder.success(nNode);
}
- return responseBuilder.error(resp.getErr());
+ return responseBuilder.error(apiError);
}
}
diff --git a/src/main/java/org/onap/dmaap/dbcapi/resources/DR_PubResource.java b/src/main/java/org/onap/dmaap/dbcapi/resources/DR_PubResource.java
index 1054b03..928a7e2 100644
--- a/src/main/java/org/onap/dmaap/dbcapi/resources/DR_PubResource.java
+++ b/src/main/java/org/onap/dmaap/dbcapi/resources/DR_PubResource.java
@@ -46,7 +46,6 @@ 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.Feed;
-import org.onap.dmaap.dbcapi.service.ApiService;
import org.onap.dmaap.dbcapi.service.DR_PubService;
import org.onap.dmaap.dbcapi.service.FeedService;
@@ -87,10 +86,8 @@ public class DR_PubResource extends BaseLoggingClass {
@ApiResponse( code = 200, message = "Success", response = DR_Pub.class),
@ApiResponse( code = 400, message = "Error", response = ApiError.class )
})
- public Response addDr_Pub(
- DR_Pub pub
- ) {
- ApiService resp = new ApiService();
+ public Response addDr_Pub(DR_Pub pub) {
+ ApiError apiError = new ApiError();
FeedService feeds = new FeedService();
Feed fnew = null;
@@ -109,7 +106,7 @@ public class DR_PubResource extends BaseLoggingClass {
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() );
- return responseBuilder.error(resp.getErr());
+ return responseBuilder.error(apiError);
}
fnew = nfeeds.get(0);
}
@@ -123,11 +120,11 @@ public class DR_PubResource extends BaseLoggingClass {
// we may have fnew already if located by FeedName
if ( fnew == null ) {
- fnew = feeds.getFeed( pub.getFeedId(), resp.getErr() );
+ fnew = feeds.getFeed(pub.getFeedId(), apiError);
}
if ( fnew == null ) {
logger.info( "Specified feed " + pub.getFeedId() + " or " + pub.getFeedName() + " not known to Bus Controller");
- return responseBuilder.error(resp.getErr());
+ return responseBuilder.error(apiError);
}
ArrayList<DR_Pub> pubs = fnew.getPubs();
@@ -143,15 +140,15 @@ public class DR_PubResource extends BaseLoggingClass {
}
pubs.add( pub );
fnew.setPubs(pubs);
- fnew = feeds.updateFeed( fnew, resp.getErr() );
+ fnew = feeds.updateFeed(fnew, apiError);
- if ( ! resp.getErr().is2xx()) {
- return responseBuilder.error(resp.getErr());
+ if (!apiError.is2xx()) {
+ return responseBuilder.error(apiError);
}
pubs = fnew.getPubs();
logger.info( "num existing pubs after = " + pubs.size() );
- DR_Pub pnew = dr_pubService.getDr_Pub(pub.getPubId(), resp.getErr());
+ DR_Pub pnew = dr_pubService.getDr_Pub(pub.getPubId(), apiError);
return responseBuilder.success(Status.CREATED.getStatusCode(), pnew);
}
@@ -164,10 +161,7 @@ public class DR_PubResource extends BaseLoggingClass {
@ApiResponse( code = 400, message = "Error", response = ApiError.class )
})
@Path("/{pubId}")
- public Response updateDr_Pub(
- @PathParam("pubId") String name,
- DR_Pub pub
- ) {
+ public Response updateDr_Pub(@PathParam("pubId") String name, DR_Pub pub) {
logger.info( "Entry: PUT /dr_pubs");
pub.setPubId(name);
DR_Pub res = dr_pubService.updateDr_Pub(pub);
@@ -183,11 +177,9 @@ public class DR_PubResource extends BaseLoggingClass {
@ApiResponse( code = 400, message = "Error", response = ApiError.class )
})
@Path("/{pubId}")
- public Response deleteDr_Pub(
- @PathParam("pubId") String id
- ){
+ public Response deleteDr_Pub(@PathParam("pubId") String id){
- ApiService resp = new ApiService();
+ ApiError apiError = new ApiError();
try {
checker.required( "pubId", id);
@@ -195,21 +187,21 @@ public class DR_PubResource extends BaseLoggingClass {
return responseBuilder.error(rfe.getApiError());
}
- DR_Pub pub = dr_pubService.getDr_Pub( id, resp.getErr() );
- if ( ! resp.getErr().is2xx()) {
- return responseBuilder.error(resp.getErr());
+ DR_Pub pub = dr_pubService.getDr_Pub(id, apiError);
+ if ( !apiError.is2xx()) {
+ return responseBuilder.error(apiError);
}
FeedService feeds = new FeedService();
- Feed fnew = feeds.getFeed( pub.getFeedId(), resp.getErr() );
+ Feed fnew = feeds.getFeed(pub.getFeedId(), apiError);
if ( fnew == null ) {
logger.info( "Specified feed " + pub.getFeedId() + " not known to Bus Controller");
- return responseBuilder.error(resp.getErr());
+ return responseBuilder.error(apiError);
}
ArrayList<DR_Pub> pubs = fnew.getPubs();
if ( pubs.size() == 1 ) {
- resp.setCode(Status.BAD_REQUEST.getStatusCode());
- resp.setMessage( "Can't delete the last publisher of a feed");
- return responseBuilder.error(resp.getErr());
+ apiError.setCode(Status.BAD_REQUEST.getStatusCode());
+ apiError.setMessage( "Can't delete the last publisher of a feed");
+ return responseBuilder.error(apiError);
}
for( Iterator<DR_Pub> i = pubs.iterator(); i.hasNext(); ) {
@@ -219,14 +211,14 @@ public class DR_PubResource extends BaseLoggingClass {
}
}
fnew.setPubs(pubs);
- fnew = feeds.updateFeed( fnew, resp.getErr() );
- if ( ! resp.getErr().is2xx()) {
- return responseBuilder.error(resp.getErr());
+ fnew = feeds.updateFeed(fnew,apiError);
+ if (!apiError.is2xx()) {
+ return responseBuilder.error(apiError);
}
- dr_pubService.removeDr_Pub(id, resp.getErr() );
- if ( ! resp.getErr().is2xx()) {
- return responseBuilder.error(resp.getErr());
+ dr_pubService.removeDr_Pub(id, apiError);
+ if (!apiError.is2xx()) {
+ return responseBuilder.error(apiError);
}
return responseBuilder.success(Status.NO_CONTENT.getStatusCode(), null);
}
@@ -240,10 +232,8 @@ public class DR_PubResource extends BaseLoggingClass {
@ApiResponse( code = 400, message = "Error", response = ApiError.class )
})
@Path("/{pubId}")
- public Response get(
- @PathParam("pubId") String id
- ) {
- ApiService resp = new ApiService();
+ public Response get(@PathParam("pubId") String id) {
+ ApiError apiError = new ApiError();
try {
checker.required( "feedId", id);
@@ -251,9 +241,9 @@ public class DR_PubResource extends BaseLoggingClass {
return responseBuilder.error(rfe.getApiError());
}
- 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);
}
return responseBuilder.success(Status.OK.getStatusCode(), pub);
}
diff --git a/src/main/java/org/onap/dmaap/dbcapi/resources/DR_SubResource.java b/src/main/java/org/onap/dmaap/dbcapi/resources/DR_SubResource.java
index d5a96de..2fa6ccd 100644
--- a/src/main/java/org/onap/dmaap/dbcapi/resources/DR_SubResource.java
+++ b/src/main/java/org/onap/dmaap/dbcapi/resources/DR_SubResource.java
@@ -24,7 +24,6 @@ package org.onap.dmaap.dbcapi.resources;
import com.google.common.collect.Iterables;
import java.util.ArrayList;
-import java.util.Collections;
import java.util.List;
import javax.ws.rs.Consumes;
@@ -44,7 +43,6 @@ import org.onap.dmaap.dbcapi.logging.BaseLoggingClass;
import org.onap.dmaap.dbcapi.model.ApiError;
import org.onap.dmaap.dbcapi.model.DR_Sub;
import org.onap.dmaap.dbcapi.model.Feed;
-import org.onap.dmaap.dbcapi.service.ApiService;
import org.onap.dmaap.dbcapi.service.DR_SubService;
import org.onap.dmaap.dbcapi.service.FeedService;
@@ -91,11 +89,9 @@ public class DR_SubResource extends BaseLoggingClass {
@ApiResponse( code = 200, message = "Success", response = DR_Sub.class),
@ApiResponse( code = 400, message = "Error", response = ApiError.class )
})
- public Response addDr_Sub(
- DR_Sub sub
- ) {
-
- ApiService resp = new ApiService();
+ public Response addDr_Sub(DR_Sub sub) {
+
+ ApiError apiError = new ApiError();
FeedService feeds = new FeedService();
Feed fnew = null;
try {
@@ -110,14 +106,14 @@ public class DR_SubResource extends BaseLoggingClass {
// if we found a FeedName instead of a FeedId then try to look it up.
List<Feed> nfeeds = feeds.getAllFeeds( sub.getFeedName(), sub.getFeedVersion(), "equals");
if ( nfeeds.isEmpty() ) {
- resp.setCode(Status.NOT_FOUND.getStatusCode());
- resp.setFields("feedName");
- return responseBuilder.error(resp.getErr());
+ apiError.setCode(Status.NOT_FOUND.getStatusCode());
+ apiError.setFields("feedName");
+ return responseBuilder.error(apiError);
} else if (nfeeds.size() > 1) {
logger.debug( "Attempt to match "+ sub.getFeedName() + " ver="+sub.getFeedVersion() + " matched " + nfeeds.size() );
- resp.setCode(Status.CONFLICT.getStatusCode());
- resp.setFields("feedName");
- return responseBuilder.error(resp.getErr());
+ apiError.setCode(Status.CONFLICT.getStatusCode());
+ apiError.setFields("feedName");
+ return responseBuilder.error(apiError);
}
fnew = Iterables.getOnlyElement(nfeeds);
}
@@ -130,19 +126,19 @@ public class DR_SubResource extends BaseLoggingClass {
}
// we may have fnew already if located by FeedName
if ( fnew == null ) {
- fnew = feeds.getFeed( sub.getFeedId(), resp.getErr() );
+ fnew = feeds.getFeed( sub.getFeedId(), apiError);
}
if ( fnew == null ) {
logger.warn( "Specified feed " + sub.getFeedId() + " or " + sub.getFeedName() + " not known to Bus Controller");
- resp.setCode(Status.NOT_FOUND.getStatusCode());
- return responseBuilder.error(resp.getErr());
+ apiError.setCode(Status.NOT_FOUND.getStatusCode());
+ return responseBuilder.error(apiError);
}
DR_SubService dr_subService = new DR_SubService( fnew.getSubscribeURL());
ArrayList<DR_Sub> subs = fnew.getSubs();
logger.info( "num existing subs before = " + subs.size() );
- DR_Sub snew = dr_subService.addDr_Sub(sub, resp.getErr() );
- if ( ! resp.getErr().is2xx() ) {
- return responseBuilder.error(resp.getErr());
+ DR_Sub snew = dr_subService.addDr_Sub(sub, apiError);
+ if (!apiError.is2xx()) {
+ return responseBuilder.error(apiError);
}
subs.add( snew );
logger.info( "num existing subs after = " + subs.size() );
@@ -162,12 +158,9 @@ public class DR_SubResource extends BaseLoggingClass {
@ApiResponse( code = 400, message = "Error", response = ApiError.class )
})
@Path("/{subId}")
- public Response updateDr_Sub(
- @PathParam("subId") String name,
- DR_Sub sub
- ) {
+ public Response updateDr_Sub(@PathParam("subId") String name, DR_Sub sub) {
- ApiService resp = new ApiService();
+ ApiError apiError = new ApiError();
try {
checker.required( "subId", name);
@@ -179,19 +172,19 @@ public class DR_SubResource extends BaseLoggingClass {
return responseBuilder.error(rfe.getApiError());
}
FeedService feeds = new FeedService();
- Feed fnew = feeds.getFeed( sub.getFeedId(), resp.getErr() );
+ Feed fnew = feeds.getFeed(sub.getFeedId(), apiError);
if ( fnew == null ) {
logger.warn( "Specified feed " + sub.getFeedId() + " not known to Bus Controller");
- return responseBuilder.error(resp.getErr());
+ return responseBuilder.error(apiError);
}
DR_SubService dr_subService = new DR_SubService();
sub.setSubId(name);
- DR_Sub nsub = dr_subService.updateDr_Sub(sub, resp.getErr() );
+ DR_Sub nsub = dr_subService.updateDr_Sub(sub, apiError);
if ( nsub != null && nsub.isStatusValid() ) {
return responseBuilder.success(nsub);
}
- return responseBuilder.error(resp.getErr());
+ return responseBuilder.error(apiError);
}
@DELETE
@@ -203,11 +196,9 @@ public class DR_SubResource extends BaseLoggingClass {
@ApiResponse( code = 400, message = "Error", response = ApiError.class )
})
@Path("/{subId}")
- public Response deleteDr_Sub(
- @PathParam("subId") String id
- ){
+ public Response deleteDr_Sub(@PathParam("subId") String id){
- ApiService resp = new ApiService();
+ ApiError apiError = new ApiError();
try {
checker.required( "subId", id);
@@ -216,9 +207,9 @@ public class DR_SubResource extends BaseLoggingClass {
return responseBuilder.error(rfe.getApiError());
}
DR_SubService dr_subService = new DR_SubService();
- dr_subService.removeDr_Sub(id, resp.getErr() );
- if ( ! resp.getErr().is2xx() ) {
- return responseBuilder.error(resp.getErr());
+ dr_subService.removeDr_Sub(id, apiError);
+ if (!apiError.is2xx() ) {
+ return responseBuilder.error(apiError);
}
return responseBuilder.success(Status.NO_CONTENT.getStatusCode(), null );
}
@@ -232,10 +223,9 @@ public class DR_SubResource extends BaseLoggingClass {
@ApiResponse( code = 400, message = "Error", response = ApiError.class )
})
@Path("/{subId}")
- public Response get(
- @PathParam("subId") String id
- ) {
- ApiService resp = new ApiService();
+ public Response get(@PathParam("subId") String id) {
+
+ ApiError apiError = new ApiError();
try {
checker.required( "subId", id);
@@ -244,10 +234,10 @@ public class DR_SubResource extends BaseLoggingClass {
return responseBuilder.error(rfe.getApiError());
}
DR_SubService dr_subService = new DR_SubService();
- DR_Sub sub = dr_subService.getDr_Sub( id, resp.getErr() );
+ DR_Sub sub = dr_subService.getDr_Sub(id, apiError);
if ( sub != null && sub.isStatusValid() ) {
return responseBuilder.success(sub);
}
- return responseBuilder.error(resp.getErr());
+ return responseBuilder.error(apiError);
}
}
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 6df135d..6589c0d 100644
--- a/src/main/java/org/onap/dmaap/dbcapi/resources/FeedResource.java
+++ b/src/main/java/org/onap/dmaap/dbcapi/resources/FeedResource.java
@@ -46,7 +46,6 @@ 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.DmaapObject.DmaapObject_Status;
-import org.onap.dmaap.dbcapi.service.ApiService;
import org.onap.dmaap.dbcapi.service.FeedService;
@@ -94,7 +93,7 @@ public class FeedResource extends BaseLoggingClass {
@WebParam(name = "feed") Feed feed,
@QueryParam("useExisting") String useExisting) {
- ApiService resp = new ApiService();
+ ApiError apiError = new ApiError();
try {
checker.required( "feedName", feed.getFeedName());
@@ -108,32 +107,32 @@ public class FeedResource extends BaseLoggingClass {
FeedService feedService = new FeedService();
- Feed nfeed = feedService.getFeedByName( feed.getFeedName(), feed.getFeedVersion(), resp.getErr() );
+ Feed nfeed = feedService.getFeedByName( feed.getFeedName(), feed.getFeedVersion(), apiError);
if ( nfeed == null ) {
- nfeed = feedService.addFeed( feed, resp.getErr() );
+ nfeed = feedService.addFeed(feed, apiError);
if ( nfeed != null ) {
return responseBuilder.success(nfeed);
} else {
logger.error( "Unable to create: " + feed.getFeedName() + ":" + feed.getFeedVersion());
- return responseBuilder.error(resp.getErr());
+ return responseBuilder.error(apiError);
}
} else if ( nfeed.getStatus() == DmaapObject_Status.DELETED ) {
feed.setFeedId( nfeed.getFeedId());
- nfeed = feedService.updateFeed(feed, resp.getErr());
+ nfeed = feedService.updateFeed(feed, apiError);
if ( nfeed != null ) {
return responseBuilder.success(nfeed);
} else {
logger.info( "Unable to update: " + feed.getFeedName() + ":" + feed.getFeedVersion());
- return responseBuilder.error(resp.getErr());
+ return responseBuilder.error(apiError);
}
} else if ( (useExisting != null) && ("true".compareToIgnoreCase( useExisting ) == 0)) {
return responseBuilder.success(nfeed);
}
- resp.setCode(Status.CONFLICT.getStatusCode());
- return responseBuilder.error(resp.getErr());
+ apiError.setCode(Status.CONFLICT.getStatusCode());
+ return responseBuilder.error(apiError);
}
@PUT
@@ -150,7 +149,7 @@ public class FeedResource extends BaseLoggingClass {
@WebParam(name = "feed") Feed feed) {
FeedService feedService = new FeedService();
- ApiService resp = new ApiService();
+ ApiError apiError = new ApiError();
try {
checker.required( "feedId", id);
@@ -159,7 +158,7 @@ public class FeedResource extends BaseLoggingClass {
return responseBuilder.error(rfe.getApiError());
}
- Feed nfeed = feedService.getFeed( id, resp.getErr() );
+ Feed nfeed = feedService.getFeed(id, apiError);
if ( nfeed == null || nfeed.getStatus() == DmaapObject_Status.DELETED ) {
return responseBuilder.notFound();
}
@@ -170,13 +169,13 @@ public class FeedResource extends BaseLoggingClass {
nfeed.setFeedDescription(feed.getFeedDescription());
nfeed.setFormatUuid(feed.getFormatUuid());
- nfeed = feedService.updateFeed(nfeed, resp.getErr());
+ nfeed = feedService.updateFeed(nfeed, apiError);
if ( nfeed != null ) {
return responseBuilder.success(nfeed);
} else {
logger.info( "Unable to update: " + feed.getFeedName() + ":" + feed.getFeedVersion());
- return responseBuilder.error(resp.getErr());
+ return responseBuilder.error(apiError);
}
}
@@ -189,25 +188,23 @@ public class FeedResource extends BaseLoggingClass {
@ApiResponse( code = 400, message = "Error", response = ApiError.class )
})
@Path("/{id}")
- public Response deleteFeed(
- @PathParam("id") String id
- ){
- ApiService resp = new ApiService();
+ public Response deleteFeed(@PathParam("id") String id){
+ ApiError apiError = new ApiError();
logger.debug( "Entry: DELETE " + id);
FeedService feedService = new FeedService();
- Feed nfeed = feedService.getFeed( id, resp.getErr() );
+ Feed nfeed = feedService.getFeed(id, apiError);
if ( nfeed == null ) {
- resp.setCode(Status.NOT_FOUND.getStatusCode());
- return responseBuilder.error(resp.getErr());
+ apiError.setCode(Status.NOT_FOUND.getStatusCode());
+ return responseBuilder.error(apiError);
}
- nfeed = feedService.removeFeed( nfeed, resp.getErr() );
+ nfeed = feedService.removeFeed(nfeed, apiError);
if ( nfeed == null || nfeed.getStatus() == DmaapObject_Status.DELETED ) {
return responseBuilder.success(Status.NO_CONTENT.getStatusCode(), null);
}
logger.info( "Unable to delete: " + id + ":" + nfeed.getFeedVersion());
- return responseBuilder.error(resp.getErr());
+ return responseBuilder.error(apiError);
}
@GET
@@ -219,16 +216,14 @@ public class FeedResource extends BaseLoggingClass {
@ApiResponse( code = 400, message = "Error", response = ApiError.class )
})
@Path("/{id}")
- public Response getFeed(
- @PathParam("id") String id
- ) {
- ApiService resp = new ApiService();
+ public Response getFeed(@PathParam("id") String id) {
+ ApiError apiError = new ApiError();
FeedService feedService = new FeedService();
- Feed nfeed = feedService.getFeed( id, resp.getErr() );
+ Feed nfeed = feedService.getFeed(id, apiError);
if ( nfeed == null ) {
- resp.setCode(Status.NOT_FOUND.getStatusCode());
- return responseBuilder.error(resp.getErr());
+ apiError.setCode(Status.NOT_FOUND.getStatusCode());
+ return responseBuilder.error(apiError);
}
return responseBuilder.success(nfeed);
}
@@ -244,24 +239,22 @@ public class FeedResource extends BaseLoggingClass {
@ApiResponse( code = 400, message = "Error", response = ApiError.class )
})
@Path( "/sync")
- public Response syncFeeds (
- @QueryParam("hard") String hardParam
- ) {
- ApiService resp = new ApiService();
+ public Response syncFeeds (@QueryParam("hard") String hardParam) {
+ ApiError error = new ApiError();
FeedService feedService = new FeedService();
boolean hard = false;
if ( hardParam != null && hardParam.equalsIgnoreCase("true")) {
hard = true;
}
- feedService.sync( hard, resp.getErr() );
- if ( resp.getErr().is2xx()) {
+ feedService.sync( hard, error );
+ if ( error.is2xx()) {
List<Feed> nfeeds = feedService.getAllFeeds();
GenericEntity<List<Feed>> list = new GenericEntity<List<Feed>>(nfeeds) {
};
return responseBuilder.success(list);
}
- return responseBuilder.error(resp.getErr());
+ return responseBuilder.error(error);
}
}
diff --git a/src/main/java/org/onap/dmaap/dbcapi/resources/MR_ClientResource.java b/src/main/java/org/onap/dmaap/dbcapi/resources/MR_ClientResource.java
index a65007d..6df8ef6 100644
--- a/src/main/java/org/onap/dmaap/dbcapi/resources/MR_ClientResource.java
+++ b/src/main/java/org/onap/dmaap/dbcapi/resources/MR_ClientResource.java
@@ -45,7 +45,6 @@ import org.onap.dmaap.dbcapi.model.ApiError;
import org.onap.dmaap.dbcapi.model.MR_Client;
import org.onap.dmaap.dbcapi.model.MR_Cluster;
import org.onap.dmaap.dbcapi.model.Topic;
-import org.onap.dmaap.dbcapi.service.ApiService;
import org.onap.dmaap.dbcapi.service.MR_ClientService;
import org.onap.dmaap.dbcapi.service.MR_ClusterService;
import org.onap.dmaap.dbcapi.service.TopicService;
@@ -91,9 +90,8 @@ public class MR_ClientResource extends BaseLoggingClass {
@ApiResponse( code = 200, message = "Success", response = MR_Client.class),
@ApiResponse( code = 400, message = "Error", response = ApiError.class )
})
- public Response addMr_Client(
- MR_Client client) {
- ApiService resp = new ApiService();
+ public Response addMr_Client(MR_Client client) {
+ ApiError apiError = new ApiError();
try {
checker.required( "fqtn", client.getFqtn());
@@ -111,38 +109,38 @@ public class MR_ClientResource extends BaseLoggingClass {
}
MR_ClusterService clusters = new MR_ClusterService();
- MR_Cluster cluster = clusters.getMr_Cluster(client.getDcaeLocationName(), resp.getErr());
+ MR_Cluster cluster = clusters.getMr_Cluster(client.getDcaeLocationName(), apiError);
if ( cluster == null ) {
- resp.setCode(Status.BAD_REQUEST.getStatusCode());
- resp.setMessage( "MR_Cluster alias not found for dcaeLocation: " + client.getDcaeLocationName());
- resp.setFields("dcaeLocationName");
- logger.warn( resp.toString() );
- return responseBuilder.error(resp.getErr());
+ apiError.setCode(Status.BAD_REQUEST.getStatusCode());
+ apiError.setMessage( "MR_Cluster alias not found for dcaeLocation: " + client.getDcaeLocationName());
+ apiError.setFields("dcaeLocationName");
+ logger.warn(apiError.toString());
+ return responseBuilder.error(apiError);
}
String url = cluster.getFqdn();
if ( url == null || url.isEmpty() ) {
- resp.setCode(Status.BAD_REQUEST.getStatusCode());
- resp.setMessage("FQDN not set for dcaeLocation " + client.getDcaeLocationName() );
- resp.setFields("fqdn");
- logger.warn( resp.toString() );
- return responseBuilder.error(resp.getErr());
+ apiError.setCode(Status.BAD_REQUEST.getStatusCode());
+ apiError.setMessage("FQDN not set for dcaeLocation " + client.getDcaeLocationName() );
+ apiError.setFields("fqdn");
+ logger.warn(apiError.toString());
+ return responseBuilder.error(apiError);
}
TopicService topics = new TopicService();
- Topic t = topics.getTopic(client.getFqtn(), resp.getErr() );
+ Topic t = topics.getTopic(client.getFqtn(), apiError);
if ( t == null ) {
- return responseBuilder.error(resp.getErr());
+ return responseBuilder.error(apiError);
}
- MR_Client nClient = mr_clientService.addMr_Client(client, t, resp.getErr());
- if ( resp.getErr().is2xx()) {
- t = topics.getTopic(client.getFqtn(), resp.getErr());
- topics.checkForBridge(t, resp.getErr());
+ MR_Client nClient = mr_clientService.addMr_Client(client, t, apiError);
+ if (apiError.is2xx()) {
+ t = topics.getTopic(client.getFqtn(), apiError);
+ topics.checkForBridge(t, apiError);
return responseBuilder.success(nClient);
}
else {
- return responseBuilder.error(resp.getErr());
+ return responseBuilder.error(apiError);
}
}
@@ -155,11 +153,8 @@ public class MR_ClientResource extends BaseLoggingClass {
@ApiResponse( code = 400, message = "Error", response = ApiError.class )
})
@Path("/{clientId}")
- public Response updateMr_Client(
- @PathParam("clientId") String clientId,
- MR_Client client
- ) {
- ApiService resp = new ApiService();
+ public Response updateMr_Client(@PathParam("clientId") String clientId, MR_Client client) {
+ ApiError apiError = new ApiError();
try {
checker.required( "fqtn", client.getFqtn());
@@ -172,13 +167,13 @@ public class MR_ClientResource extends BaseLoggingClass {
return responseBuilder.error(rfe.getApiError());
}
client.setMrClientId(clientId);
- MR_Client nClient = mr_clientService.updateMr_Client(client, resp.getErr() );
- if ( resp.getErr().is2xx()) {
+ MR_Client nClient = mr_clientService.updateMr_Client(client, apiError);
+ if (apiError.is2xx()) {
return Response.ok(nClient)
.build();
}
- return Response.status(resp.getErr().getCode())
- .entity( resp.getErr() )
+ return Response.status(apiError.getCode())
+ .entity(apiError)
.build();
}
@@ -191,10 +186,8 @@ public class MR_ClientResource extends BaseLoggingClass {
@ApiResponse( code = 400, message = "Error", response = ApiError.class )
})
@Path("/{subId}")
- public Response deleteMr_Client(
- @PathParam("subId") String id
- ){
- ApiService resp = new ApiService();
+ public Response deleteMr_Client(@PathParam("subId") String id){
+ ApiError apiError = new ApiError();
try {
checker.required( "clientId", id);
@@ -202,12 +195,12 @@ public class MR_ClientResource extends BaseLoggingClass {
logger.debug( rfe.getApiError().toString() );
return responseBuilder.error(rfe.getApiError());
}
- mr_clientService.removeMr_Client(id, true, resp.getErr() );
- if ( resp.getErr().is2xx()) {
+ mr_clientService.removeMr_Client(id, true, apiError);
+ if (apiError.is2xx()) {
return responseBuilder.success(NO_CONTENT.getStatusCode(), null);
}
- return responseBuilder.error(resp.getErr());
+ return responseBuilder.error(apiError);
}
@GET
@@ -219,10 +212,8 @@ public class MR_ClientResource extends BaseLoggingClass {
@ApiResponse( code = 400, message = "Error", response = ApiError.class )
})
@Path("/{subId}")
- public Response test(
- @PathParam("subId") String id
- ) {
- ApiService resp = new ApiService();
+ public Response test(@PathParam("subId") String id) {
+ ApiError apiError = new ApiError();
try {
checker.required( "clientId", id);
@@ -230,10 +221,10 @@ public class MR_ClientResource extends BaseLoggingClass {
logger.debug( rfe.getApiError().toString() );
return responseBuilder.error(rfe.getApiError());
}
- MR_Client nClient = mr_clientService.getMr_Client( id, resp.getErr() );
- if ( resp.getErr().is2xx()) {
+ MR_Client nClient = mr_clientService.getMr_Client(id, apiError);
+ if (apiError.is2xx()) {
return responseBuilder.success(nClient);
}
- return responseBuilder.error(resp.getErr());
+ return responseBuilder.error(apiError);
}
}
diff --git a/src/main/java/org/onap/dmaap/dbcapi/resources/MR_ClusterResource.java b/src/main/java/org/onap/dmaap/dbcapi/resources/MR_ClusterResource.java
index 598fcc2..0a361ff 100644
--- a/src/main/java/org/onap/dmaap/dbcapi/resources/MR_ClusterResource.java
+++ b/src/main/java/org/onap/dmaap/dbcapi/resources/MR_ClusterResource.java
@@ -43,7 +43,6 @@ import javax.ws.rs.core.Response.Status;
import org.onap.dmaap.dbcapi.logging.BaseLoggingClass;
import org.onap.dmaap.dbcapi.model.ApiError;
import org.onap.dmaap.dbcapi.model.MR_Cluster;
-import org.onap.dmaap.dbcapi.service.ApiService;
import org.onap.dmaap.dbcapi.service.MR_ClusterService;
@@ -82,9 +81,8 @@ public class MR_ClusterResource extends BaseLoggingClass {
@ApiResponse( code = 200, message = "Success", response = MR_Cluster.class),
@ApiResponse( code = 400, message = "Error", response = ApiError.class )
})
- public Response addMr_Cluster(
- MR_Cluster cluster) {
- ApiService resp = new ApiService();
+ public Response addMr_Cluster(MR_Cluster cluster) {
+ ApiError apiError = new ApiError();
try {
checker.required( "dcaeLocationName", cluster.getDcaeLocationName());
@@ -92,11 +90,11 @@ public class MR_ClusterResource extends BaseLoggingClass {
} catch( RequiredFieldException rfe ) {
return responseBuilder.error(rfe.getApiError());
}
- MR_Cluster mrc = mr_clusterService.addMr_Cluster(cluster, resp.getErr() );
+ MR_Cluster mrc = mr_clusterService.addMr_Cluster(cluster, apiError);
if ( mrc != null && mrc.isStatusValid() ) {
return responseBuilder.success(Status.CREATED.getStatusCode(), mrc);
}
- return responseBuilder.error(resp.getErr());
+ return responseBuilder.error(apiError);
}
@@ -109,11 +107,8 @@ public class MR_ClusterResource extends BaseLoggingClass {
@ApiResponse( code = 400, message = "Error", response = ApiError.class )
})
@Path("/{clusterId}")
- public Response updateMr_Cluster(
- @PathParam("clusterId") String clusterId,
- MR_Cluster cluster
- ) {
- ApiService resp = new ApiService();
+ public Response updateMr_Cluster(@PathParam("clusterId") String clusterId, MR_Cluster cluster) {
+ ApiError apiError = new ApiError();
try {
checker.required( "fqdn", clusterId);
@@ -122,11 +117,11 @@ public class MR_ClusterResource extends BaseLoggingClass {
return responseBuilder.error(rfe.getApiError());
}
cluster.setDcaeLocationName(clusterId);
- MR_Cluster mrc = mr_clusterService.updateMr_Cluster(cluster, resp.getErr() );
+ MR_Cluster mrc = mr_clusterService.updateMr_Cluster(cluster, apiError);
if ( mrc != null && mrc.isStatusValid() ) {
return responseBuilder.success(Status.CREATED.getStatusCode(), mrc);
}
- return responseBuilder.error(resp.getErr());
+ return responseBuilder.error(apiError);
}
@DELETE
@@ -138,21 +133,19 @@ public class MR_ClusterResource extends BaseLoggingClass {
@ApiResponse( code = 400, message = "Error", response = ApiError.class )
})
@Path("/{clusterId}")
- public Response deleteMr_Cluster(
- @PathParam("clusterId") String id
- ){
- ApiService resp = new ApiService();
+ public Response deleteMr_Cluster(@PathParam("clusterId") String id){
+ ApiError apiError = new ApiError();
try {
checker.required( "fqdn", id);
} catch( RequiredFieldException rfe ) {
return responseBuilder.error(rfe.getApiError());
}
- mr_clusterService.removeMr_Cluster(id, resp.getErr() );
- if ( resp.getErr().is2xx()) {
+ mr_clusterService.removeMr_Cluster(id, apiError);
+ if (apiError.is2xx()) {
return responseBuilder.success(Status.NO_CONTENT.getStatusCode(), null);
}
- return responseBuilder.error(resp.getErr());
+ return responseBuilder.error(apiError);
}
@GET
@@ -164,20 +157,18 @@ public class MR_ClusterResource extends BaseLoggingClass {
@ApiResponse( code = 400, message = "Error", response = ApiError.class )
})
@Path("/{clusterId}")
- public Response getMR_Cluster(
- @PathParam("clusterId") String id
- ) {
- ApiService resp = new ApiService();
+ public Response getMR_Cluster(@PathParam("clusterId") String id) {
+ ApiError apiError = new ApiError();
try {
checker.required( "dcaeLocationName", id);
} catch( RequiredFieldException rfe ) {
return responseBuilder.error(rfe.getApiError());
}
- MR_Cluster mrc = mr_clusterService.getMr_Cluster( id, resp.getErr() );
+ MR_Cluster mrc = mr_clusterService.getMr_Cluster(id, apiError);
if ( mrc != null && mrc.isStatusValid() ) {
return responseBuilder.success(Status.CREATED.getStatusCode(), mrc);
}
- return responseBuilder.error(resp.getErr());
+ return responseBuilder.error(apiError);
}
}
diff --git a/src/main/java/org/onap/dmaap/dbcapi/resources/TopicResource.java b/src/main/java/org/onap/dmaap/dbcapi/resources/TopicResource.java
index 96b6a4a..3206cf7 100644
--- a/src/main/java/org/onap/dmaap/dbcapi/resources/TopicResource.java
+++ b/src/main/java/org/onap/dmaap/dbcapi/resources/TopicResource.java
@@ -46,7 +46,6 @@ import org.onap.dmaap.dbcapi.model.ApiError;
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;
@@ -102,12 +101,9 @@ public class TopicResource extends BaseLoggingClass {
@ApiResponse( code = 200, message = "Success", response = Topic.class),
@ApiResponse( code = 400, message = "Error", response = ApiError.class )
})
- public Response addTopic(
- Topic topic,
- @QueryParam("useExisting") String useExisting
- ) {
+ public Response addTopic(Topic topic, @QueryParam("useExisting") String useExisting) {
logger.info( "addTopic request: " + topic + " useExisting=" + useExisting );
- ApiService check = new ApiService();
+ ApiError apiError = new ApiError();
try {
checker.required( "topicName", topic.getTopicName(), "^\\S+$" ); //no white space allowed in topicName
@@ -141,11 +137,11 @@ public class TopicResource extends BaseLoggingClass {
flag = "true".compareToIgnoreCase( useExisting ) == 0;
}
- Topic mrc = mr_topicService.addTopic(topic, check.getErr(), flag);
- if ( mrc != null && check.getErr().is2xx() ) {
+ Topic mrc = mr_topicService.addTopic(topic, apiError, flag);
+ if ( mrc != null && apiError.is2xx() ) {
return responseBuilder.success(CREATED.getStatusCode(), mrc);
}
- return responseBuilder.error(check.getErr());
+ return responseBuilder.error(apiError);
}
@PUT
@@ -157,15 +153,13 @@ public class TopicResource extends BaseLoggingClass {
@ApiResponse( code = 400, message = "Error", response = ApiError.class )
})
@Path("/{topicId}")
- public Response updateTopic(
- @PathParam("topicId") String topicId
- ) {
- ApiService check = new ApiService();
+ public Response updateTopic(@PathParam("topicId") String topicId) {
+ ApiError apiError = new ApiError();
- check.setCode(Status.BAD_REQUEST.getStatusCode());
- check.setMessage( "Method /PUT not supported for /topics");
+ apiError.setCode(Status.BAD_REQUEST.getStatusCode());
+ apiError.setMessage( "Method /PUT not supported for /topics");
- return responseBuilder.error(check.getErr());
+ return responseBuilder.error(apiError);
}
@DELETE
@@ -177,10 +171,8 @@ public class TopicResource extends BaseLoggingClass {
@ApiResponse( code = 400, message = "Error", response = ApiError.class )
})
@Path("/{topicId}")
- public Response deleteTopic(
- @PathParam("topicId") String id
- ){
- ApiService check = new ApiService();
+ public Response deleteTopic(@PathParam("topicId") String id){
+ ApiError apiError = new ApiError();
try {
checker.required( "fqtn", id);
@@ -189,11 +181,11 @@ public class TopicResource extends BaseLoggingClass {
return responseBuilder.error(rfe.getApiError());
}
- mr_topicService.removeTopic(id, check.getErr());
- if ( check.getErr().is2xx()) {
+ mr_topicService.removeTopic(id, apiError);
+ if (apiError.is2xx()) {
return responseBuilder.success(Status.NO_CONTENT.getStatusCode(), null);
}
- return responseBuilder.error(check.getErr());
+ return responseBuilder.error(apiError);
}
@@ -206,11 +198,9 @@ public class TopicResource extends BaseLoggingClass {
@ApiResponse( code = 400, message = "Error", response = ApiError.class )
})
@Path("/{topicId}")
- public Response getTopic(
- @PathParam("topicId") String id
- ) {
+ public Response getTopic(@PathParam("topicId") String id) {
logger.info("Entry: /GET " + id);
- ApiService check = new ApiService();
+ ApiError apiError = new ApiError();
try {
checker.required( "topicName", id, "^\\S+$" ); //no white space allowed in topicName
@@ -218,9 +208,9 @@ public class TopicResource extends BaseLoggingClass {
logger.error("Error", rfe.getApiError());
return responseBuilder.error(rfe.getApiError());
}
- Topic mrc = mr_topicService.getTopic( id, check.getErr() );
+ Topic mrc = mr_topicService.getTopic(id, apiError);
if ( mrc == null ) {
- return responseBuilder.error(check.getErr());
+ return responseBuilder.error(apiError);
}
return responseBuilder.success(mrc);
}
diff --git a/src/main/java/org/onap/dmaap/dbcapi/service/ApiService.java b/src/main/java/org/onap/dmaap/dbcapi/service/ApiService.java
index 35e61db..e1beb28 100644
--- a/src/main/java/org/onap/dmaap/dbcapi/service/ApiService.java
+++ b/src/main/java/org/onap/dmaap/dbcapi/service/ApiService.java
@@ -100,25 +100,6 @@ public class ApiService extends BaseLoggingClass {
return err;
}
-
- public void setErr(ApiError err) {
- this.err = err;
- }
-
- public void setCode(int statusCode) {
- err.setCode(statusCode);
- }
-
-
- public void setMessage(String string) {
- err.setMessage(string);
- }
-
-
- public void setFields(String string) {
- err.setFields(string);
- }
-
public void checkAuthorization() throws Exception {
MDC.put(MDC_KEY_REQUEST_ID, requestId);