@Override public void execute() { Account owner = _accountService.getAccount(getEntityOwnerId()); boolean result = _ravService.removeVpnUser(owner.getId(), userName, CallContext.current().getCallingAccount()); if (!result) { 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"); } SuccessResponse response = new SuccessResponse(getCommandName()); setResponseObject(response); } }
@Override 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, ex.getMessage()); } VpnUsersResponse vpnResponse = new VpnUsersResponse(); vpnResponse.setId(vpnUser.getUuid()); vpnResponse.setUserName(vpnUser.getUsername()); vpnResponse.setAccountName(account.getAccountName()); Domain domain = _entityMgr.findById(Domain.class, account.getDomainId()); if (domain != null) { vpnResponse.setDomainId(domain.getUuid()); vpnResponse.setDomainName(domain.getName()); } vpnResponse.setResponseName(getCommandName()); vpnResponse.setObjectName("vpnuser"); setResponseObject(vpnResponse); }
@Override public void execute() { final Account owner = _accountService.getAccount(getEntityOwnerId()); final boolean result = _ravService.removeVpnUser(owner.getId(), userName, CallContext.current().getCallingAccount()); if (!result) { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to remove vpn user"); } if (!_ravService.applyVpnUsers(owner.getId(), userName)) { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to apply vpn user removal"); } final SuccessResponse response = new SuccessResponse(getCommandName()); setResponseObject(response); }
@Override public void execute() { final VpnUser vpnUser = _entityMgr.findById(VpnUser.class, getEntityId()); final Account account = _entityMgr.findById(Account.class, vpnUser.getAccountId()); if (!_ravService.applyVpnUsers(vpnUser.getAccountId(), userName)) { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to add vpn user"); } final VpnUsersResponse vpnResponse = new VpnUsersResponse(); vpnResponse.setId(vpnUser.getUuid()); vpnResponse.setUserName(vpnUser.getUsername()); vpnResponse.setAccountName(account.getAccountName()); final Domain domain = _entityMgr.findById(Domain.class, account.getDomainId()); if (domain != null) { vpnResponse.setDomainId(domain.getUuid()); vpnResponse.setDomainName(domain.getName()); } vpnResponse.setResponseName(getCommandName()); vpnResponse.setObjectName("vpnuser"); setResponseObject(vpnResponse); }