diff options
Diffstat (limited to 'src/main')
12 files changed, 102 insertions, 90 deletions
diff --git a/src/main/java/org/onap/music/datastore/jsonobjects/JSONCallbackResponse.java b/src/main/java/org/onap/music/datastore/jsonobjects/JSONCallbackResponse.java index f869c342..c5a56a71 100755 --- a/src/main/java/org/onap/music/datastore/jsonobjects/JSONCallbackResponse.java +++ b/src/main/java/org/onap/music/datastore/jsonobjects/JSONCallbackResponse.java @@ -27,20 +27,20 @@ import java.util.Map; public class JSONCallbackResponse { - private String full_table; + private String fullTable; private String keyspace; private Map<String, String> changeValue; private String operation; - private String table_name; - private String primary_key; + private String tableName; + private String primaryKey; private Object miscObjects; private List<String> updateList; public String getFull_table() { - return full_table; + return fullTable; } - public void setFull_table(String full_table) { - this.full_table = full_table; + public void setFull_table(String fullTable) { + this.fullTable = fullTable; } public String getKeyspace() { return keyspace; @@ -55,16 +55,16 @@ public class JSONCallbackResponse { this.operation = operation; } public String getTable_name() { - return table_name; + return tableName; } - public void setTable_name(String table_name) { - this.table_name = table_name; + public void setTable_name(String tableName) { + this.tableName = tableName; } public String getPrimary_key() { - return primary_key; + return primaryKey; } - public void setPrimary_key(String primary_key) { - this.primary_key = primary_key; + public void setPrimary_key(String primaryKey) { + this.primaryKey = primaryKey; } public Object getMiscObjects() { return miscObjects; diff --git a/src/main/java/org/onap/music/datastore/jsonobjects/JsonInsert.java b/src/main/java/org/onap/music/datastore/jsonobjects/JsonInsert.java index c79ba9b7..456fb951 100644 --- a/src/main/java/org/onap/music/datastore/jsonobjects/JsonInsert.java +++ b/src/main/java/org/onap/music/datastore/jsonobjects/JsonInsert.java @@ -3,6 +3,7 @@ * org.onap.music * =================================================================== * Copyright (c) 2017 AT&T Intellectual Property + * Modifications Copyright (C) 2018 IBM. * =================================================================== * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -33,6 +34,11 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; +import org.onap.music.eelf.logging.EELFLoggerDelegate; +import org.onap.music.eelf.logging.format.AppMessages; +import org.onap.music.eelf.logging.format.ErrorSeverity; +import org.onap.music.eelf.logging.format.ErrorTypes; + @ApiModel(value = "JsonTable", description = "Json model for table vlaues insert") @JsonIgnoreProperties(ignoreUnknown = true) public class JsonInsert implements Serializable { @@ -41,10 +47,11 @@ public class JsonInsert implements Serializable { private transient Map<String, Object> values; private String ttl; private String timestamp; - private transient Map<String, Object> row_specification; + private transient Map<String, Object> rowSpecification; private Map<String, String> consistencyInfo; private Map<String, byte[]> objectMap; - + private static EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(JsonInsert.class); + @ApiModelProperty(value = "objectMap") public Map<String, byte[]> getObjectMap() { return objectMap; @@ -110,11 +117,11 @@ public class JsonInsert implements Serializable { @ApiModelProperty(value = "Information for selecting specific rows for insert") public Map<String, Object> getRow_specification() { - return row_specification; + return rowSpecification; } - public void setRow_specification(Map<String, Object> row_specification) { - this.row_specification = row_specification; + public void setRow_specification(Map<String, Object> rowSpecification) { + this.rowSpecification = rowSpecification; } public byte[] serialize() { @@ -124,7 +131,7 @@ public class JsonInsert implements Serializable { out = new ObjectOutputStream(bos); out.writeObject(this); } catch (IOException e) { - e.printStackTrace(); + logger.error(EELFLoggerDelegate.errorLogger, e, AppMessages.IOERROR, ErrorSeverity.ERROR, ErrorTypes.DATAERROR); } return bos.toByteArray(); } diff --git a/src/main/java/org/onap/music/datastore/jsonobjects/JsonNotification.java b/src/main/java/org/onap/music/datastore/jsonobjects/JsonNotification.java index ce244e2c..5190de58 100755 --- a/src/main/java/org/onap/music/datastore/jsonobjects/JsonNotification.java +++ b/src/main/java/org/onap/music/datastore/jsonobjects/JsonNotification.java @@ -3,6 +3,7 @@ * org.onap.music * =================================================================== * Copyright (c) 2017 AT&T Intellectual Property + * Modifications Copyright (C) 2018 IBM. * =================================================================== * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,6 +29,11 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude.Include; +import org.onap.music.eelf.logging.EELFLoggerDelegate; +import org.onap.music.eelf.logging.format.AppMessages; +import org.onap.music.eelf.logging.format.ErrorSeverity; +import org.onap.music.eelf.logging.format.ErrorTypes; + import io.swagger.annotations.ApiModel; @ApiModel(value = "JsonNotification", description = "Json model for callback") @@ -45,6 +51,7 @@ public class JsonNotification implements Serializable { private String operation_type; private String triggerName; private Map<String, String> response_body; + private static EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(JsonNotification.class); public String getNotify_field() { return notify_field; @@ -111,6 +118,7 @@ public class JsonNotification implements Serializable { try { return new com.fasterxml.jackson.databind.ObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(this); } catch (com.fasterxml.jackson.core.JsonProcessingException e) { + logger.error(EELFLoggerDelegate.errorLogger, e, AppMessages.EXECUTIONINTERRUPTED, ErrorSeverity.ERROR, ErrorTypes.GENERALSERVICEERROR); return notify_field+ " : "+endpoint+ " : "+username+ " : "+password+ " : "+response_body; } diff --git a/src/main/java/org/onap/music/lockingservice/ProtocolSupport.java b/src/main/java/org/onap/music/lockingservice/ProtocolSupport.java index 19f49beb..589e4e57 100644 --- a/src/main/java/org/onap/music/lockingservice/ProtocolSupport.java +++ b/src/main/java/org/onap/music/lockingservice/ProtocolSupport.java @@ -3,6 +3,7 @@ * org.onap.music * =================================================================== * Copyright (c) 2017 AT&T Intellectual Property + * Modifications Copyright (C) 2018 IBM. * =================================================================== * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -128,19 +129,25 @@ class ProtocolSupport { try { return operation.execute(); } catch (KeeperException.SessionExpiredException e) { - logger.error(EELFLoggerDelegate.errorLogger, e.getMessage(),AppMessages.SESSIONEXPIRED+" for: " + zookeeper + " so reconnecting due to: " + e, ErrorSeverity.ERROR, ErrorTypes.SESSIONEXPIRED); + logger.error(EELFLoggerDelegate.errorLogger, e,AppMessages.SESSIONEXPIRED+" for: " + zookeeper + " so reconnecting due to: " + e, ErrorSeverity.ERROR, ErrorTypes.SESSIONEXPIRED); throw e; } catch (KeeperException.ConnectionLossException e) { if (exception == null) { exception = e; } - logger.error(EELFLoggerDelegate.errorLogger, e.getMessage(),AppMessages.CONNCECTIVITYERROR, ErrorSeverity.ERROR, ErrorTypes.SESSIONEXPIRED); - logger.error(EELFLoggerDelegate.errorLogger, e.getMessage(),"Attempt " + i + " failed with connection loss so attempting to reconnect: " + e); + logger.error(EELFLoggerDelegate.errorLogger, e,AppMessages.CONNCECTIVITYERROR, ErrorSeverity.ERROR, ErrorTypes.SESSIONEXPIRED); + logger.error(EELFLoggerDelegate.errorLogger, e,"Attempt " + i + " failed with connection loss so attempting to reconnect: " + e); retryDelay(i); } } - throw exception; + if(exception == null) + { + throw new NullPointerException(); + } + else{ + throw exception; + } } /** @@ -148,7 +155,7 @@ class ProtocolSupport { * * @param path the lock path */ - protected void ensurePathExists(String path) { + protected void ensurePathExists(String path) { ensureExists(path, null, acl, CreateMode.PERSISTENT); } @@ -161,7 +168,7 @@ class ProtocolSupport { * @param flags create mode flags */ protected void ensureExists(final String path, final byte[] data, final List<ACL> acl, - final CreateMode flags) { + final CreateMode flags) { try { retryOperation(new ZooKeeperOperation() { public boolean execute() throws KeeperException, InterruptedException { @@ -174,11 +181,10 @@ class ProtocolSupport { } }); } catch (KeeperException e) { - logger.error("Error", e); - logger.error(EELFLoggerDelegate.errorLogger, e.getMessage(),AppMessages.KEEPERERROR, ErrorSeverity.ERROR, ErrorTypes.LOCKINGERROR); + logger.error(EELFLoggerDelegate.errorLogger, e,AppMessages.KEEPERERROR, ErrorSeverity.ERROR, ErrorTypes.LOCKINGERROR); } catch (InterruptedException e) { - logger.error("Error", e); - logger.error(EELFLoggerDelegate.errorLogger, e.getMessage(),AppMessages.EXECUTIONINTERRUPTED, ErrorSeverity.ERROR, ErrorTypes.LOCKINGERROR); + logger.error(EELFLoggerDelegate.errorLogger, e,AppMessages.EXECUTIONINTERRUPTED, ErrorSeverity.ERROR, ErrorTypes.LOCKINGERROR); + } } @@ -201,8 +207,8 @@ class ProtocolSupport { try { Thread.sleep(attemptCount * retryDelay); } catch (InterruptedException e) { - logger.error(EELFLoggerDelegate.errorLogger, e.getMessage(),AppMessages.EXECUTIONINTERRUPTED, ErrorSeverity.ERROR, ErrorTypes.GENERALSERVICEERROR); - logger.error(EELFLoggerDelegate.errorLogger, e.getMessage(),"Thread failed to sleep: " + e); + logger.error(EELFLoggerDelegate.errorLogger, e,AppMessages.EXECUTIONINTERRUPTED, ErrorSeverity.ERROR, ErrorTypes.GENERALSERVICEERROR); + logger.error(EELFLoggerDelegate.errorLogger, e,"Thread failed to sleep: " + e); Thread.currentThread().interrupt(); } } diff --git a/src/main/java/org/onap/music/lockingservice/ZNodeName.java b/src/main/java/org/onap/music/lockingservice/ZNodeName.java index 0c190f14..f4971e11 100644 --- a/src/main/java/org/onap/music/lockingservice/ZNodeName.java +++ b/src/main/java/org/onap/music/lockingservice/ZNodeName.java @@ -4,6 +4,8 @@ * =================================================================== * Copyright (c) 2017 AT&T Intellectual Property * =================================================================== + * Modifications Copyright (c) 2018 IBM + * =================================================================== * 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 @@ -59,7 +61,7 @@ class ZNodeName implements Comparable<ZNodeName> { @Override public String toString() { - return name.toString(); + return name; } @Override diff --git a/src/main/java/org/onap/music/main/CachingUtil.java b/src/main/java/org/onap/music/main/CachingUtil.java index a81887a0..18cf90d9 100755 --- a/src/main/java/org/onap/music/main/CachingUtil.java +++ b/src/main/java/org/onap/music/main/CachingUtil.java @@ -4,6 +4,8 @@ * =================================================================== * Copyright (c) 2017 AT&T Intellectual Property * =================================================================== + * Modifications Copyright (c) 2018 IBM + * =================================================================== * 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 @@ -65,6 +67,9 @@ public class CachingUtil implements Runnable { private static CacheAccess<String, List<String>> callbackNotifyList = JCS.getInstance("callbackNotifyList"); private static Map<String, Number> userAttempts = new HashMap<>(); private static Map<String, Calendar> lastFailedTime = new HashMap<>(); + + private static final String USERNAME="username"; + private static final String PASSWORD="password"; public boolean isCacheRefreshNeeded() { if (aafCache.get("initBlankMap") == null) @@ -112,8 +117,8 @@ public class CachingUtil implements Runnable { while (it.hasNext()) { Row row = it.next(); String nameSpace = row.getString("keyspace_name"); - String userId = row.getString("username"); - String password = row.getString("password"); + String userId = row.getString(USERNAME); + String password = row.getString(PASSWORD); String keySpace = row.getString("application_name"); try { userAttempts.put(nameSpace, 0); @@ -361,7 +366,7 @@ public class CachingUtil implements Runnable { logger.error(EELFLoggerDelegate.errorLogger,"Application is not onboarded. Please contact admin."); resultMap.put("Exception", "Application is not onboarded. Please contact admin."); } else { - if(!(rs.getString("username").equals(userId)) || !(BCrypt.checkpw(password, rs.getString("password")))) { + if(!(rs.getString(USERNAME).equals(userId)) || !(BCrypt.checkpw(password, rs.getString(PASSWORD)))) { logger.error(EELFLoggerDelegate.errorLogger,"", AppMessages.AUTHENTICATIONERROR, ErrorSeverity.WARN, ErrorTypes.AUTHENTICATIONERROR); logger.error(EELFLoggerDelegate.errorLogger,"Namespace, UserId and password doesn't match. namespace: "+ns+" and userId: "+userId); resultMap.put("Exception", "Namespace, UserId and password doesn't match. namespace: "+ns+" and userId: "+userId); @@ -407,8 +412,8 @@ public class CachingUtil implements Runnable { return resultMap; } else { - String user = rs.getString("username"); - pwd = rs.getString("password"); + String user = rs.getString(USERNAME); + pwd = rs.getString(PASSWORD); String ns = rs.getString("application_name"); if(!ns.equals(nameSpace)) { resultMap.put("Exception", "Namespace and keyspace doesn't match"); diff --git a/src/main/java/org/onap/music/main/MusicUtil.java b/src/main/java/org/onap/music/main/MusicUtil.java index cfad845d..d2e8591c 100755 --- a/src/main/java/org/onap/music/main/MusicUtil.java +++ b/src/main/java/org/onap/music/main/MusicUtil.java @@ -4,6 +4,8 @@ * =================================================================== * Copyright (c) 2017 AT&T Intellectual Property * =================================================================== + * Modifications Copyright (c) 2018 IBM. + * =================================================================== * 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 @@ -578,7 +580,7 @@ public class MusicUtil { authorization = authorization.replaceFirst("Basic", ""); String decoded = Base64.base64Decode(authorization); StringTokenizer token = new StringTokenizer(decoded, ":"); - authValues.put(MusicUtil.USERID, token.nextToken().toString()); + authValues.put(MusicUtil.USERID, token.nextToken()); authValues.put(MusicUtil.PASSWORD,token.nextToken()); return authValues; diff --git a/src/main/java/org/onap/music/main/PropertiesListener.java b/src/main/java/org/onap/music/main/PropertiesListener.java index 0ed18be2..026790ee 100755 --- a/src/main/java/org/onap/music/main/PropertiesListener.java +++ b/src/main/java/org/onap/music/main/PropertiesListener.java @@ -3,6 +3,7 @@ * org.onap.music * =================================================================== * Copyright (c) 2017 AT&T Intellectual Property + * Modifications Copyright (C) 2018 IBM. * =================================================================== * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -37,7 +38,7 @@ import org.onap.music.eelf.logging.format.ErrorTypes; public class PropertiesListener implements ServletContextListener { private Properties prop; - + private static final String MUSIC_PROPERTIES="music.properties"; private static EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(PropertiesListener.class); @Override @@ -51,8 +52,8 @@ public class PropertiesListener implements ServletContextListener { try { InputStream musicProps = null; projectProp.load(new FileInputStream(musicPropertiesFilePath)); - if (projectProp.containsKey("music.properties")) { - musicProps = new FileInputStream(projectProp.getProperty("music.properties")); + if (projectProp.containsKey(MUSIC_PROPERTIES)) { + musicProps = new FileInputStream(projectProp.getProperty(MUSIC_PROPERTIES)); } else { musicProps = new FileInputStream(MusicUtil.getMusicPropertiesFilePath()); } @@ -84,7 +85,7 @@ public class PropertiesListener implements ServletContextListener { case "music.rest.ip": MusicUtil.setMusicRestIp(prop.getProperty(key)); break; - case "music.properties": + case MUSIC_PROPERTIES: MusicUtil.setMusicPropertiesFilePath(prop.getProperty(key)); break; case "lock.lease.period": diff --git a/src/main/java/org/onap/music/rest/RestMusicAdminAPI.java b/src/main/java/org/onap/music/rest/RestMusicAdminAPI.java index 7fb7b1d5..67f50dbb 100755 --- a/src/main/java/org/onap/music/rest/RestMusicAdminAPI.java +++ b/src/main/java/org/onap/music/rest/RestMusicAdminAPI.java @@ -287,7 +287,7 @@ public class RestMusicAdminAPI { ResultSet rs = MusicCore.get(pQuery); List<Row> rows = rs.all(); String uuid = null; - if (rows.size() == 0) { + if (rows.isEmpty()) { resultMap.put("Exception", "Application not found. Please make sure Application exists."); logger.error(EELFLoggerDelegate.errorLogger, "", AppMessages.INCORRECTDATA, @@ -418,8 +418,7 @@ public class RestMusicAdminAPI { @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) public Response callbackOps(final JSONObject inputJsonObj) { - // {"keyspace":"conductor","full_table":"conductor.plans","changeValue":{"conductor.plans.status":"Who??","position":"3"},"operation":"update","table_name":"plans","primary_key":"3"} - Map<String, Object> resultMap = new HashMap<>(); + Map<String, Object> resultMap = new HashMap<>(); new Thread(new Runnable() { public void run() { makeAsyncCall(inputJsonObj); @@ -446,9 +445,7 @@ public class RestMusicAdminAPI { return Response.status(Status.OK).entity(resultMap).build(); } List<String> inputUpdateList = jsonResponse.getUpdateList(); - /*String field_value = changeValueMap.get("field_value"); - if(field_value == null) - field_value = jsonResponse.getFull_table();*/ + String field_value = null; List<String> notifiyList = CachingUtil.getCallbackNotifyList(); if(notifiyList == null || notifiyList.isEmpty()) { diff --git a/src/main/java/org/onap/music/rest/RestMusicBmAPI.java b/src/main/java/org/onap/music/rest/RestMusicBmAPI.java index 55eb47f2..60305bfb 100644 --- a/src/main/java/org/onap/music/rest/RestMusicBmAPI.java +++ b/src/main/java/org/onap/music/rest/RestMusicBmAPI.java @@ -1,7 +1,9 @@ /* * ============LICENSE_START========================================== org.onap.music * =================================================================== Copyright (c) 2017 AT&T - * Intellectual Property =================================================================== + * Intellectual Property + * Modifications Copyright (C) 2018 IBM. + * =================================================================== * 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 * @@ -41,8 +43,6 @@ import org.onap.music.datastore.PreparedQueryObject; import com.datastax.driver.core.DataType; import com.datastax.driver.core.TableMetadata; import io.swagger.annotations.Api; -//import io.swagger.annotations.ApiOperation; -//import io.swagger.annotations.ApiParam; /* * These are functions created purely for benchmarking purposes. Commented out Swagger - This should @@ -54,7 +54,7 @@ import io.swagger.annotations.Api; public class RestMusicBmAPI { private static EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(RestMusicBmAPI.class); - + public static final String UPDATE_CONST=" update-"; // pure zk calls... /** @@ -117,7 +117,7 @@ public class RestMusicBmAPI { String operationId = UUID.randomUUID().toString();// just for debugging purposes. String consistency = updateObj.getConsistencyInfo().get("type"); - logger.info(EELFLoggerDelegate.applicationLogger,"--------------Zookeeper " + consistency + " update-" + operationId + logger.info(EELFLoggerDelegate.applicationLogger,"--------------Zookeeper " + consistency + UPDATE_CONST + operationId + "-------------------------"); byte[] data = updateObj.serialize(); @@ -130,16 +130,17 @@ public class RestMusicBmAPI { long leasePeriod = MusicUtil.getDefaultLockLeasePeriod(); ReturnType lockAcqResult = MusicCore.acquireLockWithLease(lockname, lockId, leasePeriod); long lockAcqTime = System.currentTimeMillis(); - long zkPutTime = 0, lockReleaseTime = 0; + long zkPutTime = 0; + long lockReleaseTime = 0; if (lockAcqResult.getResult().equals(ResultType.SUCCESS)) { logger.info(EELFLoggerDelegate.applicationLogger,"acquired lock with id " + lockId); MusicCore.pureZkWrite(lockname, data); zkPutTime = System.currentTimeMillis(); boolean voluntaryRelease = true; - if (consistency.equals("atomic")) + if (("atomic").equals(consistency)) MusicCore.releaseLock(lockId, voluntaryRelease); - else if (consistency.equals("atomic_delete_lock")) + else if (("atomic_delete_lock").equals(consistency)) MusicCore.deleteLock(lockname); lockReleaseTime = System.currentTimeMillis(); } else { @@ -155,12 +156,12 @@ public class RestMusicBmAPI { + "|lock accquire time:" + (lockAcqTime - lockCreationTime) + "|zk put time:" + (zkPutTime - lockAcqTime); - if (consistency.equals("atomic")) + if ("atomic".equals(consistency)) lockingInfo = lockingInfo + "|lock release time:" + (lockReleaseTime - zkPutTime) + "|"; - else if (consistency.equals("atomic_delete_lock")) + else if ("atomic_delete_lock".equals(consistency)) lockingInfo = lockingInfo + "|lock delete time:" + (lockReleaseTime - zkPutTime) + "|"; - String timingString = "Time taken in ms for Zookeeper " + consistency + " update-" + String timingString = "Time taken in ms for Zookeeper " + consistency + UPDATE_CONST + operationId + ":" + "|total operation time:" + (endTime - startTime) + "|json parsing time:" + (jsonParseCompletionTime - startTime) + "|update time:" + (actualUpdateCompletionTime - jsonParseCompletionTime) @@ -220,7 +221,7 @@ public class RestMusicBmAPI { long startTime = System.currentTimeMillis(); String operationId = UUID.randomUUID().toString();// just for debugging purposes. String consistency = insObj.getConsistencyInfo().get("type"); - logger.info(EELFLoggerDelegate.applicationLogger,"--------------Cassandra " + consistency + " update-" + operationId + logger.info(EELFLoggerDelegate.applicationLogger,"--------------Cassandra " + consistency + UPDATE_CONST + operationId + "-------------------------"); PreparedQueryObject queryObject = new PreparedQueryObject(); Map<String, Object> valuesMap = insObj.getValues(); @@ -295,7 +296,7 @@ public class RestMusicBmAPI { long endTime = System.currentTimeMillis(); - String timingString = "Time taken in ms for Cassandra " + consistency + " update-" + String timingString = "Time taken in ms for Cassandra " + consistency + UPDATE_CONST + operationId + ":" + "|total operation time:" + (endTime - startTime) + "|json parsing time:" + (jsonParseCompletionTime - startTime) + "|update time:" + (actualUpdateCompletionTime - jsonParseCompletionTime) diff --git a/src/main/java/org/onap/music/rest/RestMusicHealthCheckAPI.java b/src/main/java/org/onap/music/rest/RestMusicHealthCheckAPI.java index 44b4a514..f6dc4e57 100644 --- a/src/main/java/org/onap/music/rest/RestMusicHealthCheckAPI.java +++ b/src/main/java/org/onap/music/rest/RestMusicHealthCheckAPI.java @@ -3,6 +3,8 @@ * org.onap.music * =================================================================== * Copyright (c) 2017 AT&T Intellectual Property + * + * Modifications Copyright (C) 2018 IBM. * =================================================================== * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -35,20 +37,14 @@ 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.Consumes; import javax.ws.rs.core.Response; -import javax.ws.rs.core.Response.ResponseBuilder; import javax.ws.rs.core.Response.Status; -import org.onap.music.response.jsonobjects.JsonResponse; import org.onap.music.eelf.healthcheck.MusicHealthCheck; import org.onap.music.eelf.logging.EELFLoggerDelegate; import org.onap.music.main.MusicUtil; -import org.onap.music.main.ResultType; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; import com.datastax.driver.core.ConsistencyLevel; import io.swagger.annotations.Api; @@ -64,7 +60,7 @@ public class RestMusicHealthCheckAPI { private static EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(MusicUtil.class); - + private static final String activeStatus = "ACTIVE"; @GET @Path("/pingCassandra/{consistency}") @@ -81,8 +77,8 @@ public class RestMusicHealthCheckAPI { } MusicHealthCheck cassHealthCheck = new MusicHealthCheck(); String status = cassHealthCheck.getCassandraStatus(consistency); - if(status.equals("ACTIVE")) { - resultMap.put("ACTIVE", "Cassandra Running and Listening to requests"); + if(status.equals(activeStatus)) { + resultMap.put(activeStatus, "Cassandra Running and Listening to requests"); return Response.status(Status.OK).entity(resultMap).build(); } else { resultMap.put("INACTIVE", "One or more nodes in the Cluster is/are down or not responding."); @@ -102,8 +98,8 @@ public class RestMusicHealthCheckAPI { 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"); + if(status.equals(activeStatus)) { + resultMap.put(activeStatus, "Zookeeper is Active and Running"); return Response.status(Status.OK).entity(resultMap).build(); }else { resultMap.put("INACTIVE", "Zookeeper is not responding"); @@ -120,13 +116,13 @@ public class RestMusicHealthCheckAPI { Map<String, Object> resultMap = new HashMap<>(); MusicHealthCheck healthCheck = new MusicHealthCheck(); String status = healthCheck.getZookeeperStatus(); - if(status.equals("ACTIVE")) { + if(status.equals(activeStatus)) { resultMap.put("ZooKeeper", "Active"); }else { resultMap.put("ZooKeeper", "Inactive"); } status = healthCheck.getCassandraStatus(ConsistencyLevel.ANY.toString()); - if(status.equals("ACTIVE")) { + if(status.equals(activeStatus)) { resultMap.put("Cassandra", "Active"); } else { resultMap.put("Cassandra", "Inactive"); diff --git a/src/main/java/org/onap/music/rest/RestMusicQAPI.java b/src/main/java/org/onap/music/rest/RestMusicQAPI.java index 1f6ec24f..a883534e 100755 --- a/src/main/java/org/onap/music/rest/RestMusicQAPI.java +++ b/src/main/java/org/onap/music/rest/RestMusicQAPI.java @@ -1,7 +1,8 @@ /* * ============LICENSE_START========================================== org.onap.music * =================================================================== Copyright (c) 2017 AT&T - * Intellectual Property =================================================================== + * Intellectual Property ===================================================================Modifications Copyright (c) 2018 IBM + * Intellectual Property =================================================================== * * 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 * @@ -62,13 +63,7 @@ import io.swagger.annotations.ApiParam; public class RestMusicQAPI { private EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(RestMusicQAPI.class); - /* - * private static final String XMINORVERSION = "X-minorVersion"; private static final String - * XPATCHVERSION = "X-patchVersion"; private static final String NS = "ns"; private static final - * String USERID = "userId"; private static final String PASSWORD = "password"; - * */ - // private static final String VERSION = "v2"; - + /** * @@ -294,7 +289,6 @@ public class RestMusicQAPI { @ApiParam(value = "Table Name", required = true) @PathParam("qname") String tablename, @Context UriInfo info) { - //logger.info(EELFLoggerDelegate.errorLogger, "", AppMessages.MISSINGDATA, ErrorSeverity.CRITICAL, ResponseBuilder response = MusicUtil.buildVersionResponse(version, minorVersion, patchVersion); if (updateObj.getValues().isEmpty()) { logger.error(EELFLoggerDelegate.errorLogger, "", AppMessages.MISSINGDATA, @@ -447,14 +441,7 @@ public class RestMusicQAPI { @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 { - /* - * PreparedQueryObject query = new RestMusicDataAPI().selectSpecificQuery(version, minorVersion, - * patchVersion, aid, ns, userId, password, keyspace, tablename, info, limit); ResultSet results - */ - /* Map<String ,String> auth = new HashMap<>(); - String userId =auth.get(MusicUtil.USERID); - String password =auth.get(MusicUtil.PASSWORD); - */ + return new RestMusicDataAPI().select(version, minorVersion, patchVersion, aid, ns, authorization, keyspace, tablename, info);// , limit) } |