Search in sources :

Example 6 with Site2SiteVpnGatewayVO

use of com.cloud.network.dao.Site2SiteVpnGatewayVO in project cloudstack by apache.

the class Site2SiteVpnManagerImpl method searchForVpnConnections.

@Override
public Pair<List<? extends Site2SiteVpnConnection>, Integer> searchForVpnConnections(ListVpnConnectionsCmd cmd) {
    Long id = cmd.getId();
    Long vpcId = cmd.getVpcId();
    Boolean display = cmd.getDisplay();
    Long domainId = cmd.getDomainId();
    boolean isRecursive = cmd.isRecursive();
    String accountName = cmd.getAccountName();
    boolean listAll = cmd.listAll();
    long startIndex = cmd.getStartIndex();
    long pageSizeVal = cmd.getPageSizeVal();
    Account caller = CallContext.current().getCallingAccount();
    List<Long> permittedAccounts = new ArrayList<Long>();
    Ternary<Long, Boolean, ListProjectResourcesCriteria> domainIdRecursiveListProject = new Ternary<Long, Boolean, ListProjectResourcesCriteria>(domainId, isRecursive, null);
    _accountMgr.buildACLSearchParameters(caller, id, accountName, cmd.getProjectId(), permittedAccounts, domainIdRecursiveListProject, listAll, false);
    domainId = domainIdRecursiveListProject.first();
    isRecursive = domainIdRecursiveListProject.second();
    ListProjectResourcesCriteria listProjectResourcesCriteria = domainIdRecursiveListProject.third();
    Filter searchFilter = new Filter(Site2SiteVpnConnectionVO.class, "id", false, startIndex, pageSizeVal);
    SearchBuilder<Site2SiteVpnConnectionVO> sb = _vpnConnectionDao.createSearchBuilder();
    _accountMgr.buildACLSearchBuilder(sb, domainId, isRecursive, permittedAccounts, listProjectResourcesCriteria);
    sb.and("id", sb.entity().getId(), SearchCriteria.Op.EQ);
    sb.and("display", sb.entity().isDisplay(), SearchCriteria.Op.EQ);
    if (vpcId != null) {
        SearchBuilder<Site2SiteVpnGatewayVO> gwSearch = _vpnGatewayDao.createSearchBuilder();
        gwSearch.and("vpcId", gwSearch.entity().getVpcId(), SearchCriteria.Op.EQ);
        sb.join("gwSearch", gwSearch, sb.entity().getVpnGatewayId(), gwSearch.entity().getId(), JoinBuilder.JoinType.INNER);
    }
    SearchCriteria<Site2SiteVpnConnectionVO> sc = sb.create();
    _accountMgr.buildACLSearchCriteria(sc, domainId, isRecursive, permittedAccounts, listProjectResourcesCriteria);
    if (display != null) {
        sc.setParameters("display", display);
    }
    if (id != null) {
        sc.addAnd("id", SearchCriteria.Op.EQ, id);
    }
    if (vpcId != null) {
        sc.setJoinParameters("gwSearch", "vpcId", vpcId);
    }
    Pair<List<Site2SiteVpnConnectionVO>, Integer> result = _vpnConnectionDao.searchAndCount(sc, searchFilter);
    return new Pair<List<? extends Site2SiteVpnConnection>, Integer>(result.first(), result.second());
}
Also used : Account(com.cloud.user.Account) Ternary(com.cloud.utils.Ternary) ArrayList(java.util.ArrayList) Site2SiteVpnConnectionVO(com.cloud.network.dao.Site2SiteVpnConnectionVO) ListProjectResourcesCriteria(com.cloud.projects.Project.ListProjectResourcesCriteria) Filter(com.cloud.utils.db.Filter) Site2SiteVpnGatewayVO(com.cloud.network.dao.Site2SiteVpnGatewayVO) List(java.util.List) ArrayList(java.util.ArrayList) Pair(com.cloud.utils.Pair)

Aggregations

Site2SiteVpnGatewayVO (com.cloud.network.dao.Site2SiteVpnGatewayVO)6 Account (com.cloud.user.Account)4 ActionEvent (com.cloud.event.ActionEvent)2 InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)2 ListProjectResourcesCriteria (com.cloud.projects.Project.ListProjectResourcesCriteria)2 Pair (com.cloud.utils.Pair)2 Ternary (com.cloud.utils.Ternary)2 Filter (com.cloud.utils.db.Filter)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Site2SiteVpnCfgCommand (com.cloud.agent.api.routing.Site2SiteVpnCfgCommand)1 DataCenterVO (com.cloud.dc.DataCenterVO)1 IpAddress (com.cloud.network.IpAddress)1 PublicIpAddress (com.cloud.network.PublicIpAddress)1 IPAddressVO (com.cloud.network.dao.IPAddressVO)1 Site2SiteCustomerGatewayVO (com.cloud.network.dao.Site2SiteCustomerGatewayVO)1 Site2SiteVpnConnectionVO (com.cloud.network.dao.Site2SiteVpnConnectionVO)1 PrivateIpAddress (com.cloud.network.vpc.PrivateIpAddress)1 Vpc (com.cloud.network.vpc.Vpc)1 VpcVO (com.cloud.network.vpc.VpcVO)1