use of com.wordnik.swagger.annotations.ApiOperation in project oxTrust by GluuFederation.
the class UserWebService method createUser.
/**
*/
@POST
@Consumes({ MEDIA_TYPE_SCIM_JSON, MediaType.APPLICATION_JSON })
@Produces({ MEDIA_TYPE_SCIM_JSON + UTF8_CHARSET_FRAGMENT, MediaType.APPLICATION_JSON + UTF8_CHARSET_FRAGMENT })
@HeaderParam("Accept")
@DefaultValue(MEDIA_TYPE_SCIM_JSON)
@ProtectedApi
@RefAdjusted
@ApiOperation(value = "Create user", notes = "https://tools.ietf.org/html/rfc7644#section-3.3", response = UserResource.class)
public Response createUser(@ApiParam(value = "User", required = true) UserResource user, @QueryParam(QUERY_PARAM_ATTRIBUTES) String attrsList, @QueryParam(QUERY_PARAM_EXCLUDED_ATTRS) String excludedAttrsList) {
Response response;
try {
log.debug("Executing web service method. createUser");
scim2UserService.createUser(user, endpointUrl);
String json = resourceSerializer.serialize(user, attrsList, excludedAttrsList);
response = Response.created(new URI(user.getMeta().getLocation())).entity(json).build();
} catch (Exception e) {
log.error("Failure at createUser method", e);
response = getErrorResponse(Response.Status.INTERNAL_SERVER_ERROR, "Unexpected error: " + e.getMessage());
}
return response;
}
use of com.wordnik.swagger.annotations.ApiOperation in project oxTrust by GluuFederation.
the class UserWebService method deleteUser.
@Path("{id}")
@DELETE
@Produces({ MEDIA_TYPE_SCIM_JSON + UTF8_CHARSET_FRAGMENT, MediaType.APPLICATION_JSON + UTF8_CHARSET_FRAGMENT })
@HeaderParam("Accept")
@DefaultValue(MEDIA_TYPE_SCIM_JSON)
@ProtectedApi
@ApiOperation(value = "Delete User", notes = "Delete User (https://tools.ietf.org/html/rfc7644#section-3.6)")
public Response deleteUser(@PathParam("id") String id) {
Response response;
try {
log.debug("Executing web service method. deleteUser");
// person cannot be null (check associated decorator method)
GluuCustomPerson person = personService.getPersonByInum(id);
scim2UserService.deleteUser(person);
response = Response.noContent().build();
} catch (Exception e) {
log.error("Failure at deleteUser method", e);
response = getErrorResponse(Response.Status.INTERNAL_SERVER_ERROR, "Unexpected error: " + e.getMessage());
}
return response;
}
use of com.wordnik.swagger.annotations.ApiOperation in project oxTrust by GluuFederation.
the class TrustRelationshipWebService method setContacts.
@POST
@Path("/set_contacts/{inum}")
@Consumes({ MediaType.APPLICATION_JSON })
@Produces(MediaType.TEXT_PLAIN)
@ApiOperation(value = "set contacts for TrustRelationship", notes = "Find TrustRelationship by inum and set contacts. Contacts parameter is List<TrustContact>")
@ApiResponses(value = { @ApiResponse(code = 200, message = "OK"), @ApiResponse(code = 500, message = "Server error") })
public void setContacts(@PathParam("inum") String trustRelationshipInum, String contacts, @Context HttpServletResponse response) {
try {
GluuSAMLTrustRelationship trustRelationship = trustService.getRelationshipByInum(trustRelationshipInum);
List<TrustContact> contactsList = objectMapper.readValue(contacts, new TypeReference<List<TrustContact>>() {
});
trustService.saveContacts(trustRelationship, contactsList);
} catch (Exception e) {
logger.error("setContacts() Exception", e);
try {
response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "INTERNAL SERVER ERROR");
} catch (Exception ex) {
}
}
}
use of com.wordnik.swagger.annotations.ApiOperation in project rhino by PLOS.
the class CommentCrudController method delete.
@RequestMapping(value = "/articles/{articleDoi}/comments/{commentDoi:.+}", method = RequestMethod.DELETE)
@ApiOperation(value = "delete", notes = "Performs a hard delete operation in the database. " + "NOTE: fails loudly if attempting to delete a comment that has any replies. All replies must " + "be deleted first.")
public ResponseEntity<?> delete(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
String deletedCommentUri = commentCrudService.deleteComment(commentId);
return reportDeleted(deletedCommentUri);
}
use of com.wordnik.swagger.annotations.ApiOperation in project rhino by PLOS.
the class ArticleCrudController method syndicate.
@RequestMapping(value = "/articles/{doi}/revisions/{number}/syndications", // Fold into PATCH operation so we can get rid of "?syndicate"?
method = RequestMethod.POST, params = "syndicate")
@ApiOperation(value = "syndicate", notes = "Send a syndication message to the queue for processing. " + "Will create and add a syndication to the database if none exist for current article and target.")
@ApiImplicitParam(name = "body", paramType = "body", dataType = "SyndicationInputView", value = "example: {\"targetQueue\": \"activemq:plos.pmc\"}")
public ResponseEntity<?> syndicate(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 created = syndicationCrudService.syndicate(revisionId, input.getTargetQueue());
return ServiceResponse.reportCreated(new SyndicationView(created)).asJsonResponse(entityGson);
}
Aggregations