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