mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-07 01:54:22 +00:00
[Task 69343] applied the feedback with regards to the specific embed functionality
This commit is contained in:
@@ -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) {
|
||||
|
@@ -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 {
|
||||
|
||||
|
@@ -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;
|
||||
|
@@ -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;
|
||||
|
@@ -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 #
|
||||
#---------------------------------------------------------------#
|
||||
|
@@ -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>
|
||||
|
Reference in New Issue
Block a user