Commit ac4c3080 by Suma Shivaprasad

Fixed review comments

parent 7794686b
......@@ -58,7 +58,7 @@ public class MetadataServiceClient {
public static final String ROWS = "rows";
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_TRAITS = "traits";
public static final String URI_SEARCH = "discovery/search";
......@@ -97,10 +97,10 @@ public class MetadataServiceClient {
static enum API {
//Type operations
CREATE_TYPE(BASE_URI + URI_TYPES, HttpMethod.POST),
GET_TYPE(BASE_URI + URI_TYPES, HttpMethod.GET),
LIST_TYPES(BASE_URI + URI_TYPES, HttpMethod.GET),
LIST_TRAIT_TYPES(BASE_URI + URI_TYPES + "?type=trait", HttpMethod.GET),
CREATE_TYPE(BASE_URI + TYPES, HttpMethod.POST),
GET_TYPE(BASE_URI + TYPES, HttpMethod.GET),
LIST_TYPES(BASE_URI + TYPES, HttpMethod.GET),
LIST_TRAIT_TYPES(BASE_URI + TYPES + "?type=trait", HttpMethod.GET),
//Entity operations
CREATE_ENTITY(BASE_URI + URI_ENTITIES, HttpMethod.POST),
......
......@@ -115,7 +115,7 @@ public class DefaultMetadataService implements MetadataService {
onTypesAddedToRepo(typesAdded);
JSONObject response = new JSONObject() {{
put(MetadataServiceClient.URI_TYPES, typesAdded.keySet());
put(MetadataServiceClient.TYPES, typesAdded.keySet());
}};
return response;
} catch (JSONException e) {
......
......@@ -31,6 +31,7 @@ import com.sun.jersey.guice.spi.container.servlet.GuiceContainer;
import org.apache.commons.configuration.ConfigurationException;
import org.apache.commons.configuration.PropertiesConfiguration;
import org.apache.hadoop.metadata.MetadataException;
import org.apache.hadoop.metadata.MetadataServiceClient;
import org.apache.hadoop.metadata.PropertiesUtil;
import org.apache.hadoop.metadata.RepositoryMetadataModule;
import org.apache.hadoop.metadata.repository.typestore.ITypeStore;
......@@ -55,8 +56,6 @@ public class GuiceServletConfig extends GuiceServletContextListener {
static final String HTTP_AUTHENTICATION_ENABLED = "metadata.http.authentication.enabled";
private Injector injector;
public static final String BASE_URI = "/api/metadata/";
@Override
protected Injector getInjector() {
LOG.info("Loading Guice modules");
......@@ -85,7 +84,7 @@ public class GuiceServletConfig extends GuiceServletContextListener {
Map<String, String> params = new HashMap<>();
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 {
......
......@@ -8,7 +8,7 @@
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
......@@ -62,10 +62,6 @@ public class TypesResource {
private final MetadataService metadataService;
static final String TYPE_ALL = "all";
private static final String URI_TYPES = "types";
@Context
UriInfo uriInfo;
@Inject
public TypesResource(MetadataService metadataService) {
......@@ -85,13 +81,11 @@ public class TypesResource {
LOG.debug("creating type with definition {} ", typeDefinition);
JSONObject typesJson = metadataService.createType(typeDefinition);
UriBuilder ub = uriInfo.getAbsolutePathBuilder();
final JSONArray typesJsonArray = typesJson.getJSONArray("types");
final JSONArray typesJsonArray = typesJson.getJSONArray(MetadataServiceClient.TYPES);
List<Map<String, String>> typesAddedList = new ArrayList<>();
for (int i = 0; i < typesJsonArray.length(); i++) {
final String name = typesJsonArray.getString(i);
final URI locationUri = ub.path(name).build();
typesAddedList.add(
new HashMap<String, String>() {{
put(MetadataServiceClient.NAME, name);
......@@ -100,7 +94,7 @@ public class TypesResource {
JSONObject response = new JSONObject();
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();
} catch (Exception 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