mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-18 07:23:08 +00:00
Merge pull request #2911 from atmire/issue-2800-workflowgroup-collection-links
[Issue 2800] workflowgroup collection links
This commit is contained in:
@@ -47,9 +47,9 @@ public class CollectionResourceWorkflowGroupHalLinkFactory
|
|||||||
Map<String, Role> roles = WorkflowUtils.getCollectionRoles(collection);
|
Map<String, Role> roles = WorkflowUtils.getCollectionRoles(collection);
|
||||||
UUID resourceUuid = UUID.fromString(halResource.getContent().getUuid());
|
UUID resourceUuid = UUID.fromString(halResource.getContent().getUuid());
|
||||||
for (Map.Entry<String, Role> entry : roles.entrySet()) {
|
for (Map.Entry<String, Role> entry : roles.entrySet()) {
|
||||||
list.add(buildLink("workflowGroups/" + entry.getKey(), getMethodOn()
|
list.add(buildLink("workflowGroups", getMethodOn()
|
||||||
.getWorkflowGroupForRole(resourceUuid, null, null,
|
.getWorkflowGroupForRole(resourceUuid, null, null,
|
||||||
entry.getKey())));
|
entry.getKey())).withName(entry.getKey()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -8,11 +8,13 @@
|
|||||||
package org.dspace.app.rest.model.hateoas;
|
package org.dspace.app.rest.model.hateoas;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
import com.fasterxml.jackson.annotation.JsonUnwrapped;
|
import com.fasterxml.jackson.annotation.JsonUnwrapped;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.hateoas.EntityModel;
|
import org.springframework.hateoas.EntityModel;
|
||||||
import org.springframework.hateoas.Link;
|
import org.springframework.hateoas.Link;
|
||||||
|
|
||||||
@@ -49,6 +51,15 @@ public abstract class HALResource<T> extends EntityModel<T> {
|
|||||||
public EntityModel<T> add(Link link) {
|
public EntityModel<T> add(Link link) {
|
||||||
if (!hasLink(link.getRel())) {
|
if (!hasLink(link.getRel())) {
|
||||||
return super.add(link);
|
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;
|
return this;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user