Search in sources :

Example 6 with InvalidParameterException

use of org.apache.nifi.minifi.c2.api.InvalidParameterException in project nifi-minifi by apache.

the class ConfigService method initConfigurationProviderValue.

public ConfigurationProviderValue initConfigurationProviderValue(ConfigurationProviderKey key) {
    if (logger.isDebugEnabled()) {
        logger.debug("Attempting to load and cache configuration with key " + key);
    }
    try {
        List<MediaType> acceptValues = key.getAcceptValues();
        Pair<MediaType, ConfigurationProvider> providerPair = getProvider(acceptValues);
        Map<String, List<String>> parameters = key.getParameters();
        Integer version = null;
        List<String> versionList = parameters.get("version");
        if (versionList != null && versionList.size() > 0) {
            try {
                version = Integer.parseInt(versionList.get(0));
            } catch (NumberFormatException e) {
                throw new InvalidParameterException("Unable to parse " + version + " as integer.", e);
            }
        }
        return new ConfigurationProviderValue(providerPair.getSecond().getConfiguration(providerPair.getFirst().toString(), version, parameters), providerPair.getFirst(), null);
    } catch (ConfigurationProviderException e) {
        return new ConfigurationProviderValue(null, null, e);
    }
}
Also used : ConfigurationProvider(org.apache.nifi.minifi.c2.api.ConfigurationProvider) ConfigurationProviderException(org.apache.nifi.minifi.c2.api.ConfigurationProviderException) InvalidParameterException(org.apache.nifi.minifi.c2.api.InvalidParameterException) MediaType(javax.ws.rs.core.MediaType) ArrayList(java.util.ArrayList) List(java.util.List)

Aggregations

List (java.util.List)6 InvalidParameterException (org.apache.nifi.minifi.c2.api.InvalidParameterException)5 Map (java.util.Map)4 ConfigurationProviderException (org.apache.nifi.minifi.c2.api.ConfigurationProviderException)4 IOException (java.io.IOException)3 InputStream (java.io.InputStream)3 HttpURLConnection (java.net.HttpURLConnection)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 MediaType (javax.ws.rs.core.MediaType)2 Configuration (org.apache.nifi.minifi.c2.api.Configuration)2 ConfigurationProvider (org.apache.nifi.minifi.c2.api.ConfigurationProvider)2 WriteableConfiguration (org.apache.nifi.minifi.c2.api.cache.WriteableConfiguration)2 AuthorizationException (org.apache.nifi.minifi.c2.api.security.authorization.AuthorizationException)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 UncheckedExecutionException (com.google.common.util.concurrent.UncheckedExecutionException)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 Closeable (java.io.Closeable)1 OutputStream (java.io.OutputStream)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1