private Map<String, String> getUuidTypeMapByResourceUuids(List<String> resourceUuids) { List<Tuple> ts = Q.New(AccountResourceRefVO.class) .select(AccountResourceRefVO_.resourceUuid, AccountResourceRefVO_.resourceType) .in(AccountResourceRefVO_.resourceUuid, resourceUuids) .listTuple(); Map<String, String> uuidType = new HashMap<String, String>(); for (Tuple t : ts) { String resUuid = t.get(0, String.class); String resType = t.get(1, String.class); uuidType.put(resUuid, resType); } return uuidType; }
@Override public RangeSet getVipUsePortRange(String vipUuid, String protocol, VipUseForList useForList){ RangeSet portRangeList = new RangeSet(); List<RangeSet.Range> portRanges = new ArrayList<RangeSet.Range>(); if (protocol.toUpperCase().equals(PortForwardingProtocolType.UDP.toString()) || protocol.toUpperCase().equals(PortForwardingProtocolType.TCP.toString())) { List<Tuple> pfPortList = Q.New(PortForwardingRuleVO.class).select(PortForwardingRuleVO_.vipPortStart, PortForwardingRuleVO_.vipPortEnd) .eq(PortForwardingRuleVO_.vipUuid, vipUuid).eq(PortForwardingRuleVO_.protocolType, PortForwardingProtocolType.valueOf(protocol.toUpperCase())).listTuple(); Iterator<Tuple> it = pfPortList.iterator(); while (it.hasNext()){ Tuple strRange = it.next(); int start = strRange.get(0, Integer.class); int end = strRange.get(1, Integer.class); RangeSet.Range range = new RangeSet.Range(start, end); portRanges.add(range); } } portRangeList.setRanges(portRanges); return portRangeList; }
private void checkIfTheAccountOwnTheResource(APIMessage.FieldParam param) throws IllegalAccessException { List<String> uuids = getResourceUuids(param); if (uuids.isEmpty()) { return; } Class resourceType = param.param.resourceType(); List<Tuple> ts = q(AccountResourceRefVO.class).select(AccountResourceRefVO_.accountUuid, AccountResourceRefVO_.resourceUuid) .in(AccountResourceRefVO_.resourceUuid, uuids) //.eq(AccountResourceRefVO_.resourceType, acntMgr.getBaseResourceType(resourceType).getSimpleName()) .listTuple(); ts.addAll( q(SharedResourceVO.class).select(SharedResourceVO_.receiverAccountUuid, SharedResourceVO_.resourceUuid) .in(SharedResourceVO_.resourceUuid, uuids) .eq(SharedResourceVO_.permission, SharedResourceVO.PERMISSION_WRITE) .eq(SharedResourceVO_.receiverAccountUuid, rbacEntity.getApiMessage().getSession().getAccountUuid()) //.eq(SharedResourceVO_.resourceType, acntMgr.getBaseResourceType(resourceType).getSimpleName()) .listTuple() ); Collection<AccountResourceBundle> bundles = toAccountResourceBundles(uuids, ts); uuids.forEach(uuid -> { Optional<AccountResourceBundle> opt = bundles.stream().filter(b -> b.accountUuid.equals(rbacEntity.getApiMessage().getSession().getAccountUuid()) && b.resourceUuid.equals(uuid)).findFirst(); if (!opt.isPresent()) { throw new OperationFailureException(operr("permission denied, the account[uuid:%s] is not the owner of the resource[uuid:%s, type:%s]", rbacEntity.getApiMessage().getSession().getAccountUuid(), uuid, resourceType.getSimpleName())); } }); }
private void addCdRomToHistoricalVm() { if (!VmCdRomGlobalProperty.addCdRomToHistoricalVm) { return; } List<String> vmUuids = getTargetVmUuids(); if (vmUuids.isEmpty()){ return; } List<Tuple> vmUuidPlatforms = Q.New(VmInstanceVO.class) .select(VmInstanceVO_.uuid, VmInstanceVO_.platform) .in(VmInstanceVO_.uuid, vmUuids) .listTuple(); for (Tuple vmTuple : vmUuidPlatforms) { String vmUuid = vmTuple.get(0, String.class); String vmPlatform = vmTuple.get(1, String.class); if (vmPlatform != null && ImagePlatform.Windows.toString().equalsIgnoreCase(vmPlatform)) { addCdRomForWindowsVm(vmUuid); continue; } addCdRomForLinuxAndOthersVm(vmUuid); } }
.eq(GlobalConfigVO_.category, AccountConstant.QUOTA_GLOBAL_CONFIG_CATETORY).listTuple();
.eq(GlobalConfigVO_.category, AccountConstant.QUOTA_GLOBAL_CONFIG_CATETORY).listTuple();