[Task 69343] applied the feedback with regards to the specific embed functionality

This commit is contained in:
Raf Ponsaerts
2020-03-06 11:16:59 +01:00
parent 3c01cc2a80
commit e0577e7322
6 changed files with 25 additions and 5 deletions

View File

@@ -158,6 +158,24 @@ public class ConverterService {
public <T extends HALResource> T toResource(RestModel restObject) {
return toResource(restObject, new Link[] {});
}
/**
* Converts the given rest object to a {@link HALResource} object.
* <p>
* If the rest object is a {@link RestAddressableModel}, the projection returned by
* {@link RestAddressableModel#getProjection()} will be used to determine which optional
* embeds and links will be added, and {@link Projection#transformResource(HALResource)}
* will be automatically called before returning the final, fully converted resource.
* </p><p>
* In all cases, the {@link HalLinkService} will be used immediately after the resource is constructed,
* to ensure all {@link HalLinkFactory}s have had a chance to add links as needed.
* </p>
*
* @param restObject the input rest object.
* @param oldLinks The old links fo the Resource Object
* @param <T> the return type, a subclass of {@link HALResource}.
* @return the fully converted resource, with all automatic links and embeds applied.
*/
public <T extends HALResource> T toResource(RestModel restObject, Link... oldLinks) {
T halResource = getResource(restObject);
if (restObject instanceof RestAddressableModel) {

View File

@@ -16,6 +16,8 @@ import org.springframework.hateoas.Link;
/**
* Projection that allows a given set of rels to be embedded.
* A Rel refers to a Link Relation, this is an Embedded Object of the HalResource and the HalResource contains
* a link to this
*/
public class EmbedRelsProjection extends AbstractProjection {

View File

@@ -22,7 +22,7 @@ public class FullProjection extends AbstractProjection {
public final static String NAME = "full";
private final int maxEmbed = DSpaceServicesFactory.getInstance().getConfigurationService()
.getIntProperty("projections.full.max", 2);
.getIntProperty("rest.projections.full.max", 2);
public String getName() {
return NAME;

View File

@@ -31,7 +31,7 @@ public class SpecificLevelProjection extends AbstractProjection {
public final static String NAME = "level";
private int maxEmbed = DSpaceServicesFactory.getInstance().getConfigurationService()
.getIntProperty("projections.full.max", 2);
.getIntProperty("rest.projections.full.max", 2);
public int getMaxEmbed() {
return maxEmbed;

View File

@@ -7,8 +7,8 @@
# Multiple allowed origin URLs may be comma separated
# (Requires reboot of servlet container, e.g. Tomcat, to reload)
rest.cors.allowed-origins = *
rest.projections.full.max = 2
rest.projection.specificLevel.maxEmbed = 5
#---------------------------------------------------------------#
# These configs are used by the deprecated REST (v4-6) module #
#---------------------------------------------------------------#

View File

@@ -4,6 +4,6 @@
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
<bean class="org.dspace.app.rest.projection.SpecificLevelProjection">
<property name="maxEmbed" value="5" />
<property name="maxEmbed" value="${rest.projection.specificLevel.maxEmbed}" />
</bean>
</beans>