Skip to content

Commit

Permalink
fix: get content type (always jsonld), profile can be space separated,
Browse files Browse the repository at this point in the history
gallery conversion to collection
  • Loading branch information
SrdjanStevanetic committed Sep 23, 2024
1 parent ed57a73 commit 695c4fa
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 8 deletions.
3 changes: 2 additions & 1 deletion set-common/src/main/resources/set.user.properties.template
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ europeana.apikey.jwttoken.siganturekey=
#europeana.search.apikey=

#API key used for invocation of search api
#europeana.search.url=https://api.europeana.eu/api/v2/search.json?wskey=MY_KEY&query=
#europeana.search.url=https://api.europeana.eu/record/v2/search.json?wskey=MY_KEY&query=


# location for the elevation file
elevation.file.folder=
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ public class WebUserSetFields extends WebUserSetModelFields {
public static final String SLASH = "/";
public static final String PAR_CHAR = "?";
public static final String AND = "&";
public static final String COMMA = ",";
public static final String COMMA = ",";
public static final String SPACE = " ";
public static final String EQUALS_PARAMETER = "=";
public static final String JSON_LD_REST = ".jsonld";
public static final String FORMAT_JSONLD = "jsonld";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -858,8 +858,9 @@ public void searchFacetsMultipleValidProfileWithFacets_Debug() throws Exception

@Test
public void searchFacetsMultipleValidProfileWithFacetsDebug() throws Exception {
//profiles can also be space separated
String profile =
LdProfiles.DEBUG.name() + "," + LdProfiles.FACETS.name() + "," + LdProfiles.MINIMAL.name();
LdProfiles.DEBUG.name() + " " + LdProfiles.FACETS.name() + " " + LdProfiles.MINIMAL.name();
mockMvc
.perform(get(SEARCH_URL).param(CommonApiConstants.QUERY_PARAM_PROFILE, profile)
.queryParam(CommonApiConstants.PARAM_WSKEY, API_KEY)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ public void getUserSet_Success() throws Exception {
.header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE))
.andReturn().getResponse();

assertEquals(response.getHeader(HttpHeaders.CONTENT_TYPE), eu.europeana.api.commons.web.http.HttpHeaders.CONTENT_TYPE_JSONLD_UTF8);
String result = response.getContentAsString();
assertNotNull(result);
assertEquals(HttpStatus.OK.value(), response.getStatus());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import eu.europeana.api.commons.web.exception.ApplicationAuthenticationException;
import eu.europeana.api.commons.web.exception.HttpException;
import eu.europeana.api.commons.web.exception.ParamValidationException;
import eu.europeana.api.commons.web.http.HttpHeaders;
import eu.europeana.api.commons.web.model.vocabulary.Operations;
import eu.europeana.set.definitions.config.UserSetConfiguration;
import eu.europeana.set.definitions.exception.UserSetProfileValidationException;
Expand Down Expand Up @@ -131,11 +132,21 @@ public List<LdProfiles> getProfiles(String profileStr, HttpServletRequest reques
ldProfiles.add(headerProfile);
}

//multiple profiles can be present seperated by comma
//multiple profiles can be present seperated by comma or space
if (StringUtils.isNotEmpty(profileStr)) {
if(profileStr.contains(WebUserSetFields.COMMA)) {
for(String profile : Arrays.asList(StringUtils.split(profileStr, WebUserSetFields.COMMA))) {
ldProfiles.add(getProfileFromParam(profile));
}
}
else if(profileStr.contains(WebUserSetFields.SPACE)) {
for(String profile : Arrays.asList(StringUtils.split(profileStr, WebUserSetFields.SPACE))) {
ldProfiles.add(getProfileFromParam(profile));
}
}
else {
ldProfiles.add(getProfileFromParam(profileStr));
}
}

validateMultipleProfiles(ldProfiles, profileStr);
Expand Down Expand Up @@ -290,7 +301,8 @@ protected ResponseEntity<String> buildGetResponse(UserSet userSet, LdProfiles pr
String etag = generateETag(userSet.getModified(), WebFields.FORMAT_JSONLD, getApiVersion());

// build response
MultiValueMap<String, String> headers = new LinkedMultiValueMap<>(5);
MultiValueMap<String, String> headers = new LinkedMultiValueMap<>(7);
headers.add(HttpHeaders.CONTENT_TYPE, HttpHeaders.CONTENT_TYPE_JSONLD_UTF8);
headers.add(LINK, UserSetHttpHeaders.VALUE_BASIC_CONTAINER);
headers.add(LINK, UserSetHttpHeaders.VALUE_BASIC_RESOURCE);
headers.add(ALLOW, UserSetHttpHeaders.ALLOW_GPD);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,7 @@ void mergeDescriptiveProperties(PersistentUserSet persistedSet, UserSet updates)
persistedSet.setType(updates.getType());
}

if (updates.getCollectionType() != null) {
persistedSet.setCollectionType(updates.getCollectionType());
}
persistedSet.setCollectionType(updates.getCollectionType());

if (updates.getVisibility() != null) {
persistedSet.setVisibility(updates.getVisibility());
Expand Down

0 comments on commit 695c4fa

Please sign in to comment.