private void init()

in cassandra/src/main/java/org/apache/ignite/activestore/impl/cassandra/persistence/PublicKeyValuePersistenceSettings.java [266:342]


    private void init(String settings) {
        Document doc;
        try {
            DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
            DocumentBuilder builder = factory.newDocumentBuilder();
            doc = builder.parse(new InputSource(new StringReader(settings)));
        }
        catch (Throwable e) {
            throw new IllegalArgumentException("Failed to parse persistence settings:" +
                SystemHelper.LINE_SEPARATOR + settings, e);
        }
        Element root = doc.getDocumentElement();
        if (!PERSISTENCE_NODE.equals(root.getNodeName())) {
            throw new IllegalArgumentException("Incorrect persistence settings specified. " +
                "Root XML element should be 'persistence'");
        }
        if (root.hasAttribute(TTL_ATTR)) {
            ttl = extractIntAttribute(root, TTL_ATTR);
        }
        if (!root.hasChildNodes()) {
            throw new IllegalArgumentException("Incorrect Cassandra persistence settings specification, " +
                "there are no key and value persistence settings specified");
        }
        NodeList children = root.getChildNodes();
        int cnt = children.getLength();
        for (int i = 0; i < cnt; i++) {
            Node node = children.item(i);
            if (node.getNodeType() != Node.ELEMENT_NODE) {
                continue;
            }
            Element el = (Element)node;
            String nodeName = el.getNodeName();
            if (nodeName.equals(TABLE_OPTIONS_NODE)) {
                tblOptions = el.getTextContent();
                tblOptions = tblOptions.replace("\n", " ").replace("\r", "").replace("\t", " ");
            }
            else if (nodeName.equals(KEY_PERSISTENCE_NODE)) {
                keyPersistenceSettings = new KeyPersistenceSettings(el);
            }
            else if (nodeName.equals(VALUE_PERSISTENCE_NODE))
                valPersistenceSettings = new ValuePersistenceSettings(el);
        }
        List<PojoField> keyFields;
        if (keyPersistenceSettings != null) {
            keyFields = keyPersistenceSettings.getFields();
            if (PersistenceStrategy.POJO.equals(keyPersistenceSettings.getStrategy()) &&
                (keyFields == null || keyFields.isEmpty())) {
                throw new IllegalArgumentException("Incorrect Cassandra persistence settings specification, " +
                    "there are no key fields found");
            }
        }
        else {
            keyFields = null;
        }
        List<PojoField> valFields;
        if (valPersistenceSettings != null) {
            valFields = valPersistenceSettings.getFields();
            if (PersistenceStrategy.POJO.equals(valPersistenceSettings.getStrategy()) &&
                (valFields == null || valFields.isEmpty())) {
                throw new IllegalArgumentException("Incorrect Cassandra persistence settings specification, " +
                    "there are no value fields found");
            }
        }
        else {
            valFields = null;
        }
        if (keyFields != null && !keyFields.isEmpty() && valFields != null && !valFields.isEmpty()) {
            for (PojoField keyField : keyFields) {
                for (PojoField valField : valFields) {
                    if (keyField.getColumn().equals(valField.getColumn())) {
                        throw new IllegalArgumentException("Incorrect Cassandra persistence settings specification, " +
                            "key column '" + keyField.getColumn() + "' also specified as a value column");
                    }
                }
            }
        }
    }