mirror of
https://github.com/ctripcorp/zeus.git
synced 2024-11-10 09:02:49 +08:00
avoid null pointer exception
This commit is contained in:
parent
1410c73ee8
commit
653c007e63
3 changed files with 32 additions and 4 deletions
|
@ -301,7 +301,11 @@ public class GroupResource {
|
||||||
public Response add(@Context HttpHeaders hh, @Context HttpServletRequest request, String requestBody,
|
public Response add(@Context HttpHeaders hh, @Context HttpServletRequest request, String requestBody,
|
||||||
@QueryParam("force") Boolean force) throws Exception {
|
@QueryParam("force") Boolean force) throws Exception {
|
||||||
ExtendedView.ExtendedGroup extendedView = ObjectJsonParser.parse(requestBody, ExtendedView.ExtendedGroup.class);
|
ExtendedView.ExtendedGroup extendedView = ObjectJsonParser.parse(requestBody, ExtendedView.ExtendedGroup.class);
|
||||||
Group g = ObjectJsonParser.parse(requestBody, Group.class).setVirtual(null);
|
Group g = ObjectJsonParser.parse(requestBody, Group.class);
|
||||||
|
if (g == null) {
|
||||||
|
throw new ValidationException("Invalid post entity. Fail to parse json to group.");
|
||||||
|
}
|
||||||
|
g.setVirtual(null);
|
||||||
trim(g);
|
trim(g);
|
||||||
|
|
||||||
Long checkId = groupCriteriaQuery.queryByName(g.getName());
|
Long checkId = groupCriteriaQuery.queryByName(g.getName());
|
||||||
|
@ -342,7 +346,11 @@ public class GroupResource {
|
||||||
public Response addVGroup(@Context HttpHeaders hh, @Context HttpServletRequest request, String requestBody,
|
public Response addVGroup(@Context HttpHeaders hh, @Context HttpServletRequest request, String requestBody,
|
||||||
@QueryParam("force") Boolean force) throws Exception {
|
@QueryParam("force") Boolean force) throws Exception {
|
||||||
ExtendedView.ExtendedGroup extendedView = ObjectJsonParser.parse(requestBody, ExtendedView.ExtendedGroup.class);
|
ExtendedView.ExtendedGroup extendedView = ObjectJsonParser.parse(requestBody, ExtendedView.ExtendedGroup.class);
|
||||||
Group g = ObjectJsonParser.parse(requestBody, Group.class).setVirtual(true);
|
Group g = ObjectJsonParser.parse(requestBody, Group.class);
|
||||||
|
if (g == null) {
|
||||||
|
throw new ValidationException("Invalid post entity. Fail to parse json to virtual group.");
|
||||||
|
}
|
||||||
|
g.setVirtual(true);
|
||||||
trim(g);
|
trim(g);
|
||||||
|
|
||||||
Long checkId = groupCriteriaQuery.queryByName(g.getName());
|
Long checkId = groupCriteriaQuery.queryByName(g.getName());
|
||||||
|
@ -423,7 +431,11 @@ public class GroupResource {
|
||||||
public Response update(@Context HttpHeaders hh, @Context HttpServletRequest request, String requestBody,
|
public Response update(@Context HttpHeaders hh, @Context HttpServletRequest request, String requestBody,
|
||||||
@QueryParam("force") Boolean force) throws Exception {
|
@QueryParam("force") Boolean force) throws Exception {
|
||||||
ExtendedView.ExtendedGroup extendedView = ObjectJsonParser.parse(requestBody, ExtendedView.ExtendedGroup.class);
|
ExtendedView.ExtendedGroup extendedView = ObjectJsonParser.parse(requestBody, ExtendedView.ExtendedGroup.class);
|
||||||
Group g = ObjectJsonParser.parse(requestBody, Group.class).setVirtual(null);
|
Group g = ObjectJsonParser.parse(requestBody, Group.class);
|
||||||
|
if (g == null) {
|
||||||
|
throw new ValidationException("Invalid post entity. Fail to parse json to group.");
|
||||||
|
}
|
||||||
|
g.setVirtual(null);
|
||||||
trim(g);
|
trim(g);
|
||||||
|
|
||||||
IdVersion[] check = groupCriteriaQuery.queryByIdAndMode(g.getId(), SelectionMode.OFFLINE_FIRST);
|
IdVersion[] check = groupCriteriaQuery.queryByIdAndMode(g.getId(), SelectionMode.OFFLINE_FIRST);
|
||||||
|
@ -472,7 +484,11 @@ public class GroupResource {
|
||||||
public Response updateVGroup(@Context HttpHeaders hh, @Context HttpServletRequest request, String requestBody
|
public Response updateVGroup(@Context HttpHeaders hh, @Context HttpServletRequest request, String requestBody
|
||||||
, @QueryParam("force") Boolean force) throws Exception {
|
, @QueryParam("force") Boolean force) throws Exception {
|
||||||
ExtendedView.ExtendedGroup extendedView = ObjectJsonParser.parse(requestBody, ExtendedView.ExtendedGroup.class);
|
ExtendedView.ExtendedGroup extendedView = ObjectJsonParser.parse(requestBody, ExtendedView.ExtendedGroup.class);
|
||||||
Group g = ObjectJsonParser.parse(requestBody, Group.class).setVirtual(true);
|
Group g = ObjectJsonParser.parse(requestBody, Group.class);
|
||||||
|
if (g == null) {
|
||||||
|
throw new ValidationException("Invalid post entity. Fail to parse json to virtual group.");
|
||||||
|
}
|
||||||
|
g.setVirtual(true);
|
||||||
trim(g);
|
trim(g);
|
||||||
|
|
||||||
DistLock lock = dbLockFactory.newLock(g.getId() + "_updateGroup");
|
DistLock lock = dbLockFactory.newLock(g.getId() + "_updateGroup");
|
||||||
|
|
|
@ -173,6 +173,9 @@ public class SlbResource {
|
||||||
public Response add(@Context HttpHeaders hh, @Context HttpServletRequest request, String requestBody) throws Exception {
|
public Response add(@Context HttpHeaders hh, @Context HttpServletRequest request, String requestBody) throws Exception {
|
||||||
ExtendedView.ExtendedSlb extendedView = ObjectJsonParser.parse(requestBody, ExtendedView.ExtendedSlb.class);
|
ExtendedView.ExtendedSlb extendedView = ObjectJsonParser.parse(requestBody, ExtendedView.ExtendedSlb.class);
|
||||||
Slb s = ObjectJsonParser.parse(requestBody, Slb.class);
|
Slb s = ObjectJsonParser.parse(requestBody, Slb.class);
|
||||||
|
if (s == null) {
|
||||||
|
throw new ValidationException("Invalid post entity. Fail to parse json to slb.");
|
||||||
|
}
|
||||||
trim(s);
|
trim(s);
|
||||||
|
|
||||||
s = slbRepository.add(s);
|
s = slbRepository.add(s);
|
||||||
|
@ -207,6 +210,9 @@ public class SlbResource {
|
||||||
public Response update(@Context HttpHeaders hh, @Context HttpServletRequest request, String requestBody) throws Exception {
|
public Response update(@Context HttpHeaders hh, @Context HttpServletRequest request, String requestBody) throws Exception {
|
||||||
ExtendedView.ExtendedSlb extendedView = ObjectJsonParser.parse(requestBody, ExtendedView.ExtendedSlb.class);
|
ExtendedView.ExtendedSlb extendedView = ObjectJsonParser.parse(requestBody, ExtendedView.ExtendedSlb.class);
|
||||||
Slb s = ObjectJsonParser.parse(requestBody, Slb.class);
|
Slb s = ObjectJsonParser.parse(requestBody, Slb.class);
|
||||||
|
if (s == null) {
|
||||||
|
throw new ValidationException("Invalid post entity. Fail to parse json to slb.");
|
||||||
|
}
|
||||||
trim(s);
|
trim(s);
|
||||||
|
|
||||||
IdVersion[] check = slbCriteriaQuery.queryByIdAndMode(s.getId(), SelectionMode.OFFLINE_FIRST);
|
IdVersion[] check = slbCriteriaQuery.queryByIdAndMode(s.getId(), SelectionMode.OFFLINE_FIRST);
|
||||||
|
|
|
@ -179,6 +179,9 @@ public class VirtualServerResource {
|
||||||
@Context HttpServletRequest request, String requestBody) throws Exception {
|
@Context HttpServletRequest request, String requestBody) throws Exception {
|
||||||
ExtendedView.ExtendedVs extendedView = ObjectJsonParser.parse(requestBody, ExtendedView.ExtendedVs.class);
|
ExtendedView.ExtendedVs extendedView = ObjectJsonParser.parse(requestBody, ExtendedView.ExtendedVs.class);
|
||||||
VirtualServer vs = ObjectJsonParser.parse(requestBody, VirtualServer.class);
|
VirtualServer vs = ObjectJsonParser.parse(requestBody, VirtualServer.class);
|
||||||
|
if (vs == null) {
|
||||||
|
throw new ValidationException("Invalid post entity. Fail to parse json to virtual server.");
|
||||||
|
}
|
||||||
trim(vs);
|
trim(vs);
|
||||||
|
|
||||||
vs = virtualServerRepository.add(vs);
|
vs = virtualServerRepository.add(vs);
|
||||||
|
@ -233,6 +236,9 @@ public class VirtualServerResource {
|
||||||
@Context HttpServletRequest request, String requestBody) throws Exception {
|
@Context HttpServletRequest request, String requestBody) throws Exception {
|
||||||
ExtendedView.ExtendedVs extendedView = ObjectJsonParser.parse(requestBody, ExtendedView.ExtendedVs.class);
|
ExtendedView.ExtendedVs extendedView = ObjectJsonParser.parse(requestBody, ExtendedView.ExtendedVs.class);
|
||||||
VirtualServer vs = ObjectJsonParser.parse(requestBody, VirtualServer.class);
|
VirtualServer vs = ObjectJsonParser.parse(requestBody, VirtualServer.class);
|
||||||
|
if (vs == null) {
|
||||||
|
throw new ValidationException("Invalid post entity. Fail to parse json to virtual server.");
|
||||||
|
}
|
||||||
trim(vs);
|
trim(vs);
|
||||||
|
|
||||||
IdVersion[] check = virtualServerCriteriaQuery.queryByIdAndMode(vs.getId(), SelectionMode.OFFLINE_FIRST);
|
IdVersion[] check = virtualServerCriteriaQuery.queryByIdAndMode(vs.getId(), SelectionMode.OFFLINE_FIRST);
|
||||||
|
|
Loading…
Reference in a new issue