Skip to content

Commit

Permalink
EA-4015 make serach return list of sets
Browse files Browse the repository at this point in the history
  • Loading branch information
SrishtiSingh-eu committed Nov 28, 2024
1 parent 47b5f56 commit b23ea1e
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
package eu.europeana.set.client;

import eu.europeana.api.commons.definitions.search.result.impl.ResultsPageImpl;
import eu.europeana.set.client.config.ClientConfiguration;
import eu.europeana.set.client.exception.SetApiClientException;
import eu.europeana.set.client.web.SearchUserSetApi;
import eu.europeana.set.client.web.WebUserSetApi;
import eu.europeana.set.definitions.model.UserSet;

import java.util.List;

/**
* Implementation of client api
* @author GordeaS
Expand Down Expand Up @@ -61,8 +62,8 @@ public UserSet updateUserSet(String identifier, String set, String profile) thro
private class SearchUserSetClient implements SearchUserSetApi {

@Override
public ResultsPageImpl<? extends UserSet> searchUserSet(String query, String[] qf,
String sort, int page, int pageSize, String facet, int facetLimit, String profile) throws SetApiClientException{
public List<? extends UserSet> searchUserSet(String query, String[] qf,
String sort, int page, int pageSize, String facet, int facetLimit, String profile) throws SetApiClientException{
return getApiConnection().searchUserSet(query, qf, sort, page, pageSize, facet, facetLimit, profile);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,15 +151,15 @@ private UserSet parseSetApiResponse(CloseableHttpResponse response, List<Integer
* @return
* @throws SetApiClientException
*/
protected ResultsPageImpl<? extends UserSet> getSearchUserSetResponse(String url, String authorizationHeaderValue) throws SetApiClientException {
protected List<? extends UserSet> getSearchUserSetResponse(String url, String authorizationHeaderValue) throws SetApiClientException {
try {
LOGGER.trace("Call to UserSet API (SEARCH): {} ", url);
CloseableHttpResponse response = getHttpConnection().get(url, "application/json", authorizationHeaderValue);
String responseBody = EntityUtils.toString(response.getEntity());
if (response.getCode() == HttpStatus.SC_OK) {
TypeReference<ResultsPageImpl<BaseUserSet>> typeRef = new TypeReference<>() {
};
return mapper.readValue(responseBody, typeRef);
return mapper.readValue(responseBody, typeRef).getItems();
} else {
AbstractUserSetApiResponse errorResponse = mapper.readValue(responseBody, AbstractUserSetApiResponse.class);
if (LOGGER.isDebugEnabled()) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package eu.europeana.set.client.connection;

import java.io.IOException;
import java.util.List;

import eu.europeana.api.commons.definitions.search.result.impl.ResultsPageImpl;
import eu.europeana.set.client.exception.SetApiClientException;
import eu.europeana.set.definitions.model.UserSet;
import org.apache.commons.lang3.StringUtils;
Expand Down Expand Up @@ -103,9 +103,9 @@ public String deleteUserSet(String identifier) throws SetApiClientException {
* @return
* @throws IOException
*/
public ResultsPageImpl<? extends UserSet> searchUserSet(String query, String[] qf, String sort, int page,
int pageSize, String facet, int facetLimit,
String profile) throws SetApiClientException {
public List<? extends UserSet> searchUserSet(String query, String[] qf, String sort, int page,
int pageSize, String facet, int facetLimit,
String profile) throws SetApiClientException {

StringBuilder urlBuilder = getUserSetServiceUri().append(buildSearchUrl(query, qf, sort, page, pageSize, facet, facetLimit, profile));
return getSearchUserSetResponse(urlBuilder.toString(), regularUserAuthorizationValue);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package eu.europeana.set.client.web;

import eu.europeana.api.commons.definitions.search.result.impl.ResultsPageImpl;
import eu.europeana.set.client.exception.SetApiClientException;
import eu.europeana.set.definitions.model.UserSet;

import java.util.List;

/**
* Search Client API interface
* @author Srishti singh
Expand All @@ -23,6 +24,6 @@ public interface SearchUserSetApi {
* @param profile
* @return
*/
ResultsPageImpl<? extends UserSet> searchUserSet(String query, String[] qf, String sort, int page, int pageSize,
String facet, int facetLimit, String profile) throws SetApiClientException;
List<? extends UserSet> searchUserSet(String query, String[] qf, String sort, int page, int pageSize,
String facet, int facetLimit, String profile) throws SetApiClientException;
}

0 comments on commit b23ea1e

Please sign in to comment.