Search in sources :

Example 11 with InterpolationException

use of org.codehaus.plexus.interpolation.InterpolationException in project indy by Commonjava.

the class AbstractKojiIT method initTestConfig.

@Override
protected void initTestConfig(CoreServerFixture fixture) throws IOException {
    super.initTestConfig(fixture);
    withNewClient((client) -> {
        try {
            File clientKeyCertPem = getClientKeyCertPem(client);
            File serverCertsPem = getServerCertsPem(client);
            Properties properties = System.getProperties();
            properties.setProperty("client.pem", clientKeyCertPem.getAbsolutePath());
            properties.setProperty("server.pem", serverCertsPem.getAbsolutePath());
            properties.setProperty("hub.url", formatSSLUrl("kojihub"));
            properties.setProperty("storage.url", formatSSLUrl("kojifiles"));
            properties.setProperty("extra.config", getKojiExtraConfig());
            StringSearchInterpolator ssi = new StringSearchInterpolator();
            ssi.addValueSource(new PropertiesBasedValueSource(properties));
            RecursionInterceptor ri = new SimpleRecursionInterceptor();
            String kojiConf = readTestResource("test-koji.conf");
            try {
                kojiConf = ssi.interpolate(kojiConf, ri);
            } catch (InterpolationException e) {
                e.printStackTrace();
                fail("Interpolation of test koji.conf failed!");
            }
            writeConfigFile("conf.d/koji.conf", kojiConf);
        } catch (IOException e) {
            e.printStackTrace();
            fail("Cannot setup SSL config files for Koji.");
        }
    });
}
Also used : StringSearchInterpolator(org.codehaus.plexus.interpolation.StringSearchInterpolator) SimpleRecursionInterceptor(org.codehaus.plexus.interpolation.SimpleRecursionInterceptor) RecursionInterceptor(org.codehaus.plexus.interpolation.RecursionInterceptor) SimpleRecursionInterceptor(org.codehaus.plexus.interpolation.SimpleRecursionInterceptor) InterpolationException(org.codehaus.plexus.interpolation.InterpolationException) IOException(java.io.IOException) Properties(java.util.Properties) File(java.io.File) PropertiesBasedValueSource(org.codehaus.plexus.interpolation.PropertiesBasedValueSource)

Example 12 with InterpolationException

use of org.codehaus.plexus.interpolation.InterpolationException in project indy by Commonjava.

the class CacheProducer method interpolateStrFromStream.

private String interpolateStrFromStream(InputStream inputStream, String path) {
    String configuration;
    try {
        configuration = IOUtils.toString(inputStream);
    } catch (IOException e) {
        throw new RuntimeException("Cannot read infinispan configuration from : " + path, e);
    }
    StringSearchInterpolator interpolator = new StringSearchInterpolator();
    interpolator.addValueSource(new PropertiesBasedValueSource(System.getProperties()));
    try {
        configuration = interpolator.interpolate(configuration);
    } catch (InterpolationException e) {
        throw new RuntimeException("Cannot resolve expressions in infinispan configuration from: " + path, e);
    }
    return configuration;
}
Also used : StringSearchInterpolator(org.codehaus.plexus.interpolation.StringSearchInterpolator) IOException(java.io.IOException) InterpolationException(org.codehaus.plexus.interpolation.InterpolationException) PropertiesBasedValueSource(org.codehaus.plexus.interpolation.PropertiesBasedValueSource)

Example 13 with InterpolationException

use of org.codehaus.plexus.interpolation.InterpolationException in project indy by Commonjava.

the class KojiContentManagerDecorator method getRepositoryName.

private String getRepositoryName(final KojiBuildInfo build, final boolean isBinaryBuild) {
    StringSearchInterpolator interpolator = new StringSearchInterpolator();
    interpolator.addValueSource(new ObjectBasedValueSource(build));
    try {
        return interpolator.interpolate(isBinaryBuild ? config.getBinayNamingFormat() : config.getNamingFormat());
    } catch (InterpolationException e) {
        throw new RuntimeException("Cannot resolve expressions in Koji configuration.", e);
    }
}
Also used : StringSearchInterpolator(org.codehaus.plexus.interpolation.StringSearchInterpolator) ObjectBasedValueSource(org.codehaus.plexus.interpolation.ObjectBasedValueSource) InterpolationException(org.codehaus.plexus.interpolation.InterpolationException)

Example 14 with InterpolationException

use of org.codehaus.plexus.interpolation.InterpolationException in project indy by Commonjava.

the class CacheProducer method start.

@PostConstruct
public void start() {
    // FIXME This is just here to trigger shutdown hook init for embedded log4j in infinispan-embedded-query.
    // FIXES:
    //
    // Thread-15 ERROR Unable to register shutdown hook because JVM is shutting down.
    // java.lang.IllegalStateException: Cannot add new shutdown hook as this is not started. Current state: STOPPED
    //
    new MarshallableTypeHints().getBufferSizePredictor(CacheHandle.class);
    File confDir = indyConfiguration.getIndyConfDir();
    File ispnConf = new File(confDir, ISPN_XML);
    String configuration;
    if (ispnConf.exists()) {
        try {
            configuration = FileUtils.readFileToString(ispnConf);
        } catch (IOException e) {
            throw new RuntimeException("Cannot read infinispan configuration from file: " + ispnConf, e);
        }
    } else {
        try (InputStream stream = Thread.currentThread().getContextClassLoader().getResourceAsStream(ISPN_XML)) {
            configuration = IOUtils.toString(stream);
        } catch (IOException e) {
            throw new RuntimeException("Cannot read infinispan configuration from classpath: " + ISPN_XML, e);
        }
    }
    StringSearchInterpolator interpolator = new StringSearchInterpolator();
    interpolator.addValueSource(new PropertiesBasedValueSource(System.getProperties()));
    try {
        configuration = interpolator.interpolate(configuration);
    } catch (InterpolationException e) {
        throw new RuntimeException("Cannot resolve expressions in infinispan configuration.", e);
    }
    Logger logger = LoggerFactory.getLogger(getClass());
    logger.info("Using Infinispan configuration:\n\n{}\n\n", configuration);
    try {
        cacheManager = new DefaultCacheManager(new ByteArrayInputStream(configuration.getBytes(StandardCharsets.UTF_8)));
    } catch (IOException e) {
        throw new RuntimeException("Cannot read infinispan configuration.", e);
    }
}
Also used : DefaultCacheManager(org.infinispan.manager.DefaultCacheManager) StringSearchInterpolator(org.codehaus.plexus.interpolation.StringSearchInterpolator) MarshallableTypeHints(org.infinispan.commons.marshall.MarshallableTypeHints) ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) IOException(java.io.IOException) InterpolationException(org.codehaus.plexus.interpolation.InterpolationException) Logger(org.slf4j.Logger) File(java.io.File) PropertiesBasedValueSource(org.codehaus.plexus.interpolation.PropertiesBasedValueSource) PostConstruct(javax.annotation.PostConstruct)

Example 15 with InterpolationException

use of org.codehaus.plexus.interpolation.InterpolationException in project sling by apache.

the class BundleListUtils method interpolateProperties.

public static void interpolateProperties(BundleList bundleList, MavenProject project, MavenSession mavenSession) throws MojoExecutionException {
    Interpolator interpolator = createInterpolator(project, mavenSession);
    for (final StartLevel sl : bundleList.getStartLevels()) {
        for (final Bundle bndl : sl.getBundles()) {
            try {
                bndl.setArtifactId(interpolator.interpolate(bndl.getArtifactId()));
                bndl.setGroupId(interpolator.interpolate(bndl.getGroupId()));
                bndl.setVersion(interpolator.interpolate(bndl.getVersion()));
                bndl.setClassifier(interpolator.interpolate(bndl.getClassifier()));
                bndl.setType(interpolator.interpolate(bndl.getType()));
            } catch (InterpolationException e) {
                throw new MojoExecutionException("Unable to interpolate properties for bundle " + bndl.toString(), e);
            }
        }
    }
}
Also used : MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) Bundle(org.apache.sling.maven.projectsupport.bundlelist.v1_0_0.Bundle) StartLevel(org.apache.sling.maven.projectsupport.bundlelist.v1_0_0.StartLevel) Interpolator(org.codehaus.plexus.interpolation.Interpolator) StringSearchInterpolator(org.codehaus.plexus.interpolation.StringSearchInterpolator) InterpolationException(org.codehaus.plexus.interpolation.InterpolationException)

Aggregations

InterpolationException (org.codehaus.plexus.interpolation.InterpolationException)19 IOException (java.io.IOException)11 StringSearchInterpolator (org.codehaus.plexus.interpolation.StringSearchInterpolator)10 MapBasedValueSource (org.codehaus.plexus.interpolation.MapBasedValueSource)7 File (java.io.File)6 RegexBasedInterpolator (org.codehaus.plexus.interpolation.RegexBasedInterpolator)5 ArrayList (java.util.ArrayList)4 Properties (java.util.Properties)4 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)4 EnvarBasedValueSource (org.codehaus.plexus.interpolation.EnvarBasedValueSource)4 ObjectBasedValueSource (org.codehaus.plexus.interpolation.ObjectBasedValueSource)4 PropertiesBasedValueSource (org.codehaus.plexus.interpolation.PropertiesBasedValueSource)4 PlexusConfiguration (org.codehaus.plexus.configuration.PlexusConfiguration)3 Interpolator (org.codehaus.plexus.interpolation.Interpolator)3 ValueSource (org.codehaus.plexus.interpolation.ValueSource)3 InputStream (java.io.InputStream)2 Artifact (org.apache.maven.artifact.Artifact)2 Activation (org.apache.maven.model.Activation)2 ActivationFile (org.apache.maven.model.ActivationFile)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1