X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Forg%2Fonap%2Fmusic%2Frest%2FRestMusicQAPI.java;h=f3df9350efc4a869bc2ddec524dff482f5921fb1;hb=0a358ea9fd56796d7dcf9c2a50df82a4f05b9738;hp=4164f27fa878be5e8dadc317ef696a8cffe9b3cb;hpb=fa56ad63a720ab32cb90142f5e690930103a82fe;p=music.git diff --git a/src/main/java/org/onap/music/rest/RestMusicQAPI.java b/src/main/java/org/onap/music/rest/RestMusicQAPI.java index 4164f27f..f3df9350 100755 --- a/src/main/java/org/onap/music/rest/RestMusicQAPI.java +++ b/src/main/java/org/onap/music/rest/RestMusicQAPI.java @@ -4,6 +4,9 @@ * =================================================================== * Copyright (c) 2017 AT&T Intellectual Property * =================================================================== + * Modifications Copyright (C) 2019 IBM. + * Modifications Copyright (c) 2019 Samsung + * =================================================================== * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -52,19 +55,17 @@ import org.apache.commons.lang3.StringUtils; import org.onap.music.datastore.MusicDataStoreHandle; import org.onap.music.datastore.PreparedQueryObject; import com.datastax.driver.core.ResultSet; +import org.onap.music.exceptions.MusicQueryException; import org.onap.music.exceptions.MusicServiceException; import org.onap.music.main.MusicCore; import org.onap.music.main.MusicUtil; import org.onap.music.main.ResultType; import org.onap.music.response.jsonobjects.JsonResponse; -import org.onap.music.service.impl.MusicZKCore; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; -// import io.swagger.models.Response; -// @Path("/v{version: [0-9]+}/priorityq/") @Path("/v2/priorityq/") @Api(value = "Q Api") public class RestMusicQAPI { @@ -96,14 +97,11 @@ public class RestMusicQAPI { @ApiParam(value = "Authorization", required = true) @HeaderParam(MusicUtil.AUTHORIZATION) String authorization, JsonTable tableObj, @ApiParam(value = "Key Space", required = true) @PathParam("keyspace") String keyspace, - @ApiParam(value = "Table Name", required = true) @PathParam("qname") String tablename) - throws Exception { - //logger.info(logger, "cjc before start in q 1** major version=" + version); - + @ApiParam(value = "Table Name", required = true) @PathParam("qname") String tablename) throws Exception { ResponseBuilder response = MusicUtil.buildVersionResponse(version, minorVersion, patchVersion); Map fields = tableObj.getFields(); - if (fields == null) { // || (!fields.containsKey("order")) ){ + if (fields == null) { logger.error(EELFLoggerDelegate.errorLogger, "", AppMessages.MISSINGDATA, ErrorSeverity.CRITICAL, ErrorTypes.DATAERROR); return response.status(Status.BAD_REQUEST) @@ -241,7 +239,7 @@ public class RestMusicQAPI { JsonInsert insObj, @ApiParam(value = "Key Space", required = true) @PathParam("keyspace") String keyspace, @ApiParam(value = "Table Name", required = true) @PathParam("qname") String tablename) - throws Exception { + { ResponseBuilder response = MusicUtil.buildVersionResponse(version, minorVersion, patchVersion); if (insObj.getValues().isEmpty()) { logger.error(EELFLoggerDelegate.errorLogger, "", AppMessages.MISSINGDATA, @@ -279,7 +277,7 @@ public class RestMusicQAPI { JsonUpdate updateObj, @ApiParam(value = "Key Space", required = true) @PathParam("keyspace") String keyspace, @ApiParam(value = "Table Name", required = true) @PathParam("qname") String tablename, - @Context UriInfo info) throws Exception { + @Context UriInfo info) throws MusicServiceException, MusicQueryException { ResponseBuilder response = MusicUtil.buildVersionResponse(version, minorVersion, patchVersion); if (updateObj.getValues().isEmpty()) { @@ -325,7 +323,7 @@ public class RestMusicQAPI { JsonDelete delObj, @ApiParam(value = "Key Space", required = true) @PathParam("keyspace") String keyspace, @ApiParam(value = "Table Name", required = true) @PathParam("qname") String tablename, - @Context UriInfo info) throws Exception { + @Context UriInfo info) throws MusicServiceException, MusicQueryException { // added checking as per RestMusicDataAPI ResponseBuilder response = MusicUtil.buildVersionResponse(version, minorVersion, patchVersion); if (delObj == null) { @@ -363,7 +361,7 @@ public class RestMusicQAPI { @ApiParam(value = "Authorization", required = true) @HeaderParam(MusicUtil.AUTHORIZATION) String authorization, @ApiParam(value = "Key Space", required = true) @PathParam("keyspace") String keyspace, @ApiParam(value = "Table Name", required = true) @PathParam("qname") String tablename, - @Context UriInfo info) throws Exception { + @Context UriInfo info) { int limit =1; //peek must return just the top row Map auth = new HashMap<>(); String userId =auth.get(MusicUtil.USERID); @@ -377,11 +375,10 @@ public class RestMusicQAPI { else { try { - queryObject = new RestMusicDataAPI().selectSpecificQuery(version, minorVersion, - patchVersion, aid, ns, userId, password, keyspace, tablename, info, limit); + queryObject = new RestMusicDataAPI().selectSpecificQuery(keyspace, tablename, info, limit); } catch (MusicServiceException ex) { logger.error(EELFLoggerDelegate.errorLogger, "", AppMessages.UNKNOWNERROR, - ErrorSeverity.WARN, ErrorTypes.GENERALSERVICEERROR); + ErrorSeverity.WARN, ErrorTypes.GENERALSERVICEERROR, ex); return response.status(Status.BAD_REQUEST) .entity(new JsonResponse(ResultType.FAILURE).setError(ex.getMessage()).toMap()) .build(); @@ -394,7 +391,7 @@ public class RestMusicQAPI { .setDataResult(MusicDataStoreHandle.marshallResults(results)).toMap()).build(); } catch (MusicServiceException ex) { logger.error(EELFLoggerDelegate.errorLogger, "", AppMessages.UNKNOWNERROR, - ErrorSeverity.ERROR, ErrorTypes.MUSICSERVICEERROR); + ErrorSeverity.ERROR, ErrorTypes.MUSICSERVICEERROR, ex); return response.status(Status.BAD_REQUEST) .entity(new JsonResponse(ResultType.FAILURE).setError(ex.getMessage()).toMap()) .build(); @@ -450,8 +447,7 @@ public class RestMusicQAPI { @ApiParam(value = "Application namespace", required = true) @HeaderParam("ns") String ns, @ApiParam(value = "Authorization", required = true) @HeaderParam(MusicUtil.AUTHORIZATION) String authorization, @ApiParam(value = "Key Space", required = true) @PathParam("keyspace") String keyspace, - @ApiParam(value = "Table Name", required = true) @PathParam("qname") String tablename) - throws Exception { + @ApiParam(value = "Table Name", required = true) @PathParam("qname") String tablename) throws Exception { return new RestMusicDataAPI().dropTable(version, minorVersion, patchVersion, aid, ns, authorization, keyspace, tablename); }