@@ -210,7 +210,7 @@ public Site2SiteCustomerGateway createCustomerGateway(CreateVpnCustomerGatewayCm
210210 }
211211 Long espLifetime = cmd .getEspLifetime ();
212212 if (espLifetime == null ) {
213- // Default value of lifetime is 1 day
213+ // Default value of lifetime is 1 hour
214214 espLifetime = (long ) 3600 ;
215215 }
216216 if (espLifetime > 86400 ) {
@@ -222,16 +222,17 @@ public Site2SiteCustomerGateway createCustomerGateway(CreateVpnCustomerGatewayCm
222222 dpd = false ;
223223 }
224224
225+ long accountId = owner .getAccountId ();
225226 if (_customerGatewayDao .findByGatewayIp (gatewayIp ) != null ) {
226- throw new InvalidParameterValueException ("The customer gateway with ip " + gatewayIp + " already existed!" );
227+ throw new InvalidParameterValueException ("The customer gateway with ip " + gatewayIp + " already existed in the system !" );
227228 }
228- if (_customerGatewayDao .findByName (name ) != null ) {
229+ if (_customerGatewayDao .findByNameAndAccountId (name , accountId ) != null ) {
229230 throw new InvalidParameterValueException ("The customer gateway with name " + name + " already existed!" );
230231 }
231232
232233 checkCustomerGatewayCidrList (guestCidrList );
233234
234- Site2SiteCustomerGatewayVO gw = new Site2SiteCustomerGatewayVO (name , owner . getAccountId () , owner .getDomainId (), gatewayIp , guestCidrList , ipsecPsk ,
235+ Site2SiteCustomerGatewayVO gw = new Site2SiteCustomerGatewayVO (name , accountId , owner .getDomainId (), gatewayIp , guestCidrList , ipsecPsk ,
235236 ikePolicy , espPolicy , ikeLifetime , espLifetime , dpd );
236237 _customerGatewayDao .persist (gw );
237238 return gw ;
@@ -454,7 +455,7 @@ public Site2SiteCustomerGateway updateCustomerGateway(UpdateVpnCustomerGatewayCm
454455 }
455456 Long espLifetime = cmd .getEspLifetime ();
456457 if (espLifetime == null ) {
457- // Default value of lifetime is 1 day
458+ // Default value of lifetime is 1 hour
458459 espLifetime = (long ) 3600 ;
459460 }
460461 if (espLifetime > 86400 ) {
@@ -467,6 +468,14 @@ public Site2SiteCustomerGateway updateCustomerGateway(UpdateVpnCustomerGatewayCm
467468 }
468469
469470 checkCustomerGatewayCidrList (guestCidrList );
471+
472+ long accountId = gw .getAccountId ();
473+ if (_customerGatewayDao .findByGatewayIp (gatewayIp ) != null ) {
474+ throw new InvalidParameterValueException ("The customer gateway with ip " + gatewayIp + " already existed in the system!" );
475+ }
476+ if (_customerGatewayDao .findByNameAndAccountId (name , accountId ) != null ) {
477+ throw new InvalidParameterValueException ("The customer gateway with name " + name + " already existed!" );
478+ }
470479
471480 gw .setName (name );
472481 gw .setGatewayIp (gatewayIp );
0 commit comments