Merge "Support AcceptsCreate for ChildCollection"
This commit is contained in:
commit
84c4d3e4b8
@ -211,9 +211,26 @@ public class RestApiServlet extends HttpServlet {
|
||||
view = c.list();
|
||||
break;
|
||||
} else {
|
||||
rsrc = c.parse(rsrc, path.remove(0));
|
||||
String id = path.remove(0);
|
||||
try {
|
||||
rsrc = c.parse(rsrc, id);
|
||||
view = null;
|
||||
} catch (ResourceNotFoundException e) {
|
||||
if (c instanceof AcceptsCreate
|
||||
&& ("POST".equals(req.getMethod())
|
||||
|| "PUT".equals(req.getMethod()))) {
|
||||
@SuppressWarnings("unchecked")
|
||||
AcceptsCreate<RestResource> ac = (AcceptsCreate<RestResource>) c;
|
||||
view = ac.create(rsrc, id);
|
||||
status = SC_CREATED;
|
||||
} else {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
if (view == null) {
|
||||
view = view(c, req.getMethod(), path);
|
||||
}
|
||||
}
|
||||
checkAccessAnnotations(view.getClass());
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user