Search in sources :

Example 61 with PackageRepository

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);
}
Also used : HttpLocalizedOperationResult(com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult) PackageRepository(com.thoughtworks.go.domain.packagerepository.PackageRepository)

Example 62 with PackageRepository

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);
        });
    }
}
Also used : OutputWriter(com.thoughtworks.go.api.base.OutputWriter) JsonReader(com.thoughtworks.go.api.representers.JsonReader) List(java.util.List) ConfigurationPropertyRepresenter(com.thoughtworks.go.api.representers.ConfigurationPropertyRepresenter) ErrorGetter(com.thoughtworks.go.api.representers.ErrorGetter) PluginConfiguration(com.thoughtworks.go.domain.config.PluginConfiguration) HashMap(java.util.HashMap) Routes(com.thoughtworks.go.spark.Routes) PackageRepository(com.thoughtworks.go.domain.packagerepository.PackageRepository) PluginConfigurationRepresenter(com.thoughtworks.go.api.representers.PluginConfigurationRepresenter) ConfigurationProperty(com.thoughtworks.go.domain.config.ConfigurationProperty) HashMap(java.util.HashMap) ErrorGetter(com.thoughtworks.go.api.representers.ErrorGetter)

Example 63 with 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);
}
Also used : HttpLocalizedOperationResult(com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult) PackageRepository(com.thoughtworks.go.domain.packagerepository.PackageRepository)

Example 64 with PackageRepository

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());
    }
}
Also used : PackageRepository(com.thoughtworks.go.domain.packagerepository.PackageRepository)

Example 65 with PackageRepository

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);
}
Also used : PackageRepository(com.thoughtworks.go.domain.packagerepository.PackageRepository)

Aggregations

PackageRepository (com.thoughtworks.go.domain.packagerepository.PackageRepository)89 Test (org.junit.jupiter.api.Test)46 PackageDefinition (com.thoughtworks.go.domain.packagerepository.PackageDefinition)40 PackageRepositories (com.thoughtworks.go.domain.packagerepository.PackageRepositories)39 HttpLocalizedOperationResult (com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult)23 Packages (com.thoughtworks.go.domain.packagerepository.Packages)13 Username (com.thoughtworks.go.server.domain.Username)13 Test (org.junit.Test)13 RepositoryConfiguration (com.thoughtworks.go.plugin.api.material.packagerepository.RepositoryConfiguration)9 PluginConfiguration (com.thoughtworks.go.domain.config.PluginConfiguration)7 ValidationResult (com.thoughtworks.go.plugin.api.response.validation.ValidationResult)7 BeforeEach (org.junit.jupiter.api.BeforeEach)6 PackageMaterialConfig (com.thoughtworks.go.config.materials.PackageMaterialConfig)5 UpdateConfigFromUI (com.thoughtworks.go.config.update.UpdateConfigFromUI)5 ConfigurationProperty (com.thoughtworks.go.domain.config.ConfigurationProperty)5 PackageConfigurations (com.thoughtworks.go.plugin.access.packagematerial.PackageConfigurations)5 XsdValidationException (com.thoughtworks.go.util.XsdValidationException)5 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)4 GoConfigInvalidException (com.thoughtworks.go.config.exceptions.GoConfigInvalidException)4 ConfigurationValue (com.thoughtworks.go.domain.config.ConfigurationValue)4