Search in sources :

Example 1 with ApiImplicitParam

use of com.wordnik.swagger.annotations.ApiImplicitParam in project rhino by PLOS.

the class ArticleCrudController method createSyndication.

@RequestMapping(value = "/articles/{doi}/revisions/{number}/syndications", method = RequestMethod.POST)
@ApiImplicitParam(name = "body", paramType = "body", dataType = "SyndicationInputView", value = "example: {\"targetQueue\": \"activemq:plos.pmc\"}")
public ResponseEntity<?> createSyndication(HttpServletRequest request, @PathVariable("doi") String doi, @PathVariable("number") int revisionNumber) throws IOException {
    ArticleRevisionIdentifier revisionId = ArticleRevisionIdentifier.create(DoiEscaping.unescape(doi), revisionNumber);
    SyndicationInputView input = readJsonFromRequest(request, SyndicationInputView.class);
    Syndication syndication = syndicationCrudService.createSyndication(revisionId, input.getTargetQueue());
    return ServiceResponse.reportCreated(new SyndicationView(syndication)).asJsonResponse(entityGson);
}
Also used : SyndicationView(org.ambraproject.rhino.view.article.SyndicationView) ArticleRevisionIdentifier(org.ambraproject.rhino.identity.ArticleRevisionIdentifier) SyndicationInputView(org.ambraproject.rhino.view.article.SyndicationInputView) Syndication(org.ambraproject.rhino.model.Syndication) ApiImplicitParam(com.wordnik.swagger.annotations.ApiImplicitParam) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 2 with ApiImplicitParam

use of com.wordnik.swagger.annotations.ApiImplicitParam in project rhino by PLOS.

the class ArticleListCrudController method update.

@Transactional(rollbackFor = { Throwable.class })
@RequestMapping(value = "/lists/{type}/journals/{journal}/keys/{key}", method = RequestMethod.PATCH)
@ApiImplicitParam(name = "body", paramType = "body", dataType = "ListInputView", value = "example #1: {\"title\": \"New Title\"}<br>" + "example #2: {\"articleDois\": [\"10.1371/journal.pone.0012345\", \"10.1371/journal.pone.0054321\"]}")
public ResponseEntity<?> update(HttpServletRequest request, @PathVariable("type") String type, @PathVariable("journal") String journalKey, @PathVariable("key") String key) throws IOException {
    final ListInputView inputView;
    try {
        inputView = readJsonFromRequest(request, ListInputView.class);
    } catch (ListInputView.PartialIdentityException e) {
        throw complainAboutListIdentityOnPatch(e);
    }
    if (inputView.getIdentity().isPresent()) {
        throw complainAboutListIdentityOnPatch(null);
    }
    ArticleListIdentity identity = new ArticleListIdentity(type, journalKey, key);
    articleListCrudService.update(identity, inputView.getTitle(), inputView.getArticleIds());
    return new ResponseEntity<>(HttpStatus.OK);
}
Also used : ArticleListIdentity(org.ambraproject.rhino.identity.ArticleListIdentity) ResponseEntity(org.springframework.http.ResponseEntity) ListInputView(org.ambraproject.rhino.view.article.ListInputView) ApiImplicitParam(com.wordnik.swagger.annotations.ApiImplicitParam) Transactional(org.springframework.transaction.annotation.Transactional) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 3 with ApiImplicitParam

use of com.wordnik.swagger.annotations.ApiImplicitParam in project rhino by PLOS.

the class VolumeCrudController method update.

@Transactional(rollbackFor = { Throwable.class })
@RequestMapping(value = "/journals/{journalKey}/volumes/{volumeDoi:.+}", method = RequestMethod.PATCH)
@ApiImplicitParam(name = "body", paramType = "body", dataType = "VolumeInputView", value = "example #1: {\"doi\": \"10.1371/volume.pmed.v01\"}<br>" + "example #2: {\"displayName\": \"2004\"}")
public ResponseEntity<?> update(HttpServletRequest request, @PathVariable("journalKey") String journalKey, @PathVariable("volumeDoi") String volumeDoi) throws IOException {
    // TODO: Validate journalKey
    VolumeIdentifier volumeId = getVolumeId(volumeDoi);
    VolumeInputView input = readJsonFromRequest(request, VolumeInputView.class);
    Volume updated = volumeCrudService.update(volumeId, input);
    VolumeOutputView view = volumeOutputViewFactory.getView(updated);
    return ServiceResponse.serveView(view).asJsonResponse(entityGson);
}
Also used : Volume(org.ambraproject.rhino.model.Volume) VolumeInputView(org.ambraproject.rhino.view.journal.VolumeInputView) VolumeOutputView(org.ambraproject.rhino.view.journal.VolumeOutputView) VolumeIdentifier(org.ambraproject.rhino.identity.VolumeIdentifier) ApiImplicitParam(com.wordnik.swagger.annotations.ApiImplicitParam) Transactional(org.springframework.transaction.annotation.Transactional) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 4 with ApiImplicitParam

use of com.wordnik.swagger.annotations.ApiImplicitParam in project rhino by PLOS.

the class IssueCrudController method update.

@Transactional(rollbackFor = { Throwable.class })
@RequestMapping(value = "/journals/{journalKey}/volumes/{volumeDoi}/issues/{issueDoi:.+}", method = RequestMethod.PATCH)
@ApiImplicitParam(name = "body", paramType = "body", dataType = "IssueInputView", value = "example #1: {\"displayName\": \"July\"}<br>" + "example #2: {\"imageArticleDoi\": \"10.1371/image.pbio.v02.i07\"}<br>" + "example #3: {\"articleOrder\": [\"10.1371/journal.pbio.0020213\", \"10.1371/journal.pbio.0020214\", " + "\"10.1371/journal.pbio.0020228\"]}")
public ResponseEntity<?> update(HttpServletRequest request, @RequestHeader(value = HttpHeaders.IF_MODIFIED_SINCE, required = false) Date ifModifiedSince, @PathVariable("journalKey") String journalKey, @PathVariable("volumeDoi") String volumeDoi, @PathVariable("issueDoi") String issueDoi) throws IOException {
    // TODO: Validate journalKey and volumeDoiObj
    IssueIdentifier issueId = getIssueId(issueDoi);
    IssueInputView input = readJsonFromRequest(request, IssueInputView.class);
    issueCrudService.update(issueId, input);
    return issueCrudService.serveIssue(issueId).getIfModified(ifModifiedSince).asJsonResponse(entityGson);
}
Also used : IssueIdentifier(org.ambraproject.rhino.identity.IssueIdentifier) 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)

Example 5 with ApiImplicitParam

use of com.wordnik.swagger.annotations.ApiImplicitParam in project rhino by PLOS.

the class CommentCrudController method create.

@RequestMapping(value = "/articles/{articleDoi}/comments", method = RequestMethod.POST)
@ApiImplicitParam(name = "body", paramType = "body", dataType = "CommentInputView", value = "example: {\"creatorUserId\": 10365, " + "\"parentCommentId\": \"10.1371/annotation/0043aae2-f69d-4a05-ab19-4709704eb749\", " + "\"title\": \"no, really watch this\", " + "\"body\": \"http://www.youtube.com/watch?v=iGQdwSAAz9I\", " + "\"highlightedText\": \"whoah...\", " + "\"competingInterestStatement\": \"I'm going for an Emmy\"}")
public ResponseEntity<?> create(HttpServletRequest request, @PathVariable("articleDoi") String articleDoi) throws IOException {
    ArticleIdentifier articleId = ArticleIdentifier.create(DoiEscaping.unescape(articleDoi));
    CommentInputView input = readJsonFromRequest(request, CommentInputView.class);
    // TODO: Pass Optional.empty() if client POSTed to "/comments"?
    Optional<ArticleIdentifier> articleIdObj = Optional.of(articleId);
    return commentCrudService.createComment(articleIdObj, input).asJsonResponse(entityGson);
}
Also used : ArticleIdentifier(org.ambraproject.rhino.identity.ArticleIdentifier) CommentInputView(org.ambraproject.rhino.view.comment.CommentInputView) ApiImplicitParam(com.wordnik.swagger.annotations.ApiImplicitParam) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

ApiImplicitParam (com.wordnik.swagger.annotations.ApiImplicitParam)13 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)13 Transactional (org.springframework.transaction.annotation.Transactional)7 ArticleIdentifier (org.ambraproject.rhino.identity.ArticleIdentifier)3 ArticleRevisionIdentifier (org.ambraproject.rhino.identity.ArticleRevisionIdentifier)3 Syndication (org.ambraproject.rhino.model.Syndication)3 RestClientException (org.ambraproject.rhino.rest.RestClientException)3 SyndicationInputView (org.ambraproject.rhino.view.article.SyndicationInputView)3 SyndicationView (org.ambraproject.rhino.view.article.SyndicationView)3 ArticleListIdentity (org.ambraproject.rhino.identity.ArticleListIdentity)2 CommentIdentifier (org.ambraproject.rhino.identity.CommentIdentifier)2 VolumeIdentifier (org.ambraproject.rhino.identity.VolumeIdentifier)2 Volume (org.ambraproject.rhino.model.Volume)2 ListInputView (org.ambraproject.rhino.view.article.ListInputView)2 CommentInputView (org.ambraproject.rhino.view.comment.CommentInputView)2 IssueInputView (org.ambraproject.rhino.view.journal.IssueInputView)2 VolumeInputView (org.ambraproject.rhino.view.journal.VolumeInputView)2 ImmutableSet (com.google.common.collect.ImmutableSet)1 ApiOperation (com.wordnik.swagger.annotations.ApiOperation)1 IssueIdentifier (org.ambraproject.rhino.identity.IssueIdentifier)1