Contribute to the DSpace Development Fund
The newly established DSpace Development Fund supports the development of new features prioritized by DSpace Governance. For a list of planned features see the fund wiki page.
Code Branch
The code of the DSapce 7 REST API have been merged in the master branch: https://github.com/DSpace/DSpace/tree/master/dspace-spring-rest
Code Representation of a DSpace Object
DSpace API Object (hibernate): org.dspace.content.DSpaceObject
This is the representation of an object from the DSpace database. Since DSpace 6, this object is populated with hibernate.
Rest Object: org.dspace.app.rest.model.DSpaceObject
This is a plain old java object (pojo) representation of a DSpace object.
Coding the REST object
- Add private properties
- Add a get/set method
- Add get and set to the class DSpaceObjectRest
- To exclude a property from JSON representation, add @JsonIgnore to the get method or to the property
Hateoas Object: org.dspace.app.rest.model.hateoas.DSpaceResource
This representation of an object allows for
- the embedding of other DSpace objects within the object. Embedded objects are always linked.
- property returns a RestModel object
- linking to other external DSpace objects
- property returns a RestModel. Property is marked with @JsonIgnore annotation.
The base class in this package uses reflection to identify attributes that are actual links to other REST resources.
If an attribute is of type RestModel, then the code will
- wrap the linked REST resource inside a DSpaceResource (so to have the identifier, self link, and links to other resources). The wrapper is actually created by the Repository responsible of the specific resource (ItemRepository, BitstreamRepository, etc.)
- https://github.com/DSpace/DSpace/blob/rest7/dspace-spring-rest/src/main/java/org/dspace/app/rest/model/hateoas/DSpaceResource.java#L58
This give a chance to add custom logic for extra links in specific resource
- https://github.com/DSpace/DSpace/blob/rest7/dspace-spring-rest/src/main/java/org/dspace/app/rest/model/hateoas/DSpaceResource.java#L58
- put the wrapper in the embedded section
- clean the attribute (not sure if useful/required/right):
Converter Object: org.dspace.app.rest.converter.DSpaceObjectConverter
Convert between the REST representation of an object and the hibernate representation of an object
Coding a converter object
- In the fromModel() function, map all object attributes from the persistence/hibernate model to the rest model
Repository Object: org.dspace.app.rest.repository.DSpaceRestRepository
Provide repository interface functions that return REST representations of DSpace objects.
Managing Object Initialization (TODO)
- When referencing a linked object, how do we control the initialization/load of reference object?