private void validate(APIUpdateL3NetworkMsg msg) { if (msg.getCategory() == null && msg.getSystem() == null) { return; } Boolean currentSystem = Q.New(L3NetworkVO.class) .select(L3NetworkVO_.system) .eq(L3NetworkVO_.uuid, msg.getL3NetworkUuid()) .findValue(); if (msg.getSystem() != null && msg.getCategory() == null && !msg.getSystem().equals(currentSystem)) { throw new ApiMessageInterceptionException(argerr("you must update system and category both")); } List<L3NetworkCategory> validNetworkCategory = Arrays.asList(L3NetworkCategory.values()); for (L3NetworkCategory category : validNetworkCategory) { if (category.toString().equalsIgnoreCase(msg.getCategory())) { msg.setCategory(category.toString()); break; } } if (msg.getSystem() == null) { msg.setSystem(currentSystem); } if (msg.getCategory() != null) { if (L3NetworkCategory.checkSystemAndCategory(msg.getSystem(), L3NetworkCategory.valueOf(msg.getCategory()))) { return; } else { throw new ApiMessageInterceptionException(argerr("not valid combination of system and category," + "only %s are valid", L3NetworkCategory.validCombination)); } } }
private void handle(APIUpdateL3NetworkMsg msg) { boolean update = false; if (msg.getName() != null) { self.setName(msg.getName()); update = true; } if (msg.getDescription() != null) { self.setDescription(msg.getDescription()); update = true; } if (msg.getSystem() != null && msg.getCategory() != null) { self.setSystem(msg.getSystem()); self.setCategory(L3NetworkCategory.valueOf(msg.getCategory())); update = true; } if (msg.getDnsDomain() != null) { self.setDnsDomain(msg.getDnsDomain()); update = true; } if (update) { self = dbf.updateAndRefresh(self); } APIUpdateL3NetworkEvent evt = new APIUpdateL3NetworkEvent(msg.getId()); evt.setInventory(getSelfInventory()); bus.publish(evt); }
vo.setZoneUuid(zoneUuid); vo.setState(L3NetworkState.Enabled); vo.setCategory(L3NetworkCategory.valueOf(msg.getCategory())); if (msg.getIpVersion() != null) { vo.setIpVersion(msg.getIpVersion());