@Override public ConfigRepoConfig doFetchEntityFromConfig(String id) { return service.getConfigRepo(id); }
private ConfigReposConfig allRepos() { return service.getConfigRepos(); }
public void createConfigRepo(ConfigRepoConfig configRepo, Username username, HttpLocalizedOperationResult result) { CreateConfigRepoCommand command = new CreateConfigRepoCommand(securityService, configRepo, username, result, configRepoExtension); update(username, configRepo.getId(), result, command); }
String createRepo(Request req, Response res) { ConfigRepoConfig repo = buildEntityFromRequestBody(req); haltIfEntityWithSameIdExists(repo); HttpLocalizedOperationResult result = new HttpLocalizedOperationResult(); service.createConfigRepo(repo, currentUsername(), result); return handleCreateOrUpdateResponse(req, res, repo, result); }
String deleteRepo(Request req, Response res) { ConfigRepoConfig repo = fetchEntityFromConfig(req.params(":id")); HttpLocalizedOperationResult result = new HttpLocalizedOperationResult(); service.deleteConfigRepo(repo.getId(), currentUsername(), result); return handleSimpleMessageResponse(res, result); }
public PartialConfigParseResult get(String fingerprint) { PartialConfigParseResult result = fingerprintOfPartialToParseResultMap.get(fingerprint); // config repository was never parsed, check if there are any material clone or update related errors if (result == null) { HealthStateScope healthStateScope = HealthStateScope.forMaterialConfig(configRepoService.findByFingerprint(fingerprint).getMaterialConfig()); List<ServerHealthState> serverHealthStates = serverHealthService.filterByScope(healthStateScope); if (!serverHealthStates.isEmpty()) { result = PartialConfigParseResult.parseFailed(null, represent(serverHealthStates.get(0))); } } //config repository was parsed, but does not have merge or clone related errors. if (result != null && result.getLastFailure() == null) { HealthStateScope healthStateScope = HealthStateScope.forPartialConfigRepo(fingerprint); List<ServerHealthState> serverHealthStates = serverHealthService.filterByScope(healthStateScope); if (!serverHealthStates.isEmpty()) { result.setException(represent(serverHealthStates.get(0))); //clear out the good modification, in case good modification is same as of latest parsed modification if (result.getLatestParsedModification().equals(result.getGoodModification())) { result.setGoodModification(null); result.setPartialConfig(null); } } } return result; }
String updateRepo(Request req, Response res) { String id = req.params(":id"); ConfigRepoConfig repoFromConfig = fetchEntityFromConfig(id); ConfigRepoConfig repoFromRequest = buildEntityFromRequestBody(req); if (isPutRequestStale(req, repoFromConfig)) { throw haltBecauseEtagDoesNotMatch(); } HttpLocalizedOperationResult result = new HttpLocalizedOperationResult(); service.updateConfigRepo(id, repoFromRequest, etagFor(repoFromConfig), currentUsername(), result); return handleCreateOrUpdateResponse(req, res, repoFromRequest, result); }
public void updateConfigRepo(String repoIdToUpdate, ConfigRepoConfig newConfigRepo, String md5OfExistingConfigRepo, Username username, HttpLocalizedOperationResult result) { UpdateConfigRepoCommand command = new UpdateConfigRepoCommand(securityService, entityHashingService, repoIdToUpdate, newConfigRepo, md5OfExistingConfigRepo, username, result, configRepoExtension); update(username, newConfigRepo.getId(), result, command); if (result.isSuccessful()) { result.setMessage("The config repo '" + repoIdToUpdate + "' was updated successfully."); } } }
private ConfigRepoConfig repoFromRequest(Request req) { String repoId = req.queryParams("repoId"); if (null == repoId) { return null; } ConfigRepoConfig repo = service.getConfigRepo(repoId); if (null == repo) { throw HaltApiResponses.haltBecauseNotFound("Could not find a config-repo with id `%s`", repoId); } return repo; } }
public ConfigRepoConfig findByFingerprint(String fingerprint) { return getConfigRepos().stream() .filter(configRepo -> configRepo.getMaterialConfig().getFingerprint().equalsIgnoreCase(fingerprint)) .findFirst().orElse(null); }
public void deleteConfigRepo(String repoId, Username username, HttpLocalizedOperationResult result) { DeleteConfigRepoCommand command = new DeleteConfigRepoCommand(securityService, repoId, username, result); update(username, repoId, result, command); if (result.isSuccessful()) { result.setMessage(LocalizedMessage.resourceDeleteSuccessful("config repo", repoId)); } }
private ConfigRepoConfig repoFromRequest(Request req) { ConfigRepoConfig repo = service.getConfigRepo(req.params(":id")); if (null == repo) { throw HaltApiResponses.haltBecauseNotFound(); } return repo; }
private List<ConfigRepoWithResult> allRepos() { return service.getConfigRepos().stream().map(r -> { PartialConfigParseResult result = dataSource.getLastParseResult(r.getMaterialConfig()); return new ConfigRepoWithResult(r, result, isMaterialUpdateInProgress(r)); }).collect(Collectors.toList()); }
@Override public void onEntityConfigChange(ConfigRepoConfig entity) { if (getConfigRepo(entity.getId()) != null) { materialUpdateService.updateMaterial(converter.toMaterial(entity.getMaterialConfig())); } } });
private ConfigRepoWithResult repoWithResultFromRequest(Request req) { ConfigRepoConfig repo = service.getConfigRepo(req.params(":id")); if (null == repo) { throw HaltApiResponses.haltBecauseNotFound(); } PartialConfigParseResult result = dataSource.getLastParseResult(repo.getMaterialConfig()); return new ConfigRepoWithResult(repo, result, isMaterialUpdateInProgress(repo)); }