Search in sources :

Example 36 with PackageRepository

use of com.thoughtworks.go.domain.packagerepository.PackageRepository in project gocd by gocd.

the class PackageRepositoryInternalControllerV1 method verifyConnection.

public String verifyConnection(Request request, Response response) throws IOException {
    PackageRepository packageRepository = buildEntityFromRequestBody(request);
    HttpLocalizedOperationResult result = new HttpLocalizedOperationResult();
    packageRepositoryService.checkConnection(packageRepository, result);
    response.status(result.httpCode());
    return writerForTopLevelObject(request, response, writer -> VerifyConnectionRepresenter.toJSON(writer, result, packageRepository));
}
Also used : HttpLocalizedOperationResult(com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult) PackageRepository(com.thoughtworks.go.domain.packagerepository.PackageRepository)

Example 37 with PackageRepository

use of com.thoughtworks.go.domain.packagerepository.PackageRepository in project gocd by gocd.

the class PackageRepositoryControllerV1 method show.

String show(Request request, Response response) throws IOException {
    String repoId = request.params("repo_id");
    PackageRepository packageRepository = fetchEntityFromConfig(repoId);
    String etag = etagFor(packageRepository);
    if (fresh(request, etag)) {
        return notModified(response);
    }
    setEtagHeader(response, etag);
    return writerForTopLevelObject(request, response, outputWriter -> PackageRepositoryRepresenter.toJSON(outputWriter, packageRepository));
}
Also used : PackageRepository(com.thoughtworks.go.domain.packagerepository.PackageRepository)

Example 38 with PackageRepository

use of com.thoughtworks.go.domain.packagerepository.PackageRepository in project gocd by gocd.

the class PackageRepositoryControllerV1 method create.

String create(Request request, Response response) {
    PackageRepository packageRepository = buildEntityFromRequestBody(request);
    packageRepository.ensureIdExists();
    HttpLocalizedOperationResult result = new HttpLocalizedOperationResult();
    packageRepositoryService.createPackageRepository(packageRepository, currentUsername(), result);
    return handleCreateOrUpdateResponse(request, response, packageRepository, result);
}
Also used : HttpLocalizedOperationResult(com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult) PackageRepository(com.thoughtworks.go.domain.packagerepository.PackageRepository)

Example 39 with PackageRepository

use of com.thoughtworks.go.domain.packagerepository.PackageRepository in project gocd by gocd.

the class PackageRepositoryRepresenter method fromJSON.

public static PackageRepository fromJSON(JsonReader jsonReader) {
    PackageRepository packageRepository = new PackageRepository();
    jsonReader.readStringIfPresent("repo_id", packageRepository::setId);
    jsonReader.readStringIfPresent("name", packageRepository::setName);
    PluginConfiguration pluginConfiguration = PluginConfigurationRepresenter.fromJSON(jsonReader.readJsonObject("plugin_metadata"));
    packageRepository.setPluginConfiguration(pluginConfiguration);
    List<ConfigurationProperty> configuration = ConfigurationPropertyRepresenter.fromJSONArray(jsonReader, "configuration");
    packageRepository.addConfigurations(configuration);
    return packageRepository;
}
Also used : ConfigurationProperty(com.thoughtworks.go.domain.config.ConfigurationProperty) PluginConfiguration(com.thoughtworks.go.domain.config.PluginConfiguration) PackageRepository(com.thoughtworks.go.domain.packagerepository.PackageRepository)

Example 40 with PackageRepository

use of com.thoughtworks.go.domain.packagerepository.PackageRepository in project gocd by gocd.

the class ConfigConverterTest method shouldConvertPackageMaterial.

@Test
void shouldConvertPackageMaterial() {
    PackageRepositories repositories = new PackageRepositories();
    PackageRepository packageRepository = new PackageRepository();
    PackageDefinition definition = new PackageDefinition("package-id", "n", new Configuration());
    packageRepository.addPackage(definition);
    repositories.add(packageRepository);
    BasicCruiseConfig cruiseConfig = new BasicCruiseConfig();
    cruiseConfig.setPackageRepositories(repositories);
    when(cachedGoConfig.currentConfig()).thenReturn(cruiseConfig);
    CRPackageMaterial crPackageMaterial = new CRPackageMaterial("name", "package-id");
    PackageMaterialConfig packageMaterialConfig = (PackageMaterialConfig) configConverter.toMaterialConfig(crPackageMaterial, context, new SCMs());
    assertThat(packageMaterialConfig.getName().toLower()).isEqualTo("name");
    assertThat(packageMaterialConfig.getPackageId()).isEqualTo("package-id");
    assertThat(packageMaterialConfig.getPackageDefinition()).isEqualTo(definition);
}
Also used : SCMs(com.thoughtworks.go.domain.scm.SCMs) PackageMaterialConfig(com.thoughtworks.go.config.materials.PackageMaterialConfig) PackageDefinition(com.thoughtworks.go.domain.packagerepository.PackageDefinition) PackageRepositories(com.thoughtworks.go.domain.packagerepository.PackageRepositories) PackageRepository(com.thoughtworks.go.domain.packagerepository.PackageRepository) Test(org.junit.jupiter.api.Test)

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