Commit 0ed96321 by Venkatesh Seetharam

ISSUE-28 Add types resource for put/get. Contributed by Venkatesh Seetharam

parent ed517933
...@@ -18,9 +18,11 @@ ...@@ -18,9 +18,11 @@
package org.apache.hadoop.metadata.web.resources; package org.apache.hadoop.metadata.web.resources;
import org.apache.hadoop.metadata.MetadataException;
import org.apache.hadoop.metadata.services.MetadataService; import org.apache.hadoop.metadata.services.MetadataService;
import org.apache.hadoop.metadata.web.util.Servlets; import org.apache.hadoop.metadata.web.util.Servlets;
import org.codehaus.jettison.json.JSONArray; import org.codehaus.jettison.json.JSONArray;
import org.codehaus.jettison.json.JSONException;
import org.codehaus.jettison.json.JSONObject; import org.codehaus.jettison.json.JSONObject;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
...@@ -78,7 +80,7 @@ public class TypesResource { ...@@ -78,7 +80,7 @@ public class TypesResource {
return Response.ok(response).build(); return Response.ok(response).build();
} catch (Exception e) { } catch (Exception e) {
LOG.error("Unable to persist entity object", e); LOG.error("Unable to persist type {}", typeName, e);
throw new WebApplicationException( throw new WebApplicationException(
Servlets.getErrorResponse(e, Response.Status.BAD_REQUEST)); Servlets.getErrorResponse(e, Response.Status.BAD_REQUEST));
} }
...@@ -98,8 +100,12 @@ public class TypesResource { ...@@ -98,8 +100,12 @@ public class TypesResource {
response.put("requestId", Thread.currentThread().getName()); response.put("requestId", Thread.currentThread().getName());
return Response.ok(response).build(); return Response.ok(response).build();
} catch (Exception e) { } catch (MetadataException e) {
LOG.error("Unable to persist entity object", e); LOG.error("Unable to get type definition for type {}", typeName, e);
throw new WebApplicationException(
Servlets.getErrorResponse(e, Response.Status.NOT_FOUND));
} catch (JSONException e) {
LOG.error("Unable to get type definition for type {}", typeName, e);
throw new WebApplicationException( throw new WebApplicationException(
Servlets.getErrorResponse(e, Response.Status.BAD_REQUEST)); Servlets.getErrorResponse(e, Response.Status.BAD_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