Revert "CLOUDSTACK-9711: Fixed error reporting while adding vpn user"

This reverts commit d7b792c3f91e8a3038d53a51fae700a158f92740.
This commit is contained in:
Jayapal 2017-02-20 16:26:45 +05:30
parent d7b792c3f9
commit a3e6bce8e6
4 changed files with 6 additions and 23 deletions

View File

@ -43,7 +43,7 @@ public interface RemoteAccessVpnService {
List<? extends VpnUser> listVpnUsers(long vpnOwnerId, String userName);
boolean applyVpnUsers(long vpnOwnerId, String userName) throws ResourceUnavailableException;
boolean applyVpnUsers(long vpnOwnerId, String userName);
Pair<List<? extends RemoteAccessVpn>, Integer> searchForRemoteAccessVpns(ListRemoteAccessVpnsCmd cmd);

View File

@ -119,12 +119,8 @@ public class AddVpnUserCmd extends BaseAsyncCreateCmd {
public void execute() {
VpnUser vpnUser = _entityMgr.findById(VpnUser.class, getEntityId());
Account account = _entityMgr.findById(Account.class, vpnUser.getAccountId());
try {
if (!_ravService.applyVpnUsers(vpnUser.getAccountId(), userName)) {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to add vpn user");
}
}catch (Exception ex) {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to add vpn user due to resource unavailable");
if (!_ravService.applyVpnUsers(vpnUser.getAccountId(), userName)) {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to add vpn user");
}
VpnUsersResponse vpnResponse = new VpnUsersResponse();

View File

@ -115,14 +115,9 @@ public class RemoveVpnUserCmd extends BaseAsyncCmd {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to remove vpn user");
}
try {
if (!_ravService.applyVpnUsers(owner.getId(), userName)) {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to apply vpn user removal");
}
}catch (Exception ex) {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to remove vpn user due to resource unavailable");
if (!_ravService.applyVpnUsers(owner.getId(), userName)) {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to apply vpn user removal");
}
SuccessResponse response = new SuccessResponse(getCommandName());
setResponseObject(response);
}

View File

@ -501,14 +501,13 @@ public class RemoteAccessVpnManagerImpl extends ManagerBase implements RemoteAcc
@DB
@Override
public boolean applyVpnUsers(long vpnOwnerId, String userName) throws ResourceUnavailableException {
public boolean applyVpnUsers(long vpnOwnerId, String userName) {
Account caller = CallContext.current().getCallingAccount();
Account owner = _accountDao.findById(vpnOwnerId);
_accountMgr.checkAccess(caller, null, true, owner);
s_logger.debug("Applying vpn users for " + owner);
List<RemoteAccessVpnVO> vpns = _remoteAccessVpnDao.findByAccount(vpnOwnerId);
RemoteAccessVpnVO vpnTemp = null;
List<VpnUserVO> users = _vpnUsersDao.listByAccount(vpnOwnerId);
@ -538,14 +537,12 @@ public class RemoteAccessVpnManagerImpl extends ManagerBase implements RemoteAcc
} else {
finals[i] = false;
success = false;
vpnTemp = vpn;
}
}
}
} catch (Exception e) {
s_logger.warn("Unable to apply vpn users ", e);
success = false;
vpnTemp = vpn;
for (int i = 0; i < finals.length; i++) {
finals[i] = false;
@ -578,11 +575,6 @@ public class RemoteAccessVpnManagerImpl extends ManagerBase implements RemoteAcc
}
}
if (!success) {
throw new ResourceUnavailableException("Failed add vpn user due to Resource unavailable ",
RemoteAccessVPNServiceProvider.class, vpnTemp.getId());
}
return success;
}