bug CLOUDSTACK-198: VPN user add, on failure remove user currently being added only, other users will remain in Add state

This commit is contained in:
Kishan Kavala 2012-09-26 13:53:08 +05:30
parent 2da5b448a1
commit 6540ff8fa1
4 changed files with 5 additions and 5 deletions

View File

@ -120,7 +120,7 @@ public class AddVpnUserCmd extends BaseAsyncCreateCmd {
public void execute(){
VpnUser vpnUser = _entityMgr.findById(VpnUser.class, getEntityId());
Account account = _entityMgr.findById(Account.class, vpnUser.getAccountId());
if (!_ravService.applyVpnUsers(vpnUser.getAccountId())) {
if (!_ravService.applyVpnUsers(vpnUser.getAccountId(), userName)) {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to add vpn user");
}

View File

@ -113,7 +113,7 @@ public class RemoveVpnUserCmd extends BaseAsyncCmd {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to remove vpn user");
}
if (!_ravService.applyVpnUsers(owner.getId())) {
if (!_ravService.applyVpnUsers(owner.getId(), userName)) {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to apply vpn user removal");
}
SuccessResponse response = new SuccessResponse(getCommandName());

View File

@ -35,7 +35,7 @@ public interface RemoteAccessVpnService {
VpnUser addVpnUser(long vpnOwnerId, String userName, String password);
boolean removeVpnUser(long vpnOwnerId, String userName);
List<? extends VpnUser> listVpnUsers(long vpnOwnerId, String userName);
boolean applyVpnUsers(long vpnOwnerId);
boolean applyVpnUsers(long vpnOwnerId, String userName);
List<? extends RemoteAccessVpn> searchForRemoteAccessVpns(ListRemoteAccessVpnsCmd cmd);
List<? extends VpnUser> searchForVpnUsers(ListVpnUsersCmd cmd);

View File

@ -418,7 +418,7 @@ public class RemoteAccessVpnManagerImpl implements RemoteAccessVpnService, Manag
@DB
@Override
public boolean applyVpnUsers(long vpnOwnerId) {
public boolean applyVpnUsers(long vpnOwnerId, String userName) {
Account caller = UserContext.current().getCaller();
Account owner = _accountDao.findById(vpnOwnerId);
_accountMgr.checkAccess(caller, null, true, owner);
@ -481,7 +481,7 @@ public class RemoteAccessVpnManagerImpl implements RemoteAccessVpnService, Manag
_vpnUsersDao.remove(user.getId());
}
} else {
if (user.getState() == State.Add) {
if (user.getState() == State.Add && (user.getUsername()).equals(userName)) {
Transaction txn = Transaction.currentTxn();
txn.start();
_vpnUsersDao.remove(user.getId());