mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-07 01:54:22 +00:00
[Task 72222] fixed a bug with the links after the implementation of the array dynamic workflowgroup links
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -44,4 +46,26 @@ public abstract class HALResource<T> extends EntityModel<T> {
|
||||
public void setPageHeader(EmbeddedPageHeader page) {
|
||||
this.pageHeader = page;
|
||||
}
|
||||
|
||||
@Override
|
||||
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());
|
||||
boolean doesNameExist = false;
|
||||
for (Link existingLink : list) {
|
||||
if (StringUtils.equalsIgnoreCase(existingLink.getName(), link.getName())) {
|
||||
doesNameExist = true;
|
||||
}
|
||||
}
|
||||
if (!doesNameExist) {
|
||||
super.add(link);
|
||||
}
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user