Source:
<code>public JSONRPC2Response process(final Map<String, Object> params) { JSONRPC2Response resp = null; try { final Number tenantId = HandlerUtils.<Number>fetchField( TenantHandler.TENANT, params, true, null); final Number dpid = HandlerUtils.<Number>fetchField( TenantHandler.VDPID, params, true, null); HandlerUtils.isValidTenantId(tenantId.intValue()); HandlerUtils <START> .isValidOVXSwitch(tenantId.intValue(), dpid.longValue()); <END> final OVXMap map = OVXMap.getInstance(); final OVXNetwork virtualNetwork = map.getVirtualNetwork(tenantId .intValue()); boolean needrm = virtualNetwork.removeSwitch(dpid.longValue()); if (needrm) { this.log.info("Removed virtual switch in virtual network {}", dpid, virtualNetwork.getTenantId()); } else { this.log.info("Virtual switch in virtual network already removed", dpid, virtualNetwork.getTenantId()); } resp = new JSONRPC2Response(0); } catch (final MissingRequiredField e) { resp = new JSONRPC2Response(new JSONRPC2Error( JSONRPC2Error.INVALID_PARAMS.getCode(), this.cmdName() + ": Unable to remove virtual network : " + e.getMessage()), 0); } catch (final InvalidDPIDException e) { resp = new JSONRPC2Response(new JSONRPC2Error( JSONRPC2Error.INVALID_PARAMS.getCode(), this.cmdName() + ": Invalid DPID : " + e.getMessage()), 0); } catch (final InvalidTenantIdException e) { resp = new JSONRPC2Response(new JSONRPC2Error( JSONRPC2Error.INVALID_PARAMS.getCode(), this.cmdName() + ": Invalid tenant id : " + e.getMessage()), 0); } catch (final NetworkMappingException e) { resp = new JSONRPC2Response(new JSONRPC2Error( JSONRPC2Error.INVALID_PARAMS.getCode(), this.cmdName() + ": " + e.getMessage()), 0); } return resp; }</code><technical_language>This method throw exception if virtual switch exist. added necessary</technical_language>

Target:
public JSONRPC2Response process(final Map<String, Object> params) { JSONRPC2Response resp = null; try { final Number tenantId = HandlerUtils.<Number>fetchField( TenantHandler.TENANT, params, true, null); final Number dpid = HandlerUtils.<Number>fetchField( TenantHandler.VDPID, params, true, null); HandlerUtils.isValidTenantId(tenantId.intValue()); HandlerUtils .isValidOVXSwitch(tenantId.intValue(), dpid.longValue()); final OVXMap map = OVXMap.getInstance(); final OVXNetwork virtualNetwork = map.getVirtualNetwork(tenantId .intValue()); OVXSwitch ovxSwitch = virtualNetwork.getSwitch(dpid.longValue()); HandlerUtils.isValidSwitchState(ovxSwitch, true); virtualNetwork.removeSwitch(dpid.longValue()); this.log.info("Removed virtual switch in virtual network {}", dpid, virtualNetwork.getTenantId()); resp = new JSONRPC2Response(0); } catch (final MissingRequiredField e) { resp = new JSONRPC2Response(new JSONRPC2Error( JSONRPC2Error.INVALID_PARAMS.getCode(), this.cmdName() + ": Unable to remove virtual network : " + e.getMessage()), 0); } catch (final InvalidDPIDException e) { resp = new JSONRPC2Response(new JSONRPC2Error( JSONRPC2Error.INVALID_PARAMS.getCode(), this.cmdName() + ": Invalid DPID : " + e.getMessage()), 0); } catch (final InvalidTenantIdException e) { resp = new JSONRPC2Response(new JSONRPC2Error( JSONRPC2Error.INVALID_PARAMS.getCode(), this.cmdName() + ": Invalid tenant id : " + e.getMessage()), 0); } catch (final NetworkMappingException e) { resp = new JSONRPC2Response(new JSONRPC2Error( JSONRPC2Error.INVALID_PARAMS.getCode(), this.cmdName() + ": " + e.getMessage()), 0); } catch (ComponentStateException e) { resp = new JSONRPC2Response(new JSONRPC2Error( JSONRPC2Error.INVALID_PARAMS.getCode(), this.cmdName() + ": Switch was already removed : " + e.getMessage()), 0); } return resp; }