diff --git a/dspace-server-webapp/src/main/java/org/dspace/app/rest/repository/LinkRestRepository.java b/dspace-server-webapp/src/main/java/org/dspace/app/rest/repository/LinkRestRepository.java index ce47f9da55..53cb8d1896 100644 --- a/dspace-server-webapp/src/main/java/org/dspace/app/rest/repository/LinkRestRepository.java +++ b/dspace-server-webapp/src/main/java/org/dspace/app/rest/repository/LinkRestRepository.java @@ -16,6 +16,13 @@ public interface LinkRestRepository { default boolean isEmbeddableRelation(Object data, String name) { return true; } + + /** + * Defines whether a relation can create a link to it on the resource or not + * @param data The data for the link + * @param name The name of the link + * @return A boolean indicating whether it's allowed or not + */ default boolean isLinkableRelation(Object data, String name) { return true; } diff --git a/dspace-server-webapp/src/main/java/org/dspace/app/rest/utils/Utils.java b/dspace-server-webapp/src/main/java/org/dspace/app/rest/utils/Utils.java index 6af8df9908..fe3a02fd0d 100644 --- a/dspace-server-webapp/src/main/java/org/dspace/app/rest/utils/Utils.java +++ b/dspace-server-webapp/src/main/java/org/dspace/app/rest/utils/Utils.java @@ -537,11 +537,23 @@ public class Utils { }); } + /** + * Calls on the LinkRepository to ask whether it's allowed to embed said relation + * @param resource The current HalResource + * @param rel The relation to be asked if it can be embedded + * @return A boolean indicating the result + */ private boolean allowEmbeddingFromLinkRepository(HALResource resource, String rel) { return getLinkResourceRepository(resource.getContent().getCategory(), resource.getContent().getType(), rel).isEmbeddableRelation(resource.getContent(), rel); } + /** + * Calls on the LinkRepository to ask whether it's allowed to link to said relation + * @param resource The current HalResource + * @param rel The relation to be asked if it can be linked to + * @return A boolean indicating the result + */ private boolean allowLinkingFromLinkRepository(HALResource resource, String rel) { return getLinkResourceRepository(resource.getContent().getCategory(),