private ValidatorError storeRegular() { // Check available entitlements Org satOrg = OrgFactory.getSatelliteOrg(); return store( channelFamily.getMaxMembers(satOrg), channelFamily.getMaxMembers(org), channelFamily.getCurrentMembers(satOrg), channelFamily.getCurrentMembers(org), newTotal, false); }
private ValidatorError storeFlex() { // Check available entitlements Org satOrg = OrgFactory.getSatelliteOrg(); return store( channelFamily.getMaxFlex(satOrg), channelFamily.getMaxFlex(org), channelFamily.getCurrentFlex(satOrg), channelFamily.getCurrentFlex(org), newFlexTotal, true); }
private ValidatorError store( Long satMax, Long orgMax, Long satCurrent, Long orgCurrent, Long proposed, boolean isFlex) { // No sense making the call if its the same. if (orgMax == proposed) { return null; } if (orgMax == null) { orgMax = 0L; } Long avail = 0L; if (satMax != null) { avail = satMax - satCurrent + orgMax; } if (proposed == null || proposed < 0 || avail < proposed) { String key = isFlex ? "org.entitlements.software.not_in_range.flex" : "org.entitlements.software.not_in_range"; return new ValidatorError(key, this.org.getName(), this.channelFamily.getName(), 0, avail); } // Proposed cannot be lower than current members if (!forceUnentitlement(orgCurrent, proposed)) { return new ValidatorError( "org.entitlements.software.proposedwarning", this.channelFamily.getName(), this.org.getName()); } Long toOrgId; Long fromOrgId; long actualTotal; // If we are decreasing the # of entitlements // we give back to the default org. if (orgMax.longValue() > proposed) { fromOrgId = this.org.getId(); toOrgId = OrgFactory.getSatelliteOrg().getId(); actualTotal = orgMax.longValue() - proposed; } else { toOrgId = this.org.getId(); fromOrgId = OrgFactory.getSatelliteOrg().getId(); actualTotal = proposed - orgMax.longValue(); } Map in = new HashMap(); // "group_label, from_org_id, to_org_id, quantity" in.put("channel_family_label", channelFamily.getLabel()); in.put("from_org_id", fromOrgId); in.put("to_org_id", toOrgId); if (isFlex) { in.put("quantity", 0); in.put("flex_quantity", actualTotal); } else { in.put("quantity", actualTotal); in.put("flex_quantity", 0); } CallableMode m = ModeFactory.getCallableMode("Org_queries", "assign_software_entitlements"); m.execute(in, new HashMap()); return null; }