Package org.rhq.core.domain.configuration

Examples of org.rhq.core.domain.configuration.PropertySimple


    private boolean isInvalidRequiredProperty(PropertyDefinition propertyDefinition) {
        boolean isInvalidRequiredProperty = false;

        if ((propertyDefinition instanceof PropertyDefinitionSimple) && propertyDefinition.isRequired()) {
            PropertySimple propertySimple = this.propertyMap.getSimple(propertyDefinition.getName());
            String errorMessage = propertySimple.getErrorMessage();

            if ((null == propertySimple.getStringValue()) || "".equals(propertySimple.getStringValue())
                || ((null != errorMessage) && (!"".equals(errorMessage.trim())))) {
                // Required properties with no value, or an invalid value (assumed if we see an error message) should never
                // be set to read-only, otherwise the user will have no way to give the property a value and thereby
                // get things to a valid state.
                isInvalidRequiredProperty = true;
View Full Code Here


        String maxVal = maxString.substring(0, PropertySimple.MAX_VALUE_LENGTH - 5); // MAX= and a line terminator
        startScriptEnv.put("MAX", maxVal);
        ssc.setStartScriptEnv(startScriptEnv);
        Assert.assertNotNull(ssc.getStartScriptEnv());
        Assert.assertEquals(ssc.getStartScriptEnv().get("MAX"), maxVal);
        PropertySimple prop = ssc.getPluginConfig().getSimple(StartScriptConfiguration.START_SCRIPT_ENV_PROP);
        Assert.assertNotNull(prop);
        Assert.assertNotNull(prop.getStringValue());
        Assert.assertEquals(prop.getStringValue().length(), PropertySimple.MAX_VALUE_LENGTH);
        Assert.assertNull(prop.getErrorMessage());

        List<String> startScriptArgs = new ArrayList<String>();
        startScriptArgs.add(maxString);
        ssc.setStartScriptArgs(startScriptArgs);
        Assert.assertNotNull(ssc.getStartScriptArgs());
        Assert.assertEquals(ssc.getStartScriptArgs().size(), 1);
        Assert.assertEquals(ssc.getStartScriptArgs().get(0), maxString);
        prop = ssc.getPluginConfig().getSimple(StartScriptConfiguration.START_SCRIPT_ARGS_PROP);
        Assert.assertNotNull(prop);
        Assert.assertNotNull(prop.getStringValue());
        Assert.assertNull(prop.getErrorMessage());

        // Now, break the camel
        config = new Configuration();
        ssc = new StartScriptConfiguration(config);
        assert config.equals(ssc.getPluginConfig());

        startScriptEnv.put("LONG2", longString);
        ssc.setStartScriptEnv(startScriptEnv);
        Assert.assertTrue(ssc.getStartScriptEnv().isEmpty());
        prop = ssc.getPluginConfig().getSimple(StartScriptConfiguration.START_SCRIPT_ENV_PROP);
        Assert.assertNotNull(prop);
        Assert.assertNull(prop.getStringValue());
        Assert.assertNotNull(prop.getErrorMessage());
        assert prop.getErrorMessage().contains("long");

        startScriptArgs.add(longString);
        ssc.setStartScriptArgs(startScriptArgs);
        Assert.assertTrue(ssc.getStartScriptArgs().isEmpty());
        prop = ssc.getPluginConfig().getSimple(StartScriptConfiguration.START_SCRIPT_ARGS_PROP);
        Assert.assertNotNull(prop);
        Assert.assertNull(prop.getStringValue());
        Assert.assertNotNull(prop.getErrorMessage());
        assert prop.getErrorMessage().contains("long");
    }
View Full Code Here

                            prepopulateLdapFields(subject);

                            //insert empty configuration to start
                            Configuration newUserConfig = new Configuration();
                            //set flag on user so that we know registration is still required.
                            PropertySimple simple = new PropertySimple("isNewUser", true);
                            newUserConfig.put(simple);
                            subject.setUserConfiguration(newUserConfig);
                        }
                    }
View Full Code Here

            assert loaded.getDescription().equals("new updated description");

            // now give it a config
            assert loaded.getConfiguration() == null : "should not have a config yet";
            Configuration config = new Configuration();
            config.put(new PropertySimple("updateCSName", "updateCSValue"));
            loaded.setConfiguration(config);
            loaded = contentSourceManager.updateContentSource(overlord, loaded, false);
            assert loaded != null : "should have been updated";
            config = loaded.getConfiguration();
            assert config != null : "should have a config now";
View Full Code Here

            assert type != null;
            assert type.getId() > 0;

            // create the content source - note it has a config that should be persisted
            Configuration config = new Configuration();
            config.put(new PropertySimple("updateCSName", "updateCSValue"));
            contentSource = new ContentSource("testUpdateContentSource2", type);
            contentSource.setConfiguration(config);
            contentSource = contentSourceManager.simpleCreateContentSource(overlord, contentSource);
            assert contentSource != null;
            int contentSourceId = contentSource.getId();
View Full Code Here

            ContentProviderPackageDetailsKey key = new ContentProviderPackageDetailsKey("testMergeWithRepofoo",
                "testMergeWithRepo-Version", packageType1.getName(), architecture1.getName(), resourceType1.getName(),
                resourceType1.getPlugin());
            ContentProviderPackageDetails details = new ContentProviderPackageDetails(key);
            details.setExtraProperties(new Configuration());
            details.getExtraProperties().put(new PropertySimple("hello", "world"));
            details.setLocation("dummy-location");
            details.setFileSize(0L); // under the covers this ends up allowing us to create a package bits of size 0
            report.addNewPackage(details);
            Map<ContentProviderPackageDetailsKey, PackageVersionContentSource> previous;
            previous = new HashMap<ContentProviderPackageDetailsKey, PackageVersionContentSource>();
View Full Code Here

        Subject overlord = LookupUtil.getSubjectManager().getOverlord();

        // create a config, then another that spends some time in INPROGRESS before succeeding
        Configuration configuration1 = new Configuration();
        configuration1.put(new PropertySimple("myboolean", "true"));

        Configuration configuration2 = new Configuration();
        configuration2.put(new PropertySimple("myboolean", "false"));
        configuration2.put(new PropertySimple("mysleep", "7000"));

        configurationManager.updateResourceConfiguration(overlord, resourceId, configuration1);
        Thread.sleep(2000); // wait for the test agent to complete the request

        ResourceConfigurationUpdate history1;
        history1 = configurationManager.getLatestResourceConfigurationUpdate(overlord, resourceId);
        assert history1 != null;
        PropertySimple myprop = history1.getConfiguration().getSimple("myboolean");
        assert myprop != null;
        assert "true".equals(myprop.getStringValue());

        // now update to that second config - the "agent" will sleep for a bit before it completes
        // so we will have an INPROGRESS configuration for a few seconds before it goes to SUCCESS
        ResourceConfigurationUpdate history2 = null;
        boolean inProgress = false;
        boolean inProgressTested = false;

        configurationManager.updateResourceConfiguration(overlord, resourceId, configuration2);

        do {
            history2 = configurationManager.getLatestResourceConfigurationUpdate(overlord, resourceId);
            inProgress = configurationManager.isResourceConfigurationUpdateInProgress(overlord, resourceId);

            if (inProgress) {
                // history2 should be history1 since the update is not complete
                assert history2 != null;
                assert history2.getId() == history1.getId();
                myprop = history2.getConfiguration().getSimple("myboolean");
                assert myprop != null;
                assert "true".equals(myprop.getStringValue());
                myprop = history2.getConfiguration().getSimple("mysleep"); // this wasn't in the first config
                assert myprop == null;
                // record that this test case ran, we expect it will if the agent delay is there
                inProgressTested = true;
            } else {
                // update is complete, history 2 should be different
                history2 = configurationManager.getLatestResourceConfigurationUpdate(overlord, resourceId);
                assert history2 != null;
                assert history2.getId() != history1.getId();
                myprop = history2.getConfiguration().getSimple("myboolean");
                assert myprop != null;
                assert "false".equals(myprop.getStringValue());
                myprop = history2.getConfiguration().getSimple("mysleep");
                assert myprop.getLongValue() != null;
                assert myprop.getLongValue().longValue() == 7000L;
            }
        } while (inProgress);

        assertTrue(inProgressTested);
    }
View Full Code Here

        Subject overlord = LookupUtil.getSubjectManager().getOverlord();

        // create 3 configs: config1 will be stored as current. config2 will be in progress, config3 should get
        // blocked from updating by the inprogress update
        Configuration configuration1 = new Configuration();
        configuration1.put(new PropertySimple("myboolean", "true"));

        Configuration configuration2 = new Configuration();
        configuration2.put(new PropertySimple("myboolean", "false"));
        configuration2.put(new PropertySimple("mysleep", "7000"));

        Configuration configuration3 = new Configuration();
        configuration3.put(new PropertySimple("mysleep", "10000"));

        // make config1 the current
        configurationManager.updateResourceConfiguration(overlord, resourceId, configuration1);
        Thread.sleep(2000); // wait for the test agent to complete the request

        ResourceConfigurationUpdate history1;
        history1 = configurationManager.getLatestResourceConfigurationUpdate(overlord, resourceId);
        assert history1 != null;
        PropertySimple myprop = history1.getConfiguration().getSimple("myboolean");
        assert myprop != null;
        assert "true".equals(myprop.getStringValue());

        // now update to config2 - the "agent" will sleep for a bit before it completes
        // so we will have an INPROGRESS configuration for a few seconds before it goes to SUCCESS
        configurationManager.updateResourceConfiguration(overlord, resourceId, configuration2);

        // now update to config3 - this should fail as you can't update while there is one in progress
        try {
            configurationManager.updateResourceConfiguration(overlord, resourceId, configuration3);
            assert false : "Should have thrown an in progress exception";

        } catch (ConfigurationUpdateStillInProgressException e) {
            System.out.println("======> " + e);

            // make sure everything works as expected (like the above test)

            boolean inProgress = false;
            boolean inProgressTested = false;

            do {
                ResourceConfigurationUpdate history2 = configurationManager.getLatestResourceConfigurationUpdate(
                    overlord, resourceId);
                inProgress = configurationManager.isResourceConfigurationUpdateInProgress(overlord, resourceId);

                if (inProgress) {
                    // history2 should be history1 since the update is not complete
                    assert history2 != null;
                    assert history2.getId() == history1.getId();
                    myprop = history2.getConfiguration().getSimple("myboolean");
                    assert myprop != null;
                    assert "true".equals(myprop.getStringValue());
                    myprop = history2.getConfiguration().getSimple("mysleep"); // this wasn't in the first config
                    assert myprop == null;
                    // record that this test case ran, we expect it will if the agent delay is there
                    inProgressTested = true;
                } else {
                    // update is complete, history 2 should be different
                    history2 = configurationManager.getLatestResourceConfigurationUpdate(overlord, resourceId);
                    assert history2 != null;
                    assert history2.getId() != history1.getId();
                    myprop = history2.getConfiguration().getSimple("myboolean");
                    assert myprop != null;
                    assert "false".equals(myprop.getStringValue());
                    myprop = history2.getConfiguration().getSimple("mysleep");
                    assert myprop.getLongValue() != null;
                    assert myprop.getLongValue().longValue() == 7000L;
                }
            } while (inProgress);

        } catch (Throwable t) {
            assert false : "Should have thrown an in progress exception, not: " + t;
View Full Code Here

        Resource resource = newResource1;

        Subject overlord = LookupUtil.getSubjectManager().getOverlord();

        Configuration configuration1 = new Configuration();
        configuration1.put(new PropertySimple("fakeReadOnly", "1"));

        Configuration configuration2 = new Configuration();
        configuration2.put(new PropertySimple("fakeReadOnly", "2"));

        Configuration current;

        current = configurationManager.getPluginConfiguration(overlord, resource.getId());
        assert current != null;
View Full Code Here

        if (proceed) {
            Log.trace("New LDAP user registration details valid for user '" + newSubject.getName() + "'.");
            //proceed with LDAP processing request.
            //clear out 'isNewUser' flag.
            if (newSubject.getUserConfiguration() != null) {
                PropertySimple simple = new PropertySimple("isNewUser", null);
                newSubject.getUserConfiguration().put(simple);
            }

            Set<String> prefsChanges = new HashSet<String>();
            prefsChanges.add("isNewUser");
View Full Code Here

TOP

Related Classes of org.rhq.core.domain.configuration.PropertySimple

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.