diff options
author | Bharath Balasubramanian <bharathb@research.att.com> | 2019-01-30 22:32:41 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2019-01-30 22:32:41 +0000 |
commit | b146c72f951cdbcecf1e3e726956082d9d8cf4b0 (patch) | |
tree | aa084d628979fe1d90dcdc3aabef37f294fb9c17 /jar/src/main/java/org/onap/music/rest | |
parent | 0e6a4dc0f90f9589e3830c8976a39f627acd10c7 (diff) | |
parent | a27be9fdbbf2d271c9c5780ba70fe15a24dbdb63 (diff) |
Merge "Push variuos changes"
Diffstat (limited to 'jar/src/main/java/org/onap/music/rest')
8 files changed, 126 insertions, 118 deletions
diff --git a/jar/src/main/java/org/onap/music/rest/RestMusicAdminAPI.java b/jar/src/main/java/org/onap/music/rest/RestMusicAdminAPI.java index e7c7fb6c..cc7c01c7 100755 --- a/jar/src/main/java/org/onap/music/rest/RestMusicAdminAPI.java +++ b/jar/src/main/java/org/onap/music/rest/RestMusicAdminAPI.java @@ -19,6 +19,7 @@ * ============LICENSE_END============================================= * ==================================================================== */ + package org.onap.music.rest; diff --git a/jar/src/main/java/org/onap/music/rest/RestMusicBmAPI.java b/jar/src/main/java/org/onap/music/rest/RestMusicBmAPI.java index 55eb47f2..097c7b40 100644 --- a/jar/src/main/java/org/onap/music/rest/RestMusicBmAPI.java +++ b/jar/src/main/java/org/onap/music/rest/RestMusicBmAPI.java @@ -15,6 +15,7 @@ * ============LICENSE_END============================================= * ==================================================================== */ + package org.onap.music.rest; import java.util.List; diff --git a/jar/src/main/java/org/onap/music/rest/RestMusicDataAPI.java b/jar/src/main/java/org/onap/music/rest/RestMusicDataAPI.java index 47d1eae7..fc31cd9e 100755 --- a/jar/src/main/java/org/onap/music/rest/RestMusicDataAPI.java +++ b/jar/src/main/java/org/onap/music/rest/RestMusicDataAPI.java @@ -7,18 +7,19 @@ * 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 - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * + * * ============LICENSE_END============================================= * ==================================================================== */ + package org.onap.music.rest; import java.util.ArrayList; @@ -85,7 +86,7 @@ public class RestMusicDataAPI { * (e.g. if the full version is 1.24.5, X-minorVersion = "24") - Is optional for the client on * request; however, this header should be provided if the client needs to take advantage of * MINOR incremented version functionality - Is mandatory for the server on response - * + * *** X-patchVersion *** - Used only to communicate a PATCH version in a response for * troubleshooting purposes only, and will not be provided by the client on request - This will * be the latest PATCH version of the MINOR requested by the client, or the latest PATCH version @@ -107,7 +108,7 @@ public class RestMusicDataAPI { private static final String USERID = "userId"; private static final String PASSWORD = "password"; private static final String VERSION = "v2"; - + private class RowIdentifier { public String primarKeyValue; public StringBuilder rowIdString; @@ -126,7 +127,7 @@ public class RestMusicDataAPI { /** * Create Keyspace REST - * + * * @param kspObject * @param keyspaceName * @return @@ -149,7 +150,7 @@ public class RestMusicDataAPI { JsonKeySpace kspObject, @ApiParam(value = "Keyspace Name",required = true) @PathParam("name") String keyspaceName) { ResponseBuilder response = MusicUtil.buildVersionResponse(VERSION, minorVersion, patchVersion); - + Map<String, Object> authMap = CachingUtil.verifyOnboarding(ns, userId, password); if (!authMap.isEmpty()) { logger.error(EELFLoggerDelegate.errorLogger,"", AppMessages.MISSINGDATA ,ErrorSeverity.CRITICAL, ErrorTypes.AUTHENTICATIONERROR); @@ -192,7 +193,7 @@ public class RestMusicDataAPI { repString = "{" + MusicUtil.jsonMaptoSqlString(replicationInfo, ",") + "}"; } catch (Exception e) { logger.error(EELFLoggerDelegate.errorLogger,e.getMessage(), AppMessages.MISSINGDATA ,ErrorSeverity.CRITICAL, ErrorTypes.DATAERROR); - + } queryObject.appendQueryString( "CREATE KEYSPACE " + keyspaceName + " WITH replication = " + repString); @@ -214,7 +215,7 @@ public class RestMusicDataAPI { logger.error(EELFLoggerDelegate.errorLogger,ex.getMessage(), AppMessages.UNKNOWNERROR ,ErrorSeverity.WARN, ErrorTypes.MUSICSERVICEERROR); return response.status(Status.BAD_REQUEST).entity(new JsonResponse(ResultType.FAILURE).setError("err:" + ex.getMessage()).toMap()).build(); } - + try { queryObject = new PreparedQueryObject(); queryObject.appendQueryString("CREATE ROLE IF NOT EXISTS '" + userId @@ -228,7 +229,7 @@ public class RestMusicDataAPI { } catch (Exception e) { logger.error(EELFLoggerDelegate.errorLogger,e.getMessage(), AppMessages.UNKNOWNERROR,ErrorSeverity.WARN, ErrorTypes.MUSICSERVICEERROR); } - + try { boolean isAAF = Boolean.valueOf(CachingUtil.isAAFApplication(ns)); String hashedpwd = BCrypt.hashpw(password, BCrypt.gensalt()); @@ -250,12 +251,12 @@ public class RestMusicDataAPI { logger.error(EELFLoggerDelegate.errorLogger,e.getMessage(), AppMessages.UNKNOWNERROR,ErrorSeverity.WARN, ErrorTypes.MUSICSERVICEERROR); return response.status(Response.Status.BAD_REQUEST).entity(new JsonResponse(ResultType.FAILURE).setError(e.getMessage()).toMap()).build(); } - + return response.status(Status.OK).entity(new JsonResponse(ResultType.SUCCESS).setMessage("Keyspace " + keyspaceName + " Created").toMap()).build(); } /** - * + * * @param kspObject * @param keyspaceName * @return @@ -325,7 +326,7 @@ public class RestMusicDataAPI { } /** - * + * * @param tableObj * @param version * @param keyspace @@ -369,7 +370,7 @@ public class RestMusicDataAPI { int counter = 0; String primaryKey; for (Map.Entry<String, String> entry : fields.entrySet()) { - + if (entry.getKey().equals("PRIMARY KEY")) { if(! entry.getValue().contains("(")) primaryKey = entry.getValue(); @@ -433,7 +434,7 @@ public class RestMusicDataAPI { } /** - * + * * @param keyspace * @param tablename * @param fieldName @@ -473,7 +474,7 @@ public class RestMusicDataAPI { PreparedQueryObject query = new PreparedQueryObject(); query.appendQueryString("Create index " + indexName + " if not exists on " + keyspace + "." + tablename + " (" + fieldName + ");"); - + ResultType result = ResultType.FAILURE; try { result = MusicCore.nonKeyRelatedPut(query, "eventual"); @@ -490,7 +491,7 @@ public class RestMusicDataAPI { } /** - * + * * @param insObj * @param keyspace * @param tablename @@ -518,7 +519,7 @@ public class RestMusicDataAPI { ResponseBuilder response = MusicUtil.buildVersionResponse(VERSION, minorVersion, patchVersion); Map<String, Object> authMap = null; - + try { authMap = MusicCore.autheticateUser(ns, userId, password, keyspace, aid, "insertIntoTable"); @@ -587,7 +588,7 @@ public class RestMusicDataAPI { } counter = counter + 1; } - + if(primaryKey == null || primaryKey.length() <= 0) { logger.error(EELFLoggerDelegate.errorLogger, "Some required partition key parts are missing: "+primaryKeyName ); return response.status(Status.BAD_REQUEST).entity(new JsonResponse(ResultType.SYNTAXERROR).setError("Some required partition key parts are missing: "+primaryKeyName).toMap()).build(); @@ -646,7 +647,7 @@ public class RestMusicDataAPI { logger.error(EELFLoggerDelegate.errorLogger,ex.getMessage(), AppMessages.UNKNOWNERROR ,ErrorSeverity.WARN, ErrorTypes.MUSICSERVICEERROR); return response.status(Status.BAD_REQUEST).entity(new JsonResponse(ResultType.FAILURE).setError(ex.getMessage()).toMap()).build(); } - + if (result==null) { logger.error(EELFLoggerDelegate.errorLogger,"", AppMessages.UNKNOWNERROR ,ErrorSeverity.WARN, ErrorTypes.MUSICSERVICEERROR); return response.status(Status.BAD_REQUEST).entity(new JsonResponse(ResultType.FAILURE).setError("Null result - Please Contact admin").toMap()).build(); @@ -655,7 +656,7 @@ public class RestMusicDataAPI { } /** - * + * * @param insObj * @param keyspace * @param tablename @@ -853,7 +854,7 @@ public class RestMusicDataAPI { timingString = timingString + lockManagementTime; } logger.info(EELFLoggerDelegate.applicationLogger, timingString); - + if (operationResult==null) { logger.error(EELFLoggerDelegate.errorLogger,"Null result - Please Contact admin", AppMessages.UNKNOWNERROR ,ErrorSeverity.WARN, ErrorTypes.GENERALSERVICEERROR); return response.status(Status.BAD_REQUEST).entity(new JsonResponse(ResultType.FAILURE).setError("Null result - Please Contact admin").toMap()).build(); @@ -864,11 +865,11 @@ public class RestMusicDataAPI { logger.error(EELFLoggerDelegate.errorLogger,operationResult.getMessage(), AppMessages.UNKNOWNERROR ,ErrorSeverity.WARN, ErrorTypes.GENERALSERVICEERROR); return response.status(Status.BAD_REQUEST).entity(new JsonResponse(operationResult.getResult()).setError(operationResult.getMessage()).toMap()).build(); } - + } /** - * + * * @param delObj * @param keyspace * @param tablename @@ -1014,7 +1015,7 @@ public class RestMusicDataAPI { } /** - * + * * @param tabObj * @param keyspace * @param tablename @@ -1066,7 +1067,7 @@ public class RestMusicDataAPI { } /** - * + * * @param selObj * @param keyspace * @param tablename @@ -1137,7 +1138,7 @@ public class RestMusicDataAPI { } else if (consistency.equalsIgnoreCase(MusicUtil.ATOMIC)) { results = MusicCore.atomicGet(keyspace, tablename, rowId.primarKeyValue, queryObject); } - + else if (consistency.equalsIgnoreCase(MusicUtil.ATOMICDELETELOCK)) { results = MusicCore.atomicGetWithDeleteLock(keyspace, tablename, rowId.primarKeyValue, queryObject); } @@ -1146,7 +1147,7 @@ public class RestMusicDataAPI { } /** - * + * * @param keyspace * @param tablename * @param info @@ -1212,7 +1213,7 @@ public class RestMusicDataAPI { } /** - * + * * @param keyspace * @param tablename * @param info @@ -1242,7 +1243,7 @@ public class RestMusicDataAPI { } /** - * + * * @param keyspace * @param tablename * @param rowParams diff --git a/jar/src/main/java/org/onap/music/rest/RestMusicHealthCheckAPI.java b/jar/src/main/java/org/onap/music/rest/RestMusicHealthCheckAPI.java index 752a538b..c1071e5b 100644 --- a/jar/src/main/java/org/onap/music/rest/RestMusicHealthCheckAPI.java +++ b/jar/src/main/java/org/onap/music/rest/RestMusicHealthCheckAPI.java @@ -19,6 +19,7 @@ * ============LICENSE_END============================================= * ==================================================================== */ + package org.onap.music.rest; import java.util.HashMap; @@ -58,56 +59,56 @@ import io.swagger.annotations.ApiOperation; @Path("/v{version: [0-9]+}/service") @Api(value="Healthcheck Api") public class RestMusicHealthCheckAPI { - - - private static EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(MusicUtil.class); - - - @GET - @Path("/cs") - @ApiOperation(value = "Get Health Status", response = Map.class) - @Produces(MediaType.APPLICATION_JSON) - public Response cassandraStatus(@Context HttpServletResponse response) { - logger.info(EELFLoggerDelegate.applicationLogger,"Replying to request for MUSIC Health Check status for Cassandra"); - - Map<String, Object> resultMap = new HashMap<>(); - - MusicHealthCheck cassHealthCheck = new MusicHealthCheck(); - String status = cassHealthCheck.getCassandraStatus(); - if(status.equals("ACTIVE")) { - resultMap.put("ACTIVE", "Cassandra Running and Listening to requests"); - return Response.status(Status.OK).entity(resultMap).build(); - }else { - resultMap.put("INACTIVE", "Cassandra Service is not responding"); - return Response.status(Status.BAD_REQUEST).entity(resultMap).build(); - } - - - - } - - @GET - @Path("/zk") - @ApiOperation(value = "Get Health Status", response = Map.class) - @Produces(MediaType.APPLICATION_JSON) - public Response ZKStatus(@Context HttpServletResponse response) { - logger.info(EELFLoggerDelegate.applicationLogger,"Replying to request for MUSIC Health Check status for Zookeeper"); - Map<String, Object> resultMap = new HashMap<>(); - MusicHealthCheck ZKHealthCheck = new MusicHealthCheck(); - String status = ZKHealthCheck.getZookeeperStatus(); - if(status.equals("ACTIVE")) { - resultMap.put("ACTIVE", "Zookeeper is Active and Running"); - return Response.status(Status.OK).entity(resultMap).build(); - }else { - resultMap.put("INACTIVE", "Zookeeper is not responding"); - return Response.status(Status.BAD_REQUEST).entity(resultMap).build(); - } - } - - - - - - + + + private static EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(MusicUtil.class); + + + @GET + @Path("/cs") + @ApiOperation(value = "Get Health Status", response = Map.class) + @Produces(MediaType.APPLICATION_JSON) + public Response cassandraStatus(@Context HttpServletResponse response) { + logger.info(EELFLoggerDelegate.applicationLogger,"Replying to request for MUSIC Health Check status for Cassandra"); + + Map<String, Object> resultMap = new HashMap<>(); + + MusicHealthCheck cassHealthCheck = new MusicHealthCheck(); + String status = cassHealthCheck.getCassandraStatus(); + if(status.equals("ACTIVE")) { + resultMap.put("ACTIVE", "Cassandra Running and Listening to requests"); + return Response.status(Status.OK).entity(resultMap).build(); + }else { + resultMap.put("INACTIVE", "Cassandra Service is not responding"); + return Response.status(Status.BAD_REQUEST).entity(resultMap).build(); + } + + + + } + + @GET + @Path("/zk") + @ApiOperation(value = "Get Health Status", response = Map.class) + @Produces(MediaType.APPLICATION_JSON) + public Response ZKStatus(@Context HttpServletResponse response) { + logger.info(EELFLoggerDelegate.applicationLogger,"Replying to request for MUSIC Health Check status for Zookeeper"); + Map<String, Object> resultMap = new HashMap<>(); + MusicHealthCheck ZKHealthCheck = new MusicHealthCheck(); + String status = ZKHealthCheck.getZookeeperStatus(); + if(status.equals("ACTIVE")) { + resultMap.put("ACTIVE", "Zookeeper is Active and Running"); + return Response.status(Status.OK).entity(resultMap).build(); + }else { + resultMap.put("INACTIVE", "Zookeeper is not responding"); + return Response.status(Status.BAD_REQUEST).entity(resultMap).build(); + } + } + + + + + + } diff --git a/jar/src/main/java/org/onap/music/rest/RestMusicLocksAPI.java b/jar/src/main/java/org/onap/music/rest/RestMusicLocksAPI.java index 22112ddf..5b587511 100644 --- a/jar/src/main/java/org/onap/music/rest/RestMusicLocksAPI.java +++ b/jar/src/main/java/org/onap/music/rest/RestMusicLocksAPI.java @@ -19,6 +19,7 @@ * ============LICENSE_END============================================= * ==================================================================== */ + package org.onap.music.rest; import java.util.Map; @@ -413,10 +414,10 @@ public class RestMusicLocksAPI { return response.status(Status.BAD_REQUEST).entity(resultMap).build(); } try{ - MusicCore.deleteLock(lockName); + MusicCore.deleteLock(lockName); }catch (Exception e) { return response.status(Status.BAD_REQUEST).entity(new JsonResponse(ResultType.FAILURE).setError(e.getMessage()).toMap()).build(); - } + } return response.status(Status.OK).entity(new JsonResponse(ResultType.SUCCESS).toMap()).build(); } diff --git a/jar/src/main/java/org/onap/music/rest/RestMusicQAPI.java b/jar/src/main/java/org/onap/music/rest/RestMusicQAPI.java index e08adaf7..1c964074 100755 --- a/jar/src/main/java/org/onap/music/rest/RestMusicQAPI.java +++ b/jar/src/main/java/org/onap/music/rest/RestMusicQAPI.java @@ -19,6 +19,7 @@ * ============LICENSE_END============================================= * ==================================================================== */ + package org.onap.music.rest; diff --git a/jar/src/main/java/org/onap/music/rest/RestMusicTestAPI.java b/jar/src/main/java/org/onap/music/rest/RestMusicTestAPI.java index 287fa176..539f43f3 100644 --- a/jar/src/main/java/org/onap/music/rest/RestMusicTestAPI.java +++ b/jar/src/main/java/org/onap/music/rest/RestMusicTestAPI.java @@ -19,6 +19,7 @@ * ============LICENSE_END============================================= * ==================================================================== */ + package org.onap.music.rest; import java.util.HashMap; @@ -41,27 +42,27 @@ import io.swagger.annotations.ApiOperation; @Path("/v{version: [0-9]+}/test") @Api(value="Test Api") public class RestMusicTestAPI { - - @SuppressWarnings("unused") + + @SuppressWarnings("unused") private EELFLoggerDelegate logger =EELFLoggerDelegate.getLogger(RestMusicTestAPI.class); - /** - * Returns a test JSON. This will confirm that REST is working. - * @return - */ - @GET - @ApiOperation(value = "Get Test", response = Map.class) - @Produces(MediaType.APPLICATION_JSON) - public Map<String, HashMap<String, String>> simpleTests( - @Context HttpServletResponse response) { - response.addHeader("X-latestVersion",MusicUtil.getVersion()); - Map<String, HashMap<String, String>> testMap = new HashMap<>(); - for(int i=0; i < 3; i++){ - HashMap<String, String> innerMap = new HashMap<>(); - innerMap.put(i+"", i+1+""); - innerMap.put(i+1+"", i+2+""); - testMap.put(i+"", innerMap); - } - return testMap; - } + /** + * Returns a test JSON. This will confirm that REST is working. + * @return + */ + @GET + @ApiOperation(value = "Get Test", response = Map.class) + @Produces(MediaType.APPLICATION_JSON) + public Map<String, HashMap<String, String>> simpleTests( + @Context HttpServletResponse response) { + response.addHeader("X-latestVersion",MusicUtil.getVersion()); + Map<String, HashMap<String, String>> testMap = new HashMap<>(); + for(int i=0; i < 3; i++){ + HashMap<String, String> innerMap = new HashMap<>(); + innerMap.put(i+"", i+1+""); + innerMap.put(i+1+"", i+2+""); + testMap.put(i+"", innerMap); + } + return testMap; + } } diff --git a/jar/src/main/java/org/onap/music/rest/RestMusicVersionAPI.java b/jar/src/main/java/org/onap/music/rest/RestMusicVersionAPI.java index a5f2ac49..74b8e5dd 100644 --- a/jar/src/main/java/org/onap/music/rest/RestMusicVersionAPI.java +++ b/jar/src/main/java/org/onap/music/rest/RestMusicVersionAPI.java @@ -19,6 +19,7 @@ * ============LICENSE_END============================================= * ==================================================================== */ + package org.onap.music.rest; import java.util.Map; @@ -46,18 +47,18 @@ import io.swagger.annotations.ApiOperation; @Api(value="Version Api") public class RestMusicVersionAPI { - private EELFLoggerDelegate logger =EELFLoggerDelegate.getLogger(RestMusicVersionAPI.class); - - /** - * Get the version of MUSIC - * @return - */ - @GET - @ApiOperation(value = "Get Version", response = Map.class) - @Produces(MediaType.APPLICATION_JSON) - public Map<String,Object> version(@Context HttpServletResponse response) { - logger.info("Replying to request for MUSIC version with MUSIC:" + MusicUtil.getVersion()); - response.addHeader("X-latestVersion",MusicUtil.getVersion()); - return new JsonResponse(ResultType.SUCCESS).setMusicVersion("MUSIC:" + MusicUtil.getVersion()).toMap(); - } + private EELFLoggerDelegate logger =EELFLoggerDelegate.getLogger(RestMusicVersionAPI.class); + + /** + * Get the version of MUSIC + * @return + */ + @GET + @ApiOperation(value = "Get Version", response = Map.class) + @Produces(MediaType.APPLICATION_JSON) + public Map<String,Object> version(@Context HttpServletResponse response) { + logger.info("Replying to request for MUSIC version with MUSIC:" + MusicUtil.getVersion()); + response.addHeader("X-latestVersion",MusicUtil.getVersion()); + return new JsonResponse(ResultType.SUCCESS).setMusicVersion("MUSIC:" + MusicUtil.getVersion()).toMap(); + } }
\ No newline at end of file |