Using pageNumber as offset, see #22999

This commit is contained in:
Francesco Mangiacrapa 2022-03-18 17:22:16 +01:00
parent fdc6f22ca0
commit 4cb97f41fa
1 changed files with 26 additions and 7 deletions

View File

@ -34,7 +34,7 @@ public class GCatCaller {
private GCatCatalogueConfiguration catalogueConfiguration;
private static final Logger LOG = LoggerFactory.getLogger(GCatCaller.class);
public final static String MODERATOR_FIELD_NAME = Moderated.SYSTEM_CM_ITEM_STATUS.replaceAll(":", "");
/**
@ -243,12 +243,16 @@ public class GCatCaller {
if (offset < 0)
offset = 0;
int pageNumber = offsetToPageNumber(limit, offset);
LOG.info("Using pageNumber {} for offset {} " + pageNumber, offset);
queryParams.put("limit", limit + "");
queryParams.put("offset", offset + "");
queryParams.put("offset", pageNumber + "");
return getListItemsForQuery(queryParams);
}
/**
* Count list items for CM status.
*
@ -317,18 +321,18 @@ public class GCatCaller {
*
* @param reload the reload
* @return the configuration
* @throws MalformedURLException
* @throws MalformedURLException
*/
public GCatCatalogueConfiguration getConfiguration(boolean reload) throws MalformedURLException {
LOG.trace("getConfiguration called");
LOG.info("Calling get configuration with reload config: "+reload);
LOG.info("Calling get configuration with reload config: " + reload);
if (reload || catalogueConfiguration == null) {
catalogueConfiguration = new GCatCatalogueConfiguration();
Configuration gCatConfig = new Configuration();
CatalogueConfiguration gCG = gCatConfig.read();
catalogueConfiguration.setCkanURL(gCG.getCkanURL());
catalogueConfiguration.setContext(gCG.getContext());
catalogueConfiguration.setDefaultOrganization(gCG.getDefaultOrganization());
@ -338,8 +342,23 @@ public class GCatCaller {
catalogueConfiguration.setSolrURL(gCG.getSolrURL());
catalogueConfiguration.setSupportedOrganizations(gCG.getSupportedOrganizations());
}
LOG.info("returning gCatConfig: "+catalogueConfiguration);
LOG.info("returning gCatConfig: " + catalogueConfiguration);
return catalogueConfiguration;
}
private static int offsetToPageNumber(int limit, int offset) {
int pageNumber = offset;
try {
pageNumber = offset / limit;
} catch (Exception e) {
LOG.warn("Page number error: ", e);
}
return pageNumber;
}
}