From 9cd6659574e58aae87a8aa40feaad492b2f3bde7 Mon Sep 17 00:00:00 2001 From: "Nelson,Thomas(tn1381)(arthurdent3)" Date: Tue, 27 Mar 2018 19:50:44 -0400 Subject: Code Coverage, Auth ID, Docker Change-Id: If9212aea5a643f2db6c18090f17cd2da71f5a968 Issue-ID: MUSIC-44, MUSIC-65, MUSIC-56 Signed-off-by: Nelson,Thomas(tn1381)(arthurdent3) --- .../java/org/onap/music/rest/RestMusicQAPI.java | 389 ++++++++++----------- 1 file changed, 191 insertions(+), 198 deletions(-) (limited to 'src/main/java/org/onap/music/rest/RestMusicQAPI.java') diff --git a/src/main/java/org/onap/music/rest/RestMusicQAPI.java b/src/main/java/org/onap/music/rest/RestMusicQAPI.java index 39233dc5..e08adaf7 100755 --- a/src/main/java/org/onap/music/rest/RestMusicQAPI.java +++ b/src/main/java/org/onap/music/rest/RestMusicQAPI.java @@ -26,7 +26,6 @@ package org.onap.music.rest; import java.util.HashMap; import java.util.Map; -import javax.servlet.http.HttpServletResponse; import javax.ws.rs.Consumes; import javax.ws.rs.DELETE; import javax.ws.rs.GET; @@ -38,6 +37,7 @@ import javax.ws.rs.PathParam; import javax.ws.rs.Produces; import javax.ws.rs.core.Context; import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; import javax.ws.rs.core.UriInfo; import org.onap.music.datastore.jsonobjects.JsonDelete; @@ -47,8 +47,6 @@ import org.onap.music.datastore.jsonobjects.JsonUpdate; import org.onap.music.eelf.logging.EELFLoggerDelegate; import org.onap.music.main.MusicCore; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; import org.onap.music.datastore.PreparedQueryObject; import com.datastax.driver.core.ResultSet; @@ -60,199 +58,194 @@ import io.swagger.annotations.ApiParam; @Path("/priorityq/") @Api(value="Q Api") public class RestMusicQAPI { - - private EELFLoggerDelegate logger =EELFLoggerDelegate.getLogger(RestMusicDataAPI.class); - - - /** - * - * @param tableObj - * @param keyspace - * @param tablename - * @throws Exception - */ - - @POST - @Path("/keyspaces/{keyspace}/{qname}") - @ApiOperation(value = "", response = Void.class) - @Consumes(MediaType.APPLICATION_JSON) - public Map createQ( - @ApiParam(value="Major Version",required=true) @PathParam("version") String version, - @ApiParam(value="Minor Version",required=false) @HeaderParam("X-minorVersion") String minorVersion, - @ApiParam(value="Patch Version",required=false) @HeaderParam("X-patchVersion") String patchVersion, - @ApiParam(value="AID",required=true) @HeaderParam("aid") String aid, - @ApiParam(value="Application namespace",required=true) @HeaderParam("ns") String ns, - @ApiParam(value="userId",required=true) @HeaderParam("userId") String userId, - @ApiParam(value="Password",required=true) @HeaderParam("password") String password, JsonTable tableObj, - @ApiParam(value="Key Space",required=true) @PathParam("keyspace") String keyspace, - @ApiParam(value="Table Name",required=true) @PathParam("tablename") String tablename, - @Context HttpServletResponse response) throws Exception{ - return new RestMusicDataAPI().createTable(version,minorVersion,patchVersion,aid, ns, userId, password, tableObj, keyspace, tablename,response); - } - - /** - * - * @param insObj - * @param keyspace - * @param tablename - * @throws Exception - */ - @POST - @Path("/keyspaces/{keyspace}/{qname}/rows") - @ApiOperation(value = "", response = Void.class) - @Consumes(MediaType.APPLICATION_JSON) - @Produces(MediaType.APPLICATION_JSON) - public Map insertIntoQ( - @ApiParam(value="Major Version",required=true) @PathParam("version") String version, - @ApiParam(value="Minor Version",required=false) @HeaderParam("X-minorVersion") String minorVersion, - @ApiParam(value="Patch Version",required=false) @HeaderParam("X-patchVersion") String patchVersion, - @ApiParam(value="AID",required=true) @HeaderParam("aid") String aid, - @ApiParam(value="Application namespace",required=true) @HeaderParam("ns") String ns, @ApiParam(value="userId",required=true) @HeaderParam("userId") String userId, - @ApiParam(value="Password",required=true) @HeaderParam("password") String password, JsonInsert insObj, - @ApiParam(value="Key Space",required=true) @PathParam("keyspace") String keyspace, - @ApiParam(value="Table Name",required=true) @PathParam("tablename") String tablename, - @Context HttpServletResponse response) throws Exception{ - return new RestMusicDataAPI().insertIntoTable(version,minorVersion,patchVersion,aid, ns, userId, password, insObj, keyspace, tablename,response); - } - - /** - * - * @param updateObj - * @param keyspace - * @param tablename - * @param info - * @return - * @throws Exception - */ - @PUT - @Path("/keyspaces/{keyspace}/{qname}/rows") - @ApiOperation(value = "", response = String.class) - @Consumes(MediaType.APPLICATION_JSON) - @Produces(MediaType.APPLICATION_JSON) - public Map updateQ( - @ApiParam(value="Major Version",required=true) @PathParam("version") String version, - @ApiParam(value="Minor Version",required=false) @HeaderParam("X-minorVersion") String minorVersion, - @ApiParam(value="Patch Version",required=false) @HeaderParam("X-patchVersion") String patchVersion, - @ApiParam(value="AID",required=true) @HeaderParam("aid") String aid, - @ApiParam(value="Application namespace",required=true) @HeaderParam("ns") String ns, @ApiParam(value="userId",required=true) @HeaderParam("userId") String userId, - @ApiParam(value="Password",required=true) @HeaderParam("password") String password, JsonUpdate updateObj, - @ApiParam(value="Key Space",required=true) @PathParam("keyspace") String keyspace, - @ApiParam(value="Table Name",required=true) @PathParam("tablename") String tablename, - @Context UriInfo info, - @Context HttpServletResponse response) throws Exception{ - return new RestMusicDataAPI().updateTable(version,minorVersion,patchVersion,aid, ns, userId, password, updateObj, keyspace, tablename, info,response); - } - - /** - * - * @param delObj - * @param keyspace - * @param tablename - * @param info - * @return - * @throws Exception - */ - @DELETE - @Path("/keyspaces/{keyspace}/{qname}/rows") - @ApiOperation(value = "", response = String.class) - @Consumes(MediaType.APPLICATION_JSON) - @Produces(MediaType.APPLICATION_JSON) - public Map deleteFromQ( - @ApiParam(value="Major Version",required=true) @PathParam("version") String version, - @ApiParam(value="Minor Version",required=false) @HeaderParam("X-minorVersion") String minorVersion, - @ApiParam(value="Patch Version",required=false) @HeaderParam("X-patchVersion") String patchVersion, - @ApiParam(value="AID",required=true) @HeaderParam("aid") String aid, - @ApiParam(value="Application namespace",required=true) @HeaderParam("ns") String ns, - @ApiParam(value="userId",required=true) @HeaderParam("userId") String userId, - @ApiParam(value="Password",required=true) @HeaderParam("password") String password, JsonDelete delObj, - @ApiParam(value="Key Space",required=true) @PathParam("keyspace") String keyspace, - @ApiParam(value="Table Name",required=true) @PathParam("tablename") String tablename, - @Context UriInfo info, - @Context HttpServletResponse response) throws Exception{ - return new RestMusicDataAPI().deleteFromTable(version,minorVersion,patchVersion,aid, ns, userId, password, delObj, keyspace, tablename, info,response); - } - - /** - * - * @param keyspace - * @param tablename - * @param info - * @return - * @throws Exception - */ - @GET - @Path("/keyspaces/{keyspace}/{qname}/peek") - @ApiOperation(value = "", response = Map.class) - @Produces(MediaType.APPLICATION_JSON) - public Map> peek( - @ApiParam(value="Major Version",required=true) @PathParam("version") String version, - @ApiParam(value="Minor Version",required=false) @HeaderParam("X-minorVersion") String minorVersion, - @ApiParam(value="Patch Version",required=false) @HeaderParam("X-patchVersion") String patchVersion, - @ApiParam(value="AID",required=true) @HeaderParam("aid") String aid, - @ApiParam(value="Application namespace",required=true) @HeaderParam("ns") String ns, - @ApiParam(value="userId",required=true) @HeaderParam("userId") String userId, - @ApiParam(value="Password",required=true) @HeaderParam("password") String password, - @ApiParam(value="Key Space",required=true) @PathParam("keyspace") String keyspace, - @ApiParam(value="Table Name",required=true) @PathParam("tablename") String tablename, - @Context UriInfo info) throws Exception{ - int limit =1; //peek must return just the top row - PreparedQueryObject query = new RestMusicDataAPI().selectSpecificQuery(version,minorVersion,patchVersion,aid, ns, userId, password,keyspace,tablename,info,limit); - ResultSet results = MusicCore.get(query); - return MusicCore.marshallResults(results); - - } - - /** - * - * - * @param keyspace - * @param tablename - * @param info - * @return - * @throws Exception - */ - @GET - @Path("/keyspaces/{keyspace}/{qname}/filter") - @ApiOperation(value = "", response = Map.class) - @Produces(MediaType.APPLICATION_JSON) - public Map> filter( - @ApiParam(value="Major Version",required=true) @PathParam("version") String version, - @ApiParam(value="Minor Version",required=false) @HeaderParam("X-minorVersion") String minorVersion, - @ApiParam(value="Patch Version",required=false) @HeaderParam("X-patchVersion") String patchVersion, - @ApiParam(value="AID",required=true) @HeaderParam("aid") String aid, - @ApiParam(value="Application namespace",required=true) @HeaderParam("ns") String ns, - @ApiParam(value="userId",required=true) @HeaderParam("userId") String userId, - @ApiParam(value="Password",required=true) @HeaderParam("password") String password, - @ApiParam(value="Key Space",required=true) @PathParam("keyspace") String keyspace, - @ApiParam(value="Table Name",required=true) @PathParam("tablename") String tablename, - @Context UriInfo info) throws Exception{ - int limit =-1; - PreparedQueryObject query = new RestMusicDataAPI().selectSpecificQuery(version,minorVersion,patchVersion,aid, ns, userId, password,keyspace,tablename,info,limit); - ResultSet results = MusicCore.get(query); - return MusicCore.marshallResults(results); - } - - /** - * - * @param tabObj - * @param keyspace - * @param tablename - * @throws Exception - */ - @DELETE - @ApiOperation(value = "", response = Void.class) - @Path("/keyspaces/{keyspace}/{qname}") - public Map dropQ( - @ApiParam(value="Major Version",required=true) @PathParam("version") String version, - @ApiParam(value="Minor Version",required=false) @HeaderParam("X-minorVersion") String minorVersion, - @ApiParam(value="Patch Version",required=false) @HeaderParam("X-patchVersion") String patchVersion, - @ApiParam(value="AID",required=true) @HeaderParam("aid") String aid, - @ApiParam(value="Application namespace",required=true) @HeaderParam("ns") String ns, - @ApiParam(value="userId",required=true) @HeaderParam("userId") String userId, - @ApiParam(value="Password",required=true) @HeaderParam("password") String password, JsonTable tabObj, - @ApiParam(value="Key Space",required=true) @PathParam("keyspace") String keyspace, - @ApiParam(value="Table Name",required=true) @PathParam("tablename") String tablename, - @Context HttpServletResponse response) throws Exception{ - return new RestMusicDataAPI().dropTable(version,minorVersion,patchVersion,aid, ns, userId, password, keyspace, tablename,response); - } + + private EELFLoggerDelegate logger =EELFLoggerDelegate.getLogger(RestMusicDataAPI.class); + + + /** + * + * @param tableObj + * @param keyspace + * @param tablename + * @throws Exception + */ + + @POST + @Path("/keyspaces/{keyspace}/{qname}") + @ApiOperation(value = "", response = Void.class) + @Consumes(MediaType.APPLICATION_JSON) + public Response createQ( + @ApiParam(value="Major Version",required=true) @PathParam("version") String version, + @ApiParam(value="Minor Version",required=false) @HeaderParam("X-minorVersion") String minorVersion, + @ApiParam(value="Patch Version",required=false) @HeaderParam("X-patchVersion") String patchVersion, + @ApiParam(value="AID",required=true) @HeaderParam("aid") String aid, + @ApiParam(value="Application namespace",required=true) @HeaderParam("ns") String ns, + @ApiParam(value="userId",required=true) @HeaderParam("userId") String userId, + @ApiParam(value="Password",required=true) @HeaderParam("password") String password, JsonTable tableObj, + @ApiParam(value="Key Space",required=true) @PathParam("keyspace") String keyspace, + @ApiParam(value="Table Name",required=true) @PathParam("tablename") String tablename) throws Exception{ + return new RestMusicDataAPI().createTable(version,minorVersion,patchVersion,aid, ns, userId, password, tableObj, keyspace, tablename); + } + + /** + * + * @param insObj + * @param keyspace + * @param tablename + * @throws Exception + */ + @POST + @Path("/keyspaces/{keyspace}/{qname}/rows") + @ApiOperation(value = "", response = Void.class) + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + public Response insertIntoQ( + @ApiParam(value="Major Version",required=true) @PathParam("version") String version, + @ApiParam(value="Minor Version",required=false) @HeaderParam("X-minorVersion") String minorVersion, + @ApiParam(value="Patch Version",required=false) @HeaderParam("X-patchVersion") String patchVersion, + @ApiParam(value="AID",required=true) @HeaderParam("aid") String aid, + @ApiParam(value="Application namespace",required=true) @HeaderParam("ns") String ns, @ApiParam(value="userId",required=true) @HeaderParam("userId") String userId, + @ApiParam(value="Password",required=true) @HeaderParam("password") String password, JsonInsert insObj, + @ApiParam(value="Key Space",required=true) @PathParam("keyspace") String keyspace, + @ApiParam(value="Table Name",required=true) @PathParam("tablename") String tablename) throws Exception{ + return new RestMusicDataAPI().insertIntoTable(version,minorVersion,patchVersion,aid, ns, userId, password, insObj, keyspace, tablename); + } + + /** + * + * @param updateObj + * @param keyspace + * @param tablename + * @param info + * @return + * @throws Exception + */ + @PUT + @Path("/keyspaces/{keyspace}/{qname}/rows") + @ApiOperation(value = "", response = String.class) + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + public Response updateQ( + @ApiParam(value="Major Version",required=true) @PathParam("version") String version, + @ApiParam(value="Minor Version",required=false) @HeaderParam("X-minorVersion") String minorVersion, + @ApiParam(value="Patch Version",required=false) @HeaderParam("X-patchVersion") String patchVersion, + @ApiParam(value="AID",required=true) @HeaderParam("aid") String aid, + @ApiParam(value="Application namespace",required=true) @HeaderParam("ns") String ns, @ApiParam(value="userId",required=true) @HeaderParam("userId") String userId, + @ApiParam(value="Password",required=true) @HeaderParam("password") String password, JsonUpdate updateObj, + @ApiParam(value="Key Space",required=true) @PathParam("keyspace") String keyspace, + @ApiParam(value="Table Name",required=true) @PathParam("tablename") String tablename, + @Context UriInfo info) throws Exception{ + return new RestMusicDataAPI().updateTable(version,minorVersion,patchVersion,aid, ns, userId, password, updateObj, keyspace, tablename, info); + } + + /** + * + * @param delObj + * @param keyspace + * @param tablename + * @param info + * @return + * @throws Exception + */ + @DELETE + @Path("/keyspaces/{keyspace}/{qname}/rows") + @ApiOperation(value = "", response = String.class) + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + public Response deleteFromQ( + @ApiParam(value="Major Version",required=true) @PathParam("version") String version, + @ApiParam(value="Minor Version",required=false) @HeaderParam("X-minorVersion") String minorVersion, + @ApiParam(value="Patch Version",required=false) @HeaderParam("X-patchVersion") String patchVersion, + @ApiParam(value="AID",required=true) @HeaderParam("aid") String aid, + @ApiParam(value="Application namespace",required=true) @HeaderParam("ns") String ns, + @ApiParam(value="userId",required=true) @HeaderParam("userId") String userId, + @ApiParam(value="Password",required=true) @HeaderParam("password") String password, JsonDelete delObj, + @ApiParam(value="Key Space",required=true) @PathParam("keyspace") String keyspace, + @ApiParam(value="Table Name",required=true) @PathParam("tablename") String tablename, + @Context UriInfo info) throws Exception{ + return new RestMusicDataAPI().deleteFromTable(version,minorVersion,patchVersion,aid, ns, userId, password, delObj, keyspace, tablename, info); + } + + /** + * + * @param keyspace + * @param tablename + * @param info + * @return + * @throws Exception + */ + @GET + @Path("/keyspaces/{keyspace}/{qname}/peek") + @ApiOperation(value = "", response = Map.class) + @Produces(MediaType.APPLICATION_JSON) + public Map> peek( + @ApiParam(value="Major Version",required=true) @PathParam("version") String version, + @ApiParam(value="Minor Version",required=false) @HeaderParam("X-minorVersion") String minorVersion, + @ApiParam(value="Patch Version",required=false) @HeaderParam("X-patchVersion") String patchVersion, + @ApiParam(value="AID",required=true) @HeaderParam("aid") String aid, + @ApiParam(value="Application namespace",required=true) @HeaderParam("ns") String ns, + @ApiParam(value="userId",required=true) @HeaderParam("userId") String userId, + @ApiParam(value="Password",required=true) @HeaderParam("password") String password, + @ApiParam(value="Key Space",required=true) @PathParam("keyspace") String keyspace, + @ApiParam(value="Table Name",required=true) @PathParam("tablename") String tablename, + @Context UriInfo info) throws Exception{ + int limit =1; //peek must return just the top row + PreparedQueryObject query = new RestMusicDataAPI().selectSpecificQuery(version,minorVersion,patchVersion,aid, ns, userId, password,keyspace,tablename,info,limit); + ResultSet results = MusicCore.get(query); + return MusicCore.marshallResults(results); + + } + + /** + * + * + * @param keyspace + * @param tablename + * @param info + * @return + * @throws Exception + */ + @GET + @Path("/keyspaces/{keyspace}/{qname}/filter") + @ApiOperation(value = "", response = Map.class) + @Produces(MediaType.APPLICATION_JSON) + public Map> filter( + @ApiParam(value="Major Version",required=true) @PathParam("version") String version, + @ApiParam(value="Minor Version",required=false) @HeaderParam("X-minorVersion") String minorVersion, + @ApiParam(value="Patch Version",required=false) @HeaderParam("X-patchVersion") String patchVersion, + @ApiParam(value="AID",required=true) @HeaderParam("aid") String aid, + @ApiParam(value="Application namespace",required=true) @HeaderParam("ns") String ns, + @ApiParam(value="userId",required=true) @HeaderParam("userId") String userId, + @ApiParam(value="Password",required=true) @HeaderParam("password") String password, + @ApiParam(value="Key Space",required=true) @PathParam("keyspace") String keyspace, + @ApiParam(value="Table Name",required=true) @PathParam("tablename") String tablename, + @Context UriInfo info) throws Exception{ + int limit =-1; + PreparedQueryObject query = new RestMusicDataAPI().selectSpecificQuery(version,minorVersion,patchVersion,aid, ns, userId, password,keyspace,tablename,info,limit); + ResultSet results = MusicCore.get(query); + return MusicCore.marshallResults(results); + } + + /** + * + * @param tabObj + * @param keyspace + * @param tablename + * @throws Exception + */ + @DELETE + @ApiOperation(value = "", response = Void.class) + @Path("/keyspaces/{keyspace}/{qname}") + public Response dropQ( + @ApiParam(value="Major Version",required=true) @PathParam("version") String version, + @ApiParam(value="Minor Version",required=false) @HeaderParam("X-minorVersion") String minorVersion, + @ApiParam(value="Patch Version",required=false) @HeaderParam("X-patchVersion") String patchVersion, + @ApiParam(value="AID",required=true) @HeaderParam("aid") String aid, + @ApiParam(value="Application namespace",required=true) @HeaderParam("ns") String ns, + @ApiParam(value="userId",required=true) @HeaderParam("userId") String userId, + @ApiParam(value="Password",required=true) @HeaderParam("password") String password, JsonTable tabObj, + @ApiParam(value="Key Space",required=true) @PathParam("keyspace") String keyspace, + @ApiParam(value="Table Name",required=true) @PathParam("tablename") String tablename) throws Exception{ + return new RestMusicDataAPI().dropTable(version,minorVersion,patchVersion,aid, ns, userId, password, keyspace, tablename); + } } -- cgit 1.2.3-korg