mirror of
https://github.com/ctripcorp/zeus.git
synced 2024-11-11 01:24:27 +08:00
move removable validation to validator
This commit is contained in:
parent
66280a9255
commit
59dc5680d2
2 changed files with 6 additions and 13 deletions
|
@ -11,10 +11,8 @@ import com.ctrip.zeus.restful.filter.FilterSet;
|
|||
import com.ctrip.zeus.restful.filter.QueryExecuter;
|
||||
import com.ctrip.zeus.restful.message.ResponseHandler;
|
||||
import com.ctrip.zeus.restful.message.TrimmedQueryParam;
|
||||
import com.ctrip.zeus.service.activate.ActivateService;
|
||||
import com.ctrip.zeus.service.model.SlbRepository;
|
||||
import com.ctrip.zeus.service.model.VirtualServerRepository;
|
||||
import com.ctrip.zeus.service.query.GroupCriteriaQuery;
|
||||
import com.ctrip.zeus.service.query.SlbCriteriaQuery;
|
||||
import com.ctrip.zeus.service.query.VirtualServerCriteriaQuery;
|
||||
import com.ctrip.zeus.tag.PropertyService;
|
||||
|
@ -52,10 +50,6 @@ public class VirtualServerResource {
|
|||
private PropertyService propertyService;
|
||||
@Resource
|
||||
private ResponseHandler responseHandler;
|
||||
@Resource
|
||||
private ActivateService activateService;
|
||||
@Resource
|
||||
private GroupCriteriaQuery groupCriteriaQuery;
|
||||
|
||||
@GET
|
||||
@Path("/vses")
|
||||
|
@ -178,13 +172,6 @@ public class VirtualServerResource {
|
|||
if (slb == null) {
|
||||
throw new ValidationException("Cannot find slb with vsId " + vsId + ".");
|
||||
}
|
||||
if (activateService.isVSActivated(vsId)){
|
||||
throw new ValidationException("Vs need to be deactivated before delete!");
|
||||
}
|
||||
Set<Long> groupIds = groupCriteriaQuery.queryByVsId(vsId);
|
||||
if ( groupIds!=null && groupIds.size() > 0 ){
|
||||
throw new ValidationException("Has groups related to Vs["+vsId+"]; GroupIds:"+groupIds.toString() );
|
||||
}
|
||||
virtualServerRepository.deleteVirtualServer(vsId);
|
||||
return responseHandler.handle("Successfully deleted virtual server with id " + vsId + ".", hh.getMediaType());
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import com.ctrip.zeus.dal.core.*;
|
|||
import com.ctrip.zeus.exceptions.ValidationException;
|
||||
import com.ctrip.zeus.model.entity.Domain;
|
||||
import com.ctrip.zeus.model.entity.VirtualServer;
|
||||
import com.ctrip.zeus.service.activate.ActivateService;
|
||||
import com.ctrip.zeus.service.model.handler.VirtualServerValidator;
|
||||
import com.ctrip.zeus.service.query.GroupCriteriaQuery;
|
||||
import com.netflix.config.DynamicPropertyFactory;
|
||||
|
@ -23,6 +24,8 @@ public class DefaultVirtualServerValidator implements VirtualServerValidator {
|
|||
@Resource
|
||||
private GroupCriteriaQuery groupCriteriaQuery;
|
||||
@Resource
|
||||
private ActivateService activateService;
|
||||
@Resource
|
||||
private SlbVirtualServerDao slbVirtualServerDao;
|
||||
|
||||
@Override
|
||||
|
@ -51,6 +54,9 @@ public class DefaultVirtualServerValidator implements VirtualServerValidator {
|
|||
public void removable(VirtualServer virtualServer) throws Exception {
|
||||
if (groupCriteriaQuery.queryByVsId(virtualServer.getId()).size() > 0)
|
||||
throw new ValidationException("Virtual server with id " + virtualServer.getId() + " cannot be deleted. Dependencies exist.");
|
||||
if (activateService.isVSActivated(virtualServer.getId())) {
|
||||
throw new ValidationException("Vs need to be deactivated before delete!");
|
||||
}
|
||||
}
|
||||
|
||||
private Set<String> getPortWhiteList() {
|
||||
|
|
Loading…
Reference in a new issue