use of com.thoughtworks.go.domain.packagerepository.PackageRepository in project gocd by gocd.
the class PackageRepositoryControllerV1 method remove.
String remove(Request request, Response response) {
String repoId = request.params("repo_id");
HttpLocalizedOperationResult result = new HttpLocalizedOperationResult();
PackageRepository packageRepository = fetchEntityFromConfig(repoId);
packageRepositoryService.deleteRepository(currentUsername(), packageRepository, result);
return handleSimpleMessageResponse(response, result);
}
use of com.thoughtworks.go.domain.packagerepository.PackageRepository in project gocd by gocd.
the class PackageRepositoryRepresenter method toJSON.
public static void toJSON(OutputWriter outputWriter, PackageRepository packageRepository) {
outputWriter.addLinks(linkWriter -> {
linkWriter.addLink("self", Routes.PackageRepository.self(packageRepository.getId()));
linkWriter.addAbsoluteLink("doc", Routes.PackageRepository.DOC);
linkWriter.addLink("find", Routes.PackageRepository.FIND);
});
outputWriter.add("repo_id", packageRepository.getId());
outputWriter.add("name", packageRepository.getName());
outputWriter.addChild("plugin_metadata", childWriter -> PluginConfigurationRepresenter.toJSON(childWriter, packageRepository.getPluginConfiguration()));
outputWriter.addChildList("configuration", configWriter -> ConfigurationPropertyRepresenter.toJSON(configWriter, packageRepository.getConfiguration()));
outputWriter.addChild("_embedded", embeddedWriter -> embeddedWriter.addChildList("packages", packageWriter -> PackagesRepresenter.toJSON(packageWriter, packageRepository.getPackages())));
if (!packageRepository.errors().isEmpty()) {
outputWriter.addChild("errors", errorWriter -> {
HashMap<String, String> errorMapping = new HashMap<>();
new ErrorGetter(errorMapping).toJSON(errorWriter, packageRepository);
});
}
}
use of com.thoughtworks.go.domain.packagerepository.PackageRepository in project gocd by gocd.
the class PackageRepositoryControllerV1 method update.
String update(Request request, Response response) {
PackageRepository packageRepository = buildEntityFromRequestBody(request);
String repoId = request.params("repo_id");
PackageRepository oldPackageRepository = fetchEntityFromConfig(repoId);
String etag = etagFor(oldPackageRepository);
HttpLocalizedOperationResult result = new HttpLocalizedOperationResult();
if (isPutRequestStale(request, oldPackageRepository)) {
throw haltBecauseEtagDoesNotMatch("package repository", repoId);
}
packageRepositoryService.updatePackageRepository(packageRepository, currentUsername(), etag, result, repoId);
setEtagHeader(packageRepository, response);
return handleCreateOrUpdateResponse(request, response, packageRepository, result);
}
use of com.thoughtworks.go.domain.packagerepository.PackageRepository in project gocd by gocd.
the class BasicCruiseConfig method savePackageRepository.
@Override
public void savePackageRepository(final PackageRepository packageRepository) {
packageRepository.clearEmptyConfigurations();
if (StringUtils.isBlank(packageRepository.getRepoId())) {
packageRepository.setId(UUID.randomUUID().toString());
}
PackageRepository existingPackageRepository = packageRepositories.find(packageRepository.getRepoId());
if (existingPackageRepository == null) {
packageRepositories.add(packageRepository);
} else {
existingPackageRepository.setName(packageRepository.getName());
existingPackageRepository.setPluginConfiguration(packageRepository.getPluginConfiguration());
existingPackageRepository.setConfiguration(packageRepository.getConfiguration());
}
}
use of com.thoughtworks.go.domain.packagerepository.PackageRepository in project gocd by gocd.
the class BasicCruiseConfig method savePackageDefinition.
@Override
public void savePackageDefinition(PackageDefinition packageDefinition) {
packageDefinition.clearEmptyConfigurations();
PackageRepository packageRepository = packageRepositories.find(packageDefinition.getRepository().getId());
packageDefinition.setId(UUID.randomUUID().toString());
packageRepository.addPackage(packageDefinition);
}
Aggregations