- /**
- *
- * @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) throws Exception {
- 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(version, minorVersion,
- patchVersion, aid, ns, userId, password, keyspace, tablename, info, limit);
- } catch (MusicServiceException ex) {
- logger.error(EELFLoggerDelegate.errorLogger, "", AppMessages.UNKNOWNERROR,
- ErrorSeverity.WARN, ErrorTypes.GENERALSERVICEERROR);
- return response.status(Status.BAD_REQUEST)
+ /**
+ *
+ * @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,
+ ErrorSeverity.WARN, ErrorTypes.GENERALSERVICEERROR, 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)