Package org.rhq.core.pluginapi.inventory

Examples of org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException


    String beanName;
    if (parentPluginConfig.get(JBossCacheComponent.CACHE_SEARCH_STRING) != null)
      beanName = parentPluginConfig.getSimple(
          JBossCacheComponent.CACHE_SEARCH_STRING).getStringValue();
    else
      throw new InvalidPluginConfigurationException(
          "Invalid plugin configuration in JBossCache component.");

    Configuration defaultConfig = context.getDefaultPluginConfiguration();

    EmsConnection connection = parentComponent.getEmsConnection();
View Full Code Here


    static Connection buildConnection(Configuration pluginConfig) throws SQLException {
        String driverClass = pluginConfig.getSimpleValue(DRIVER_CLASS_PROPERTY, "org.h2.Driver");
        try {
            Class.forName(driverClass);
        } catch (ClassNotFoundException e) {
            throw new InvalidPluginConfigurationException("Specified JDBC driver class (" + driverClass
                + ") not found.");
        }

        String url = pluginConfig.getSimpleValue(URL_PROPERTY, "jdbc:h2:test");
        String username = pluginConfig.getSimpleValue(USERNAME_PROPERTY, "sa");
View Full Code Here

            }
            availabilityType = DOWN;
        }

        if (!securityRealmReady) {
            throw new InvalidPluginConfigurationException("The security realm of the HTTP management interface"
                + " is not ready to process requests. This usually indicates that no user is configured");
        }

        if (availabilityType == DOWN) {
            releaseVersion = null;
View Full Code Here

            baseDir = null;
            LOG.error("Failed to validate base dir for " + getResourceDescription() + ".", e);
        }
        if ((runtimeBaseDir != null) && (baseDir != null)) {
            if (!runtimeBaseDir.equals(baseDir)) {
                throw new InvalidPluginConfigurationException("The server listening on "
                    + serverPluginConfig.getHostname() + ":" + serverPluginConfig.getPort() + " has base dir ["
                    + runtimeBaseDir + "], but the base dir we expected was [" + baseDir
                    + "]. Perhaps the management hostname or port has been changed for the server with base dir ["
                    + baseDir + "].");
            }
        }

        // Validate the config dir (e.g. /opt/jboss-as-7.1.1.Final/standalone/configuration).
        File runtimeConfigDir;
        File configDir = null;
        try {
            String runtimeConfigDirString = readAttribute(getEnvironmentAddress(), getConfigDirAttributeName());
            // Canonicalize both paths before comparing them!
            runtimeConfigDir = new File(runtimeConfigDirString).getCanonicalFile();
            File configDirTmp = serverPluginConfig.getConfigDir();
            if (configDirTmp != null) { // may be null for manually added servers
                configDir = configDirTmp.getCanonicalFile();
            }
        } catch (Exception e) {
            runtimeConfigDir = null;
            configDir = null;
            LOG.error("Failed to validate config dir for " + getResourceDescription() + ".", e);
        }
        if ((runtimeConfigDir != null) && (configDir != null)) {
            if (!runtimeConfigDir.equals(configDir)) {
                throw new InvalidPluginConfigurationException("The server listening on "
                        + serverPluginConfig.getHostname() + ":" + serverPluginConfig.getPort() + " has config dir ["
                        + runtimeConfigDir + "], but the config dir we expected was [" + configDir
                        + "]. Perhaps the management hostname or port has been changed for the server with config dir ["
                        + configDir + "].");
            }
        }

        // Validate the mode (e.g. STANDALONE or DOMAIN).
        String runtimeMode;
        try {
            runtimeMode = readAttribute("launch-type");
        } catch (Exception e) {
            runtimeMode = null;
            LOG.error("Failed to validate mode for " + getResourceDescription() + ".", e);
        }
        if (runtimeMode != null) {
            String mode = getMode().name();
            if (!runtimeMode.equals(mode)) {
                throw new InvalidPluginConfigurationException("The original mode discovered for this AS7 server was "
                    + getMode() + ", but the server is now reporting its mode is [" + runtimeMode + "].");
            }
        }

        // Validate the product type (e.g. AS or EAP).
        String expectedRuntimeProductName = pluginConfiguration.getSimpleValue("expectedRuntimeProductName");
        String runtimeProductName;
        try {
            runtimeProductName = readAttribute(getHostAddress(), "product-name");
        } catch (Exception e) {
            throw new InvalidPluginConfigurationException("Failed to validate product type for "
                + getResourceDescription(), e);
        }
        if (runtimeProductName == null || runtimeProductName.trim().isEmpty()) {
            String releaseVersionNumber;
            try {
                releaseVersionNumber = readAttribute(getHostAddress(), "release-version");
            } catch (Exception e) {
                throw new InvalidPluginConfigurationException("Failed to validate product type for "
                    + getResourceDescription(), e);
            }
            if (releaseVersionNumber.startsWith("8.")) {
                runtimeProductName = WILDFLY8.PRODUCT_NAME;
            } else {
                runtimeProductName = AS.PRODUCT_NAME;
            }
        }
        if (!runtimeProductName.equals(expectedRuntimeProductName)) {
            throw new InvalidPluginConfigurationException("The original product type discovered for this server was "
                + expectedRuntimeProductName + ", but the server is now reporting its product type is ["
                + runtimeProductName + "]");
        }
    }
View Full Code Here

        String path = pluginConfig.getSimple("urlBase").getStringValue();
        URL url;
        try {
            url = new URL(path);
        } catch (MalformedURLException e) {
            throw new InvalidPluginConfigurationException("Value of 'urlBase' property is not a valid URL.");
        }

        try {

            DiscoveredResourceDetails sonarqube = new DiscoveredResourceDetails(
View Full Code Here

        baseObjectName = objectName.getStringValue();
        this.context = context;

        PropertySimple tcProp = context.getPluginConfiguration().getSimple("isTreeCache");
        if (tcProp == null || tcProp.getBooleanValue() == null)
            throw new InvalidPluginConfigurationException("Cache flavour not provided");
        else
            isTreeCache = tcProp.getBooleanValue();

        parentServer = (JBossCacheSubsystemComponent) context.getParentResourceComponent();
View Full Code Here

    static PortNetServiceComponentConfiguration createComponentConfiguration(Configuration pluginConfig)
        throws InvalidPluginConfigurationException {
        String addressString = pluginConfig.getSimpleValue(ConfigKeys.ADDRESS, EMPTY_STRING);
        if (isBlank(addressString)) {
            throw new InvalidPluginConfigurationException("Address is not defined");
        }
        String portString = pluginConfig.getSimpleValue(ConfigKeys.PORT, EMPTY_STRING);
        if (isBlank(portString)) {
            throw new InvalidPluginConfigurationException("Port is not defined");
        }
        int port;
        try {
            port = Integer.parseInt(portString);
        } catch (NumberFormatException e) {
            throw new InvalidPluginConfigurationException("Invalid port number: " + portString);
        }
        InetAddress address;
        try {
            address = InetAddress.getByName(addressString);
        } catch (UnknownHostException uhe) {
            throw new InvalidPluginConfigurationException(uhe);
        }
        return new PortNetServiceComponentConfiguration(address, port);
    }
View Full Code Here

    static HTTPNetServiceComponentConfiguration createComponentConfiguration(Configuration pluginConfig) {

        URL endPointUrl = null;
        String configUrl = pluginConfig.getSimpleValue(URL, EMPTY_STRING);
        if (isBlank(configUrl)) {
            throw new InvalidPluginConfigurationException("Endpoint URL is not defined");
        }
        try {
            endPointUrl = new URL(configUrl);
        } catch (MalformedURLException e) {
            throw new InvalidPluginConfigurationException(configUrl + " is not a valid URL");
        }
        String protocol = endPointUrl.getProtocol();
        if (!protocol.equals("http") && !protocol.equals("https")) {
            throw new InvalidPluginConfigurationException(configUrl + "does not point to an http(s) resource");
        }

        HttpMethod httpMethod = null;
        String configMethod = pluginConfig.getSimpleValue(METHOD, EMPTY_STRING);
        try {
            httpMethod = HttpMethod.valueOf(configMethod);
        } catch (IllegalArgumentException e) {
            throw new InvalidPluginConfigurationException("Invalid http method: " + configMethod);
        }

        Pattern responseValidationPattern = null;
        String configValidateResponsePattern = pluginConfig.getSimpleValue(VALIDATE_RESPONSE_PATTERN);
        if (configValidateResponsePattern != null) {
            if (httpMethod.equals(HEAD)) {
                throw new InvalidPluginConfigurationException("Cannot validate response content with HEAD request");
            }
            try {
                responseValidationPattern = Pattern.compile(configValidateResponsePattern);
            } catch (PatternSyntaxException e) {
                throw new InvalidPluginConfigurationException("Invalid pattern: " + configValidateResponsePattern);
            }
        }

        ProxyMode proxyMode;
        String configProxyMode = pluginConfig.getSimpleValue(PROXY_MODE, NONE.name());
        try {
            proxyMode = ProxyMode.valueOf(configProxyMode);
        } catch (IllegalArgumentException e) {
            throw new InvalidPluginConfigurationException("Invalid proxy mode: " + configProxyMode);
        }

        String proxyHost = pluginConfig.getSimpleValue(PROXY_HOST, EMPTY_STRING);
        String configProxyPort = pluginConfig.getSimpleValue(PROXY_PORT, EMPTY_STRING);
        int proxyPort = -1;

        switch (proxyMode) {
        case MANUAL:
            if (isBlank(proxyHost)) {
                throw new InvalidPluginConfigurationException("In '" + MANUAL.name() + "' proxy mode the " + PROXY_HOST
                    + " property must be set");
            }
            if (isBlank(configProxyPort)) {
                throw new InvalidPluginConfigurationException("In '" + MANUAL.name() + "' proxy mode the " + PROXY_PORT
                    + " property must be set");
            }
            try {
                proxyPort = Integer.parseInt(configProxyPort);
            } catch (NumberFormatException e) {
                throw new InvalidPluginConfigurationException(configProxyPort + " is not a number");
            }
            if (proxyPort < 1 || proxyPort > 65535) {
                throw new InvalidPluginConfigurationException(configProxyPort + " is not a valid port number");
            }
            break;
        default:
        }
View Full Code Here

        Connection connection = null;
        ResultSet resultSet = null;
        try {
            connection = getConnectionFromComponent(parentComponent);
            if (connection == null) {
                throw new InvalidPluginConfigurationException("cannot obtain connection from parent");
            }
            statement = connection.createStatement();
            statement.setMaxRows(1);
            statement.setFetchSize(1);
            // This is more efficient than 'count(*)'
 
View Full Code Here

        case piql:
            resourceKey = processComponentConfig.getPiql();
            resourceDescription = processInfo.getBaseName() + " process with PIQL expression [" + resourceKey + "]";
            break;
        default:
            throw new InvalidPluginConfigurationException("Unknown type: " + processComponentConfig.getType());
        }

        return new DiscoveredResourceDetails(context.getResourceType(), resourceKey, processInfo.getBaseName(),
            null /*version*/, resourceDescription, pluginConfig, processInfo);
    }
View Full Code Here

TOP

Related Classes of org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.