Package org.apache.roller.planet.pojos

Examples of org.apache.roller.planet.pojos.RuntimeConfigProperty


    public String save() {
       
        try {
            // only set values for properties that are already defined
            String propName = null;
            RuntimeConfigProperty updProp = null;
            String incomingProp = null;
            Iterator propsIT = getProperties().keySet().iterator();
            while(propsIT.hasNext()) {
                propName = (String) propsIT.next();
               
                log.debug("Checking property ["+propName+"]");
               
                updProp = (RuntimeConfigProperty) getProperties().get(propName);
                String[] propValues = (String[]) getParameters().get(updProp.getName());
                if(propValues != null && propValues.length > 0) {
                    // we don't deal with multi-valued props
                    incomingProp = propValues[0];
                }
               
                // some special treatment for booleans
                // this is a bit hacky since we are assuming that any prop
                // with a value of "true" or "false" is meant to be a boolean
                // it may not always be the case, but we should be okay for now
                if( updProp.getValue() != null // null check needed w/Oracle
                        && (updProp.getValue().equals("true") || updProp.getValue().equals("false"))) {
                   
                    if(incomingProp == null || !incomingProp.equals("on"))
                        incomingProp = "false";
                    else
                        incomingProp = "true";
                }
               
                // only work on props that were submitted with the request
                if(incomingProp != null) {
                    log.debug("Setting new value for ["+propName+"]");
                   
                    updProp.setValue(incomingProp.trim());
                }
            }
           
            // save it
            PropertiesManager pMgr = PlanetFactory.getPlanet().getPropertiesManager();
View Full Code Here


        log.debug("Handling update request");
       
        try {
            // only set values for properties that are already defined
            String propName = null;
            RuntimeConfigProperty updProp = null;
            String incomingProp = null;
            Iterator propsIT = this.properties.keySet().iterator();
            while(propsIT.hasNext()) {
                propName = (String) propsIT.next();
               
                log.debug("Checking property ["+propName+"]");
               
                updProp = (RuntimeConfigProperty) this.properties.get(propName);
                String[] propValues = (String[]) this.parameters.get(updProp.getName());
                if(propValues != null && propValues.length > 0) {
                    // we don't deal with multi-valued props
                    incomingProp = propValues[0];
                }
               
                // some special treatment for booleans
                // this is a bit hacky since we are assuming that any prop
                // with a value of "true" or "false" is meant to be a boolean
                // it may not always be the case, but we should be okay for now
                if( updProp.getValue() != null // null check needed w/Oracle
                        && (updProp.getValue().equals("true") || updProp.getValue().equals("false"))) {
                   
                    if(incomingProp == null || !incomingProp.equals("on"))
                        incomingProp = "false";
                    else
                        incomingProp = "true";
                }
               
                // only work on props that were submitted with the request
                if(incomingProp != null) {
                    log.debug("Setting new value for ["+propName+"]");
                   
                    updProp.setValue(incomingProp.trim());
                }
            }
           
            // save it
            PropertiesManager pMgr = PlanetFactory.getPlanet().getPropertiesManager();
View Full Code Here

       
        // remember, the properties table is initialized during Roller startup
        PropertiesManager mgr = PlanetFactory.getPlanet().getPropertiesManager();
        TestUtils.endSession(true);
       
        RuntimeConfigProperty prop = null;
       
        // get a property by name
        prop = mgr.getProperty("site.name");
        assertNotNull(prop);
       
        // update a property
        prop.setValue("testtest");
        mgr.saveProperty(prop);
        TestUtils.endSession(true);
       
        // make sure property was updated
        prop = null;
        prop = mgr.getProperty("site.name");
        assertNotNull(prop);
        assertEquals("testtest", prop.getValue());
       
        // get all properties
        Map props = mgr.getProperties();
        assertNotNull(props);
        assertTrue(props.containsKey("site.name"));
       
        // update multiple properties
        prop = (RuntimeConfigProperty) props.get("site.name");
        prop.setValue("foofoo");
        prop = (RuntimeConfigProperty) props.get("site.description");
        prop.setValue("blahblah");
        mgr.saveProperties(props);
        TestUtils.endSession(true);
       
        // make sure all properties were updated
        props = mgr.getProperties();
View Full Code Here

         * for convenience sake we are going to put the list of props
         * into a map for users to access it.  The value element of the
         * hash still needs to be the RuntimeConfigProperty object so that
         * we can save the elements again after they have been updated
         */
        RuntimeConfigProperty prop = null;
        Iterator it = list.iterator();
        while(it.hasNext()) {
            prop = (RuntimeConfigProperty) it.next();
            props.put(prop.getName(), prop);
        }
       
        return props;
    }
View Full Code Here

                while(propdefs.hasNext()) {
                    propDef = (PropertyDef) propdefs.next();
                   
                    // do we already have this prop?  if not then add it
                    if(!props.containsKey(propDef.getName())) {
                        RuntimeConfigProperty newprop =
                                new RuntimeConfigProperty(propDef.getName(), propDef.getDefaultValue());
                       
                        props.put(propDef.getName(), newprop);
                       
                        log.info("Found uninitialized property "+propDef.getName()+
                                " ... setting value to ["+propDef.getDefaultValue()+"]");
View Full Code Here

    public String save() {
       
        try {
            // only set values for properties that are already defined
            String propName = null;
            RuntimeConfigProperty updProp = null;
            String incomingProp = null;
            Iterator propsIT = getProperties().keySet().iterator();
            while(propsIT.hasNext()) {
                propName = (String) propsIT.next();
               
                log.debug("Checking property ["+propName+"]");
               
                updProp = (RuntimeConfigProperty) getProperties().get(propName);
                String[] propValues = (String[]) getParameters().get(updProp.getName());
                if(propValues != null && propValues.length > 0) {
                    // we don't deal with multi-valued props
                    incomingProp = propValues[0];
                }
               
                // some special treatment for booleans
                // this is a bit hacky since we are assuming that any prop
                // with a value of "true" or "false" is meant to be a boolean
                // it may not always be the case, but we should be okay for now
                if( updProp.getValue() != null // null check needed w/Oracle
                        && (updProp.getValue().equals("true") || updProp.getValue().equals("false"))) {
                   
                    if(incomingProp == null || !incomingProp.equals("on"))
                        incomingProp = "false";
                    else
                        incomingProp = "true";
                }
               
                // only work on props that were submitted with the request
                if(incomingProp != null) {
                    log.debug("Setting new value for ["+propName+"]");
                   
                    updProp.setValue(incomingProp.trim());
                }
            }
           
            // save it
            PropertiesManager pMgr = PlanetFactory.getPlanet().getPropertiesManager();
View Full Code Here

TOP

Related Classes of org.apache.roller.planet.pojos.RuntimeConfigProperty

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.