use of com.faforever.api.data.domain.FeaturedMod in project faf-java-api by FAForever.
the class FeaturedModEnricherTest method enrich.
@Test
public void enrich() {
FeaturedMod featuredMod = new FeaturedMod();
featuredMod.setTechnicalName("faf");
featuredModEnricher.enrich(featuredMod);
assertThat(featuredMod.getBireusUrl(), is("http://example.com/faf"));
}
use of com.faforever.api.data.domain.FeaturedMod in project faf-java-api by FAForever.
the class GitHubDeploymentService method performDeployment.
private void performDeployment(GHDeployment ghDeployment, GHRepository repository, int deploymentId) throws IOException {
String modName = ghDeployment.getPayload();
FeaturedMod featuredMod = featuredModService.findModByTechnicalName(modName).orElseThrow(() -> new IllegalArgumentException("No such mod: " + modName));
applicationContext.getBean(LegacyFeaturedModDeploymentTask.class).setStatusDescriptionListener(statusText -> updateDeploymentStatus(deploymentId, repository, GHDeploymentState.PENDING, statusText)).setFeaturedMod(featuredMod).run();
updateDeploymentStatus(deploymentId, repository, GHDeploymentState.SUCCESS, "Successfully deployed");
}
use of com.faforever.api.data.domain.FeaturedMod in project faf-java-api by FAForever.
the class GitHubDeploymentService method createDeploymentIfEligible.
@SneakyThrows
void createDeploymentIfEligible(Push push) {
String ref = push.getRef();
Optional<FeaturedMod> optional = featuredModService.findByGitUrlAndGitBranch(push.getRepository().gitHttpTransportUrl(), push.getRef().replace("refs/heads/", ""));
if (!optional.isPresent()) {
log.warn("No configuration present for repository '{}' and ref '{}'", push.getRepository().gitHttpTransportUrl(), push.getRef());
return;
}
GHDeployment ghDeployment = push.getRepository().createDeployment(ref).autoMerge(false).environment(fafApiProperties.getGitHub().getDeploymentEnvironment()).payload(optional.get().getTechnicalName()).requiredContexts(Collections.emptyList()).create();
log.info("Created deployment: {}", ghDeployment);
}
use of com.faforever.api.data.domain.FeaturedMod in project faf-java-api by FAForever.
the class FeaturedModsController method getFiles.
@Async
@RequestMapping(path = "/{modId}/files/{version}")
@ApiOperation("Lists the required files for a specific featured mod version")
public CompletableFuture<JsonApiDocument> getFiles(@PathVariable("modId") int modId, @PathVariable("version") String version, @RequestParam(value = "page[number]", required = false) Integer page) {
Integer innerPage = Optional.ofNullable(page).orElse(0);
if (innerPage > 1) {
return CompletableFuture.completedFuture(new JsonApiDocument(new Data<>(Collections.emptyList())));
}
ImmutableMap<Integer, FeaturedMod> mods = Maps.uniqueIndex(featuredModService.getFeaturedMods(), FeaturedMod::getId);
FeaturedMod featuredMod = mods.get(modId);
Integer innerVersion = "latest".equals(version) ? null : Integer.valueOf(version);
List<Resource> values = featuredModService.getFiles(featuredMod.getTechnicalName(), innerVersion).stream().map(modFileMapper()).collect(Collectors.toList());
return CompletableFuture.completedFuture(new JsonApiDocument(new Data<>(values)));
}
Aggregations