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