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));
}
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));
}
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);
}
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;
}
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);
}
Aggregations