Source:
<code>public ResponseEntity addOrUpdateRepository(@ApiParam(value = "The storageId", required = true) @PathVariable String storageId, @ApiParam(value = "The repositoryId", required = true) @PathVariable String repositoryId, @ApiParam(value = "The repository object", required = true) @RequestBody @Validated({ Default.class, ProxyConfigurationFormChecks.class }) RepositoryForm repositoryForm, BindingResult bindingResult, @RequestHeader(HttpHeaders.ACCEPT) String accept) { if (bindingResult.hasErrors()) { throw new RequestBodyValidationException(FAILED_SAVE_REPOSITORY, bindingResult); } <START> if(configurationManagementService.getConfiguration().getStorage(storageId) != null) <END> { try { MutableRepository repository = conversionService.convert(repositoryForm, MutableRepository.class); logger.debug("Creating repository " + storageId + ":" + repositoryId + "..."); configurationManagementService.saveRepository(storageId, repository); final RepositoryPath repositoryPath = repositoryPathResolver.resolve(new Repository(repository)); if (!Files.exists(repositoryPath)) { repositoryManagementService.createRepository(storageId, repository.getId()); } return getSuccessfulResponseEntity(SUCCESSFUL_REPOSITORY_SAVE, accept); } catch (IOException | ConfigurationException | RepositoryManagementStrategyException e) { logger.error(e.getMessage(), e); return getFailedResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR, FAILED_REPOSITORY_SAVE, accept); } } else { return getFailedResponseEntity(HttpStatus.NOT_FOUND,REPOSITORY_NOT_FOUND, accept); } }</code><technical_language>This good, bindingResult check executed if storageId exists. In other words, this: suggestion if(configurationManagementService.getConfiguration().getStorage(storageId) != null) { if (bindingResult.hasErrors()) { throw new RequestBodyValidationException(FAILED_SAVE_REPOSITORY, bindingResult); } // rest of code... } else { // }</technical_language>

Target:
public ResponseEntity addOrUpdateRepository(@ApiParam(value = "The storageId", required = true) @PathVariable String storageId, @ApiParam(value = "The repositoryId", required = true) @PathVariable String repositoryId, @ApiParam(value = "The repository object", required = true) @RequestBody @Validated({ Default.class, ProxyConfigurationFormChecks.class }) RepositoryForm repositoryForm, BindingResult bindingResult, @RequestHeader(HttpHeaders.ACCEPT) String accept) { if (configurationManagementService.getConfiguration().getStorage(storageId) != null) { if (bindingResult.hasErrors()) { throw new RequestBodyValidationException(FAILED_SAVE_REPOSITORY, bindingResult); } try { MutableRepository repository = conversionService.convert(repositoryForm, MutableRepository.class); logger.debug("Creating repository " + storageId + ":" + repositoryId + "..."); configurationManagementService.saveRepository(storageId, repository); final RepositoryPath repositoryPath = repositoryPathResolver.resolve(new Repository(repository)); if (!Files.exists(repositoryPath)) { repositoryManagementService.createRepository(storageId, repository.getId()); } return getSuccessfulResponseEntity(SUCCESSFUL_REPOSITORY_SAVE, accept); } catch (IOException | ConfigurationException | RepositoryManagementStrategyException e) { logger.error(e.getMessage(), e); return getFailedResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR, FAILED_REPOSITORY_SAVE, accept); } } else { return getFailedResponseEntity(HttpStatus.NOT_FOUND, STORAGE_NOT_FOUND, accept); } }