Skip to content

Commit

Permalink
profile parameter can be a comma separated string
Browse files Browse the repository at this point in the history
  • Loading branch information
SrdjanStevanetic committed Jun 11, 2024
1 parent a507767 commit dd497c2
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,15 @@ ItemIdsResultPage buildItemIdsResultsPage(String setId, List<String> itemIds, in
* @return profiled user set value
*/
void applyProfile(UserSet userSet, LdProfiles profile);

/**
* Gets the profile for pagination urls and item page. Basically gets the profile valid for
* collection page from the list of profiles passed during search request
*
* @param profiles
* @return
*/
LdProfiles getProfileForPagination(List<LdProfiles> profiles);

/**
* Return the List of entity sets with
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,10 @@ protected ResponseEntity<String> storeUserSet(String userSetJsonLdStr,
throws HttpException {
try {

LdProfiles profile = getProfile(profileStr, request);
// validate params - profile
List<LdProfiles> profiles = getProfiles(profileStr, request);
// get profile for pagination urls and item Page
LdProfiles profile = getUserSetService().getProfileForPagination(profiles);

// parse user set
UserSet webUserSet = getUserSetService().parseUserSetLd(userSetJsonLdStr);
Expand Down Expand Up @@ -213,7 +216,10 @@ private ResponseEntity<String> getUserSet(String profileStr, String identifier,
HttpServletRequest request, String sort, String sortOrder, Integer pageNr, int pageSize,
Authentication authentication) throws HttpException {
try {
LdProfiles profile = getProfile(profileStr, request);
// validate params - profile
List<LdProfiles> profiles = getProfiles(profileStr, request);
// get profile for pagination urls and item Page
LdProfiles profile = getUserSetService().getProfileForPagination(profiles);

// retrieve a Set based on its identifier - process query
// if the Set doesn’t exist, respond with HTTP 404
Expand Down Expand Up @@ -289,7 +295,10 @@ protected ResponseEntity<String> updateUserSet(HttpServletRequest request, Authe
String identifier, String userSetJsonLdStr, String profileStr) throws HttpException {

try {
LdProfiles profile = getProfile(profileStr, request);
// validate params - profile
List<LdProfiles> profiles = getProfiles(profileStr, request);
// get profile for pagination urls and item Page
LdProfiles profile = getUserSetService().getProfileForPagination(profiles);

// check if the Set exists, if not respond with HTTP 404
// retrieve an existing user set based on its identifier
Expand Down Expand Up @@ -407,8 +416,12 @@ protected ResponseEntity<String> publishUnpublishUserSet(String identifier,
UserSet updatedUserSet =
getUserSetService().publishUnpublishUserSet(identifier, issued, authentication, publish);

// validate params - profile
List<LdProfiles> profiles = getProfiles(profileStr, request);
// get profile for pagination urls and item Page
LdProfiles profile = getUserSetService().getProfileForPagination(profiles);

// serialize to JsonLd
LdProfiles profile = getProfile(profileStr, request);
String serializedUserSetJsonLdStr = serializeUserSet(profile, updatedUserSet);
String etag =
generateETag(updatedUserSet.getModified(), WebFields.FORMAT_JSONLD, getApiVersion());
Expand Down Expand Up @@ -470,7 +483,10 @@ protected ResponseEntity<String> insertItemIntoUserSet(HttpServletRequest reques
String position, String profileStr) throws HttpException {

try {
LdProfiles profile = getProfile(profileStr, request);
// validate params - profile
List<LdProfiles> profiles = getProfiles(profileStr, request);
// get profile for pagination urls and item Page
LdProfiles profile = getUserSetService().getProfileForPagination(profiles);

// check if the Set exists, if not respond with HTTP 404
// retrieve an existing user set based on its identifier
Expand Down Expand Up @@ -648,8 +664,11 @@ protected ResponseEntity<String> deleteItemFromUserSet(HttpServletRequest reques
String profileStr) throws HttpException {

try {
LdProfiles profile = getProfile(profileStr, request);

// validate params - profile
List<LdProfiles> profiles = getProfiles(profileStr, request);
// get profile for pagination urls and item Page
LdProfiles profile = getUserSetService().getProfileForPagination(profiles);

// check if the Set exists, if not respond with HTTP 404
// retrieve an existing user set based on its identifier
UserSet existingUserSet = getUserSetService().getUserSetById(identifier);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -462,13 +462,7 @@ private boolean isUri(String value) {
return value.startsWith("http://") || value.startsWith("https://");
}

/**
* Gets the profile for pagination urls and item page. Basically gets the profile valid for
* collection page from the list of profiles passed during search request
*
* @param profiles
* @return
*/
@Override
public LdProfiles getProfileForPagination(List<LdProfiles> profiles) {
LdProfiles profile = null;
for (LdProfiles ldProfile : profiles) {
Expand Down

0 comments on commit dd497c2

Please sign in to comment.