Commit ac4c3080 by Suma Shivaprasad

Fixed review comments

parent 7794686b
...@@ -58,7 +58,7 @@ public class MetadataServiceClient { ...@@ -58,7 +58,7 @@ public class MetadataServiceClient {
public static final String ROWS = "rows"; public static final String ROWS = "rows";
public static final String BASE_URI = "api/metadata/"; public static final String BASE_URI = "api/metadata/";
public static final String URI_TYPES = "types"; public static final String TYPES = "types";
public static final String URI_ENTITIES = "entities"; public static final String URI_ENTITIES = "entities";
public static final String URI_TRAITS = "traits"; public static final String URI_TRAITS = "traits";
public static final String URI_SEARCH = "discovery/search"; public static final String URI_SEARCH = "discovery/search";
...@@ -97,10 +97,10 @@ public class MetadataServiceClient { ...@@ -97,10 +97,10 @@ public class MetadataServiceClient {
static enum API { static enum API {
//Type operations //Type operations
CREATE_TYPE(BASE_URI + URI_TYPES, HttpMethod.POST), CREATE_TYPE(BASE_URI + TYPES, HttpMethod.POST),
GET_TYPE(BASE_URI + URI_TYPES, HttpMethod.GET), GET_TYPE(BASE_URI + TYPES, HttpMethod.GET),
LIST_TYPES(BASE_URI + URI_TYPES, HttpMethod.GET), LIST_TYPES(BASE_URI + TYPES, HttpMethod.GET),
LIST_TRAIT_TYPES(BASE_URI + URI_TYPES + "?type=trait", HttpMethod.GET), LIST_TRAIT_TYPES(BASE_URI + TYPES + "?type=trait", HttpMethod.GET),
//Entity operations //Entity operations
CREATE_ENTITY(BASE_URI + URI_ENTITIES, HttpMethod.POST), CREATE_ENTITY(BASE_URI + URI_ENTITIES, HttpMethod.POST),
......
...@@ -115,7 +115,7 @@ public class DefaultMetadataService implements MetadataService { ...@@ -115,7 +115,7 @@ public class DefaultMetadataService implements MetadataService {
onTypesAddedToRepo(typesAdded); onTypesAddedToRepo(typesAdded);
JSONObject response = new JSONObject() {{ JSONObject response = new JSONObject() {{
put(MetadataServiceClient.URI_TYPES, typesAdded.keySet()); put(MetadataServiceClient.TYPES, typesAdded.keySet());
}}; }};
return response; return response;
} catch (JSONException e) { } catch (JSONException e) {
......
...@@ -31,6 +31,7 @@ import com.sun.jersey.guice.spi.container.servlet.GuiceContainer; ...@@ -31,6 +31,7 @@ import com.sun.jersey.guice.spi.container.servlet.GuiceContainer;
import org.apache.commons.configuration.ConfigurationException; import org.apache.commons.configuration.ConfigurationException;
import org.apache.commons.configuration.PropertiesConfiguration; import org.apache.commons.configuration.PropertiesConfiguration;
import org.apache.hadoop.metadata.MetadataException; import org.apache.hadoop.metadata.MetadataException;
import org.apache.hadoop.metadata.MetadataServiceClient;
import org.apache.hadoop.metadata.PropertiesUtil; import org.apache.hadoop.metadata.PropertiesUtil;
import org.apache.hadoop.metadata.RepositoryMetadataModule; import org.apache.hadoop.metadata.RepositoryMetadataModule;
import org.apache.hadoop.metadata.repository.typestore.ITypeStore; import org.apache.hadoop.metadata.repository.typestore.ITypeStore;
...@@ -55,8 +56,6 @@ public class GuiceServletConfig extends GuiceServletContextListener { ...@@ -55,8 +56,6 @@ public class GuiceServletConfig extends GuiceServletContextListener {
static final String HTTP_AUTHENTICATION_ENABLED = "metadata.http.authentication.enabled"; static final String HTTP_AUTHENTICATION_ENABLED = "metadata.http.authentication.enabled";
private Injector injector; private Injector injector;
public static final String BASE_URI = "/api/metadata/";
@Override @Override
protected Injector getInjector() { protected Injector getInjector() {
LOG.info("Loading Guice modules"); LOG.info("Loading Guice modules");
...@@ -85,7 +84,7 @@ public class GuiceServletConfig extends GuiceServletContextListener { ...@@ -85,7 +84,7 @@ public class GuiceServletConfig extends GuiceServletContextListener {
Map<String, String> params = new HashMap<>(); Map<String, String> params = new HashMap<>();
params.put(PackagesResourceConfig.PROPERTY_PACKAGES, packages); params.put(PackagesResourceConfig.PROPERTY_PACKAGES, packages);
serve(BASE_URI + "*").with(GuiceContainer.class, params); serve("/" + MetadataServiceClient.BASE_URI + "*").with(GuiceContainer.class, params);
} }
private void configureAuthenticationFilter() throws ConfigurationException { private void configureAuthenticationFilter() throws ConfigurationException {
......
...@@ -62,10 +62,6 @@ public class TypesResource { ...@@ -62,10 +62,6 @@ public class TypesResource {
private final MetadataService metadataService; private final MetadataService metadataService;
static final String TYPE_ALL = "all"; static final String TYPE_ALL = "all";
private static final String URI_TYPES = "types";
@Context
UriInfo uriInfo;
@Inject @Inject
public TypesResource(MetadataService metadataService) { public TypesResource(MetadataService metadataService) {
...@@ -85,13 +81,11 @@ public class TypesResource { ...@@ -85,13 +81,11 @@ public class TypesResource {
LOG.debug("creating type with definition {} ", typeDefinition); LOG.debug("creating type with definition {} ", typeDefinition);
JSONObject typesJson = metadataService.createType(typeDefinition); JSONObject typesJson = metadataService.createType(typeDefinition);
UriBuilder ub = uriInfo.getAbsolutePathBuilder(); final JSONArray typesJsonArray = typesJson.getJSONArray(MetadataServiceClient.TYPES);
final JSONArray typesJsonArray = typesJson.getJSONArray("types");
List<Map<String, String>> typesAddedList = new ArrayList<>(); List<Map<String, String>> typesAddedList = new ArrayList<>();
for (int i = 0; i < typesJsonArray.length(); i++) { for (int i = 0; i < typesJsonArray.length(); i++) {
final String name = typesJsonArray.getString(i); final String name = typesJsonArray.getString(i);
final URI locationUri = ub.path(name).build();
typesAddedList.add( typesAddedList.add(
new HashMap<String, String>() {{ new HashMap<String, String>() {{
put(MetadataServiceClient.NAME, name); put(MetadataServiceClient.NAME, name);
...@@ -100,7 +94,7 @@ public class TypesResource { ...@@ -100,7 +94,7 @@ public class TypesResource {
JSONObject response = new JSONObject(); JSONObject response = new JSONObject();
response.put(MetadataServiceClient.REQUEST_ID, Servlets.getRequestId()); response.put(MetadataServiceClient.REQUEST_ID, Servlets.getRequestId());
response.put(MetadataServiceClient.URI_TYPES, typesAddedList); response.put(MetadataServiceClient.TYPES, typesAddedList);
return Response.status(ClientResponse.Status.CREATED).entity(response).build(); return Response.status(ClientResponse.Status.CREATED).entity(response).build();
} catch (Exception e) { } catch (Exception e) {
LOG.error("Unable to persist types", e); LOG.error("Unable to persist types", e);
......
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