diff --git a/set-definitions/src/main/java/eu/europeana/set/definitions/model/utils/UserSetUtils.java b/set-definitions/src/main/java/eu/europeana/set/definitions/model/utils/UserSetUtils.java index b2831a12..4d981cef 100644 --- a/set-definitions/src/main/java/eu/europeana/set/definitions/model/utils/UserSetUtils.java +++ b/set-definitions/src/main/java/eu/europeana/set/definitions/model/utils/UserSetUtils.java @@ -167,5 +167,18 @@ public static String extractItemIdentifier(String dataEuropeanaUri, String item return StringUtils.substring(dataEuropeanaUri, itemDataEndpoint.length()); } } + + //returns -1 if invalid or not provided + public static int parseItemsPosition(String position) { + int positionFinal = -1; + if (StringUtils.isNotEmpty(position)) { + try { + positionFinal = Integer.parseInt(position); + } catch (RuntimeException e) { + return -1; + } + } + return positionFinal; + } } diff --git a/set-integration-testing/src/integration-test/java/eu/europeana/api/set/integration/web/EntityBestItemsSetIT.java b/set-integration-testing/src/integration-test/java/eu/europeana/api/set/integration/web/EntityBestItemsSetIT.java index 51585cb9..11601192 100644 --- a/set-integration-testing/src/integration-test/java/eu/europeana/api/set/integration/web/EntityBestItemsSetIT.java +++ b/set-integration-testing/src/integration-test/java/eu/europeana/api/set/integration/web/EntityBestItemsSetIT.java @@ -8,7 +8,10 @@ import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.put; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; +import java.util.ArrayList; +import java.util.List; import org.apache.commons.lang3.StringUtils; +import org.codehaus.jettison.json.JSONArray; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; @@ -453,6 +456,97 @@ void insertPinnedItems_EntityUserSets_withEditorUser() throws Exception { // getUserSetService().deleteUserSet(identifier); } + // test insert multiple items + @Test + void insertMultipleItems_EntityUserSets_withEditorUser() throws Exception { + WebUserSetImpl userSet = createTestUserSet(ENTITY_USER_SET_REGULAR, editorUserToken); + String identifier = userSet.getIdentifier(); + + List newItems=new ArrayList<>(); + String item1="http://data.europeana.eu/item/01/123_pinnedItem"; + String item2="/02/123_pinnedItem"; + JSONArray newItemsJson = new JSONArray(); + newItemsJson.put(item1); + newItemsJson.put(item2); + + String result = mockMvc + .perform( + put(BASE_URL + "{identifier}/items", identifier) + .content(newItemsJson.toString()) + .queryParam(WebUserSetFields.PATH_PARAM_POSITION, + WebUserSetModelFields.PINNED_POSITION) + .header(HttpHeaders.AUTHORIZATION, editor2UserToken) + .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE)) + .andExpect(status().is(HttpStatus.OK.value())) + .andReturn().getResponse() + .getContentAsString(); + + assertTrue(containsKeyOrValue(result, userSet.getId())); + + UserSet existingUserSet = getUserSetService().getUserSetById(userSet.getIdentifier()); + //check for the new items + assertEquals(0, existingUserSet.getItems().indexOf(item1)); + assertEquals(1, existingUserSet.getItems().indexOf(item2)); + assertEquals(2, existingUserSet.getPinned()); + assertEquals(4, existingUserSet.getItems().size()); + + // insert pinned items, some of which already exist (and can be pinned or not-pinned in the set) + newItems.clear(); + String item3="/03/123_pinnedItem"; + newItems.add(item2); + String item4Existing=existingUserSet.getItems().get(2); + newItems.add(item4Existing); + newItems.add(item3); + getUserSetService().insertMultipleItems(newItems, WebUserSetModelFields.PINNED_POSITION, -1, existingUserSet); + //check the new items + assertEquals(0, existingUserSet.getItems().indexOf(item2)); + assertEquals(1, existingUserSet.getItems().indexOf(item4Existing)); + assertEquals(2, existingUserSet.getItems().indexOf(item3)); + assertEquals(3, existingUserSet.getItems().indexOf(item1)); + assertEquals(4, existingUserSet.getPinned()); + assertEquals(5, existingUserSet.getItems().size()); + + //insert un-pinned items, some of which may exist (and can be pinned or not-pinned in the set) + newItems.clear(); + //adding an existing pinned item in the request of un-pinned items + newItems.add(item1); + String item5="/05/123_unPinnedItem"; + newItems.add(item5); + String item6Existing=existingUserSet.getItems().get(4); + newItems.add(item6Existing); + getUserSetService().insertMultipleItems(newItems, "4", 4, existingUserSet); + //check the new items + assertEquals(0, existingUserSet.getItems().indexOf(item2)); + assertEquals(1, existingUserSet.getItems().indexOf(item4Existing)); + assertEquals(2, existingUserSet.getItems().indexOf(item3)); + assertEquals(3, existingUserSet.getItems().indexOf(item1)); + assertEquals(4, existingUserSet.getPinned()); + assertEquals(4, existingUserSet.getItems().indexOf(item5)); + assertEquals(5, existingUserSet.getItems().indexOf(item6Existing)); + assertEquals(4, existingUserSet.getPinned()); + assertEquals(6, existingUserSet.getItems().size()); + + //insert item to the last position + newItems.clear(); + String item7="/07/123_unPinnedItem"; + newItems.add(item7); + getUserSetService().insertMultipleItems(newItems, null, -1, existingUserSet); + //check the new items + assertEquals(6, existingUserSet.getItems().indexOf(item7)); + assertEquals(4, existingUserSet.getPinned()); + assertEquals(7, existingUserSet.getItems().size()); + //insert item to the position grater than the total size of items + newItems.clear(); + String item8="/08/123_unPinnedItem"; + newItems.add(item8); + getUserSetService().insertMultipleItems(newItems, "100", 100, existingUserSet); + //check the new items + assertEquals(7, existingUserSet.getItems().indexOf(item8)); + assertEquals(4, existingUserSet.getPinned()); + assertEquals(8, existingUserSet.getItems().size()); + + } + // test conversion of pinned -> normal item @Test void insertAlreadyExistingPinnedItemAsNormalItem_EntityUserSets_withEditorUser() diff --git a/set-web/src/main/java/eu/europeana/set/web/config/UserSetI18nConstants.java b/set-web/src/main/java/eu/europeana/set/web/config/UserSetI18nConstants.java index adf41d19..4cae4336 100644 --- a/set-web/src/main/java/eu/europeana/set/web/config/UserSetI18nConstants.java +++ b/set-web/src/main/java/eu/europeana/set/web/config/UserSetI18nConstants.java @@ -18,6 +18,7 @@ private UserSetI18nConstants() { public static final String INVALID_HEADER_FORMAT = "error.userset_invalid_header_format"; public static final String INVALID_HEADER_VALUE = "error.userset_invalid_header_value"; public static final String INVALID_SUBJECT_VALUE = "error.userset_subject_invalid_value"; + public static final String INVALID_UNPINNED_ITEMS_POSITION = "error.userset_unpinned_items_position_invalid"; public static final String USERSET_VALIDATION = "error.userset_validation"; public static final String USERSET_DUPLICATION = "error.userset_duplication"; diff --git a/set-web/src/main/java/eu/europeana/set/web/http/SwaggerConstants.java b/set-web/src/main/java/eu/europeana/set/web/http/SwaggerConstants.java index 4f1770a7..46380dc8 100644 --- a/set-web/src/main/java/eu/europeana/set/web/http/SwaggerConstants.java +++ b/set-web/src/main/java/eu/europeana/set/web/http/SwaggerConstants.java @@ -12,6 +12,7 @@ private SwaggerConstants() { public static final String SAMPLES_JSONLD = "Please find JSON-LD samples for user set in templates. "; public static final String SEARCH_HELP_NOTE = "Identifier is a number."; public static final String INSERT_ITEM_NOTE = "Please create your insert item request using selected parameters."; + public static final String INSERT_MULTIPLE_ITEM_NOTE = "Please create your insert multiple items request using selected parameters."; public static final String PUBLISH_SET_NOTE = "Please create the request for publishing the set using the provided parameters."; public static final String CHECK_ITEM_NOTE = "Check if item is already in a user set"; public static final String DELETE_ITEM_NOTE = "Delete a item from the set "; diff --git a/set-web/src/main/java/eu/europeana/set/web/service/UserSetService.java b/set-web/src/main/java/eu/europeana/set/web/service/UserSetService.java index 211f0ef9..3e347440 100644 --- a/set-web/src/main/java/eu/europeana/set/web/service/UserSetService.java +++ b/set-web/src/main/java/eu/europeana/set/web/service/UserSetService.java @@ -10,6 +10,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.set.definitions.config.UserSetConfiguration; import eu.europeana.set.definitions.model.UserSet; import eu.europeana.set.definitions.model.search.UserSetFacetQuery; import eu.europeana.set.definitions.model.search.UserSetQuery; @@ -131,13 +132,16 @@ UserSet fetchItems(UserSet storedUserSet, String sort, String sortOrder, int pag UserSet insertItem(String datasetId, String localId, String position, UserSet existingUserSet) throws ApplicationAuthenticationException, ItemValidationException; + public UserSet insertMultipleItems(List items, String position, int itemsPosition, UserSet existingUserSet) + throws ItemValidationException; + /** * This method updates existing item list * * @param existingUserSet * @return updated user set */ - UserSet updateItemList(UserSet existingUserSet); + UserSet updateUserSetInMongo(UserSet existingUserSet); /** * search user sets using the given query and profile @@ -257,4 +261,6 @@ ItemIdsResultPage buildItemIdsResultsPage(String setId, List itemIds, in void validateGallerySize(UserSet webUserSet, int newItems) throws ItemValidationException; + UserSet updatePagination(UserSet userSet, UserSetConfiguration config); + } \ No newline at end of file diff --git a/set-web/src/main/java/eu/europeana/set/web/service/controller/jsonld/WebUserSetRest.java b/set-web/src/main/java/eu/europeana/set/web/service/controller/jsonld/WebUserSetRest.java index b32ea3c9..a34ad74e 100644 --- a/set-web/src/main/java/eu/europeana/set/web/service/controller/jsonld/WebUserSetRest.java +++ b/set-web/src/main/java/eu/europeana/set/web/service/controller/jsonld/WebUserSetRest.java @@ -415,6 +415,7 @@ protected ResponseEntity publishUnpublishUserSet(String identifier, Auth } } + @Deprecated @PutMapping(value = {"/set/{identifier}/{datasetId}/{localId}"}, produces = {HttpHeaders.CONTENT_TYPE_JSONLD_UTF8, HttpHeaders.CONTENT_TYPE_JSON_UTF8}) @Operation(description = SwaggerConstants.INSERT_ITEM_NOTE, @@ -433,6 +434,21 @@ public ResponseEntity insertItemIntoUserSet( return insertItemIntoUserSet(request, authentication, identifier, datasetId, localId, position); } + @PutMapping(value = {"/set/{identifier}/items"}, + produces = {HttpHeaders.CONTENT_TYPE_JSONLD_UTF8, HttpHeaders.CONTENT_TYPE_JSON_UTF8}) + @Operation(description = SwaggerConstants.INSERT_MULTIPLE_ITEM_NOTE, + summary = "Insert multiple items to an existing user set") + public ResponseEntity insertMultipleItemsIntoUserSet( + @PathVariable(value = WebUserSetFields.PATH_PARAM_SET_ID) String identifier, + @RequestParam(value = WebUserSetFields.PATH_PARAM_POSITION, required = false) String position, + @RequestBody List items, + HttpServletRequest request) throws HttpException { + // check user credentials, if invalid respond with HTTP 401, + // or if unauthorized respond with HTTP 403 + Authentication authentication = verifyWriteAccess(Operations.UPDATE, request); + return insertMultipleItemsIntoUserSet(request, authentication, identifier, items, position); + } + /** * This method validates input values, retrieves user set object and inserts item within user set * to given position or at the end if no valid position provided. @@ -443,10 +459,10 @@ public ResponseEntity insertItemIntoUserSet( * @param datasetId The identifier of the dataset, typically a number * @param localId The local identifier within the provider * @param position The position in the existin item list - * @param profileStr The profile definition * @return response entity that comprises response body, headers and status code * @throws HttpException */ + @Deprecated protected ResponseEntity insertItemIntoUserSet(HttpServletRequest request, Authentication authentication, String identifier, String datasetId, String localId, String position) throws HttpException { @@ -482,6 +498,83 @@ protected ResponseEntity insertItemIntoUserSet(HttpServletRequest reques UserSet updatedUserSet = getUserSetService().insertItem(datasetId, localId, position, existingUserSet); + getUserSetService().updatePagination(updatedUserSet, getConfiguration()); + + String serializedUserSetJsonLdStr = serializeUserSet(LdProfiles.MINIMAL, updatedUserSet); + + String etag = + generateETag(updatedUserSet.getModified(), WebFields.FORMAT_JSONLD, getApiVersion()); + + // build response entity with headers + MultiValueMap headers = new LinkedMultiValueMap<>(); + headers.add(HttpHeaders.ALLOW, UserSetHttpHeaders.ALLOW_PPGHD); + headers.add(UserSetHttpHeaders.VARY, HttpHeaders.PREFER); + headers.add(UserSetHttpHeaders.PREFERENCE_APPLIED, LdProfiles.MINIMAL.getPreferHeaderValue()); + headers.add(UserSetHttpHeaders.ETAG, etag); + return new ResponseEntity<>(serializedUserSetJsonLdStr, headers, HttpStatus.OK); + + } catch (UserSetValidationException e) { + throw new RequestValidationException(UserSetI18nConstants.USERSET_VALIDATION, + new String[] {e.getMessage()}, e); + } catch (HttpException e) { + throw e; + } catch (RuntimeException | IOException e) { + throw new InternalServerException(e); + } + } + + /** + * This method validates input values, retrieves user set object and inserts multiple items + * within user set to the given position or at the end if no valid position provided. + * + * @param request + * @param authentication The Authentication object + * @param identifier The identifier of a user set + * @param items Items to be added to the set + * @param position The position in the existin item list + * @return response entity that comprises response body, headers and status code + * @throws HttpException + */ + protected ResponseEntity insertMultipleItemsIntoUserSet(HttpServletRequest request, + Authentication authentication, String identifier, List items, String position) throws HttpException { + try { + // 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); + + if (existingUserSet.isOpenSet()) { + // cannot add items to open sets + throw new RequestValidationException(UserSetI18nConstants.USER_SET_OPERATION_NOT_ALLOWED, + new String[] {"'Insert item to existing user set'", "open"}); + } + + // if set is not entity best item set and position is "pin", throw exception + if (!existingUserSet.isEntityBestItemsSet() + && StringUtils.equals(position, WebUserSetFields.PINNED_POSITION)) { + throw new RequestValidationException(UserSetI18nConstants.USER_SET_OPERATION_NOT_ALLOWED, + new String[] {"Pinning item ", existingUserSet.getType()}); + } + + int itemsPosition=UserSetUtils.parseItemsPosition(position); + if(!StringUtils.equals(position, WebUserSetFields.PINNED) && itemsPosition>=0 && itemsPosition < existingUserSet.getPinned()) { + throw new RequestValidationException(UserSetI18nConstants.INVALID_UNPINNED_ITEMS_POSITION, null); + } + + // check visibility level for given user + getUserSetService().verifyPermissionToUpdate(existingUserSet, authentication, true); + + // for entity user sets, add users with 'editor' role as contributors + addContributorForEntitySet(existingUserSet, authentication); + + // check timestamp if provided within the “If-Match” HTTP header, if false + // respond with HTTP 412 + String eTagOrigin = + generateETag(existingUserSet.getModified(), WebFields.FORMAT_JSONLD, getApiVersion()); + checkIfMatchHeader(eTagOrigin, request); + + UserSet updatedUserSet = + getUserSetService().insertMultipleItems(items, position, itemsPosition, existingUserSet); + getUserSetService().updatePagination(updatedUserSet, getConfiguration()); String serializedUserSetJsonLdStr = serializeUserSet(LdProfiles.MINIMAL, updatedUserSet); @@ -661,7 +754,9 @@ protected ResponseEntity deleteItemFromUserSet(Authentication authentica existingUserSet.getItems().remove(newItem); // update an existing user set - UserSet updatedUserSet = getUserSetService().updateItemList(existingUserSet); + UserSet updatedUserSet = getUserSetService().updateUserSetInMongo(existingUserSet); + //update pagination fields (used only for the response serialization) + getUserSetService().updatePagination(updatedUserSet, getConfiguration()); // serialize to JsonLd String serializedUserSetJsonLdStr = serializeUserSet(LdProfiles.MINIMAL, updatedUserSet); diff --git a/set-web/src/main/java/eu/europeana/set/web/service/impl/BaseUserSetServiceImpl.java b/set-web/src/main/java/eu/europeana/set/web/service/impl/BaseUserSetServiceImpl.java index 3076507f..060b5d6f 100644 --- a/set-web/src/main/java/eu/europeana/set/web/service/impl/BaseUserSetServiceImpl.java +++ b/set-web/src/main/java/eu/europeana/set/web/service/impl/BaseUserSetServiceImpl.java @@ -62,6 +62,13 @@ public abstract class BaseUserSetServiceImpl implements UserSetService { private SearchApiClient setApiService = new SearchApiClientImpl(); Logger logger = LogManager.getLogger(getClass()); + + + //update the pagination fields of the set (used only for the serialization to the output) + @Override + public UserSet updatePagination(UserSet userSet, UserSetConfiguration config) { + return userSetUtils.updatePagination(userSet, config); + } protected PersistentUserSetService getMongoPersistence() { return mongoPersistance; @@ -501,6 +508,8 @@ private void validateAndSetItems(UserSet storedUserSet, UserSet userSetUpdates) } } + //this method is to be deprecated when the new items insert is used + @Deprecated protected void validateItems(List items) throws ItemValidationException { if(items==null || items.isEmpty()) { return; @@ -518,7 +527,35 @@ protected void validateItems(List items) throws ItemValidationException throw new ItemValidationException(UserSetI18nConstants.USERSET_ITEM_INVALID_FORMAT, new String[] {invalidItems.toString()} ); } } - + + //items can be either a uri or a record identifier (e.g. "/1234/XPTO_2") + protected void validateItemsStrings(List items) throws ItemValidationException { + if(items==null || items.isEmpty()) { + return; + } + List invalidItems = new ArrayList<>(); + for(String item : items) { + try { + if(item.startsWith(getConfiguration().getItemDataEndpoint())) { + String itemWithoutBase = item.replace(getConfiguration().getItemDataEndpoint(), ""); + if(!itemWithoutBase.startsWith("/")) { + itemWithoutBase = "/" + itemWithoutBase; + } + validateItemPartial(itemWithoutBase); + } + else { + validateItemPartial(item); + } + } + catch (ItemValidationException ex) { + invalidItems.add(item); + } + } + if(invalidItems.size()>0) { + throw new ItemValidationException(UserSetI18nConstants.USERSET_ITEM_INVALID_FORMAT, new String[] {invalidItems.toString()} ); + } + } + protected void validateItemWhole(String item) throws ItemValidationException { if(!item.startsWith(getConfiguration().getItemDataEndpoint())) { throw new ItemValidationException(UserSetI18nConstants.USERSET_ITEM_INVALID_FORMAT, new String[] {item}); diff --git a/set-web/src/main/java/eu/europeana/set/web/service/impl/UserSetServiceImpl.java b/set-web/src/main/java/eu/europeana/set/web/service/impl/UserSetServiceImpl.java index 3e6c9314..fffb7b3f 100644 --- a/set-web/src/main/java/eu/europeana/set/web/service/impl/UserSetServiceImpl.java +++ b/set-web/src/main/java/eu/europeana/set/web/service/impl/UserSetServiceImpl.java @@ -26,7 +26,6 @@ import eu.europeana.api.commons.web.exception.HttpException; import eu.europeana.api.commons.web.exception.InternalServerException; import eu.europeana.api.commons.web.exception.ParamValidationException; -import eu.europeana.set.definitions.config.UserSetConfigurationImpl; import eu.europeana.set.definitions.exception.UserSetAttributeInstantiationException; import eu.europeana.set.definitions.exception.UserSetInstantiationException; import eu.europeana.set.definitions.model.UserSet; @@ -227,6 +226,92 @@ int validatePosition(String position, List items, int pinnedItems) { } return positionInt; } + + int calculatePosition(int position, List items) { + int positionFinal = items.size(); + if (position >= 0 && position < items.size()) { + positionFinal = position; + } + return positionFinal; + } + + public UserSet insertMultipleItems(List items, String position, int itemsPosition, UserSet existingUserSet) + throws ItemValidationException { + + validateItemsStrings(items); + + // check if the position is "pin" and is a EntityBestItem set then + // insert the item at the 0 position + UserSet userSet; + + if (WebUserSetModelFields.PINNED_POSITION.equals(position)) { + userSet=updateItemsFromPinned(existingUserSet, items); + } else { + userSet=updateItemsFromUnpinned(existingUserSet, items, itemsPosition); + } + + return userSet; + } + + private UserSet updateItemsFromPinned(UserSet existingUserSet, List items) { + List usersetItems=existingUserSet.getItems(); + if(usersetItems==null) { + usersetItems=new ArrayList<>(); + } + else { + /*remove all duplicate items from the set and count the number + of removed pinned items, to change the pinned field + */ + for(String newItem : items) { + int itemindex=usersetItems.indexOf(newItem); + if(itemindex>=0) { + if(itemindex < existingUserSet.getPinned()) { + existingUserSet.setPinned(existingUserSet.getPinned() - 1); + } + usersetItems.remove(newItem); + } + } + } + + usersetItems.addAll(0, items); + existingUserSet.setPinned(existingUserSet.getPinned() + items.size()); + UserSet updatedSet=updateUserSetInMongo(existingUserSet); + return updatedSet; + } + + private UserSet updateItemsFromUnpinned(UserSet existingUserSet, List items, int position) throws ItemValidationException { + List usersetItems=existingUserSet.getItems(); + List newItemsCopy=new ArrayList<>(items); + if(usersetItems==null) { + usersetItems=new ArrayList<>(); + } + else { + /*remove from the new items the ones that were pinned before + *and from the user set the ones that are duplicates + */ + for(String newItem : newItemsCopy) { + int itemindex=usersetItems.indexOf(newItem); + if(itemindex>=0) { + if(itemindex < existingUserSet.getPinned()) { + items.remove(newItem); + } + else { + usersetItems.remove(newItem); + } + } + } + //validation of the number of items for type Gallery + if(existingUserSet.isGallery() && (usersetItems.size() + items.size()) > getConfiguration().getGalleryMaxSize()) { + throw new ItemValidationException(UserSetI18nConstants.USERSET_ITEMS_LIMIT_REACHED, + new String[] {String.valueOf(getConfiguration().getGalleryMaxSize())} ); + } + } + + int positionFinal=calculatePosition(position, usersetItems); + usersetItems.addAll(positionFinal, items); + UserSet updatedSet=updateUserSetInMongo(existingUserSet); + return updatedSet; + } /* * (non-Javadoc) @@ -261,7 +346,7 @@ public UserSet insertItem(String datasetId, String localId, String position, validatePosition(position, existingUserSet.getItems(), existingUserSet.getPinned()); userSet = insertItem(existingUserSet, newItem, positionInt, false); } - getUserSetUtils().updatePagination(userSet, getConfiguration()); + //getUserSetUtils().updatePagination(userSet, getConfiguration()); return userSet; } @@ -291,7 +376,7 @@ private UserSet insertItem(UserSet existingUserSet, String newItem, int position // add item && create item list if needed addNewItemToList(existingUserSet, finalPosition, newItem); updatePinCount(existingUserSet, pinnedItem, -1); - extUserSet = updateItemList(existingUserSet); + extUserSet = updateUserSetInMongo(existingUserSet); } else { // replace item int oldPosition = existingUserSet.getItems().indexOf(newItem); @@ -302,7 +387,7 @@ private UserSet insertItem(UserSet existingUserSet, String newItem, int position } else { replaceItem(existingUserSet, finalPosition, newItem); updatePinCount(existingUserSet, pinnedItem, oldPosition); - extUserSet = updateItemList(existingUserSet); + extUserSet = updateUserSetInMongo(existingUserSet); } } @@ -340,7 +425,7 @@ private void updatePinCount(UserSet existingUserSet, boolean pinnedItem, int old * @see eu.europeana.set.web.service.UserSetService#updateItemList(eu.europeana.set. * definitions.model.UserSet) */ - public UserSet updateItemList(UserSet existingUserSet) { + public UserSet updateUserSetInMongo(UserSet existingUserSet) { // update total updateTotal(existingUserSet); // generate and add a created and modified timestamp to the Set @@ -350,7 +435,7 @@ public UserSet updateItemList(UserSet existingUserSet) { // update an existing user set. merge user sets - insert new fields in existing // object UserSet updatedUserSet = getMongoPersistence().update((PersistentUserSet) existingUserSet); - getUserSetUtils().updatePagination(updatedUserSet, getConfiguration()); + //getUserSetUtils().updatePagination(updatedUserSet, getConfiguration()); return updatedUserSet; } diff --git a/set-web/src/main/resources/messages_en.properties b/set-web/src/main/resources/messages_en.properties index 6511af35..6cdccfa7 100644 --- a/set-web/src/main/resources/messages_en.properties +++ b/set-web/src/main/resources/messages_en.properties @@ -50,6 +50,7 @@ error.no_entity_userset_found=No entity user set found in database. error.no_elevation_generated=There are no items present in the entity user sets OR entity references are invalid. error.userset_validation_search_request_not_valid=Error serialising the search API request body. error.userset_lock_not_in_effect=No write lock in effect! +error.userset_unpinned_items_position_invalid=Position value for inserting un-pinned items should come after the pinned items. #500 error.server_unexpected_error=An unexpected error occurred on server!