/** {@inheritDoc} */ protected Site parseData(String siteIdentifier, Map<String, Object> json) { if (extraPropertiesCache.get(siteIdentifier) != null) { CacheSiteExtraProperties extraProperties = extraPropertiesCache.get(siteIdentifier); json.put(OnPremiseConstant.ISPENDINGMEMBER_VALUE, extraProperties.isPendingMember); json.put(OnPremiseConstant.ISMEMBER_VALUE, extraProperties.isMember); json.put(OnPremiseConstant.ISFAVORITE_VALUE, extraProperties.isFavorite); } return SiteImpl.parseJson((Map<String, Object>) json); }
/** {@inheritDoc} */ @SuppressWarnings("unchecked") protected PagingResult<Site> computeSites(UrlBuilder url, ListingContext listingContext) { HttpUtils.Response resp = read(url, ErrorCodeRegistry.SITE_GENERIC); List<Object> json = JsonUtils.parseArray(resp.getStream(), resp.getCharset()); int size = json.size(); List<Site> result = new ArrayList<Site>(); int fromIndex = 0, toIndex = size; Boolean hasMoreItems = false; // Define Listing Context if (listingContext != null) { fromIndex = (listingContext.getSkipCount() > size) ? size : listingContext.getSkipCount(); // Case if skipCount > result size if (listingContext.getMaxItems() + fromIndex >= size) { toIndex = size; hasMoreItems = false; } else { toIndex = listingContext.getMaxItems() + fromIndex; hasMoreItems = true; } } String siteName = null; Map<String, Object> mapProperties = null; CacheSiteExtraProperties extraProperties = null; for (int i = fromIndex; i < toIndex; i++) { mapProperties = (Map<String, Object>) json.get(i); if (mapProperties != null) { siteName = JSONConverter.getString(mapProperties, OnPremiseConstant.SHORTNAME_VALUE); if (extraPropertiesCache.get(siteName) != null) { extraProperties = extraPropertiesCache.get(siteName); mapProperties.put( OnPremiseConstant.ISPENDINGMEMBER_VALUE, extraProperties.isPendingMember); mapProperties.put(OnPremiseConstant.ISMEMBER_VALUE, extraProperties.isMember); mapProperties.put(OnPremiseConstant.ISFAVORITE_VALUE, extraProperties.isFavorite); } result.add(SiteImpl.parseJson((Map<String, Object>) json.get(i))); } } if (listingContext != null) { Collections.sort( result, new AlphaComparator(listingContext.isSortAscending(), listingContext.getSortProperty())); } return new PagingResultImpl<Site>(result, hasMoreItems, size); }