Changes Listed below:
[music.git] / src / main / java / org / onap / music / rest / RestMusicQAPI.java
index f3df935..3940c84 100755 (executable)
@@ -70,8 +70,8 @@ import io.swagger.annotations.ApiParam;
 @Api(value = "Q Api")
 public class RestMusicQAPI {
 
-  private EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(RestMusicQAPI.class);
-  
+    private EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(RestMusicQAPI.class);
+
 
   /**
    * 
@@ -81,138 +81,135 @@ public class RestMusicQAPI {
    * @throws Exception
    */
  
-  @POST
-  @Path("/keyspaces/{keyspace}/{qname}") // qname same as tablename
-  @ApiOperation(value = "Create Q", response = String.class)
-  @Consumes(MediaType.APPLICATION_JSON)
-  @Produces(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 = false) @HeaderParam("aid") String aid,
-          @ApiParam(value = "Application namespace", required = true) @HeaderParam("ns") String ns,
-          @ApiParam(value = "Authorization", required = true) @HeaderParam(MusicUtil.AUTHORIZATION) String authorization,
-          JsonTable tableObj, 
-          @ApiParam(value = "Key Space", required = true) @PathParam("keyspace") String keyspace,
+    @POST
+    @Path("/keyspaces/{keyspace}/{qname}") // qname same as tablename
+    @ApiOperation(value = "Create Q", response = String.class)
+    @Consumes(MediaType.APPLICATION_JSON)
+    @Produces(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 = false) @HeaderParam("aid") String aid,
+        @ApiParam(value = "Application namespace", required = true) @HeaderParam("ns") String ns,
+        @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 {
-    ResponseBuilder response = MusicUtil.buildVersionResponse(version, minorVersion, patchVersion);
+        ResponseBuilder response = MusicUtil.buildVersionResponse(version, minorVersion, patchVersion);
 
-    Map<String, String> fields = tableObj.getFields();
+        Map<String, String> fields = tableObj.getFields();
     if (fields == null) {
-      logger.error(EELFLoggerDelegate.errorLogger, "", AppMessages.MISSINGDATA,
-              ErrorSeverity.CRITICAL, ErrorTypes.DATAERROR);
-      return response.status(Status.BAD_REQUEST)
-              .entity(new JsonResponse(ResultType.FAILURE)
-                      .setError("CreateQ/Required table fields are empty or not set").toMap())
-              .build();
-    }
-
-    String primaryKey = tableObj.getPrimaryKey();
-    String partitionKey = tableObj.getPartitionKey();
-    String clusteringKey = tableObj.getClusteringKey();
-    String filteringKey = tableObj.getFilteringKey();
-    String clusteringOrder = tableObj.getClusteringOrder();
-
-    if(primaryKey == null) {
-        primaryKey = tableObj.getFields().get("PRIMARY KEY");
-    }
-
-    if ((primaryKey == null) && (partitionKey == null)) {
-        logger.error(EELFLoggerDelegate.errorLogger, "", AppMessages.MISSINGDATA,
+            logger.error(EELFLoggerDelegate.errorLogger, "", AppMessages.MISSINGDATA,
                 ErrorSeverity.CRITICAL, ErrorTypes.DATAERROR);
-        return response.status(Status.BAD_REQUEST)
+            return response.status(Status.BAD_REQUEST)
                 .entity(new JsonResponse(ResultType.FAILURE)
-                        .setError("CreateQ: Partition key cannot be empty").toMap())
+                .setError("CreateQ/Required table fields are empty or not set").toMap())
                 .build();
-      }
+        }
 
-    if ((primaryKey == null) && (clusteringKey == null)) {
-        logger.error(EELFLoggerDelegate.errorLogger, "", AppMessages.MISSINGDATA,
-                ErrorSeverity.CRITICAL, ErrorTypes.DATAERROR);
-        return response.status(Status.BAD_REQUEST)
-                .entity(new JsonResponse(ResultType.FAILURE)
-                        .setError("CreateQ: Clustering key cannot be empty").toMap())
-                .build();
-      }
+        String primaryKey = tableObj.getPrimaryKey();
+        String partitionKey = tableObj.getPartitionKey();
+        String clusteringKey = tableObj.getClusteringKey();
+        String filteringKey = tableObj.getFilteringKey();
+        String clusteringOrder = tableObj.getClusteringOrder();
 
-    if (clusteringOrder == null) {
-        logger.error(EELFLoggerDelegate.errorLogger, "", AppMessages.MISSINGDATA,
-                ErrorSeverity.CRITICAL, ErrorTypes.DATAERROR);
-        return response.status(Status.BAD_REQUEST)
-                .entity(new JsonResponse(ResultType.FAILURE)
-                        .setError("CreateQ: Clustering Order cannot be empty").toMap())
-                .build();
-      }
+        if(primaryKey == null) {
+            primaryKey = tableObj.getFields().get("PRIMARY KEY");
+        }
 
-    if ((primaryKey!=null) && (partitionKey == null)) {
-        primaryKey = primaryKey.trim();
-        int count1 = StringUtils.countMatches(primaryKey,')');
-        int count2 = StringUtils.countMatches(primaryKey,'(');
-        if (count1 != count2) {
-            return response.status(Status.BAD_REQUEST).entity(new JsonResponse(ResultType.FAILURE)
-                      .setError("CreateQ Error: primary key '(' and ')' do not match, primary key=" + primaryKey)
-                      .toMap()).build();
+        if ((primaryKey == null) && (partitionKey == null)) {
+            logger.error(EELFLoggerDelegate.errorLogger, "", AppMessages.MISSINGDATA,
+                    ErrorSeverity.CRITICAL, ErrorTypes.DATAERROR);
+            return response.status(Status.BAD_REQUEST)
+                    .entity(new JsonResponse(ResultType.FAILURE)
+                            .setError("CreateQ: Partition key cannot be empty").toMap())
+                    .build();
         }
 
-        if ( primaryKey.indexOf('(') == -1  || ( count2 == 1 && (primaryKey.lastIndexOf(')') +1) ==  primaryKey.length() ) )
-        {
-            if (primaryKey.contains(",") ) {
-                partitionKey= primaryKey.substring(0,primaryKey.indexOf(','));
-                partitionKey=partitionKey.replaceAll("[\\(]+","");
-                clusteringKey=primaryKey.substring(primaryKey.indexOf(',')+1);  // make sure index
-                clusteringKey=clusteringKey.replaceAll("[)]+", "");
+        if ((primaryKey == null) && (clusteringKey == null)) {
+            logger.error(EELFLoggerDelegate.errorLogger, "", AppMessages.MISSINGDATA,
+                    ErrorSeverity.CRITICAL, ErrorTypes.DATAERROR);
+            return response.status(Status.BAD_REQUEST)
+                    .entity(new JsonResponse(ResultType.FAILURE)
+                            .setError("CreateQ: Clustering key cannot be empty").toMap())
+                    .build();
+        }
+
+        if (clusteringOrder == null) {
+            logger.error(EELFLoggerDelegate.errorLogger, "", AppMessages.MISSINGDATA,
+                    ErrorSeverity.CRITICAL, ErrorTypes.DATAERROR);
+            return response.status(Status.BAD_REQUEST)
+                    .entity(new JsonResponse(ResultType.FAILURE)
+                            .setError("CreateQ: Clustering Order cannot be empty").toMap())
+                    .build();
+        }
+
+        if ((primaryKey!=null) && (partitionKey == null)) {
+            primaryKey = primaryKey.trim();
+            int count1 = StringUtils.countMatches(primaryKey,')');
+            int count2 = StringUtils.countMatches(primaryKey,'(');
+            if (count1 != count2) {
+                return response.status(Status.BAD_REQUEST).entity(new JsonResponse(ResultType.FAILURE)
+                    .setError("CreateQ Error: primary key '(' and ')' do not match, primary key=" + primaryKey)
+                    .toMap()).build();
+            }
+
+            if ( primaryKey.indexOf('(') == -1  || ( count2 == 1 && (primaryKey.lastIndexOf(')') +1) ==  primaryKey.length() ) ) {
+                if (primaryKey.contains(",") ) {
+                    partitionKey= primaryKey.substring(0,primaryKey.indexOf(','));
+                    partitionKey=partitionKey.replaceAll("[\\(]+","");
+                    clusteringKey=primaryKey.substring(primaryKey.indexOf(',')+1);  // make sure index
+                    clusteringKey=clusteringKey.replaceAll("[)]+", "");
+                } else {
+                    partitionKey=primaryKey;
+                    partitionKey=partitionKey.replaceAll("[\\)]+","");
+                    partitionKey=partitionKey.replaceAll("[\\(]+","");
+                    clusteringKey="";
+                }
             } else {
-              partitionKey=primaryKey;
-              partitionKey=partitionKey.replaceAll("[\\)]+","");
-              partitionKey=partitionKey.replaceAll("[\\(]+","");
-              clusteringKey="";
-           }
-      } else {
-            partitionKey= primaryKey.substring(0,primaryKey.indexOf(')'));
-            partitionKey=partitionKey.replaceAll("[\\(]+","");
-            partitionKey = partitionKey.trim();
-            clusteringKey= primaryKey.substring(primaryKey.indexOf(')'));
-            clusteringKey=clusteringKey.replaceAll("[\\(]+","");
-            clusteringKey=clusteringKey.replaceAll("[\\)]+","");
-            clusteringKey = clusteringKey.trim();
-            if (clusteringKey.indexOf(',') == 0) clusteringKey=clusteringKey.substring(1);
-            clusteringKey = clusteringKey.trim();
-            if (clusteringKey.equals(",") ) clusteringKey=""; // print error if needed    ( ... ),)
-         }
-    }
+                partitionKey= primaryKey.substring(0,primaryKey.indexOf(')'));
+                partitionKey=partitionKey.replaceAll("[\\(]+","");
+                partitionKey = partitionKey.trim();
+                clusteringKey= primaryKey.substring(primaryKey.indexOf(')'));
+                clusteringKey=clusteringKey.replaceAll("[\\(]+","");
+                clusteringKey=clusteringKey.replaceAll("[\\)]+","");
+                clusteringKey = clusteringKey.trim();
+                if (clusteringKey.indexOf(',') == 0) clusteringKey=clusteringKey.substring(1);
+                clusteringKey = clusteringKey.trim();
+                if (clusteringKey.equals(",") ) clusteringKey=""; // print error if needed    ( ... ),)
+            }
+        }
 
-    if (partitionKey.trim().isEmpty()) {
-        logger.error(EELFLoggerDelegate.errorLogger, "", AppMessages.MISSINGDATA,
+        if (partitionKey.trim().isEmpty()) {
+            logger.error(EELFLoggerDelegate.errorLogger, "", AppMessages.MISSINGDATA,
                 ErrorSeverity.CRITICAL, ErrorTypes.DATAERROR);
-        return response.status(Status.BAD_REQUEST)
+            return response.status(Status.BAD_REQUEST)
                 .entity(new JsonResponse(ResultType.FAILURE)
-                        .setError("CreateQ: Partition key cannot be empty").toMap())
+                .setError("CreateQ: Partition key cannot be empty").toMap())
                 .build();
-    }
+        }
 
-    if (clusteringKey.trim().isEmpty()) {
-        logger.error(EELFLoggerDelegate.errorLogger, "", AppMessages.MISSINGDATA,
+        if (clusteringKey.trim().isEmpty()) {
+            logger.error(EELFLoggerDelegate.errorLogger, "", AppMessages.MISSINGDATA,
                 ErrorSeverity.CRITICAL, ErrorTypes.DATAERROR);
-        return response.status(Status.BAD_REQUEST)
+            return response.status(Status.BAD_REQUEST)
                 .entity(new JsonResponse(ResultType.FAILURE)
-                        .setError("CreateQ: Clustering key cannot be empty").toMap())
+                .setError("CreateQ: Clustering key cannot be empty").toMap())
                 .build();
-    }
+        }
 
-    if((filteringKey != null) && (filteringKey.equalsIgnoreCase(partitionKey))) {
-        logger.error(EELFLoggerDelegate.errorLogger, "", AppMessages.MISSINGDATA,
+        if((filteringKey != null) && (filteringKey.equalsIgnoreCase(partitionKey))) {
+            logger.error(EELFLoggerDelegate.errorLogger, "", AppMessages.MISSINGDATA,
                 ErrorSeverity.CRITICAL, ErrorTypes.DATAERROR);
-        return response.status(Status.BAD_REQUEST)
+            return response.status(Status.BAD_REQUEST)
                 .entity(new JsonResponse(ResultType.FAILURE)
-                        .setError("CreateQ: Filtering key cannot be same as Partition Key").toMap())
+                .setError("CreateQ: Filtering key cannot be same as Partition Key").toMap())
                 .build();
-    }
+        }
 
-    return new RestMusicDataAPI().createTable(version, minorVersion, patchVersion, aid, ns, authorization, tableObj, keyspace, tablename);
-  }
+        return new RestMusicDataAPI().createTable(version, minorVersion, patchVersion, aid, ns, authorization, tableObj, keyspace, tablename);
+    }
 
   /**
    * 
@@ -221,234 +218,225 @@ public class RestMusicQAPI {
    * @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<String, Object> insertIntoQ(
-  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 = false) @HeaderParam("aid") String aid,
-          @ApiParam(value = "Application namespace", required = true) @HeaderParam("ns") String ns,
-          @ApiParam(value = "Authorization", required = true) @HeaderParam(MusicUtil.AUTHORIZATION) String authorization,
-          JsonInsert insObj,
-          @ApiParam(value = "Key Space", required = true) @PathParam("keyspace") String keyspace,
-          @ApiParam(value = "Table Name", required = true) @PathParam("qname") String tablename)
-           {
-    ResponseBuilder response = MusicUtil.buildVersionResponse(version, minorVersion, patchVersion);
-    if (insObj.getValues().isEmpty()) {
-      logger.error(EELFLoggerDelegate.errorLogger, "", AppMessages.MISSINGDATA,
-              ErrorSeverity.CRITICAL, ErrorTypes.DATAERROR);
-      return response.status(Status.BAD_REQUEST).entity(new JsonResponse(ResultType.FAILURE)
-              .setError("Required HTTP Request body is missing.").toMap()).build();
-    }
-    return new RestMusicDataAPI().insertIntoTable(version, minorVersion, patchVersion, aid, ns,
+    @POST
+    @Path("/keyspaces/{keyspace}/{qname}/rows")
+    @ApiOperation(value = "", response = Void.class)
+    @Consumes(MediaType.APPLICATION_JSON)
+    @Produces(MediaType.APPLICATION_JSON)
+    // public Map<String, Object> insertIntoQ(
+    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 = false) @HeaderParam("aid") String aid,
+        @ApiParam(value = "Application namespace", required = true) @HeaderParam("ns") String ns,
+        @ApiParam(value = "Authorization", required = true) @HeaderParam(MusicUtil.AUTHORIZATION) String authorization,
+        JsonInsert insObj,
+        @ApiParam(value = "Key Space", required = true) @PathParam("keyspace") String keyspace,
+        @ApiParam(value = "Table Name", required = true) @PathParam("qname") String tablename) {
+        
+        ResponseBuilder response = MusicUtil.buildVersionResponse(version, minorVersion, patchVersion);
+        if (insObj.getValues().isEmpty()) {
+            logger.error(EELFLoggerDelegate.errorLogger, "", AppMessages.MISSINGDATA,
+            ErrorSeverity.CRITICAL, ErrorTypes.DATAERROR);
+            return response.status(Status.BAD_REQUEST).entity(new JsonResponse(ResultType.FAILURE)
+                .setError("Required HTTP Request body is missing.").toMap()).build();
+        }
+        return new RestMusicDataAPI().insertIntoTable(version, minorVersion, patchVersion, aid, ns,
             authorization, insObj, keyspace, tablename);
-  }
-
-  /**
-   * 
-   * @param updateObj
-   * @param keyspace
-   * @param tablename
-   * @param info
-   * @return
-   * @throws Exception
-   */
-  @PUT
-  @Path("/keyspaces/{keyspace}/{qname}/rows")
-  @ApiOperation(value = "updateQ", 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 = false) @HeaderParam("aid") String aid,
-          @ApiParam(value = "Application namespace", required = true) @HeaderParam("ns") String ns,
-          @ApiParam(value = "Authorization", required = true) @HeaderParam(MusicUtil.AUTHORIZATION) String authorization,
-          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 MusicServiceException, MusicQueryException {
-
-    ResponseBuilder response = MusicUtil.buildVersionResponse(version, minorVersion, patchVersion);
-    if (updateObj.getValues().isEmpty()) {
-      logger.error(EELFLoggerDelegate.errorLogger, "", AppMessages.MISSINGDATA,
-              ErrorSeverity.CRITICAL, ErrorTypes.DATAERROR);
-      return response.status(Status.BAD_REQUEST)
-              .entity(new JsonResponse(ResultType.FAILURE).setError(
-                      "Required HTTP Request body is missing. JsonUpdate updateObj.getValues() is empty. ")
-                      .toMap())
-              .build();
-
     }
-    return new RestMusicDataAPI().updateTable(version, minorVersion, patchVersion, aid, ns, 
-            authorization,updateObj, keyspace, tablename, info);
-  }
 
-  /**
-   * 
-   * @param delObj
-   * @param keyspace
-   * @param tablename
-   * @param info
-   * 
-   * @return
-   * @throws Exception
-   */
+    /**
+    * 
+    * @param updateObj
+    * @param keyspace
+    * @param tablename
+    * @param info
+    * @return
+    * @throws Exception
+    */
+    @PUT
+    @Path("/keyspaces/{keyspace}/{qname}/rows")
+    @ApiOperation(value = "updateQ", 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 = false) @HeaderParam("aid") String aid,
+        @ApiParam(value = "Application namespace", required = true) @HeaderParam("ns") String ns,
+        @ApiParam(value = "Authorization", required = true) @HeaderParam(MusicUtil.AUTHORIZATION) String authorization,
+        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 MusicServiceException, MusicQueryException {
+
+        ResponseBuilder response = MusicUtil.buildVersionResponse(version, minorVersion, patchVersion);
+        if (updateObj.getValues().isEmpty()) {
+            logger.error(EELFLoggerDelegate.errorLogger, "", AppMessages.MISSINGDATA,
+                ErrorSeverity.CRITICAL, ErrorTypes.DATAERROR);
+            return response.status(Status.BAD_REQUEST)
+                .entity(new JsonResponse(ResultType.FAILURE)
+                .setError("Required HTTP Request body is missing. JsonUpdate updateObj.getValues() is empty. ")
+                .toMap())
+                .build();
+        }
+        return new RestMusicDataAPI().updateTable(version, minorVersion, patchVersion, aid, ns, 
+            authorization,updateObj, keyspace, tablename, info);
+    }
 
-  @DELETE
-  @Path("/keyspaces/{keyspace}/{qname}/rows")
-  @ApiOperation(value = "deleteQ", 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 = false) @HeaderParam("aid") String aid,
-          @ApiParam(value = "Application namespace", required = true) @HeaderParam("ns") String ns,
-          @ApiParam(value = "Authorization", required = true) @HeaderParam(MusicUtil.AUTHORIZATION) String authorization,
-          JsonDelete delObj,
-          @ApiParam(value = "Key Space", required = true) @PathParam("keyspace") String keyspace,
-          @ApiParam(value = "Table Name", required = true) @PathParam("qname") String tablename,
+    /**
+    * 
+    * @param delObj
+    * @param keyspace
+    * @param tablename
+    * @param info
+    * 
+    * @return
+    * @throws Exception
+    */
+
+    @DELETE
+    @Path("/keyspaces/{keyspace}/{qname}/rows")
+    @ApiOperation(value = "deleteQ", 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 = false) @HeaderParam("aid") String aid,
+    @ApiParam(value = "Application namespace", required = true) @HeaderParam("ns") String ns,
+    @ApiParam(value = "Authorization", required = true) @HeaderParam(MusicUtil.AUTHORIZATION) String authorization,
+    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 MusicServiceException, MusicQueryException {
     // added checking as per RestMusicDataAPI
     ResponseBuilder response = MusicUtil.buildVersionResponse(version, minorVersion, patchVersion);
     if (delObj == null) {
-      logger.error(EELFLoggerDelegate.errorLogger, "", AppMessages.MISSINGDATA,
-              ErrorSeverity.CRITICAL, ErrorTypes.DATAERROR);
-      return response.status(Status.BAD_REQUEST).entity(new JsonResponse(ResultType.FAILURE)
-              .setError("deleteFromQ JsonDelete delObjis empty").toMap()).build();
+        logger.error(EELFLoggerDelegate.errorLogger, "", AppMessages.MISSINGDATA,
+            ErrorSeverity.CRITICAL, ErrorTypes.DATAERROR);
+        return response.status(Status.BAD_REQUEST).entity(new JsonResponse(ResultType.FAILURE)
+            .setError("deleteFromQ JsonDelete delObjis empty").toMap()).build();
     }
 
-    return new RestMusicDataAPI().deleteFromTable(version, minorVersion, patchVersion, aid, ns,
-            authorization, delObj, keyspace, tablename, info);
-  }
+    return new RestMusicDataAPI().deleteFromTable(version, minorVersion, patchVersion, aid, ns,         
+        authorization, 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<String, HashMap<String, Object>> peek(
-  public Response 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 = false) @HeaderParam("aid") String aid,
-          @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,
+    /**
+    * 
+    * @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<String, HashMap<String, Object>> peek(
+    public Response 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 = false) @HeaderParam("aid") String aid,
+        @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,
           @Context UriInfo info)  {
-    int limit =1; //peek must return just the top row
-    Map<String ,String> auth = new HashMap<>();
-    String userId =auth.get(MusicUtil.USERID);
-    String password =auth.get(MusicUtil.PASSWORD);  
-    ResponseBuilder response = MusicUtil.buildVersionResponse(version, minorVersion, patchVersion);
-   
-    PreparedQueryObject queryObject = new PreparedQueryObject();
-    if (info.getQueryParameters() == null ) //|| info.getQueryParameters().isEmpty())
-      queryObject.appendQueryString(
-              "SELECT *  FROM " + keyspace + "." + tablename + " LIMIT " + limit + ";");
-    else {
-
-      try {
-        queryObject = new RestMusicDataAPI().selectSpecificQuery(keyspace, tablename, info, limit);
-      } catch (MusicServiceException ex) {
-        logger.error(EELFLoggerDelegate.errorLogger, "", AppMessages.UNKNOWNERROR,
+        int limit =1; //peek must return just the top row
+        Map<String ,String> auth = new HashMap<>();
+        String userId =auth.get(MusicUtil.USERID);
+        String password =auth.get(MusicUtil.PASSWORD);  
+        ResponseBuilder response = MusicUtil.buildVersionResponse(version, minorVersion, patchVersion);
+
+        PreparedQueryObject queryObject = new PreparedQueryObject();
+        if (info.getQueryParameters() == null ) { //|| info.getQueryParameters().isEmpty())
+            queryObject.appendQueryString(
+                "SELECT *  FROM " + keyspace + "." + tablename + " LIMIT " + limit + ";");
+        } else {
+            try {
+                queryObject = new RestMusicDataAPI().selectSpecificQuery(keyspace, tablename, info, limit);
+            } catch (MusicServiceException ex) {
+                logger.error(EELFLoggerDelegate.errorLogger, "", AppMessages.UNKNOWNERROR,
                 ErrorSeverity.WARN, ErrorTypes.GENERALSERVICEERROR, ex);
-        return response.status(Status.BAD_REQUEST)
+                return response.status(Status.BAD_REQUEST)
+                    .entity(new JsonResponse(ResultType.FAILURE).setError(ex.getMessage()).toMap())
+                    .build();
+            }
+        }
+
+        try {
+            ResultSet results = MusicCore.get(queryObject);
+            return response.status(Status.OK).entity(new JsonResponse(ResultType.SUCCESS)
+                .setDataResult(MusicDataStoreHandle.marshallResults(results)).toMap()).build();
+        } catch (MusicServiceException ex) {
+            logger.error(EELFLoggerDelegate.errorLogger, "", AppMessages.UNKNOWNERROR,
+              ErrorSeverity.ERROR, ErrorTypes.MUSICSERVICEERROR, ex);
+            return response.status(Status.BAD_REQUEST)
                 .entity(new JsonResponse(ResultType.FAILURE).setError(ex.getMessage()).toMap())
                 .build();
-      }
+        }
     }
 
-    try {
-      ResultSet results = MusicCore.get(queryObject);
-      return response.status(Status.OK).entity(new JsonResponse(ResultType.SUCCESS)
-              .setDataResult(MusicDataStoreHandle.marshallResults(results)).toMap()).build();
-    } catch (MusicServiceException ex) {
-      logger.error(EELFLoggerDelegate.errorLogger, "", AppMessages.UNKNOWNERROR,
-              ErrorSeverity.ERROR, ErrorTypes.MUSICSERVICEERROR, ex);
-      return response.status(Status.BAD_REQUEST)
-              .entity(new JsonResponse(ResultType.FAILURE).setError(ex.getMessage()).toMap())
-              .build();
-    }
-  }
+    /**
+    * 
+    *
+    * @param keyspace
+    * @param tablename
+    * @param info
+    * @return
+    * @throws Exception
+    */
+    @GET
+    @Path("/keyspaces/{keyspace}/{qname}/filter")
+    @ApiOperation(value = "filter", response = Map.class)
+    @Produces(MediaType.APPLICATION_JSON)
+    // public Map<String, HashMap<String, Object>> filter(
+    public Response 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 = false) @HeaderParam("aid") String aid,
+        @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,
+        @Context UriInfo info) throws Exception {
+
+        return new RestMusicDataAPI().select(version, minorVersion, patchVersion, aid, ns, authorization, keyspace, tablename, info);// , limit)
 
-  /**
-   * 
-   *
-   * @param keyspace
-   * @param tablename
-   * @param info
-   * @return
-   * @throws Exception
-   */
-  @GET
-  @Path("/keyspaces/{keyspace}/{qname}/filter")
-  @ApiOperation(value = "filter", response = Map.class)
-  @Produces(MediaType.APPLICATION_JSON)
-  // public Map<String, HashMap<String, Object>> filter(
-  public Response 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 = false) @HeaderParam("aid") String aid,
-      @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,
-      @Context UriInfo info) throws Exception {
-    return new RestMusicDataAPI().select(version, minorVersion, patchVersion, aid, ns, authorization, keyspace, tablename, info);// , limit)
-    
-  }
+    }
 
-  /**
-   * 
-   * @param tabObj
-   * @param keyspace
-   * @param tablename
-   * @throws Exception
-   */
-  @DELETE
-  @ApiOperation(value = "DropQ", response = String.class)
-  @Path("/keyspaces/{keyspace}/{qname}")
-  @Produces(MediaType.APPLICATION_JSON)
-  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 = false) @HeaderParam("aid") String aid,
-          @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,
+    /**
+    
+    * @param tabObj
+    * @param keyspace
+    * @param tablename
+    * @throws Exception
+    */
+    @DELETE
+    @ApiOperation(value = "DropQ", response = String.class)
+    @Path("/keyspaces/{keyspace}/{qname}")
+    @Produces(MediaType.APPLICATION_JSON)
+    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 = false) @HeaderParam("aid") String aid,
+        @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 {
 
-    return new RestMusicDataAPI().dropTable(version, minorVersion, patchVersion, aid, ns, authorization, keyspace, tablename);
-  }
+        return new RestMusicDataAPI().dropTable(version, minorVersion, patchVersion, aid, ns, authorization, keyspace, tablename);
+
+    }
 }