Package com.adito.boot

Examples of com.adito.boot.PropertyDefinition


     * (non-Javadoc)
     *
     * @see com.adito.properties.PropertyType#retrieve(com.adito.properties.PropertyKey)
     */
    public String retrievePropertyImpl(AbstractPropertyKey key) throws IllegalArgumentException {
        PropertyDefinition def = getDefinition(key.getName());
        ResourceKey resourceKey = (ResourceKey) key;
        try {
            String val = ProfilesFactory.getInstance().retrieveAttributeValue(resourceKey);
            if (def.getType() == PropertyDefinition.TYPE_PASSWORD) {
                try {
                    val = ContextHolder.getContext().deobfuscatePassword(val);
                } catch (Throwable t) {
                    log.warn("Password property " + def.getName() + " could not be decoded. It has been result to the default.", t);
                }
            }
            return val == null ? def.getDefaultValue() : val;
        } catch (Exception e) {
            log.error("Failed to retrieve property.", e);
        }
        return null;
    }
View Full Code Here


        }
        return null;
    }

    public String storePropertyImpl(AbstractPropertyKey key, String value) throws IllegalArgumentException {
        PropertyDefinition def = getDefinition(key.getName());
        ResourceKey resourceKey = (ResourceKey) key;
        String oldValue = retrieveProperty(key);
        if (def.getDefaultValue().equals(value)) {
            value = null;
        }

        if ((oldValue == null && value != null) || (oldValue != null && value == null) || !oldValue.equals(value)) {

            if (def.getType() == PropertyDefinition.TYPE_PASSWORD) {
                try {
                    value = ContextHolder.getContext().obfuscatePassword(value);
                } catch (Throwable t) {
                    log.warn("Password property " + def.getName() + " could not be encoded.", t);
                }
            }
            try {
                ProfilesFactory.getInstance()
                .storeAttributeValue(resourceKey, value);
View Full Code Here

     */
    public String retrievePropertyImpl(AbstractPropertyKey key) throws IllegalArgumentException {
        if (!(key instanceof ProfilePropertyKey)) {
            throw new IllegalArgumentException("Property key is not an instanceof ProfilePropertyKey");
        }
        PropertyDefinition def = getDefinition(key.getName());
        ProfilePropertyKey profilesKey = (ProfilePropertyKey) key;
        try {
            String val = ProfilesFactory.getInstance().retrieveGenericProperty(profilesKey.getName(),
                profilesKey.isUserSpecific() ? profilesKey.getUsername() : "",
                String.valueOf(profilesKey.getProfile()),
                String.valueOf(profilesKey.getRealm()),
                "");
            // If a username was supplied, then now try the global profiles
            if(val == null && profilesKey.isUserSpecific()) {
                val = ProfilesFactory.getInstance().retrieveGenericProperty(profilesKey.getName(),
                    "",
                    String.valueOf(profilesKey.getProfile()),
                    String.valueOf(profilesKey.getRealm()),
                    "");
            }
           
            // Fallback to defaults
            if (val == null) {
                val = def.getDefaultValue();
            } else {
                if (def.getType() == PropertyDefinition.TYPE_PASSWORD) {
                    try {
                        val = ContextHolder.getContext().deobfuscatePassword(val);
                    } catch (Throwable t) {
                        log.warn("Password property " + def.getName() + " could not be decoded. It has been result to the default.",
                            t);
                    }
                }
            }
            return val;
View Full Code Here

    public String storePropertyImpl(AbstractPropertyKey key, String value) throws IllegalArgumentException {
        if (!(key instanceof ProfilePropertyKey)) {
            throw new IllegalArgumentException("Property key is not an instanceof ProfilePropertyKey");
        }
        PropertyDefinition def = getDefinition(key.getName());
        ProfilePropertyKey profilesKey = (ProfilePropertyKey) key;

        String oldValue = retrieveProperty(key);

        if (def.getType() == PropertyDefinition.TYPE_PASSWORD) {
            try {
                value = ContextHolder.getContext().obfuscatePassword(value);
            } catch (Throwable t) {
                log.warn("Password property " + def.getName() + " could not be encoded.", t);
            }
        }

        // If the definitions shows a visibilitiy of CONTEXT_CONFIGURATION then
        // set the property value in the context
View Full Code Here

     * @param sessionInfo session info
     * @return old value
     */
    public static String setProperty(AbstractPropertyKey key, String newValue, SessionInfo sessionInfo) {

        PropertyDefinition def = getDefinition(key);
        PropertyProfile p = null;
        try {
            PropertyClass t = def.getPropertyClass();
            String oldVal = t.storeProperty(key, newValue);
            if ( ( oldVal == null && newValue != null ) || !oldVal.equals(newValue)) {
                if (key instanceof ProfilePropertyKey) {
                    p = ProfilesFactory.getInstance().getPropertyProfile(((ProfilePropertyKey) key).getProfile());
                }
View Full Code Here

     * @param key property key
     * @return value
     * @throws IllegalArgumentException if property doesn't exist
     */
    public static String getProperty(AbstractPropertyKey key) throws IllegalArgumentException {
        PropertyDefinition def = getDefinition(key);
        if (def == null) {
            throw new IllegalArgumentException("Invalid key. " + key);
        }
        PropertyClass t = def.getPropertyClass();
        return t.retrieveProperty(key);
    }
View Full Code Here

TOP

Related Classes of com.adito.boot.PropertyDefinition

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.