Commit 3f6490c8 by Shwetha G S

Merge pull request #130 from shwethags/utf8

setting response mime type charset to utf8
parents 5fce46d4 ef2332ef
...@@ -133,12 +133,12 @@ public class GraphBackedDiscoveryService implements DiscoveryService { ...@@ -133,12 +133,12 @@ public class GraphBackedDiscoveryService implements DiscoveryService {
if (either.isRight()) { if (either.isRight()) {
Expressions.Expression expression = either.right().get(); Expressions.Expression expression = either.right().get();
return evaluate(expression); return evaluate(expression);
} else {
throw new DiscoveryException("Invalid expression : " + dslQuery + ". " + either.left());
} }
} catch (Exception e) { // unable to catch ExpressionException } catch (Exception e) { // unable to catch ExpressionException
throw new DiscoveryException("Invalid expression : " + dslQuery, e); throw new DiscoveryException("Invalid expression : " + dslQuery, e);
} }
throw new DiscoveryException("Invalid expression : " + dslQuery);
} }
public GremlinQueryResult evaluate(Expressions.Expression expression) { public GremlinQueryResult evaluate(Expressions.Expression expression) {
......
...@@ -85,8 +85,8 @@ public class EntityResource { ...@@ -85,8 +85,8 @@ public class EntityResource {
* Submits an entity definition (instance) corresponding to a given type. * Submits an entity definition (instance) corresponding to a given type.
*/ */
@POST @POST
@Consumes(MediaType.APPLICATION_JSON) @Consumes(Servlets.JSON_MEDIA_TYPE)
@Produces(MediaType.APPLICATION_JSON) @Produces(Servlets.JSON_MEDIA_TYPE)
public Response submit(@Context HttpServletRequest request) { public Response submit(@Context HttpServletRequest request) {
try { try {
final String entity = Servlets.getRequestPayload(request); final String entity = Servlets.getRequestPayload(request);
...@@ -127,7 +127,7 @@ public class EntityResource { ...@@ -127,7 +127,7 @@ public class EntityResource {
*/ */
@GET @GET
@Path("{guid}") @Path("{guid}")
@Produces(MediaType.APPLICATION_JSON) @Produces(Servlets.JSON_MEDIA_TYPE)
public Response getEntityDefinition(@PathParam("guid") String guid) { public Response getEntityDefinition(@PathParam("guid") String guid) {
try { try {
LOG.debug("Fetching entity definition for guid={} ", guid); LOG.debug("Fetching entity definition for guid={} ", guid);
...@@ -164,7 +164,7 @@ public class EntityResource { ...@@ -164,7 +164,7 @@ public class EntityResource {
* @param entityType name of a type which is unique * @param entityType name of a type which is unique
*/ */
@GET @GET
@Produces(MediaType.APPLICATION_JSON) @Produces(Servlets.JSON_MEDIA_TYPE)
public Response getEntityListByType(@QueryParam("type") String entityType) { public Response getEntityListByType(@QueryParam("type") String entityType) {
try { try {
Preconditions.checkNotNull(entityType, "Entity type cannot be null"); Preconditions.checkNotNull(entityType, "Entity type cannot be null");
...@@ -203,7 +203,8 @@ public class EntityResource { ...@@ -203,7 +203,8 @@ public class EntityResource {
*/ */
@PUT @PUT
@Path("{guid}") @Path("{guid}")
@Produces(MediaType.APPLICATION_JSON) @Consumes(Servlets.JSON_MEDIA_TYPE)
@Produces(Servlets.JSON_MEDIA_TYPE)
public Response update(@PathParam("guid") String guid, public Response update(@PathParam("guid") String guid,
@QueryParam("property") String property, @QueryParam("property") String property,
@QueryParam("value") String value) { @QueryParam("value") String value) {
...@@ -233,7 +234,7 @@ public class EntityResource { ...@@ -233,7 +234,7 @@ public class EntityResource {
*/ */
@GET @GET
@Path("{guid}/traits") @Path("{guid}/traits")
@Produces(MediaType.APPLICATION_JSON) @Produces(Servlets.JSON_MEDIA_TYPE)
public Response getTraitNames(@PathParam("guid") String guid) { public Response getTraitNames(@PathParam("guid") String guid) {
try { try {
LOG.debug("Fetching trait names for entity={}", guid); LOG.debug("Fetching trait names for entity={}", guid);
...@@ -264,8 +265,8 @@ public class EntityResource { ...@@ -264,8 +265,8 @@ public class EntityResource {
*/ */
@POST @POST
@Path("{guid}/traits") @Path("{guid}/traits")
@Consumes(MediaType.APPLICATION_JSON) @Consumes(Servlets.JSON_MEDIA_TYPE)
@Produces(MediaType.APPLICATION_JSON) @Produces(Servlets.JSON_MEDIA_TYPE)
public Response addTrait(@Context HttpServletRequest request, public Response addTrait(@Context HttpServletRequest request,
@PathParam("guid") String guid) { @PathParam("guid") String guid) {
try { try {
...@@ -300,8 +301,8 @@ public class EntityResource { ...@@ -300,8 +301,8 @@ public class EntityResource {
*/ */
@DELETE @DELETE
@Path("{guid}/traits/{traitName}") @Path("{guid}/traits/{traitName}")
@Consumes(MediaType.APPLICATION_JSON) @Consumes(Servlets.JSON_MEDIA_TYPE)
@Produces(MediaType.APPLICATION_JSON) @Produces(Servlets.JSON_MEDIA_TYPE)
public Response deleteTrait(@Context HttpServletRequest request, public Response deleteTrait(@Context HttpServletRequest request,
@PathParam("guid") String guid, @PathParam("guid") String guid,
@PathParam(TRAIT_NAME) String traitName) { @PathParam(TRAIT_NAME) String traitName) {
......
...@@ -64,8 +64,8 @@ public class HiveLineageResource { ...@@ -64,8 +64,8 @@ public class HiveLineageResource {
*/ */
@GET @GET
@Path("table/{tableName}/inputs/graph") @Path("table/{tableName}/inputs/graph")
@Consumes(MediaType.APPLICATION_JSON) @Consumes(Servlets.JSON_MEDIA_TYPE)
@Produces(MediaType.APPLICATION_JSON) @Produces(Servlets.JSON_MEDIA_TYPE)
public Response inputsGraph(@Context HttpServletRequest request, public Response inputsGraph(@Context HttpServletRequest request,
@PathParam("tableName") String tableName) { @PathParam("tableName") String tableName) {
LOG.info("Fetching lineage inputs graph for tableName={}", tableName); LOG.info("Fetching lineage inputs graph for tableName={}", tableName);
...@@ -98,8 +98,8 @@ public class HiveLineageResource { ...@@ -98,8 +98,8 @@ public class HiveLineageResource {
*/ */
@GET @GET
@Path("table/{tableName}/outputs/graph") @Path("table/{tableName}/outputs/graph")
@Consumes(MediaType.APPLICATION_JSON) @Consumes(Servlets.JSON_MEDIA_TYPE)
@Produces(MediaType.APPLICATION_JSON) @Produces(Servlets.JSON_MEDIA_TYPE)
public Response outputsGraph(@Context HttpServletRequest request, public Response outputsGraph(@Context HttpServletRequest request,
@PathParam("tableName") String tableName) { @PathParam("tableName") String tableName) {
LOG.info("Fetching lineage outputs graph for tableName={}", tableName); LOG.info("Fetching lineage outputs graph for tableName={}", tableName);
...@@ -132,8 +132,8 @@ public class HiveLineageResource { ...@@ -132,8 +132,8 @@ public class HiveLineageResource {
*/ */
@GET @GET
@Path("table/{tableName}/schema") @Path("table/{tableName}/schema")
@Consumes(MediaType.APPLICATION_JSON) @Consumes(Servlets.JSON_MEDIA_TYPE)
@Produces(MediaType.APPLICATION_JSON) @Produces(Servlets.JSON_MEDIA_TYPE)
public Response schema(@Context HttpServletRequest request, public Response schema(@Context HttpServletRequest request,
@PathParam("tableName") String tableName) { @PathParam("tableName") String tableName) {
LOG.info("Fetching schema for tableName={}", tableName); LOG.info("Fetching schema for tableName={}", tableName);
......
...@@ -32,6 +32,7 @@ import org.slf4j.LoggerFactory; ...@@ -32,6 +32,7 @@ import org.slf4j.LoggerFactory;
import javax.inject.Inject; import javax.inject.Inject;
import javax.inject.Singleton; import javax.inject.Singleton;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET; import javax.ws.rs.GET;
import javax.ws.rs.Path; import javax.ws.rs.Path;
import javax.ws.rs.Produces; import javax.ws.rs.Produces;
...@@ -75,7 +76,8 @@ public class MetadataDiscoveryResource { ...@@ -75,7 +76,8 @@ public class MetadataDiscoveryResource {
*/ */
@GET @GET
@Path("search") @Path("search")
@Produces(MediaType.APPLICATION_JSON) @Consumes(Servlets.JSON_MEDIA_TYPE)
@Produces(Servlets.JSON_MEDIA_TYPE)
public Response search(@QueryParam("query") String query) { public Response search(@QueryParam("query") String query) {
JSONObject response; JSONObject response;
try { // fall back to dsl try { // fall back to dsl
...@@ -125,7 +127,8 @@ public class MetadataDiscoveryResource { ...@@ -125,7 +127,8 @@ public class MetadataDiscoveryResource {
*/ */
@GET @GET
@Path("search/dsl") @Path("search/dsl")
@Produces(MediaType.APPLICATION_JSON) @Consumes(Servlets.JSON_MEDIA_TYPE)
@Produces(Servlets.JSON_MEDIA_TYPE)
public Response searchUsingQueryDSL(@QueryParam("query") String dslQuery) { public Response searchUsingQueryDSL(@QueryParam("query") String dslQuery) {
try { try {
ParamChecker.notEmpty(dslQuery, "dslQuery cannot be null"); ParamChecker.notEmpty(dslQuery, "dslQuery cannot be null");
...@@ -156,7 +159,8 @@ public class MetadataDiscoveryResource { ...@@ -156,7 +159,8 @@ public class MetadataDiscoveryResource {
*/ */
@GET @GET
@Path("search/gremlin") @Path("search/gremlin")
@Produces(MediaType.APPLICATION_JSON) @Consumes(Servlets.JSON_MEDIA_TYPE)
@Produces(Servlets.JSON_MEDIA_TYPE)
public Response searchUsingGremlinQuery(@QueryParam("query") String gremlinQuery) { public Response searchUsingGremlinQuery(@QueryParam("query") String gremlinQuery) {
try { try {
ParamChecker.notEmpty(gremlinQuery, "gremlinQuery cannot be null or empty"); ParamChecker.notEmpty(gremlinQuery, "gremlinQuery cannot be null or empty");
...@@ -196,7 +200,8 @@ public class MetadataDiscoveryResource { ...@@ -196,7 +200,8 @@ public class MetadataDiscoveryResource {
*/ */
@GET @GET
@Path("search/fulltext") @Path("search/fulltext")
@Produces(MediaType.APPLICATION_JSON) @Consumes(Servlets.JSON_MEDIA_TYPE)
@Produces(Servlets.JSON_MEDIA_TYPE)
public Response searchUsingFullText(@QueryParam("query") String query) { public Response searchUsingFullText(@QueryParam("query") String query) {
try { try {
ParamChecker.notEmpty(query, "query cannot be null or empty"); ParamChecker.notEmpty(query, "query cannot be null or empty");
......
...@@ -115,7 +115,7 @@ public class RexsterGraphResource { ...@@ -115,7 +115,7 @@ public class RexsterGraphResource {
*/ */
@GET @GET
@Path("/vertices/{id}") @Path("/vertices/{id}")
@Produces({MediaType.APPLICATION_JSON}) @Produces({Servlets.JSON_MEDIA_TYPE})
public Response getVertex(@PathParam("id") final String vertexId) { public Response getVertex(@PathParam("id") final String vertexId) {
LOG.info("Get vertex for vertexId= {}", vertexId); LOG.info("Get vertex for vertexId= {}", vertexId);
validateInputs("Invalid argument: vertex id passed is null or empty.", vertexId); validateInputs("Invalid argument: vertex id passed is null or empty.", vertexId);
...@@ -152,7 +152,7 @@ public class RexsterGraphResource { ...@@ -152,7 +152,7 @@ public class RexsterGraphResource {
*/ */
@GET @GET
@Path("/vertices/properties/{id}") @Path("/vertices/properties/{id}")
@Produces({MediaType.APPLICATION_JSON}) @Produces({Servlets.JSON_MEDIA_TYPE})
public Response getVertexProperties(@PathParam("id") final String vertexId, public Response getVertexProperties(@PathParam("id") final String vertexId,
@DefaultValue("false") @QueryParam("relationships") @DefaultValue("false") @QueryParam("relationships")
final String relationships) { final String relationships) {
...@@ -192,7 +192,7 @@ public class RexsterGraphResource { ...@@ -192,7 +192,7 @@ public class RexsterGraphResource {
*/ */
@GET @GET
@Path("/vertices") @Path("/vertices")
@Produces({MediaType.APPLICATION_JSON}) @Produces({Servlets.JSON_MEDIA_TYPE})
public Response getVertices(@QueryParam("key") final String key, public Response getVertices(@QueryParam("key") final String key,
@QueryParam("value") final String value) { @QueryParam("value") final String value) {
LOG.info("Get vertices for property key= {}, value= {}", key, value); LOG.info("Get vertices for property key= {}, value= {}", key, value);
...@@ -216,7 +216,7 @@ public class RexsterGraphResource { ...@@ -216,7 +216,7 @@ public class RexsterGraphResource {
*/ */
@GET @GET
@Path("vertices/{id}/{direction}") @Path("vertices/{id}/{direction}")
@Produces({MediaType.APPLICATION_JSON}) @Produces({Servlets.JSON_MEDIA_TYPE})
public Response getVertexEdges(@PathParam("id") String vertexId, public Response getVertexEdges(@PathParam("id") String vertexId,
@PathParam("direction") String direction) { @PathParam("direction") String direction) {
LOG.info("Get vertex edges for vertexId= {}, direction= {}", vertexId, direction); LOG.info("Get vertex edges for vertexId= {}, direction= {}", vertexId, direction);
...@@ -288,7 +288,7 @@ public class RexsterGraphResource { ...@@ -288,7 +288,7 @@ public class RexsterGraphResource {
*/ */
@GET @GET
@Path("/edges/{id}") @Path("/edges/{id}")
@Produces({MediaType.APPLICATION_JSON}) @Produces({Servlets.JSON_MEDIA_TYPE})
public Response getEdge(@PathParam("id") final String edgeId) { public Response getEdge(@PathParam("id") final String edgeId) {
LOG.info("Get vertex for edgeId= {}", edgeId); LOG.info("Get vertex for edgeId= {}", edgeId);
validateInputs("Invalid argument: edge id passed is null or empty.", edgeId); validateInputs("Invalid argument: edge id passed is null or empty.", edgeId);
......
...@@ -78,8 +78,8 @@ public class TypesResource { ...@@ -78,8 +78,8 @@ public class TypesResource {
* domain. Could represent things like Hive Database, Hive Table, etc. * domain. Could represent things like Hive Database, Hive Table, etc.
*/ */
@POST @POST
@Consumes(MediaType.APPLICATION_JSON) @Consumes(Servlets.JSON_MEDIA_TYPE)
@Produces(MediaType.APPLICATION_JSON) @Produces(Servlets.JSON_MEDIA_TYPE)
public Response submit(@Context HttpServletRequest request) { public Response submit(@Context HttpServletRequest request) {
try { try {
final String typeDefinition = Servlets.getRequestPayload(request); final String typeDefinition = Servlets.getRequestPayload(request);
...@@ -119,7 +119,7 @@ public class TypesResource { ...@@ -119,7 +119,7 @@ public class TypesResource {
*/ */
@GET @GET
@Path("{typeName}") @Path("{typeName}")
@Produces(MediaType.APPLICATION_JSON) @Produces(Servlets.JSON_MEDIA_TYPE)
public Response getDefinition(@Context HttpServletRequest request, public Response getDefinition(@Context HttpServletRequest request,
@PathParam("typeName") String typeName) { @PathParam("typeName") String typeName) {
try { try {
...@@ -155,7 +155,7 @@ public class TypesResource { ...@@ -155,7 +155,7 @@ public class TypesResource {
* @return entity names response payload as json * @return entity names response payload as json
*/ */
@GET @GET
@Produces(MediaType.APPLICATION_JSON) @Produces(Servlets.JSON_MEDIA_TYPE)
public Response getTypesByFilter(@Context HttpServletRequest request, public Response getTypesByFilter(@Context HttpServletRequest request,
@DefaultValue(TYPE_ALL) @QueryParam("type") String type) { @DefaultValue(TYPE_ALL) @QueryParam("type") String type) {
try { try {
......
...@@ -48,6 +48,7 @@ public final class Servlets { ...@@ -48,6 +48,7 @@ public final class Servlets {
/* singleton */ /* singleton */
} }
public static final String JSON_MEDIA_TYPE = MediaType.APPLICATION_JSON + "; charset=UTF-8";
/** /**
* Returns the user of the given request. * Returns the user of the given request.
* *
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment