public String getLicensePlanId(String licenseName) { Office365License lic = getLicensePlan(licenseName); if (lic != null) { return lic.getSkuID(); } else { return null; } }
private void populateSKUs() { log.info("populateSKUs"); this.licenses = new HashMap<String, Office365License>(); this.servicePlanIDs = new HashMap<String, String>(); JSONObject obj = getRequest("/subscribedSkus?api-version=" + Office365Connection.API_VERSION); try { JSONArray skus = obj.getJSONArray("value"); for (int i = 0; i < skus.length(); i++) { JSONObject sku = skus.getJSONObject(i); String skuID = sku.getString("skuId"); String skuPartNumber = sku.getString("skuPartNumber"); Office365License license = new Office365License(skuID); license.setSkuPartNumber(skuPartNumber); license.setObjectID(sku.getString("objectId")); license.setConsumedUnits(sku.getInt("consumedUnits")); JSONObject prepaidUnits = sku.getJSONObject("prepaidUnits"); license.setPrepaidUnitsEnabled(prepaidUnits.getInt("enabled")); license.setPrepaidUnitsSuspended(prepaidUnits.getInt("suspended")); license.setPrepaidUnitsWarning(prepaidUnits.getInt("warning")); JSONArray servicePlans = sku.getJSONArray("servicePlans"); for (int j = 0; j < servicePlans.length(); j++) { JSONObject planObj = servicePlans.getJSONObject(j); String planID = planObj.getString("servicePlanId"); String planName = planObj.getString("servicePlanName"); Office365ServicePlan plan = new Office365ServicePlan(planID, planName); license.addServicePlan(plan); this.servicePlanIDs.put(planName, planID); } this.licenses.put(skuPartNumber, license); } } catch (JSONException je) { log.error(je, "Error populating skus"); } }