Skip to content

Commit

Permalink
Merge branch 'main' into rest-demo
Browse files Browse the repository at this point in the history
  • Loading branch information
tdonohue committed Aug 7, 2020
2 parents 9397271 + d1ee942 commit 278b813
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
Expand Up @@ -47,9 +47,9 @@ protected void addLinks(CollectionResource halResource, Pageable pageable, Linke
Map<String, Role> roles = WorkflowUtils.getCollectionRoles(collection);
UUID resourceUuid = UUID.fromString(halResource.getContent().getUuid());
for (Map.Entry<String, Role> entry : roles.entrySet()) {
list.add(buildLink("workflowGroups/" + entry.getKey(), getMethodOn()
list.add(buildLink("workflowGroups", getMethodOn()
.getWorkflowGroupForRole(resourceUuid, null, null,
entry.getKey())));
entry.getKey())).withName(entry.getKey()));
}
}

Expand Down
Expand Up @@ -8,11 +8,13 @@
package org.dspace.app.rest.model.hateoas;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonUnwrapped;
import org.apache.commons.lang3.StringUtils;
import org.springframework.hateoas.EntityModel;
import org.springframework.hateoas.Link;

Expand Down Expand Up @@ -49,6 +51,15 @@ public void setPageHeader(EmbeddedPageHeader page) {
public EntityModel<T> add(Link link) {
if (!hasLink(link.getRel())) {
return super.add(link);
} else {
String name = link.getName();
if (StringUtils.isNotBlank(name)) {
List<Link> list = this.getLinks(link.getRel());
// If a link of this name doesn't already exist in the list, add it
if (!list.stream().anyMatch((l -> StringUtils.equalsIgnoreCase(l.getName(), name)))) {
super.add(link);
}
}
}
return this;
}
Expand Down

0 comments on commit 278b813

Please sign in to comment.