/** * @return upper range for which a org can get entitlements (org1 max - org1 consumed + org max) */ public Long getUpperRange() { Long defaultMax = EntitlementManager.getMaxEntitlements(this.getEntitlement(), OrgFactory.getSatelliteOrg()); Long defaultCur = EntitlementManager.getUsedEntitlements(this.getEntitlement(), OrgFactory.getSatelliteOrg()); Long upper = getMaxEntitlements() + (defaultMax - defaultCur); return upper; }
/** * Get the count of the number of used slots. * * @return Long count, null if unlimited */ public Long getCurrentEntitlements() { Long count = EntitlementManager.getUsedEntitlements(this.getEntitlement(), org); if (count == null) { return new Long(0); } return count; }
/** * Constructor .. * * @param entIn to transfer * @param orgIn who we are viewing */ public OrgEntitlementDto(Entitlement entIn, Org orgIn) { super(entIn, null); this.org = orgIn; ent = entIn; Long availEnts = EntitlementManager.getAvailableEntitlements(entIn, orgIn); this.setAvailbleEntitlements(availEnts); }
/** @return OrgEntitlementDto object */ public OrgEntitlementDto getDto() { if (this.orgEntDto == null) { Org orgObj = OrgFactory.lookupById(new Long(this.orgid.longValue())); this.orgEntDto = new OrgEntitlementDto(EntitlementManager.getByName(this.entname), orgObj); } return this.orgEntDto; }
private Entitlement verifyEntitlementExists(String sysLabel) { Entitlement ent = EntitlementManager.getByName(sysLabel); if (ent == null) { throw new NoSuchEntitlementException(sysLabel); } return ent; }
/** * Set an organizations entitlement allocation for a channel family. * * <p>If increasing the entitlement allocation, the default organization (i.e. orgId=1) must have * a sufficient number of free entitlements. * * @param sessionKey User's session key. * @param orgId Organization ID to set allocation for. * @param systemEntitlementLabel System entitlement to set allocation for. * @param allocation New entitlement allocation. * @return 1 on success. * @xmlrpc.doc Set an organization's entitlement allocation for the given software entitlement. * <p>If increasing the entitlement allocation, the default organization (i.e. orgId=1) must * have a sufficient number of free entitlements. * @xmlrpc.param #param("string", "sessionKey") * @xmlrpc.param #param("int", "orgId") * @xmlrpc.param #param_desc("string", "label", "System entitlement label. Valid values include:") * #options() #item("enterprise_entitled") #item("monitoring_entitled") * #item("provisioning_entitled") #item("virtualization_host") * #item("virtualization_host_platform") #options_end() * @xmlrpc.param #param("int", "allocation") * @xmlrpc.returntype #return_int_success() */ public int setSystemEntitlements( String sessionKey, Integer orgId, String systemEntitlementLabel, Integer allocation) { getSatAdmin(sessionKey); Org org = verifyOrgExists(orgId); Entitlement ent = EntitlementManager.getByName(systemEntitlementLabel); if (ent == null || (!EntitlementManager.getAddonEntitlements().contains(ent) && !EntitlementManager.getBaseEntitlements().contains(ent))) { throw new InvalidEntitlementException(); } UpdateOrgSystemEntitlementsCommand cmd = new UpdateOrgSystemEntitlementsCommand(ent, org, new Long(allocation)); ValidatorError ve = cmd.store(); if (ve != null) { throw new ValidationException(ve.getMessage()); } return 1; }
/** * Set of Entitlements that can be a BaseEntitlement available to the Org * * @return Set of Entitlements */ public Set<Entitlement> getValidBaseEntitlementsForOrg() { Set<Entitlement> baseEntitlements = new HashSet<Entitlement>(); Iterator<EntitlementServerGroup> i = getEntitledServerGroups().iterator(); while (i.hasNext()) { ServerGroupType sgt = i.next().getGroupType(); // Filter out the update entitlement for satellite: if (sgt.isBase() && !sgt.getLabel().equals(EntitlementManager.UPDATE.getLabel())) { baseEntitlements.add(EntitlementManager.getByName(sgt.getLabel())); } } return baseEntitlements; }
/** * Set of Entitlements that can be an add-on entitlement available to the Org * * @return Set of Entitlements */ public Set<Entitlement> getValidAddOnEntitlementsForOrg() { Set<Entitlement> addonEntitlements = new HashSet<Entitlement>(); Iterator<EntitlementServerGroup> i = getEntitledServerGroups().iterator(); while (i.hasNext()) { ServerGroupType sgt = i.next().getGroupType(); if (!sgt.isBase()) { Entitlement ent = EntitlementManager.getByName(sgt.getLabel()); if (ent != null) { addonEntitlements.add(ent); } } } return addonEntitlements; }
public void testExecuteSubmit() throws Exception { user.getOrg().addRole(RoleFactory.SAT_ADMIN); user.addPermanentRole(RoleFactory.SAT_ADMIN); setRequestPathInfo("/admin/multiorg/OrgSystemSubscriptions"); addRequestParameter(RequestContext.ORG_ID, user.getOrg().getId().toString()); addRequestParameter(EntitlementManager.ENTERPRISE_ENTITLED, new Long(1).toString()); addRequestParameter(EntitlementManager.MONITORING_ENTITLED, new Long(0).toString()); addRequestParameter(EntitlementManager.PROVISIONING_ENTITLED, new Long(0).toString()); addRequestParameter(EntitlementManager.VIRTUALIZATION_ENTITLED, new Long(0).toString()); addRequestParameter( EntitlementManager.VIRTUALIZATION_PLATFORM_ENTITLED, new Long(0).toString()); addSubmitted(); actionPerform(); assertTrue(getActualForward().contains("oid=" + user.getOrg().getId())); verifyActionMessage("org.entitlements.syssoft.success"); assertEquals( 1, EntitlementManager.getAvailableEntitlements(EntitlementManager.MANAGEMENT, user.getOrg()) .longValue()); }
/** @return Long total of the available Entitlements in the default Org */ public Long getSatelliteTotal() { Org defaultOrg = OrgFactory.getSatelliteOrg(); return EntitlementManager.getAvailableEntitlements(this.getEntitlement(), defaultOrg); }