public static void prepare()

in collector/utils/src/main/java/org/apache/karaf/decanter/collector/utils/PropertiesPreparator.java [41:93]


    public static void prepare(Map<String, Object> data, Dictionary<String, Object> properties) throws Exception {
        // add the karaf instance name if it doesn't exist in the data
        String karafName = (String) data.get("karafName");
        if (karafName == null) {
            karafName = System.getProperty("karaf.name");
            if (karafName != null) {
                data.put("karafName", karafName);
            }
        }

        // add the network details
        String hostAddress = (String) data.get("hostAddress");
        if (hostAddress == null) {
            hostAddress =  InetAddress.getLocalHost().getHostAddress();
        }
        data.put("hostAddress", hostAddress);
        String hostName = (String) data.get("hostName");
        if (hostName == null) {
            hostName = InetAddress.getLocalHost().getHostName();
        }
        data.put("hostName", hostName);

        // custom fields
        if (properties != null) {
            Enumeration<String> keys = properties.keys();
            while (keys.hasMoreElements()) {
                String key = keys.nextElement();
                if (key.startsWith(FIELDS_ADD)) {
                    if ("UUID".equals(properties.get(key).toString().trim())) {
                        String uuid = UUID.randomUUID().toString();
                        data.put(key.substring(FIELDS_ADD.length()), uuid);
                    } else if ("TIMESTAMP".equals(properties.get(key).toString().trim())) {
                        Date date = new Date();
                        data.put(key.substring(FIELDS_ADD.length()), tsFormat.format(date));
                    } else {
                        data.put(key.substring(FIELDS_ADD.length()), properties.get(key));
                    }
                } else if (key.startsWith(FIELDS_RENAME)) {
                    if (data.containsKey(key.substring(FIELDS_RENAME.length()))) {
                        Object value = data.get(key.substring(FIELDS_RENAME.length()));
                        data.remove(key.substring(FIELDS_RENAME.length()));
                        data.put(properties.get(key).toString().trim(), value);
                    }
                } else if (key.startsWith(FIELDS_REMOVE)) {
                    if (data.containsKey(key.substring(FIELDS_REMOVE.length()))) {
                        data.remove(key.substring(FIELDS_REMOVE.length()));
                    }
                } else {
                    data.put(key, properties.get(key));
                }
            }
        }
    }