Search in sources :

Example 6 with VolumeIdentifier

use of org.ambraproject.rhino.identity.VolumeIdentifier in project rhino by PLOS.

the class IssueCrudController method create.

@Transactional(rollbackFor = { Throwable.class })
@RequestMapping(value = "/journals/{journalKey}/volumes/{volumeDoi}/issues", method = RequestMethod.POST)
@ApiImplicitParam(name = "body", paramType = "body", dataType = "IssueInputView", value = "example: {\"doi\": \"10.1371/issue.pbio.v02.i07\", " + "\"displayName\": \"July\", " + "\"imageArticleDoi\": \"10.1371/image.pbio.v02.i07\", " + "\"articleOrder\": [\"10.1371/journal.pbio.0020213\", \"10.1371/journal.pbio.0020214\", " + "\"10.1371/journal.pbio.0020228\"]}")
public ResponseEntity<?> create(HttpServletRequest request, @PathVariable("journalKey") String journalKey, @PathVariable("volumeDoi") String volumeDoi) throws IOException {
    // TODO: Validate journalKey
    VolumeIdentifier volumeId = VolumeIdentifier.create(DoiEscaping.unescape(volumeDoi));
    IssueInputView input = readJsonFromRequest(request, IssueInputView.class);
    if (StringUtils.isBlank(input.getDoi())) {
        throw new RestClientException("issueUri required", HttpStatus.BAD_REQUEST);
    }
    Issue issue = issueCrudService.create(volumeId, input);
    return ServiceResponse.reportCreated(issueOutputViewFactory.getView(issue)).asJsonResponse(entityGson);
}
Also used : Issue(org.ambraproject.rhino.model.Issue) RestClientException(org.ambraproject.rhino.rest.RestClientException) VolumeIdentifier(org.ambraproject.rhino.identity.VolumeIdentifier) IssueInputView(org.ambraproject.rhino.view.journal.IssueInputView) ApiImplicitParam(com.wordnik.swagger.annotations.ApiImplicitParam) Transactional(org.springframework.transaction.annotation.Transactional) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

VolumeIdentifier (org.ambraproject.rhino.identity.VolumeIdentifier)6 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)4 Volume (org.ambraproject.rhino.model.Volume)3 Transactional (org.springframework.transaction.annotation.Transactional)3 ApiImplicitParam (com.wordnik.swagger.annotations.ApiImplicitParam)2 RestClientException (org.ambraproject.rhino.rest.RestClientException)2 Issue (org.ambraproject.rhino.model.Issue)1 Journal (org.ambraproject.rhino.model.Journal)1 IssueInputView (org.ambraproject.rhino.view.journal.IssueInputView)1 IssueOutputView (org.ambraproject.rhino.view.journal.IssueOutputView)1 VolumeInputView (org.ambraproject.rhino.view.journal.VolumeInputView)1 VolumeOutputView (org.ambraproject.rhino.view.journal.VolumeOutputView)1