Skip to content

Commit

Permalink
move profile extraction closer to its use
Browse files Browse the repository at this point in the history
  • Loading branch information
GordeaS authored and GordeaS committed Jun 28, 2024
1 parent 0a1a26f commit 306133b
Showing 1 changed file with 12 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,7 @@ protected ResponseEntity<String> storeUserSet(String userSetJsonLdStr,

// 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 All @@ -119,6 +117,9 @@ protected ResponseEntity<String> storeUserSet(String userSetJsonLdStr,

UserSet storedUserSet = getUserSetService().storeUserSet(webUserSet, authentication);

// get profile for pagination urls and item Page
LdProfiles profile = getUserSetService().getProfileForPagination(profiles);

if (mustFetchItems(storedUserSet, profile)) {
int derefItems =
getDerefItemsCount(storedUserSet, UserSetConfigurationImpl.DEFAULT_ITEMS_PER_PAGE);
Expand Down Expand Up @@ -218,9 +219,7 @@ private ResponseEntity<String> getUserSet(String profileStr, String identifier,
try {
// 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
// if the Set is disabled respond with HTTP 410
Expand All @@ -231,6 +230,9 @@ private ResponseEntity<String> getUserSet(String profileStr, String identifier,
getUserSetService().verifyOwnerOrAdmin(userSet, authentication, false);
}

// get profile for pagination urls and item Page
LdProfiles profile = getUserSetService().getProfileForPagination(profiles);

if (mustFetchItems(userSet, profile)) {
// pageNr, if empty default value 0 is sent for fetching items
int page = (pageNr != null) ? pageNr : UserSetUtils.DEFAULT_PAGE;
Expand Down Expand Up @@ -297,9 +299,7 @@ protected ResponseEntity<String> updateUserSet(HttpServletRequest request, Authe
try {
// 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 All @@ -317,6 +317,9 @@ protected ResponseEntity<String> updateUserSet(HttpServletRequest request, Authe
// parse fields of the new user set to an object
UserSet newUserSet = getUserSetService().parseUserSetLd(userSetJsonLdStr);

// get profile for pagination urls and item Page
LdProfiles profile = getUserSetService().getProfileForPagination(profiles);

// Respond with HTTP 200
// update an existing user set. merge user sets - insert new fields in existing
// object
Expand Down

0 comments on commit 306133b

Please sign in to comment.