public String store()

in alerting/service/src/main/java/org/apache/karaf/decanter/alerting/service/store/LuceneStoreImpl.java [119:164]


    public String store(Event event) throws Exception {
        Document document = new Document();
        for (String property : event.getPropertyNames()) {
            Object value = event.getProperty(property);
            if (value instanceof Long) {
                document.add(new LongPoint(property, ((Long) value)));
                document.add(new StoredField(property, ((Long) value)));
                points.put(property, new PointsConfig(NumberFormat.getInstance(), Long.class));
            } else if (value instanceof Integer) {
                document.add(new IntPoint(property, ((Integer) value)));
                document.add(new StoredField(property, ((Integer) value)));
                points.put(property, new PointsConfig(NumberFormat.getInstance(), Integer.class));
            } else if (value instanceof Float) {
                document.add(new FloatPoint(property, ((Float) value)));
                document.add(new StoredField(property, ((Integer) value)));
                points.put(property, new PointsConfig(NumberFormat.getInstance(), Float.class));
            } else if (value instanceof Double) {
                document.add(new DoublePoint(property, ((Double) value)));
                document.add(new StoredField(property, ((Double) value)));
                points.put(property, new PointsConfig(NumberFormat.getInstance(), Double.class));
            } else {
                if (value != null) {
                    String stringValue = value.toString();
                    if (stringValue.getBytes("UTF-8").length > 32766) {
                        stringValue = new String(stringValue.getBytes("UTF-8"), 0, 32766, "UTF-8");
                    }
                    document.add(new StringField(property, stringValue, Field.Store.YES));
                }
            }
        }
        if (event.getProperty("alertTimestamp") == null) {
            long now = System.currentTimeMillis();
            document.add(new LongPoint("alertTimestamp", System.currentTimeMillis()));
            document.add(new StoredField("alertTimestamp", now));
            points.put("alertTimestamp", new PointsConfig(NumberFormat.getInstance(), Long.class));
        }
        String uuid = UUID.randomUUID().toString();
        document.add(new StringField("alertUUID", uuid, Field.Store.YES));
        try {
            indexWriter.addDocument(document);
            indexWriter.commit();
        } catch (Exception e) {
            LOGGER.warn("Can't store alert: {}", e.getMessage());
        }
        return uuid;
    }