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


Java HttpStatus.UNPROCESSABLE_ENTITY属性代码示例

本文整理汇总了Java中org.springframework.http.HttpStatus.UNPROCESSABLE_ENTITY属性的典型用法代码示例。如果您正苦于以下问题:Java HttpStatus.UNPROCESSABLE_ENTITY属性的具体用法?Java HttpStatus.UNPROCESSABLE_ENTITY怎么用?Java HttpStatus.UNPROCESSABLE_ENTITY使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在org.springframework.http.HttpStatus的用法示例。


在下文中一共展示了HttpStatus.UNPROCESSABLE_ENTITY属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: putResourceConnector

@ApiOperation(value = "Creates or updates connector configuration for external resource attributes for the given "
        + "zone.", tags = { "Attribute Connector Management" })
@ApiResponses(value = {
        @ApiResponse(code = 201, message = "Connector configuration for the given zone is successfully created.") })
@RequestMapping(method = PUT, value = V1 + AcsApiUriTemplates.RESOURCE_CONNECTOR_URL,
        consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<String> putResourceConnector(
        @ApiParam(value = "New or updated connector configuration for external resource attributes",
                required = true) @RequestBody final AttributeConnector connector) {
    try {
        boolean connectorCreated = this.service.upsertResourceConnector(connector);

        if (connectorCreated) {
            // return 201 with empty response body
            return created(V1 + AcsApiUriTemplates.RESOURCE_CONNECTOR_URL, false);
        }
        // return 200 with empty response body
        return ok();
    } catch (AttributeConnectorException e) {
        throw new RestApiException(HttpStatus.UNPROCESSABLE_ENTITY, e.getMessage(), e);
    }
}
 
开发者ID:eclipse,项目名称:keti,代码行数:22,代码来源:AttributeConnectorController.java

示例2: getSubjectConnector

@ApiOperation(value = "Retrieves connector configuration for external subject attributes for the given zone.",
        tags = { "Attribute Connector Management" }, response = AttributeConnector.class)
@ApiResponses(
        value = { @ApiResponse(code = 404, message = "Connector configuration for the given zone is not found.") })
@RequestMapping(method = GET, value = V1 + AcsApiUriTemplates.SUBJECT_CONNECTOR_URL)
public ResponseEntity<AttributeConnector> getSubjectConnector() {
    try {
        AttributeConnector connector = this.service.retrieveSubjectConnector();
        if (connector != null) {
            return ok(obfuscateAdapterSecret(connector));
        }
        return notFound();
    } catch (AttributeConnectorException e) {
        throw new RestApiException(HttpStatus.UNPROCESSABLE_ENTITY, e);
    }
}
 
开发者ID:eclipse,项目名称:keti,代码行数:16,代码来源:AttributeConnectorController.java

示例3: getResourceConnector

@ApiOperation(value = "Retrieves connector configuration for external resource attributes for the given zone.",
        tags = { "Attribute Connector Management" }, response = AttributeConnector.class)
@ApiResponses(
        value = { @ApiResponse(code = 404, message = "Connector configuration for the given zone is not found.") })
@RequestMapping(method = GET, value = V1 + AcsApiUriTemplates.RESOURCE_CONNECTOR_URL)
public ResponseEntity<AttributeConnector> getResourceConnector() {
    try {
        AttributeConnector connector = this.service.retrieveResourceConnector();
        if (connector != null) {
            return ok(obfuscateAdapterSecret(connector));
        }
        return notFound();
    } catch (AttributeConnectorException e) {
        throw new RestApiException(HttpStatus.UNPROCESSABLE_ENTITY, e);
    }
}
 
开发者ID:eclipse,项目名称:keti,代码行数:16,代码来源:AttributeConnectorController.java

示例4: doPutResource

private ResponseEntity<BaseResource> doPutResource(final BaseResource resource, final String resourceIdentifier) {
    try {
        boolean createdResource = this.service.upsertResource(resource);

        URI resourceUri = UriTemplateUtils.expand(MANAGED_RESOURCE_URL, "resourceIdentifier:" + resourceIdentifier);

        if (createdResource) {
            return created(resourceUri.getPath(), false);
        }

        // CHECK if path returns the right info
        return created(resourceUri.getPath(), true);
    } catch (Exception e) {
        throw new RestApiException(HttpStatus.UNPROCESSABLE_ENTITY, e);
    }
}
 
开发者ID:eclipse,项目名称:keti,代码行数:16,代码来源:ResourcePrivilegeManagementController.java

示例5: deleteSubjectConnector

@ApiOperation(value = "Deletes connector configuration for external subject attributes for the given zone.",
        tags = { "Attribute Connector Management" })
@ResponseStatus(value = HttpStatus.NO_CONTENT)
@ApiResponses(value = {
        @ApiResponse(code = 204, message = "Connector configuration for the given zone is successfully deleted."),
        @ApiResponse(code = 404, message = "Connector configuration for the given zone is not found.") })
@RequestMapping(method = DELETE, value = V1 + AcsApiUriTemplates.SUBJECT_CONNECTOR_URL)
public ResponseEntity<Void> deleteSubjectConnector() {
    try {
        Boolean deleted = this.service.deleteSubjectConnector();
        if (deleted) {
            return noContent();
        }
        return notFound();
    } catch (AttributeConnectorException e) {
        throw new RestApiException(HttpStatus.UNPROCESSABLE_ENTITY, e.getMessage(), e);
    }
}
 
开发者ID:eclipse,项目名称:keti,代码行数:18,代码来源:AttributeConnectorController.java

示例6: putSubjectConnector

@ApiOperation(value = "Creates or updates connector configuration for external subject attributes for the given "
        + "zone.", tags = { "Attribute Connector Management" })
@ApiResponses(value = {
        @ApiResponse(code = 201, message = "Connector configuration for the given zone is successfully created.") })
@RequestMapping(method = PUT, value = V1 + AcsApiUriTemplates.SUBJECT_CONNECTOR_URL,
        consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<String> putSubjectConnector(
        @ApiParam(value = "New or updated connector configuration for external subject attributes",
                required = true) @RequestBody final AttributeConnector connector) {
    try {
        boolean connectorCreated = this.service.upsertSubjectConnector(connector);

        if (connectorCreated) {
            // return 201 with empty response body
            return created(V1 + AcsApiUriTemplates.SUBJECT_CONNECTOR_URL, false);
        }
        // return 200 with empty response body
        return ok();
    } catch (AttributeConnectorException e) {
        throw new RestApiException(HttpStatus.UNPROCESSABLE_ENTITY, e.getMessage(), e);
    }
}
 
开发者ID:eclipse,项目名称:keti,代码行数:22,代码来源:AttributeConnectorController.java

示例7: createPolicySet

@ApiOperation(value = "Creates/Updates a policy set for the given zone.", tags = { "Policy Set Management" })
@ApiResponses(value = { @ApiResponse(code = 201,
        message = "Policy set creation successful. Policy set URI is returned in 'Location' header."), })
@RequestMapping(method = PUT, value = POLICY_SET_URL, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<String> createPolicySet(@RequestBody final PolicySet policySet,
        @PathVariable("policySetId") final String policySetId) {

    validatePolicyIdOrFail(policySet, policySetId);

    try {
        this.service.upsertPolicySet(policySet);
        URI policySetUri = UriTemplateUtils.expand(POLICY_SET_URL, "policySetId:" + policySet.getName());
        return created(policySetUri.getPath());
    } catch (PolicyManagementException e) {
        throw new RestApiException(HttpStatus.UNPROCESSABLE_ENTITY, e.getMessage(), e);
    }
}
 
开发者ID:eclipse,项目名称:keti,代码行数:17,代码来源:PolicyManagementController.java

示例8: vote

/**
 * POST  /posts/:id -> get the "id" post.
 */
@RequestMapping(value = "/posts/{id:\\d+}/vote",
    method = RequestMethod.POST,
    produces = MediaType.APPLICATION_JSON_VALUE)
@Timed
public ResponseEntity<PostVoteDTO> vote(@PathVariable Long id, @RequestParam(required = true) String type) {
    log.debug("REST request to vote-up Post : {}", id);

    Post post = postRepository.findByStatusAndId(PostStatus.PUBLIC, id);

    if (post == null || !(type.equals("up") || type.equals("down"))) {
        return new ResponseEntity<>(new PostVoteDTO(), HttpStatus.UNPROCESSABLE_ENTITY);
    }

    String result;
    if (type.equals("up")) {
        result = voteService.voteUp(post, userService.getUserWithAuthorities());
    } else {
        result = voteService.voteDown(post, userService.getUserWithAuthorities());
    }
    return new ResponseEntity<>(new PostVoteDTO(post, result), HttpStatus.OK);
}
 
开发者ID:ugouku,项目名称:shoucang,代码行数:24,代码来源:PostResource.java

示例9: signin

public String signin(String username, String password) {
  try {
    authenticationManager.authenticate(new UsernamePasswordAuthenticationToken(username, password));
    return jwtTokenProvider.createToken(username, userRepository.findByUsername(username).getRoles());
  } catch (AuthenticationException e) {
    throw new CustomException("Invalid username/password supplied", HttpStatus.UNPROCESSABLE_ENTITY);
  }
}
 
开发者ID:murraco,项目名称:spring-boot-jwt,代码行数:8,代码来源:UserService.java

示例10: signup

public String signup(User user) {
  if (!userRepository.existsByUsername(user.getUsername())) {
    user.setPassword(passwordEncoder.encode(user.getPassword()));
    userRepository.save(user);
    return jwtTokenProvider.createToken(user.getUsername(), user.getRoles());
  } else {
    throw new CustomException("Username is already in use", HttpStatus.UNPROCESSABLE_ENTITY);
  }
}
 
开发者ID:murraco,项目名称:spring-boot-jwt,代码行数:9,代码来源:UserService.java

示例11: add

/**
 * Add booking with the specified information.
 *
 * @param bookingVO
 * @return A non-null booking.
 */
@RequestMapping(method = RequestMethod.POST)
public ResponseEntity<Booking> add(@RequestBody BookingVO bookingVO) {
    logger.info(String.format("booking-service add() invoked: %s for %s", bookingService.getClass().getName(), bookingVO.getName()));
    System.out.println(bookingVO);
    Booking booking = new Booking(null, null, null, null, null, null, null);
    BeanUtils.copyProperties(bookingVO, booking);
    try {
        bookingService.add(booking);
    } catch (Exception ex) {
        logger.log(Level.WARNING, "Exception raised add Booking REST Call {0}", ex);
        return new ResponseEntity<>(HttpStatus.UNPROCESSABLE_ENTITY);
    }
    return new ResponseEntity<>(HttpStatus.CREATED);
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Microservices-with-Java-9-Second-Edition,代码行数:20,代码来源:BookingController.java

示例12: add

/**
 * Add restaurant with the specified information.
 *
 * @param restaurantVO
 * @return A non-null restaurant.
 */
@RequestMapping(method = RequestMethod.POST)
public ResponseEntity<Restaurant> add(@RequestBody RestaurantVO restaurantVO) {
    logger.info(String.format("restaurant-service add() invoked: %s for %s", restaurantService.getClass().getName(), restaurantVO.getName()));
    System.out.println(restaurantVO);
    Restaurant restaurant = new Restaurant(null, null, null, null);
    BeanUtils.copyProperties(restaurantVO, restaurant);
    try {
        restaurantService.add(restaurant);
    } catch (Exception ex) {
        logger.log(Level.WARNING, "Exception raised add Restaurant REST Call {0}", ex);
        return new ResponseEntity<>(HttpStatus.UNPROCESSABLE_ENTITY);
    }
    return new ResponseEntity<>(HttpStatus.CREATED);
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Microservices-with-Java-9-Second-Edition,代码行数:20,代码来源:RestaurantController.java

示例13: add

/**
 * Add user with the specified information.
 *
 * @param userVO
 * @return A non-null user.
 */
@RequestMapping(method = RequestMethod.POST)
public ResponseEntity<User> add(@RequestBody UserVO userVO) {
    logger.info(String.format("user-service add() invoked: %s for %s", userService.getClass().getName(), userVO.getName()));
    System.out.println(userVO);
    User user = new User(null, null, null, null, null);
    BeanUtils.copyProperties(userVO, user);
    try {
        userService.add(user);
    } catch (Exception ex) {
        logger.log(Level.WARNING, "Exception raised add Booking REST Call {0}", ex);
        return new ResponseEntity<>(HttpStatus.UNPROCESSABLE_ENTITY);
    }
    return new ResponseEntity<>(HttpStatus.CREATED);
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Microservices-with-Java-9-Second-Edition,代码行数:20,代码来源:UserController.java

示例14: validResourceIdentifierOrFail

private void validResourceIdentifierOrFail(final BaseResource resource, final String resourceIdentifier) {
    if (!resourceIdentifier.equals(resource.getResourceIdentifier())) {
        throw new RestApiException(HttpStatus.UNPROCESSABLE_ENTITY,
                String.format("Resource identifier = %s, does not match the one provided in URI = %s",
                        resource.getResourceIdentifier(), resourceIdentifier));
    }
}
 
开发者ID:eclipse,项目名称:keti,代码行数:7,代码来源:ResourcePrivilegeManagementController.java

示例15: add

/**
 * Add user with the specified information.
 *
 * @param userVO
 * @return A non-null user.
 */
@RequestMapping(method = RequestMethod.POST)
public ResponseEntity<User> add(@RequestBody UserVO userVO) {
    logger.info(String.format("user-service add() invoked: %s for %s", userService.getClass().getName(), userVO.getName()));
    System.out.println(userVO);
    User user = new User(null, null, null, null, null);
    BeanUtils.copyProperties(userVO, user);
    try {
        userService.add(user);
    } catch (Exception ex) {
        logger.log(Level.WARNING, "Exception raised add User REST Call {0}", ex);
        return new ResponseEntity<>(HttpStatus.UNPROCESSABLE_ENTITY);
    }
    return new ResponseEntity<>(HttpStatus.CREATED);
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Microservices-with-Java-9-Second-Edition,代码行数:20,代码来源:UserController.java


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