Skip to content

Commit

Permalink
Add default value for collection max size if not available in
Browse files Browse the repository at this point in the history
configurations, improve handling of max items presented in search
results.  #EA-3871
  • Loading branch information
GordeaS authored and GordeaS committed Jul 25, 2024
1 parent 98ca962 commit 1442361
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,8 @@ public class UserSetConfigurationImpl implements UserSetConfiguration {
public static final String KEY_RETRIEVE_DEREFERENCE_ITEMS = "set.retrieve.dereference.items.max";

public static final int DEFAULT_ITEMS_PER_PAGE = 10;
@Deprecated
/**
* use getMaxPageSize instead
*/
public static final int MAX_ITEMS_TO_PRESENT = 1000;
public static final int DEFAULT_MAX_COLLECTION_SIZE = 100;
public static final int DEFAULT_MAX_ITEMS_TO_PRESENT = 1000;


public static final String SET_API_ENDPOINT = "set.api.endpoint.baseUrl";
Expand Down Expand Up @@ -110,7 +107,7 @@ public String getEnvironment() {
public int getMaxPageSize(String profile) {
// TODO enable configuration per profile when specified
String key = PREFIX_RETRIEVE_MAX_PAGE_SIZE + LdProfiles.STANDARD.name().toLowerCase();
return Integer.parseInt(getSetProperties().getProperty(key));
return Integer.parseInt(getSetProperties().getProperty(key, ""+DEFAULT_MAX_ITEMS_TO_PRESENT));
}

public int getMaxSearchDereferencedItems() {
Expand Down Expand Up @@ -186,6 +183,6 @@ public String getEuropeanaPublisherNickname() {

@Override
public int getCollectionMaxSize() {
return Integer.parseInt(getSetProperties().getProperty(COLLECTION_SIZE_MAX));
return Integer.parseInt(getSetProperties().getProperty(COLLECTION_SIZE_MAX, ""+DEFAULT_MAX_COLLECTION_SIZE));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -848,9 +848,10 @@ public void applyProfile(UserSet userSet, LdProfiles profile) {
// presented
if (profile != LdProfiles.MINIMAL && userSet.getItems() != null) {
int itemsCount = userSet.getItems().size();
if (itemsCount > UserSetConfigurationImpl.MAX_ITEMS_TO_PRESENT) {
final int maxPageSize = getConfiguration().getMaxPageSize(profile.getRequestParamValue());
if (itemsCount > maxPageSize) {
List<String> itemsPage =
userSet.getItems().subList(0, UserSetConfigurationImpl.MAX_ITEMS_TO_PRESENT);
userSet.getItems().subList(0, maxPageSize);
userSet.setItems(itemsPage);
profile = LdProfiles.STANDARD;
getLogger().debug("Profile switched to standard, due to set size!");
Expand Down

0 comments on commit 1442361

Please sign in to comment.