Package org.dcm4che3.conf.api

Examples of org.dcm4che3.conf.api.ConfigurationException


    @Override
    public void removeCurrentNode() throws ConfigurationException {
        try {
            prefs.removeNode();
        } catch (BackingStoreException e) {
            throw new ConfigurationException("Cannot remove config node "+prefs.absolutePath() ,e);
        }
    }
View Full Code Here


        ConfigClass ccAnno = (ConfigClass) confClass.getAnnotation(ConfigClass.class);

        // no annotation - no configuration
        if (ccAnno == null)
            throw new ConfigurationException("The configuration class must be annotated with @ConfigClass");

        if (ccAnno.nodeName().equals(""))
            throw new ConfigurationException("To use java preferences config, specify node name for the config class in @ConfigClass annotation");

        nodename = ccAnno.nodeName();

    }
View Full Code Here

            try {
           
                reflectiveConfig.storeConfig(confObj, prefsWriter);
           
            } catch (Exception e) {
                throw new ConfigurationException("Unable to store configuration for class "+confClass.getSimpleName()+
                        " for device: " + device.getDeviceName() , e);
            }
        }
    }
View Full Code Here

        T confObj;

        try {
            confObj = confClass.newInstance();
        } catch (Exception e) {
            throw new ConfigurationException(e);
        }

        ConfigReader prefsReader = new PrefsConfigReader(deviceNode.node(nodename));
       
        try {
       
            reflectiveConfig.readConfig(confObj, prefsReader);
            device.addDeviceExtension(confObj);

        } catch (Exception e) {
            throw new ConfigurationException("Unable to read configuration for class "+confClass.getSimpleName()+
                    " for device: " + device.getDeviceName() ,e);
        }
    }
View Full Code Here

            try {
           
                reflectiveConfig.storeConfig(confObj, prefsWriter);
           
            } catch (Exception e) {
                throw new ConfigurationException("Unable to store configuration for class "+confClass.getSimpleName()+
                        (confObj.getDevice() != null ? " for device: " + confObj.getDevice().getDeviceName(): "") , e);
            }
        } else {
            ConfigWriter prefsDiffWriter = new PrefsConfigWriter(xdsNode);
           
View Full Code Here

                // this is done in the next phase after flush
                if (!customRep.isWritingChildren(classField))
                    customRep.write(serialized.get(fieldAnno.name()), config, writer, classField);
            } else {
                throw new ConfigurationException("Corresponding 'writer' was not found for field" + fieldAnno.name());
            }
        }

        // do actual store
        writer.flushWriter();
View Full Code Here

            Object value;

            try {
                value = PropertyUtils.getSimpleProperty(obj, classField.getName());
            } catch (Exception e) {
                throw new ConfigurationException("Error while writing configuration field " + fieldAnno.name(), e);
            }

            // find typeadapter
            ConfigTypeAdapter customRep = config.lookupTypeAdapter(classField.getType());

            if (customRep != null) {
                Object serialized = customRep.serialize(value, config, classField);
                cnode.put(fieldAnno.name(), serialized);
            } else {
                throw new ConfigurationException("Corresponding 'writer' was not found for field " + fieldAnno.name());
            }

        }
        return cnode;
View Full Code Here

                    cnode.put(fieldAnno.name(), value);
                } catch (ConfigurationNotFoundException e) {
                    if (fieldAnno.failIfNotPresent()) throw e;
                }
            } else
                throw new ConfigurationException("Corresponding 'reader' was not found for field " + fieldAnno.name());
        }

        return cnode;
    }
View Full Code Here

        // e.g., in other config extensions
        if (providedConfObj == null) {
            try {
                confObj = (T) clazz.newInstance();
            } catch (Exception e) {
                throw new ConfigurationException("Error while instantiating config class " + clazz.getSimpleName()
                        + ". Check whether null-arg constructor exists.", e);
            }
        } else
            confObj = providedConfObj;

        for (Field classField : clazz.getDeclaredFields()) {

            // if field is not annotated, skip it
            ConfigField fieldAnno = (ConfigField) classField.getAnnotation(ConfigField.class);
            if (fieldAnno == null)
                continue;

            // find typeadapter
            ConfigTypeAdapter customRep = config.lookupTypeAdapter(classField.getType());

            if (customRep != null) {
                try {
                    Object value = customRep.deserialize(serialized.get(fieldAnno.name()), config, classField);

                    // set using a setter, exception is when failIfNotPresent is false and there were no value
                    if (value != null || fieldAnno.failIfNotPresent())
                        PropertyUtils.setSimpleProperty(confObj, classField.getName(), value);
                } catch (Exception e) {
                    throw new ConfigurationException("Error while reading configuration field " + fieldAnno.name(), e);
                }

            } else
                throw new ConfigurationException("Corresponding 'reader' was not found for field " + fieldAnno.name());

        }

        return confObj;
View Full Code Here

                ConfigTypeAdapter customRep = config.lookupTypeAdapter(classField.getType());

                customRep.merge(prevProp, currProp, config, diffwriter, classField);

            } catch (Exception e) {
                throw new ConfigurationException("Cannot store diff for field " + fieldAnno.name(), e);
            }

        }

        // do actual merge
View Full Code Here

TOP

Related Classes of org.dcm4che3.conf.api.ConfigurationException

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.