Source:
<code>public void checkNetworkPermissions(Account owner, Network network) { if (network == null) { throw new CloudRuntimeException("cannot check permissions on (Network) <null>"); } <START> if ((network.getGuestType() != Network.GuestType.Shared && network.getGuestType() != GuestType.L2) || <END> (network.getGuestType() == Network.GuestType.Shared && network.getAclType() == ACLType.Account)) { AccountVO networkOwner = _accountDao.findById(network.getAccountId()); if (networkOwner == null) throw new PermissionDeniedException("Unable to use network with id= " + ((NetworkVO)network).getUuid() + ", network does not have an owner"); if (owner.getType() != Account.ACCOUNT_TYPE_PROJECT && networkOwner.getType() == Account.ACCOUNT_TYPE_PROJECT) { if (!_projectAccountDao.canAccessProjectAccount(owner.getAccountId(), network.getAccountId())) { throw new PermissionDeniedException("Unable to use network with id= " + ((NetworkVO)network).getUuid() + ", permission denied"); } } else { List<NetworkVO> networkMap = _networksDao.listBy(owner.getId(), network.getId()); if (networkMap == null || networkMap.isEmpty()) { throw new PermissionDeniedException("Unable to use network with id= " + ((NetworkVO)network).getUuid() + ", permission denied"); } } } else { if (!isNetworkAvailableInDomain(network.getId(), owner.getDomainId())) { DomainVO ownerDomain = _domainDao.findById(owner.getDomainId()); if (ownerDomain == null) { throw new CloudRuntimeException("cannot check permission on account " + owner.getAccountName() + " whose domain does not exist"); } throw new PermissionDeniedException("Shared network id=" + ((NetworkVO)network).getUuid() + " is not available in domain id=" + ownerDomain.getUuid()); } } }</code><technical_language>Network.GuestType.Shared is GuestType.L2 directly. please cleanup imports scope for java class</technical_language>

Target:
public void checkNetworkPermissions(Account owner, Network network) { if (network == null) { throw new CloudRuntimeException("cannot check permissions on (Network) <null>"); } if ((network.getGuestType() != GuestType.Shared && network.getGuestType() != GuestType.L2) || (network.getGuestType() == GuestType.Shared && network.getAclType() == ACLType.Account)) { AccountVO networkOwner = _accountDao.findById(network.getAccountId()); if (networkOwner == null) throw new PermissionDeniedException("Unable to use network with id= " + ((NetworkVO)network).getUuid() + ", network does not have an owner"); if (owner.getType() != Account.ACCOUNT_TYPE_PROJECT && networkOwner.getType() == Account.ACCOUNT_TYPE_PROJECT) { if (!_projectAccountDao.canAccessProjectAccount(owner.getAccountId(), network.getAccountId())) { throw new PermissionDeniedException("Unable to use network with id= " + ((NetworkVO)network).getUuid() + ", permission denied"); } } else { List<NetworkVO> networkMap = _networksDao.listBy(owner.getId(), network.getId()); if (networkMap == null || networkMap.isEmpty()) { throw new PermissionDeniedException("Unable to use network with id= " + ((NetworkVO)network).getUuid() + ", permission denied"); } } } else { if (!isNetworkAvailableInDomain(network.getId(), owner.getDomainId())) { DomainVO ownerDomain = _domainDao.findById(owner.getDomainId()); if (ownerDomain == null) { throw new CloudRuntimeException("cannot check permission on account " + owner.getAccountName() + " whose domain does not exist"); } throw new PermissionDeniedException("Shared network id=" + ((NetworkVO)network).getUuid() + " is not available in domain id=" + ownerDomain.getUuid()); } } }