Example usage for org.springframework.http MediaType APPLICATION_JSON_UTF8_VALUE

List of usage examples for org.springframework.http MediaType APPLICATION_JSON_UTF8_VALUE

Introduction

In this page you can find the example usage for org.springframework.http MediaType APPLICATION_JSON_UTF8_VALUE.

Prototype

String APPLICATION_JSON_UTF8_VALUE

To view the source code for org.springframework.http MediaType APPLICATION_JSON_UTF8_VALUE.

Click Source Link

Document

A String equivalent of MediaType#APPLICATION_JSON_UTF8 .

Usage

From source file:com.snv.user.UsersController.java

/**
 * {@inheritDoc}//from ww  w. j a va 2s  . c o m
 */
@Override
@RequestMapping(method = RequestMethod.POST, path = "/login", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public User login(@RequestBody final Credential credential, final HttpServletResponse response) {
    try {
        return this.authenticationService.authenticate(credential, response);
    } catch (HmacException e) {
        LOG.error("Authentication failure", e);
    }
    throw new InvalidCredentialException("Authentication failure");
}

From source file:com.snv.user.Users.java

/**
 * Get a user by identifier//from  w w w. ja  v  a2 s.  c  om
 * @param userId, the identifier to get the user
 * @return the user found by the identifier, null otherwise
 */
@ApiOperation(value = "Get user by Identifier", notes = "Get the user by his technical identifier")
@ApiResponses(value = { @ApiResponse(code = 200, message = "Success", response = User.class),
        @ApiResponse(code = 400, message = "Bad Request"), @ApiResponse(code = 401, message = "Unauthorized"),
        @ApiResponse(code = 403, message = "Forbidden"), @ApiResponse(code = 404, message = "Not Found"),
        @ApiResponse(code = 500, message = "Internal Server Error") })
@RequestMapping(value = "/{userId}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
User get(
        @ApiParam(value = "User technical identifier", required = true) @PathVariable("userId") final Long userId);

From source file:com.example.user.UserEndpoint.java

@PostMapping(consumes = { MediaType.APPLICATION_JSON_VALUE,
        MediaType.APPLICATION_JSON_UTF8_VALUE }, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
UserJson createUserWithJson(@RequestBody final UserJson.Request request) {
    final UserEntity userEntity = new UserEntity(request.getUsername());
    final ResponseEntity<Resource<UserEntity>> responseEntity = postUserToDbApp(userEntity);
    return userJson(responseEntity);
}

From source file:com.snv.todo.Todos.java

/**
 * Udapte user PUT endpoint/* w  w  w  .j  a v a  2 s  .  com*/
 * @param todo the todo to update
 * @return the same todo.
 */
@ApiOperation(value = "Update todo pareyer passed", notes = "Update the todo to the data")
@ApiResponses(value = { @ApiResponse(code = 200, message = "Success", response = Todo.class),
        @ApiResponse(code = 400, message = "Bad Request"), @ApiResponse(code = 401, message = "Unauthorized"),
        @ApiResponse(code = 403, message = "Forbidden"), @ApiResponse(code = 404, message = "Not Found"),
        @ApiResponse(code = 500, message = "Internal Server Error") })
@RequestMapping(method = RequestMethod.PUT, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
Todo put(@ApiParam(required = true) @RequestBody final Todo todo);

From source file:com.github.ichenkaihua.test.web.Swagger2MarkupTest.java

@Test
public void createSpringfoxSwaggerJson() throws Exception {
    //String designFirstSwaggerLocation = Swagger2MarkupTest.class.getResource("/swagger.yaml").getPath();

    String outputDir = System.getProperty("io.springfox.staticdocs.outputDir");
    System.out.println(outputDir);
    //  String out = "/home/chenkh/git/ssm-easy-template/build/asciidoc";
    MvcResult mvcResult = this.mockMvc.perform(get("/v2/api-docs")
            //api-docs?group=user-api
            .param("group", "user-api").accept(MediaType.APPLICATION_JSON_UTF8_VALUE)).andDo(print())
            .andDo(SwaggerResultHandler.outputDirectory(outputDir).build()).andExpect(status().isOk())
            .andReturn();/* www. j a  v  a2s  .  c o m*/

    String springfoxSwaggerJson = mvcResult.getResponse().getContentAsString();
    System.out.println(springfoxSwaggerJson);

    //SwaggerAssertions.assertThat(Swagger20Parser.parse(springfoxSwaggerJson)).isEqualTo(designFirstSwaggerLocation);
}

From source file:com.snv.calendar.Calendars.java

/**
 * Udapte user PUT endpoint/*from  w  ww  .j a v  a  2 s  .c  o  m*/
 *
 * @param calendar the calendar to update
 * @return the same calendar.
 */
@ApiOperation(value = "Update calendar pareyer passed", notes = "Update the calendar to the data")
@ApiResponses(value = { @ApiResponse(code = 200, message = "Success", response = Calendar.class),
        @ApiResponse(code = 400, message = "Bad Request"), @ApiResponse(code = 401, message = "Unauthorized"),
        @ApiResponse(code = 403, message = "Forbidden"), @ApiResponse(code = 404, message = "Not Found"),
        @ApiResponse(code = 500, message = "Internal Server Error") })
@RequestMapping(method = RequestMethod.PUT, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
Calendar put(@ApiParam(required = true) @RequestBody final Calendar calendar);

From source file:com.snv.user.Users.java

/**
 * Get all users//  w  w  w. j  ava  2s. co m
 * @return the list of user containing all dataBase users
 */
@ApiOperation(value = "Get all users", notes = "Return all users found in DataBase")
@ApiResponses(value = { @ApiResponse(code = 200, message = "Success", response = User.class),
        @ApiResponse(code = 400, message = "Bad Request"), @ApiResponse(code = 401, message = "Unauthorized"),
        @ApiResponse(code = 403, message = "Forbidden"), @ApiResponse(code = 404, message = "Not Found"),
        @ApiResponse(code = 500, message = "Internal Server Error") })
@RequestMapping(method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
List<User> getAll();

From source file:com.snv.bank.account.Accounts.java

/**
 * Get all user bank account endPoint//from  w  w w  .j  av  a  2s. co m
 *
 * @return the list of user bank account, empty List otherwise
 */
@ApiOperation(value = "Get all user bank account", notes = "Get all user bank account in the data base")
@ApiResponses(value = { @ApiResponse(code = 200, message = "Success", response = Account.class),
        @ApiResponse(code = 400, message = "Bad Request"), @ApiResponse(code = 401, message = "Unauthorized"),
        @ApiResponse(code = 403, message = "Forbidden"), @ApiResponse(code = 404, message = "Not Found"),
        @ApiResponse(code = 500, message = "Internal Server Error") })
@RequestMapping(method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
List<Account> getAll();

From source file:su90.mybatisdemo.web.endpoints.EmployeesEndpoints.java

@RequestMapping(value = { "/update/{id}" }, method = RequestMethod.PUT, consumes = {
        MediaType.APPLICATION_JSON_UTF8_VALUE }, produces = { MediaType.APPLICATION_JSON_UTF8_VALUE })
@ApiOperation(value = "update one employee if possible")
public ResponseEntity<EmployeeOut> updateEmployee(@PathVariable("id") Long id, @RequestBody EmployeeIn empIn) {
    Employee curemp = employeesService.getEntryById(id);

    if (curemp == null) {
        return new ResponseEntity<>(HttpStatus.NOT_FOUND);
    }/*from ww w  .  ja v  a 2 s  .  c  om*/

    Employee tobeupdated = empIn.getDomain();
    tobeupdated.setId(id);

    employeesService.updateEntry(tobeupdated);

    return new ResponseEntity<>(employeesService.getWebBeanById(id), HttpStatus.OK);
}

From source file:com.snv.todo.Todos.java

/**
 * Delete todo POST endpoint/*from   ww  w  .j av a 2 s .  com*/
 * @param todoId the todo technical identifier to delete
 * @return boolean true if todo is successfully deleted, false otherwise
 */
@ApiOperation(value = "Delete todo endPoint", notes = "Delete the parameter passed todo")
@ApiResponses(value = { @ApiResponse(code = 200, message = "Success"),
        @ApiResponse(code = 400, message = "Bad Request"), @ApiResponse(code = 401, message = "Unauthorized"),
        @ApiResponse(code = 403, message = "Forbidden"), @ApiResponse(code = 404, message = "Not Found"),
        @ApiResponse(code = 500, message = "Internal Server Error") })
@RequestMapping(path = "/{todoId}", method = RequestMethod.DELETE, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
Boolean delete(@ApiParam(required = true) @PathVariable("todoId") final Long todoId);