Commit 5c3180ad by Shwetha GS

Merge branch 'master' into dal

parents 57c17116 666d92e9
...@@ -82,7 +82,7 @@ public class MetadataServiceClient { ...@@ -82,7 +82,7 @@ public class MetadataServiceClient {
PropertiesConfiguration clientConfig = null; PropertiesConfiguration clientConfig = null;
try { try {
clientConfig = getClientProperties(); clientConfig = getClientProperties();
if (clientConfig.getBoolean(TLS_ENABLED) || clientConfig.getString("metadata.http.authentication.type") != null) { if (clientConfig.getBoolean(TLS_ENABLED, false)) {
// create an SSL properties configuration if one doesn't exist. SSLFactory expects a file, so forced to create a // create an SSL properties configuration if one doesn't exist. SSLFactory expects a file, so forced to create a
// configuration object, persist it, then subsequently pass in an empty configuration to SSLFactory // configuration object, persist it, then subsequently pass in an empty configuration to SSLFactory
SecureClientUtils.persistSSLClientConfiguration(clientConfig); SecureClientUtils.persistSSLClientConfiguration(clientConfig);
......
...@@ -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) {
......
...@@ -53,6 +53,7 @@ import org.slf4j.LoggerFactory; ...@@ -53,6 +53,7 @@ import org.slf4j.LoggerFactory;
import javax.inject.Inject; import javax.inject.Inject;
import javax.inject.Singleton; import javax.inject.Singleton;
import java.util.HashMap;
import java.util.LinkedHashSet; import java.util.LinkedHashSet;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -83,8 +84,8 @@ public class DefaultMetadataService implements MetadataService { ...@@ -83,8 +84,8 @@ public class DefaultMetadataService implements MetadataService {
this.typeSystem = TypeSystem.getInstance(); this.typeSystem = TypeSystem.getInstance();
this.repository = repository; this.repository = repository;
restoreTypeSystem();
registerListener(searchIndexer); registerListener(searchIndexer);
restoreTypeSystem();
} }
private void restoreTypeSystem() { private void restoreTypeSystem() {
...@@ -113,17 +114,18 @@ public class DefaultMetadataService implements MetadataService { ...@@ -113,17 +114,18 @@ public class DefaultMetadataService implements MetadataService {
return; // this is already registered return; // this is already registered
} }
Map<String, IDataType> superTypes = new HashMap();
HierarchicalTypeDefinition<ClassType> superTypeDefinition = HierarchicalTypeDefinition<ClassType> superTypeDefinition =
TypesUtil.createClassTypeDef(MetadataServiceClient.INFRASTRUCTURE_SUPER_TYPE, TypesUtil.createClassTypeDef(MetadataServiceClient.INFRASTRUCTURE_SUPER_TYPE,
ImmutableList.<String>of(), ImmutableList.<String>of(), NAME_ATTRIBUTE, DESCRIPTION_ATTRIBUTE);
NAME_ATTRIBUTE, DESCRIPTION_ATTRIBUTE); superTypes.put(MetadataServiceClient.INFRASTRUCTURE_SUPER_TYPE, typeSystem.defineClassType
typeSystem.defineClassType(superTypeDefinition); (superTypeDefinition));
superTypeDefinition = superTypeDefinition =
TypesUtil.createClassTypeDef(MetadataServiceClient.DATA_SET_SUPER_TYPE, TypesUtil.createClassTypeDef(MetadataServiceClient.DATA_SET_SUPER_TYPE,
ImmutableList.<String>of(), ImmutableList.<String>of(),
NAME_ATTRIBUTE, DESCRIPTION_ATTRIBUTE); NAME_ATTRIBUTE, DESCRIPTION_ATTRIBUTE);
typeSystem.defineClassType(superTypeDefinition); superTypes.put(MetadataServiceClient.DATA_SET_SUPER_TYPE, typeSystem.defineClassType(superTypeDefinition));
superTypeDefinition = superTypeDefinition =
TypesUtil.createClassTypeDef(MetadataServiceClient.PROCESS_SUPER_TYPE, TypesUtil.createClassTypeDef(MetadataServiceClient.PROCESS_SUPER_TYPE,
...@@ -136,7 +138,8 @@ public class DefaultMetadataService implements MetadataService { ...@@ -136,7 +138,8 @@ public class DefaultMetadataService implements MetadataService {
DataTypes.arrayTypeName(MetadataServiceClient.DATA_SET_SUPER_TYPE), DataTypes.arrayTypeName(MetadataServiceClient.DATA_SET_SUPER_TYPE),
new Multiplicity(0, Integer.MAX_VALUE, false), false, null) new Multiplicity(0, Integer.MAX_VALUE, false), false, null)
); );
typeSystem.defineClassType(superTypeDefinition); superTypes.put(MetadataServiceClient.PROCESS_SUPER_TYPE, typeSystem.defineClassType(superTypeDefinition));
onTypesAddedToRepo(superTypes);
} }
/** /**
......
...@@ -70,7 +70,7 @@ public abstract class HierarchicalType<ST extends HierarchicalType, T> extends A ...@@ -70,7 +70,7 @@ public abstract class HierarchicalType<ST extends HierarchicalType, T> extends A
this.fieldMapping = null; this.fieldMapping = null;
this.numFields = numFields; this.numFields = numFields;
this.superTypes = superTypes; this.superTypes = superTypes;
this.immediateAttrs = null; this.immediateAttrs = ImmutableList.of();
this.attributeNameToType = null; this.attributeNameToType = null;
} }
...@@ -86,7 +86,7 @@ public abstract class HierarchicalType<ST extends HierarchicalType, T> extends A ...@@ -86,7 +86,7 @@ public abstract class HierarchicalType<ST extends HierarchicalType, T> extends A
this.attributeNameToType = p.right; this.attributeNameToType = p.right;
this.numFields = this.fieldMapping.fields.size(); this.numFields = this.fieldMapping.fields.size();
this.superTypes = superTypes == null ? ImmutableList.<String>of() : superTypes; this.superTypes = superTypes == null ? ImmutableList.<String>of() : superTypes;
this.immediateAttrs = ImmutableList.<AttributeInfo>copyOf(fields); this.immediateAttrs = ImmutableList.copyOf(fields);
} }
@Override @Override
...@@ -184,7 +184,7 @@ public abstract class HierarchicalType<ST extends HierarchicalType, T> extends A ...@@ -184,7 +184,7 @@ public abstract class HierarchicalType<ST extends HierarchicalType, T> extends A
(ST) typeSystem.getDataType(superTypeClass, currentPath.typeName); (ST) typeSystem.getDataType(superTypeClass, currentPath.typeName);
ImmutableList<AttributeInfo> superTypeFields = superType == this ? ImmutableList<AttributeInfo> superTypeFields = superType == this ?
ImmutableList.<AttributeInfo>copyOf(fields) : superType.immediateAttrs; ImmutableList.copyOf(fields) : superType.immediateAttrs;
Set<String> immediateFields = new HashSet<String>(); Set<String> immediateFields = new HashSet<String>();
......
...@@ -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);
...@@ -165,7 +165,7 @@ public class EntityResource { ...@@ -165,7 +165,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");
...@@ -204,7 +204,8 @@ public class EntityResource { ...@@ -204,7 +204,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) {
...@@ -237,7 +238,7 @@ public class EntityResource { ...@@ -237,7 +238,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);
...@@ -268,8 +269,8 @@ public class EntityResource { ...@@ -268,8 +269,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 {
...@@ -304,8 +305,8 @@ public class EntityResource { ...@@ -304,8 +305,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) {
......
...@@ -65,8 +65,8 @@ public class HiveLineageResource { ...@@ -65,8 +65,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);
...@@ -103,8 +103,8 @@ public class HiveLineageResource { ...@@ -103,8 +103,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);
...@@ -141,8 +141,8 @@ public class HiveLineageResource { ...@@ -141,8 +141,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