当前位置: 首页>>代码示例>>Java>>正文


Java MimeTypeUtils.APPLICATION_JSON_VALUE属性代码示例

本文整理汇总了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));
}
 
开发者ID:redlink-gmbh,项目名称:smarti,代码行数:17,代码来源:ConversationWebservice.java

示例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();
    }

}
 
开发者ID:redlink-gmbh,项目名称:smarti,代码行数:17,代码来源:UserWebservice.java

示例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");
}
 
开发者ID:softwaremill,项目名称:janusz-backend,代码行数:21,代码来源:KudosRestController.java

示例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));
}
 
开发者ID:redlink-gmbh,项目名称:smarti,代码行数:13,代码来源:ConversationWebservice.java

示例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();
}
 
开发者ID:redlink-gmbh,项目名称:smarti,代码行数:27,代码来源:ConversationWebservice.java

示例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())));
}
 
开发者ID:redlink-gmbh,项目名称:smarti,代码行数:11,代码来源:UserWebservice.java

示例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);
    }
}
 
开发者ID:redlink-gmbh,项目名称:smarti,代码行数:13,代码来源:UserWebservice.java

示例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();
    }
}
 
开发者ID:redlink-gmbh,项目名称:smarti,代码行数:15,代码来源:ConversationAdminWebservice.java

示例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;
}
 
开发者ID:softwaremill,项目名称:janusz-backend,代码行数:12,代码来源:MistakesController.java

示例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");
}
 
开发者ID:softwaremill,项目名称:janusz-backend,代码行数:13,代码来源:RulesController.java

示例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");
}
 
开发者ID:softwaremill,项目名称:janusz-backend,代码行数:15,代码来源:MoodRestController.java

示例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);
}
 
开发者ID:softwaremill,项目名称:janusz-backend,代码行数:12,代码来源:KudosRestController.java

示例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);
}
 
开发者ID:softwaremill,项目名称:janusz-backend,代码行数:7,代码来源:KudosRestController.java

示例14: name

@RequestMapping(value = "/detail", produces = MimeTypeUtils.APPLICATION_JSON_VALUE)
public Detail name() {
    return new Detail("Bar");
}
 
开发者ID:rsdomingues,项目名称:netflixmicroservices-tdc2017,代码行数:4,代码来源:BarService.java

示例15: returnJson1

@RequestMapping(value = "/return-json-1", produces = MimeTypeUtils.APPLICATION_JSON_VALUE)
@ResponseBody
public String returnJson1() throws SomeException {
  throw new SomeException();
}
 
开发者ID:chanjarster,项目名称:spring-mvc-error-handling-example,代码行数:5,代码来源:FooController.java


注:本文中的org.springframework.util.MimeTypeUtils.APPLICATION_JSON_VALUE属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。