/** * Validate property name and existence * * @param uid * target uid */ protected void assertPropertyExist(String name) { Util.assertHasLength(name); if (!existProperty(name)) { throw new PropertyNotFoundException(name); } }
/** * Check that current feature does not exist. * * @param uid * current feature identifier.s */ protected void assertPropertyNotExist(String uid) { Util.assertHasLength(uid); if (existProperty(uid)) { throw new PropertyAlreadyExistException(uid); } }
/** * Initialize store from XML Configuration File. * * @param xmlConfFile * xml configuration file */ public Map<String, Property<?>> importPropertiesFromXmlFile(String xmlConfFile) { // Argument validation if (xmlConfFile == null || xmlConfFile.isEmpty()) { throw new IllegalArgumentException("Configuration filename cannot be null nor empty"); } // Load as Inputstream InputStream xmlIS = getClass().getClassLoader().getResourceAsStream(xmlConfFile); if (xmlIS == null) { throw new IllegalArgumentException("File " + xmlConfFile + " could not be read, please check path and rights"); } // Use the Feature Parser XmlConfig conf = new XmlParser().parseConfigurationFile(xmlIS); Map<String, Property<?>> properties = conf.getProperties(); // Override existing configuration within database for (Map.Entry<String,Property<?>> featureName : properties.entrySet()) { if (existProperty(featureName.getKey())) { deleteProperty(featureName.getKey()); } createProperty(featureName.getValue()); } return properties; }
/** {@inheritDoc} */ @Override public void importProperties(Collection<Property<?>> properties) { // Do not use target as the delete/create operation will be traced if (properties != null) { for (Property<?> property : properties) { if (existProperty(property.getName())) { deleteProperty(property.getName()); } createProperty(property); } } }