本文整理汇总了Java中org.springframework.util.MimeTypeUtils.APPLICATION_JSON_VALUE属性的典型用法代码示例。如果您正苦于以下问题:Java MimeTypeUtils.APPLICATION_JSON_VALUE属性的具体用法?Java MimeTypeUtils.APPLICATION_JSON_VALUE怎么用?Java MimeTypeUtils.APPLICATION_JSON_VALUE使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.springframework.util.MimeTypeUtils
的用法示例。
在下文中一共展示了MimeTypeUtils.APPLICATION_JSON_VALUE属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updateConversation
@ApiOperation(value = "update a conversation", response = Conversation.class)
@RequestMapping(value = "{id}", method = RequestMethod.PUT, consumes = MimeTypeUtils.APPLICATION_JSON_VALUE)
public ResponseEntity<?> updateConversation(
AuthContext authContext,
@PathVariable("id") ObjectId id,
@RequestBody Conversation conversation
) {
final Conversation storedC = authenticationService.assertConversation(authContext, id);
// make sure the id is the right one
conversation.setId(storedC.getId());
final Client client = authenticationService.assertClient(authContext, conversation.getOwner());
//TODO: check that the
// * the user is from the client the stored conversation as as owner
return ResponseEntity.ok(conversationService.update(client, conversation,true, null));
}
示例2: signUp
@ApiOperation(value = "signup", notes = "create a new account", response = UserDetailsResponse.class)
@RequestMapping(value = "/auth/signup", method = RequestMethod.POST, consumes = MimeTypeUtils.APPLICATION_JSON_VALUE)
public ResponseEntity<UserDetailsResponse> signUp(@RequestBody Map<String, String> data) {
if (!securityConfigurationProperties.getMongo().isEnableSignup()) {
return ResponseEntity.badRequest().build();
}
// Public access
final String login = data.get("login"),
password = data.get("password"),
mail = data.get("email");
if ( StringUtils.isNoneBlank(login, password, mail) && emailValidator.isValid(mail)) {
return ResponseEntity.ok(UserDetailsResponse.wrap(accountService.createAccount(login, mail, password)));
} else {
return ResponseEntity.badRequest().build();
}
}
示例3: addNewPlusOne
@RequestMapping(value = "/{kudosId}/plusOnes", method = RequestMethod.POST, consumes = MimeTypeUtils.APPLICATION_JSON_VALUE, produces = MimeTypeUtils.APPLICATION_JSON_VALUE)
public ResponseMessage addNewPlusOne(@RequestBody @Valid NewPlusOneRequest newPlusOneRequest, BindingResult result, @PathVariable("kudosId") Long kudosId) {
logger.info("New request " + newPlusOneRequest.toString());
if (result.hasErrors()) {
throw new IllegalArgumentException("Invalid request data " + result.toString());
}
Kudos kudos = kudosRepository.findOne(kudosId);
if(kudos == null) {
throw new IllegalArgumentException("There is no kudos with id=" + kudosId);
}
PlusOne plusOne = new PlusOne(
slackUsersProvider.mapSlackUserNameToUserId(newPlusOneRequest.getUserName()),
newPlusOneRequest.getDescription(),
kudos
);
plusOneRepository.save(plusOne);
kudos.addPlusOne(plusOne);
return new ResponseMessage("ok");
}
示例4: addMessage
@ApiOperation(value = "append a message to the conversation", response = Conversation.class)
@RequestMapping(value = "{id}/message", method = RequestMethod.POST, consumes = MimeTypeUtils.APPLICATION_JSON_VALUE)
public ResponseEntity<?> addMessage(
AuthContext authContext,
@PathVariable("id") ObjectId id,
@RequestBody Message message
) {
final Conversation conversation = authenticationService.assertConversation(authContext, id);
final Client client = authenticationService.assertClient(authContext, conversation.getOwner());
return ResponseEntity.ok(conversationService.appendMessage(client, conversation, message));
}
示例5: getQuery
@ApiOperation(value = "update a query based on new slot-assignments", response = Query.class)
@RequestMapping(value = "{id}/query/{template}/{creator}", method = RequestMethod.POST, consumes = MimeTypeUtils.APPLICATION_JSON_VALUE)
public ResponseEntity<?> getQuery(
AuthContext authContext,
@PathVariable("id") ObjectId id,
@PathVariable("template") int templateIdx,
@PathVariable("creator") String creator,
@ApiParam(hidden = true) @RequestParam(required = false) MultiValueMap<String, String> params,
@RequestBody QueryUpdate queryUpdate
) {
final Conversation conversation = authenticationService.assertConversation(authContext, id);
final Client client = authenticationService.assertClient(authContext, conversation.getOwner());
final Configuration clientConf = configService.getClientConfiguration(client.getId());
if(clientConf == null){
log.info("Client {} of Conversation {} has no longer a configuration assigned ... returning 404 NOT FOUND",
conversation.getChannelId(), conversation.getId());
return ResponseEntity.notFound().build();
}
final Template template = conversation.getTemplates().get(templateIdx);
if (template == null) return ResponseEntity.notFound().build();
//NOTE: conversationService.getConversation(..) already update the queries if necessary
//so at this place we only need to retrieve the requested query
Optional<Query> query = template.getQueries().stream().filter(q -> Objects.equals(creator, q.getCreator())).findFirst();
return query.isPresent() ? ResponseEntity.ok(query.get()) : ResponseEntity.notFound().build();
}
示例6: createUser
@RequestMapping(value = "/user", method = RequestMethod.POST, consumes = MimeTypeUtils.APPLICATION_JSON_VALUE)
public ResponseEntity<SmartiUserData> createUser(AuthContext authContext,
@RequestBody SmartiUserData user) {
authenticationService.assertRole(authContext, AuthenticationService.ADMIN);
if (StringUtils.isBlank(user.getLogin())) {
return ResponseEntity.unprocessableEntity().build();
}
return ResponseEntity.ok(SmartiUserData.fromModel(userService.createUser(user.toModel())));
}
示例7: updateUser
@RequestMapping(value = "/user/{login}", method = RequestMethod.PUT, consumes = MimeTypeUtils.APPLICATION_JSON_VALUE)
public SmartiUserData updateUser(AuthContext authentication,
@PathVariable("login") String login,
@RequestBody SmartiUserData user) {
// Access only for ADMIN or @me
if (authenticationService.hasLogin(authentication, login)
|| authenticationService.hasRole(authentication, AuthenticationService.ADMIN)) {
return SmartiUserData.fromModel(userService.updateProfile(login, user.getProfile()));
} else {
throw new AccessDeniedException("No access for " + authentication);
}
}
示例8: importConversations
@ApiOperation(value = "import conversations")
@RequestMapping(value = "import", method = RequestMethod.POST, consumes = MimeTypeUtils.APPLICATION_JSON_VALUE)
public ResponseEntity<?> importConversations(
AuthContext authContext,
@RequestParam("owner") ObjectId owner,
@RequestParam(value = "replace", defaultValue = "false", required = false) boolean replace,
@RequestBody List<Conversation> conversations
) {
if (authenticationService.hasAccessToClient(authContext, owner)) {
conversationService.importConversations(owner, conversations, replace);
return ResponseEntity.noContent().build();
} else {
return ResponseEntity.badRequest().build();
}
}
示例9: checkForMistakes
@RequestMapping(method = RequestMethod.POST, consumes = MimeTypeUtils.APPLICATION_JSON_VALUE, produces = MimeTypeUtils.APPLICATION_JSON_VALUE + CHARSET_UTF_8)
public MistakesCheckingResult checkForMistakes(@RequestBody @Valid MistakesCheckRequest mistakesCheckRequest, BindingResult result) {
if (result.hasErrors()) {
throw new IllegalArgumentException("Invalid request data " + result.toString());
}
MistakesCheckingResult response = mistakesCheckRequestHandler.handleRequest(mistakesCheckRequest);
if (response.getMistake()) {
logger.info("Mistake detected, response: " + response.getMessage());
}
return response;
}
示例10: addRule
@RequestMapping(method = RequestMethod.POST, consumes = MimeTypeUtils.APPLICATION_JSON_VALUE, produces = MimeTypeUtils.APPLICATION_JSON_VALUE + CHARSET_UTF_8)
public ResponseMessage addRule(@RequestBody @Valid AddRuleRequest addRuleRequest, BindingResult result) {
logger.info("New request " + addRuleRequest.toString());
if (result.hasErrors()) {
throw new IllegalArgumentException("Invalid request data " + result.toString());
}
String error = new LowerCaseAsciiString(addRuleRequest.getError()).toString();
if(rulesRepository.countByError(error) > 0) {
return new ResponseMessage("Reguła dla słowa *" + error + "* już istnieje.");
}
rulesRepository.save(new Rule(error, addRuleRequest.getCorrectForm()));
return new ResponseMessage("ok");
}
示例11: addNewMoodEntry
@RequestMapping(method = RequestMethod.POST,
consumes = MimeTypeUtils.APPLICATION_JSON_VALUE,
produces = MimeTypeUtils.APPLICATION_JSON_VALUE)
public ResponseMessage addNewMoodEntry(@RequestBody @Valid NewMoodRequest newMoodRequest, BindingResult result) {
logger.info("New request " + newMoodRequest.toString());
if (result.hasErrors()) {
throw new IllegalArgumentException("Invalid request data " + result.toString());
}
Mood newMood = new Mood(newMoodRequest.getUserName(), newMoodRequest.getUserId(), newMoodRequest.getMood(),
newMoodRequest.getDescription(), nowProvider.now());
moodRepository.save(newMood);
return new ResponseMessage("ok");
}
示例12: addNewKudos
@RequestMapping(method = RequestMethod.POST, consumes = MimeTypeUtils.APPLICATION_JSON_VALUE, produces = MimeTypeUtils.APPLICATION_JSON_VALUE)
public String addNewKudos(@RequestBody @Valid NewKudosRequest newKudosRequest, BindingResult result) throws JsonProcessingException {
logger.info("New request " + newKudosRequest.toString());
if (result.hasErrors()) {
throw new IllegalArgumentException("Invalid request data " + result.toString());
}
Kudos newKudos = new Kudos(newKudosRequest.getUserName(), newKudosRequest.getDescription(), newKudosRequest.getKudoer(), nowProvider.now());
Kudos addedKudos = kudosRepository.save(newKudos);
return objectMapper.writeValueAsString(addedKudos);
}
示例13: getKudosForUser
@RequestMapping(value = "/{userId}", method = RequestMethod.GET, produces = MimeTypeUtils.APPLICATION_JSON_VALUE)
public String getKudosForUser(@PathVariable String userId) throws JsonProcessingException {
Preconditions.checkArgument(userId != null, "User ID value is required");
List<KudosDto> kudosForUser = getKudosRequestHandler.getKudosForUser(userId);
return objectMapper.writeValueAsString(kudosForUser);
}
示例14: name
@RequestMapping(value = "/detail", produces = MimeTypeUtils.APPLICATION_JSON_VALUE)
public Detail name() {
return new Detail("Bar");
}
示例15: returnJson1
@RequestMapping(value = "/return-json-1", produces = MimeTypeUtils.APPLICATION_JSON_VALUE)
@ResponseBody
public String returnJson1() throws SomeException {
throw new SomeException();
}