Search in sources :

Example 1 with GlobalModuleGroup

use of org.jboss.pnc.common.json.GlobalModuleGroup in project pnc by project-ncl.

the class BpmMock method mockGlobalConfig.

private static GlobalModuleGroup mockGlobalConfig() {
    GlobalModuleGroup bpmConfig = Mockito.mock(GlobalModuleGroup.class);
    Mockito.when(bpmConfig.getBpmUrl()).thenReturn("http://bpm.svc.cluster.local/business-central");
    Mockito.when(bpmConfig.getIndyUrl()).thenReturn("http://indy.svc.cluster.local/");
    return bpmConfig;
}
Also used : GlobalModuleGroup(org.jboss.pnc.common.json.GlobalModuleGroup)

Example 2 with GlobalModuleGroup

use of org.jboss.pnc.common.json.GlobalModuleGroup in project pnc by project-ncl.

the class GlobalConfigTest method loadGlobalConfigTest.

@Test
public void loadGlobalConfigTest() throws ConfigurationParseException {
    Configuration configuration = new Configuration();
    GlobalModuleGroup globalConfig = configuration.getGlobalConfig();
    assertNotNull(globalConfig);
    assertEquals("http://127.0.0.1:8001", globalConfig.getBpmUrl());
    assertEquals("http://127.0.0.1:8002", globalConfig.getCartographerUrl());
    assertEquals("http://127.0.0.1:8003", globalConfig.getDaUrl());
    assertEquals("http://127.0.0.1:8004", globalConfig.getIndyUrl());
    assertEquals("http://127.0.0.1:8005", globalConfig.getPncUrl());
    assertEquals("http://127.0.0.1:8006", globalConfig.getRepourUrl());
    assertEquals("http://127.0.0.1:8007", globalConfig.getDelAnalUrl());
    assertEquals("http://1.2.3.4", globalConfig.getExternalBifrostUrl());
    assertEquals("http://1.2.3.5", globalConfig.getExternalDaUrl());
    assertEquals("http://1.2.3.6", globalConfig.getExternalCausewayUrl());
    assertEquals("http://1.2.3.7", globalConfig.getExternalIndyUrl());
    assertEquals("http://1.2.3.8", globalConfig.getExternalKafkaStoreUrl());
    assertEquals("http://1.2.3.9", globalConfig.getExternalPncUrl());
    assertEquals("http://1.2.3.10", globalConfig.getExternalRepourUrl());
}
Also used : Configuration(org.jboss.pnc.common.Configuration) GlobalModuleGroup(org.jboss.pnc.common.json.GlobalModuleGroup) Test(org.junit.Test)

Example 3 with GlobalModuleGroup

use of org.jboss.pnc.common.json.GlobalModuleGroup in project pnc by project-ncl.

the class BuildTaskEndpointImpl method build.

@Override
public Response build(BuildExecutionConfigurationRest buildExecutionConfiguration, String usernameTriggered, String callbackUrl) {
    try {
        logger.debug("Endpoint /execute-build requested for buildTaskId [{}], from [{}]", buildExecutionConfiguration.getId(), request.getRemoteAddr());
        boolean temporaryBuild = buildExecutionConfiguration.isTempBuild();
        MDCUtils.addBuildContext(buildExecutionConfiguration.getBuildContentId(), temporaryBuild, ExpiresDate.getTemporaryBuildExpireDate(systemConfig.getTemporaryBuildsLifeSpan(), temporaryBuild), userService.currentUser().getId().toString());
        logger.info("Build execution requested.");
        logger.debug("Staring new build execution for configuration: {}. Caller requested a callback to {}.", buildExecutionConfiguration.toString(), callbackUrl);
        BuildExecutionSession buildExecutionSession = buildExecutorTriggerer.executeBuild(buildExecutionConfiguration.toBuildExecutionConfiguration(), callbackUrl, userService.currentUserToken());
        GlobalModuleGroup globalConfig = configuration.getGlobalConfig();
        UriBuilder uriBuilder = UriBuilder.fromUri(globalConfig.getExternalPncUrl()).path("/ws/executor/notifications");
        AcceptedResponse acceptedResponse = new AcceptedResponse(buildExecutionConfiguration.getId(), uriBuilder.build().toString());
        return Response.ok().entity(acceptedResponse).build();
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
        throw new RuntimeException(e);
    } finally {
        MDCUtils.removeBuildContext();
    }
}
Also used : BuildExecutionSession(org.jboss.pnc.spi.executor.BuildExecutionSession) AcceptedResponse(org.jboss.pnc.rest.endpoints.internal.dto.AcceptedResponse) GlobalModuleGroup(org.jboss.pnc.common.json.GlobalModuleGroup) UriBuilder(javax.ws.rs.core.UriBuilder) InvalidEntityException(org.jboss.pnc.facade.validation.InvalidEntityException)

Example 4 with GlobalModuleGroup

use of org.jboss.pnc.common.json.GlobalModuleGroup in project pnc by project-ncl.

the class BuildTaskEndpointImpl method build.

@Override
public Response build(BuildExecutionConfigurationWithCallbackRest buildExecutionConfiguration) {
    try {
        String callbackUrl = buildExecutionConfiguration.getCompletionCallbackUrl();
        boolean temporaryBuild = buildExecutionConfiguration.isTempBuild();
        MDCUtils.addBuildContext(buildExecutionConfiguration.getBuildContentId(), temporaryBuild, ExpiresDate.getTemporaryBuildExpireDate(systemConfig.getTemporaryBuildsLifeSpan(), temporaryBuild), userService.currentUser().getId().toString());
        logger.info("Build execution requested.");
        logger.debug("Staring new build execution for configuration: {}. Caller requested a callback to {}.", buildExecutionConfiguration.toString(), callbackUrl);
        BuildExecutionSession buildExecutionSession = buildExecutorTriggerer.executeBuild(buildExecutionConfiguration.toBuildExecutionConfiguration(), callbackUrl, userService.currentUserToken());
        GlobalModuleGroup globalConfig = configuration.getGlobalConfig();
        UriBuilder uriBuilder = UriBuilder.fromUri(globalConfig.getExternalPncUrl()).path("/ws/executor/notifications");
        AcceptedResponse acceptedResponse = new AcceptedResponse(buildExecutionConfiguration.getId(), uriBuilder.build().toString());
        return Response.ok().entity(acceptedResponse).build();
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
        throw new RuntimeException(e);
    } finally {
        MDCUtils.removeBuildContext();
    }
}
Also used : BuildExecutionSession(org.jboss.pnc.spi.executor.BuildExecutionSession) AcceptedResponse(org.jboss.pnc.rest.endpoints.internal.dto.AcceptedResponse) GlobalModuleGroup(org.jboss.pnc.common.json.GlobalModuleGroup) UriBuilder(javax.ws.rs.core.UriBuilder) InvalidEntityException(org.jboss.pnc.facade.validation.InvalidEntityException)

Example 5 with GlobalModuleGroup

use of org.jboss.pnc.common.json.GlobalModuleGroup in project pnc by project-ncl.

the class AbstractArtifactMapper method fillDeployAndPublicUrl.

private void fillDeployAndPublicUrl(org.jboss.pnc.model.Artifact artifactDB, Consumer<String> deployUrlSetter, Consumer<String> publicUrlSetter) {
    GlobalModuleGroup globalConfig = null;
    try {
        globalConfig = config.getGlobalConfig();
    } catch (ConfigurationParseException e) {
        logger.error("Cannot read configuration", e);
    }
    if (globalConfig == null) {
        return;
    }
    TargetRepository targetRepository = artifactDB.getTargetRepository();
    if (targetRepository == null) {
        logger.error("Artifact DB object does not have target repository set: {}", artifactDB);
        return;
    }
    RepositoryType repositoryType = targetRepository.getRepositoryType();
    if (repositoryType.equals(RepositoryType.MAVEN) || repositoryType.equals(RepositoryType.NPM)) {
        if (artifactDB.getDeployPath() == null || artifactDB.getDeployPath().equals("")) {
            deployUrlSetter.accept("");
            publicUrlSetter.accept("");
        } else {
            try {
                deployUrlSetter.accept(UrlUtils.buildUrl(globalConfig.getIndyUrl(), targetRepository.getRepositoryPath(), artifactDB.getDeployPath()));
                publicUrlSetter.accept(UrlUtils.buildUrl(globalConfig.getExternalIndyUrl(), targetRepository.getRepositoryPath(), artifactDB.getDeployPath()));
            } catch (MalformedURLException e) {
                logger.error("Cannot construct internal artifactDB URL.", e);
                deployUrlSetter.accept(null);
                publicUrlSetter.accept(null);
            }
        }
    } else {
        deployUrlSetter.accept(artifactDB.getOriginUrl());
        publicUrlSetter.accept(artifactDB.getOriginUrl());
    }
}
Also used : TargetRepository(org.jboss.pnc.model.TargetRepository) MalformedURLException(java.net.MalformedURLException) ConfigurationParseException(org.jboss.pnc.common.json.ConfigurationParseException) GlobalModuleGroup(org.jboss.pnc.common.json.GlobalModuleGroup) RepositoryType(org.jboss.pnc.enums.RepositoryType)

Aggregations

GlobalModuleGroup (org.jboss.pnc.common.json.GlobalModuleGroup)10 Before (org.junit.Before)4 UriBuilder (javax.ws.rs.core.UriBuilder)2 Configuration (org.jboss.pnc.common.Configuration)2 IndyRepoDriverModuleConfig (org.jboss.pnc.common.json.moduleconfig.IndyRepoDriverModuleConfig)2 InvalidEntityException (org.jboss.pnc.facade.validation.InvalidEntityException)2 AcceptedResponse (org.jboss.pnc.rest.endpoints.internal.dto.AcceptedResponse)2 BuildExecutionSession (org.jboss.pnc.spi.executor.BuildExecutionSession)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 File (java.io.File)1 MalformedURLException (java.net.MalformedURLException)1 Properties (java.util.Properties)1 BootStatus (org.commonjava.propulsor.boot.BootStatus)1 ConfigurationParseException (org.jboss.pnc.common.json.ConfigurationParseException)1 ModuleConfigJson (org.jboss.pnc.common.json.ModuleConfigJson)1 PNCModuleGroup (org.jboss.pnc.common.json.PNCModuleGroup)1 ScmModuleConfig (org.jboss.pnc.common.json.moduleconfig.ScmModuleConfig)1 SystemConfig (org.jboss.pnc.common.json.moduleconfig.SystemConfig)1 UIModuleConfig (org.jboss.pnc.common.json.moduleconfig.UIModuleConfig)1 PncConfigProvider (org.jboss.pnc.common.json.moduleprovider.PncConfigProvider)1