Search in sources :

Example 6 with FeaturedMod

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"));
}
Also used : FeaturedMod(com.faforever.api.data.domain.FeaturedMod) Test(org.junit.Test)

Example 7 with FeaturedMod

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");
}
Also used : FeaturedMod(com.faforever.api.data.domain.FeaturedMod)

Example 8 with FeaturedMod

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);
}
Also used : GHDeployment(org.kohsuke.github.GHDeployment) FeaturedMod(com.faforever.api.data.domain.FeaturedMod) SneakyThrows(lombok.SneakyThrows)

Example 9 with FeaturedMod

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)));
}
Also used : JsonApiDocument(com.yahoo.elide.jsonapi.models.JsonApiDocument) Resource(com.yahoo.elide.jsonapi.models.Resource) Data(com.yahoo.elide.jsonapi.models.Data) FeaturedMod(com.faforever.api.data.domain.FeaturedMod) Async(org.springframework.scheduling.annotation.Async) ApiOperation(io.swagger.annotations.ApiOperation) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

FeaturedMod (com.faforever.api.data.domain.FeaturedMod)9 Test (org.junit.Test)5 Path (java.nio.file.Path)3 FeaturedModFile (com.faforever.api.featuredmods.FeaturedModFile)2 List (java.util.List)2 SneakyThrows (lombok.SneakyThrows)2 FafApiProperties (com.faforever.api.config.FafApiProperties)1 Deployment (com.faforever.api.config.FafApiProperties.Deployment)1 GitWrapper (com.faforever.api.deployment.git.GitWrapper)1 FeaturedModService (com.faforever.api.featuredmods.FeaturedModService)1 FilePermissionUtil (com.faforever.api.utils.FilePermissionUtil)1 ForgedAllianceExePatcher (com.faforever.commons.fa.ForgedAllianceExePatcher)1 ModReader (com.faforever.commons.mod.ModReader)1 NoCatch.noCatch (com.github.nocatch.NoCatch.noCatch)1 Hashing.md5 (com.google.common.hash.Hashing.md5)1 ByteStreams (com.google.common.io.ByteStreams)1 Files.hash (com.google.common.io.Files.hash)1 Data (com.yahoo.elide.jsonapi.models.Data)1 JsonApiDocument (com.yahoo.elide.jsonapi.models.JsonApiDocument)1 Resource (com.yahoo.elide.jsonapi.models.Resource)1