Skip to content

Commit

Permalink
Align item endpoint with items endpoint
Browse files Browse the repository at this point in the history
Add option to skip members, e.g. if the goal of the request to just get the metadata of a group item

Signed-off-by: spacemanspiff2007 <[email protected]>
  • Loading branch information
spacemanspiff2007 authored and spacemanspiff2007 committed Oct 30, 2021
1 parent 9d9dc70 commit 17daddd
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ public Response getItems(final @Context UriInfo uriInfo, final @Context HttpHead
public Response getItemData(final @Context UriInfo uriInfo, final @Context HttpHeaders httpHeaders,
@HeaderParam(HttpHeaders.ACCEPT_LANGUAGE) @Parameter(description = "language") @Nullable String language,
@QueryParam("metadata") @Parameter(description = "metadata selector") @Nullable String namespaceSelector,
@DefaultValue("true") @QueryParam("recursive") @Parameter(description = "get member items if the item is a group item") boolean recursive,
@PathParam("itemname") @Parameter(description = "item name") String itemname) {
final Locale locale = localeService.getLocale(language);
final Set<String> namespaces = splitAndFilterNamespaces(namespaceSelector, locale);
Expand All @@ -238,7 +239,8 @@ public Response getItemData(final @Context UriInfo uriInfo, final @Context HttpH

// if it exists
if (item != null) {
EnrichedItemDTO dto = EnrichedItemDTOMapper.map(item, true, null, uriBuilder(uriInfo, httpHeaders), locale);
EnrichedItemDTO dto = EnrichedItemDTOMapper.map(item, recursive, null, uriBuilder(uriInfo, httpHeaders),
locale);
addMetadata(dto, namespaces, null);
dto.editable = isEditable(dto.name);
return JSONResponse.createResponse(Status.OK, dto, null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ public void shouldReturnUnicodeItems() throws IOException, TransformationExcepti
public void shouldReturnUnicodeItem() throws IOException, TransformationException {
item4.setLabel(ITEM_LABEL4);

Response response = itemResource.getItemData(uriInfo, httpHeaders, null, null, ITEM_NAME4);
Response response = itemResource.getItemData(uriInfo, httpHeaders, null, null, true, ITEM_NAME4);
assertThat(readItemLabelsFromResponse(response), hasItems(ITEM_LABEL4));
}

Expand Down

0 comments on commit 17daddd

Please sign in to comment.