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


Java HttpStatus.CONFLICT属性代码示例

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


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

示例1: create

public Topic create(String name) {
	if (repository.findByName(name).isPresent()) {
		throw new HttpClientErrorException(HttpStatus.CONFLICT, name + " 이미 등록된 태그 입니다.");
	}

	return repository.save(new Topic(name));
}
 
开发者ID:spring-sprout,项目名称:osoon,代码行数:7,代码来源:TopicService.java

示例2: deleteImageResource

@GetMapping(path="/deleteImage")
@ResponseBody
public ResponseEntity<Object> deleteImageResource (@RequestParam String email,
                                                   @RequestParam String fileName) {
    ResponseEntity response = null;
    User user;

    if(email.equals("") || email == null){
        response = new ResponseEntity<>("Email must not be empty", HttpStatus.NOT_ACCEPTABLE);
    }
    if(fileName.equals("") || fileName == null){
        response = new ResponseEntity<>("File name must not be empty", HttpStatus.NOT_ACCEPTABLE);
    }

    user = userRepository.findByEmail(email);
    if(user == null){
        response = new ResponseEntity<>("User not found with provided email", HttpStatus.CONFLICT);
    }

    try{
        imageRepository.deleteByFileName(fileName);
    }catch(Exception e){
        response = new ResponseEntity<>("Image not found", HttpStatus.BAD_REQUEST);
    }

    return response;
}
 
开发者ID:KobePig,项目名称:NutriBuddi,代码行数:27,代码来源:ImageController.java

示例3: createCustomer

@SuppressWarnings({ "unchecked", "rawtypes" })
@RequestMapping(value = "/customer/", method = RequestMethod.POST)
public ResponseEntity<?> createCustomer(@RequestBody Customer customer, UriComponentsBuilder ucBuilder) {
	logger.info("Creating Customer : {}", customer);
	
	System.out.println(customerService.customerExist(customer));
	
	if (customerService.customerExist(customer)) {
		logger.error("Unable to create a customer with username {}", customer.getUsername());
		return new ResponseEntity(new CustomErrorType("A customer with username " + 
		customer.getUsername() + " already exists."),HttpStatus.CONFLICT);
	}
	
	Customer currentCustomer = customerService.createCustomer(customer);
	Long currentCustomerId = currentCustomer.getCustomerId();
	JSONObject customerInfo = new JSONObject();
	customerInfo.put("customerId", currentCustomerId);

	HttpHeaders headers = new HttpHeaders();
	headers.setLocation(ucBuilder.path("/api/customer/{customerId").buildAndExpand(customer.getCustomerId()).toUri());;
	return new ResponseEntity<JSONObject>(customerInfo, HttpStatus.CREATED);
}
 
开发者ID:dockersamples,项目名称:atsea-sample-shop-app,代码行数:22,代码来源:CustomerController.java

示例4: handlePackageDeleteException

@ExceptionHandler(PackageDeleteException.class)
public ResponseEntity<Map<String, String>> handlePackageDeleteException(PackageDeleteException error) {
	// TODO investigate why SkipperErrorAttributes is not being invoked.
	Map<String, String> map = new HashMap<>();
	map.put("exception", error.getClass().getName());
	map.put("message", error.getMessage());
	return new ResponseEntity<Map<String, String>>(map, HttpStatus.CONFLICT);
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-skipper,代码行数:8,代码来源:ReleaseController.java

示例5: handleDataIntegrityViolationException

@Loggable
@ResponseStatus(code = HttpStatus.CONFLICT)
@ExceptionHandler(DataIntegrityViolationException.class)
public ErrorDto handleDataIntegrityViolationException(DataIntegrityViolationException ex) {
    if (uniqueConstraintList != null && ex.getCause() != null && ex.getCause() instanceof ConstraintViolationException) {
        Optional<DataUniqueConstraint> matchCons = uniqueConstraintList.stream().filter((cons) ->
                ((ConstraintViolationException) ex.getCause()).getConstraintName().contains(cons.getConstraintName())).findFirst();
        if (matchCons.isPresent()) {
            return ErrorDto.builder()
                    .errorCode(ErrorCodes.DATA_VALIDATION)
                    .error(ValidationErrorDto.builder()
                            .errorCode("UNIQUE")
                            .fieldName(Arrays.stream(matchCons.get().getFieldNames())
                                    .map(Object::toString)
                                    .collect(Collectors.joining(", ")))
                            .build())
                    .message(ex.getLocalizedMessage())
                    .build();
        }
    }

    return ErrorDto.builder()
            .errorCode(ErrorCodes.UNKNOWN)
            .message(ex.getLocalizedMessage())
            .build();
}
 
开发者ID:rozidan,项目名称:project-template,代码行数:26,代码来源:DataExceptionHandlers.java

示例6: register

/**
 * Authenticates an user with an given user and password. Returns Unauthorized,
 * when username or password is not correct.
 * 
 * @param username
 *            Unique Username that is supposed to be set
 * @param password
 *            Password that is supposed to be set
 * @return User and Password or Unauthorized
 */
@RequestMapping(value = "/register", method = RequestMethod.POST)
public Object register(@RequestBody AuthenticationRequestBody body) {
	String username = body.username;
	char[] password = body.password.toCharArray();
	log("New User registration ( username:'" + username + "' , password: '" + String.valueOf(password) + "' )");
	ServiceBundle service = new ServiceBundle();
	Optional<User> userOpt = service.registerUser(username, password);
	if (userOpt.isPresent()) {
		return userOpt.get();
	} else {
		return new ResponseEntity<String>(
				"The registration failed. Does there maybe exist an user with the same Name?", HttpStatus.CONFLICT);
	}
}
 
开发者ID:SystemOfAProg,项目名称:VS2Labor,代码行数:24,代码来源:FunctionsController.java

示例7: handleDataAccessExceptions

@ExceptionHandler(DataAccessException.class)
@ResponseStatus(value=HttpStatus.CONFLICT)
public ModelAndView handleDataAccessExceptions(HttpServletRequest request, DataAccessException ex) {
    logger.warn("DataAccessException: " + request.getRequestURL(), ex);
    ModelAndView mav = new ModelAndView();
    mav.setViewName("error");
    return mav;
}
 
开发者ID:university-information-system,项目名称:uis,代码行数:8,代码来源:GlobalExceptionHandler.java

示例8: createBot

/**
 * Creates a new Bot configuration.
 *
 * @param user      the authenticated user.
 * @param botConfig the new Bot config.
 * @return 201 'Created' HTTP status code if create successful, some other HTTP status code otherwise.
 */
@PreAuthorize("hasRole('ADMIN')")
@RequestMapping(method = RequestMethod.POST)
public ResponseEntity<?> createBot(@AuthenticationPrincipal User user, @RequestBody BotConfig botConfig) {

    LOG.info("POST " + CONFIG_ENDPOINT_BASE_URI + " - createBot()"); // - caller: " + user.getUsername());
    LOG.info("Request: " + botConfig);

    final BotConfig createdConfig = botConfigService.createBotConfig(botConfig);
    return createdConfig == null
            ? new ResponseEntity<>(HttpStatus.CONFLICT)
            : buildResponseEntity(createdConfig, HttpStatus.CREATED);
}
 
开发者ID:gazbert,项目名称:bxbot-ui-server,代码行数:19,代码来源:BotsConfigController.java

示例9: handleInvalidMetadataDocumentState

@ResponseStatus(HttpStatus.CONFLICT)
@ExceptionHandler(InvalidMetadataDocumentStateException.class)
public @ResponseBody
ExceptionInfo handleInvalidMetadataDocumentState(HttpServletRequest request, Exception e) {
    getLog().warn(String.format("Attempt a failed metadata document state transition at '%s'; " +
                    "this will generate a CONFLICT RESPONSE",
            request.getRequestURL().toString()));
    getLog().debug("Handling InvalidMetadataDocumentStateException and returning CONFLICT response", e);
    return new ExceptionInfo(request.getRequestURL().toString(), e.getLocalizedMessage());
}
 
开发者ID:HumanCellAtlas,项目名称:ingest-core,代码行数:10,代码来源:GlobalStateExceptionHandler.java

示例10: createUser

@RequestMapping(value = "/users", method = RequestMethod.POST)
public ResponseEntity<?> createUser(@RequestBody User user, UriComponentsBuilder ucBuilder) {
    logger.info("Creating User : {}", user);

    if (userService.isUserExist(user)) {
        logger.error("Unable to create. A User with name {} already exist", user.getUsername());
        return new ResponseEntity(new CustomErrorType("Unable to create. A User with name " +
                user.getUsername() + " already exist."),HttpStatus.CONFLICT);
    }
    userService.addUser(user);

    HttpHeaders headers = new HttpHeaders();
    headers.setLocation(ucBuilder.path("/api/user/{id}").buildAndExpand(user.getId()).toUri());
    return new ResponseEntity<String>(headers, HttpStatus.CREATED);
}
 
开发者ID:noveogroup-amorgunov,项目名称:spring-mvc-react,代码行数:15,代码来源:UserController.java

示例11: processConcurrencyError

@ExceptionHandler(ConcurrencyFailureException.class)
@ResponseStatus(HttpStatus.CONFLICT)
@ResponseBody
public ErrorVM processConcurrencyError(ConcurrencyFailureException ex) {
    return new ErrorVM(ErrorConstants.ERR_CONCURRENCY_FAILURE);
}
 
开发者ID:oktadeveloper,项目名称:jhipster-microservices-example,代码行数:6,代码来源:ExceptionTranslator.java

示例12: handleDuplicateEntityException

@ExceptionHandler(value = {DuplicateEntityException.class})
@ResponseStatus(HttpStatus.CONFLICT)
public Resource handleDuplicateEntityException(DuplicateEntityException ex) {
    return new Resource(ex.getMessage());
}
 
开发者ID:tsypuk,项目名称:springrestdoc,代码行数:5,代码来源:SpeakerController.java

示例13: exception

@CrossOrigin
@ResponseStatus(HttpStatus.CONFLICT)
@ExceptionHandler(UserProjectException.class)
public MessageDTO exception(UserProjectException e) {
    return new MessageDTO(e.getMessage());
}
 
开发者ID:Code4SocialGood,项目名称:c4sg-services,代码行数:6,代码来源:C4SGController.java

示例14: userExists

@ExceptionHandler(UserAlreadyExistsException.class)
@ResponseStatus(HttpStatus.CONFLICT)
@ResponseBody
public ErrorInfo userExists(HttpServletRequest req, Exception ex) {
	return new ErrorInfo(req.getRequestURL().toString(), ex, HttpStatus.CONFLICT.value());
}
 
开发者ID:oojorgeoo89,项目名称:QuizZz,代码行数:6,代码来源:RestExceptionHandler.java

示例15: processConcurencyError

@ExceptionHandler(ConcurrencyFailureException.class)
@ResponseStatus(HttpStatus.CONFLICT)
@ResponseBody
public ErrorDTO processConcurencyError(ConcurrencyFailureException ex) {
    return new ErrorDTO(ErrorConstants.ERR_CONCURRENCY_FAILURE);
}
 
开发者ID:ugouku,项目名称:shoucang,代码行数:6,代码来源:ExceptionTranslator.java


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