use of org.apache.hadoop.yarn.webapp.ForbiddenException in project hadoop by apache.
the class TimelineWebServices method putDomain.
/**
* Store the given domain into the timeline store, and return the errors
* that happen during storing.
*/
@PUT
@Path("/domain")
@Consumes({ MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8 })
public TimelinePutResponse putDomain(@Context HttpServletRequest req, @Context HttpServletResponse res, TimelineDomain domain) {
init(res);
UserGroupInformation callerUGI = getUser(req);
if (callerUGI == null) {
String msg = "The owner of the posted timeline domain is not set";
LOG.error(msg);
throw new ForbiddenException(msg);
}
domain.setOwner(callerUGI.getShortUserName());
try {
timelineDataManager.putDomain(domain, callerUGI);
} catch (YarnException e) {
// The user doesn't have the access to override the existing domain.
LOG.error(e.getMessage(), e);
throw new ForbiddenException(e);
} catch (RuntimeException e) {
LOG.error("Error putting domain", e);
throw new WebApplicationException(e, Response.Status.INTERNAL_SERVER_ERROR);
} catch (IOException e) {
LOG.error("Error putting domain", e);
throw new WebApplicationException(e, Response.Status.INTERNAL_SERVER_ERROR);
}
return new TimelinePutResponse();
}
Aggregations