mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-11 20:13:17 +00:00
Merge pull request #3079 from atmire/3078-EntityTypeLabelRestController-GetByLabelImprove
3078 Change EntityTypeLabelRestController get by label to return REST…
This commit is contained in:
@@ -13,6 +13,7 @@ import javax.servlet.http.HttpServletResponse;
|
|||||||
|
|
||||||
import org.dspace.app.rest.converter.ConverterService;
|
import org.dspace.app.rest.converter.ConverterService;
|
||||||
import org.dspace.app.rest.model.EntityTypeRest;
|
import org.dspace.app.rest.model.EntityTypeRest;
|
||||||
|
import org.dspace.app.rest.model.hateoas.EntityTypeResource;
|
||||||
import org.dspace.app.rest.utils.ContextUtil;
|
import org.dspace.app.rest.utils.ContextUtil;
|
||||||
import org.dspace.app.rest.utils.Utils;
|
import org.dspace.app.rest.utils.Utils;
|
||||||
import org.dspace.content.EntityType;
|
import org.dspace.content.EntityType;
|
||||||
@@ -51,15 +52,15 @@ public class EntityTypeLabelRestController {
|
|||||||
protected Utils utils;
|
protected Utils utils;
|
||||||
|
|
||||||
@GetMapping("/label/{entity-type-label}")
|
@GetMapping("/label/{entity-type-label}")
|
||||||
public EntityTypeRest get(HttpServletRequest request, HttpServletResponse response,
|
public EntityTypeResource get(HttpServletRequest request, HttpServletResponse response,
|
||||||
@PathVariable("entity-type-label") String label) {
|
@PathVariable("entity-type-label") String label) {
|
||||||
Context context = ContextUtil.obtainContext(request);
|
Context context = ContextUtil.obtainContext(request);
|
||||||
try {
|
try {
|
||||||
EntityType entityType = this.entityTypeService.findByEntityType(context, label);
|
EntityType entityType = this.entityTypeService.findByEntityType(context, label);
|
||||||
if (entityType == null) {
|
if (entityType == null) {
|
||||||
throw new ResourceNotFoundException("There was no entityType found with label: " + label);
|
throw new ResourceNotFoundException("There was no entityType found with label: " + label);
|
||||||
}
|
}
|
||||||
return converter.toRest(entityType, utils.obtainProjection());
|
return converter.toResource(converter.toRest(entityType, utils.obtainProjection()));
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
throw new RuntimeException(e.getMessage(), e);
|
throw new RuntimeException(e.getMessage(), e);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user