use of com.wordnik.swagger.annotations.ApiImplicitParam 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);
}
use of com.wordnik.swagger.annotations.ApiImplicitParam in project rhino by PLOS.
the class JournalCrudController method update.
@Transactional(rollbackFor = { Throwable.class })
@RequestMapping(value = "/journals/{journalKey}", method = RequestMethod.PATCH)
@ApiImplicitParam(name = "body", paramType = "body", dataType = "JournalInputView", value = "example: {\"currentIssueDoi\": \"10.1371/issue.pmed.v13.i09\"}")
public ResponseEntity<?> update(@RequestHeader(value = HttpHeaders.IF_MODIFIED_SINCE, required = false) Date ifModifiedSince, HttpServletRequest request, @PathVariable String journalKey) throws IOException {
JournalInputView input = readJsonFromRequest(request, JournalInputView.class);
journalCrudService.update(journalKey, input);
return journalCrudService.serve(journalKey).getIfModified(ifModifiedSince).asJsonResponse(entityGson);
}
use of com.wordnik.swagger.annotations.ApiImplicitParam in project rhino by PLOS.
the class VolumeCrudController method create.
@Transactional(rollbackFor = { Throwable.class })
@RequestMapping(value = "/journals/{journalKey}/volumes", method = RequestMethod.POST)
@ApiImplicitParam(name = "body", paramType = "body", dataType = "VolumeInputView", value = "example: {\"doi\": \"10.1371/volume.pmed.v01\", \"displayName\": \"2004\"}")
public ResponseEntity<?> create(HttpServletRequest request, @PathVariable String journalKey) throws IOException {
VolumeInputView input = readJsonFromRequest(request, VolumeInputView.class);
if (StringUtils.isBlank(input.getDoi())) {
throw new RestClientException("Volume DOI required", HttpStatus.BAD_REQUEST);
}
Volume volume = volumeCrudService.create(journalKey, input);
return ServiceResponse.reportCreated(volumeOutputViewFactory.getView(volume)).asJsonResponse(entityGson);
}
use of com.wordnik.swagger.annotations.ApiImplicitParam in project rhino by PLOS.
the class ArticleListCrudController method create.
@Transactional(rollbackFor = { Throwable.class })
@RequestMapping(value = "/lists", method = RequestMethod.POST)
@ApiImplicitParam(name = "body", paramType = "body", dataType = "ListInputView", value = "example: {\"journal\": \"PLoSONE\", \"type\": \"admin\", \"key\": \"plosone_news\", " + "\"title\": \"test\", \"articleDois\": [\"10.1371/journal.pone.0095668\"]}")
public ResponseEntity<?> create(HttpServletRequest request) throws IOException {
final ListInputView inputView;
try {
inputView = readJsonFromRequest(request, ListInputView.class);
} catch (ListInputView.PartialIdentityException e) {
throw complainAboutRequiredListIdentity(e);
}
Optional<ArticleListIdentity> identity = inputView.getIdentity();
if (!identity.isPresent()) {
throw complainAboutRequiredListIdentity(null);
}
Optional<String> title = inputView.getTitle();
if (!title.isPresent()) {
throw new RestClientException("title required", HttpStatus.BAD_REQUEST);
}
Optional<ImmutableSet<ArticleIdentifier>> articleDois = inputView.getArticleIds();
if (!articleDois.isPresent()) {
throw new RestClientException("articleDois required", HttpStatus.BAD_REQUEST);
}
ArticleListView listView = articleListCrudService.create(identity.get(), title.get(), articleDois.get());
return ServiceResponse.reportCreated(listView).asJsonResponse(entityGson);
}
use of com.wordnik.swagger.annotations.ApiImplicitParam in project rhino by PLOS.
the class CommentCrudController method patch.
@RequestMapping(value = "/articles/{articleDoi}/comments/{commentDoi:.+}", method = RequestMethod.PATCH)
@ApiImplicitParam(name = "body", paramType = "body", dataType = "CommentInputView", value = "example #1: {\"title\": \"new title\"}<br>" + "example #2: {\"body\": \"comment body replacement text\"}<br>" + "example #3: {\"isRemoved\": \"true\"}")
public ResponseEntity<?> patch(HttpServletRequest request, @PathVariable("articleDoi") String articleDoi, @PathVariable("commentDoi") String commentDoi) throws IOException {
ArticleIdentifier articleId = ArticleIdentifier.create(DoiEscaping.unescape(articleDoi));
CommentIdentifier commentId = CommentIdentifier.create(DoiEscaping.unescape(commentDoi));
// TODO: Validate articleId
CommentInputView input = readJsonFromRequest(request, CommentInputView.class);
return commentCrudService.patchComment(commentId, input).asJsonResponse(entityGson);
}
Aggregations