private PassthroughWrapper(final InternalEvent internal) { if (internal == null || internal.getEventObj() == null || internal.getEventObj().getPayload() == null) { wrapped = null; } else { wrapped = internal.getEventObj().getPayload(); } }
/** * Returns true if the event matches the filter. * * @param ievent {@link DeserializedEvent} has payload to filter against. */ @Override public boolean test(InternalEvent ievent) { DeserializedEvent devent = ievent.getEventObj(); if (devent == null) { return false; } boolean found; try { String field = devent.getFieldAsString(this.path); found = this.pattern.matcher(field).matches(); } catch (FieldNotFoundException e) { found = false; } /* * When false is returned then the event is excluded from the stream. */ return this.exclude != found; } }
/** * The {@link DeserializedEvent} payload must be a {@link JsonObject}. * * @param event Event with payload to mutate. */ protected void mutateEvent(DeserializedEvent event) throws OperationException { Object payload = event.getPayload(); if (payload == null) { return; } if (!(payload instanceof JsonObject)) { throw new OperationException("Payload data is not a JsonObject"); } Object o; try { o = event.getField(path); } catch (FieldNotFoundException e) { throw new OperationException(e); } if (!(o instanceof JsonObject)) { throw new OperationException("specified node '" + path +"' is not an object"); } event.setPayload(o); }
protected static Pair<String, Object> getFieldAndSource(DeserializedEvent devent, List<String> sourceFieldsNames, boolean asString) throws FieldNotFoundException { Object sourceValue = null; String foundSourceFieldName = null; for (String sourceFieldName : sourceFieldsNames) { try { if (asString) { sourceValue = devent.getFieldAsString(sourceFieldName); } else { sourceValue = devent.getField(sourceFieldName); } foundSourceFieldName = sourceFieldName; break; } catch (FieldNotFoundException e) { continue; } } if (sourceValue == null) { throw new FieldNotFoundException(); } return new ImmutablePair<String, Object>(foundSourceFieldName, sourceValue); } }
devent.setField(this.key, kv.getValue()); } catch (FieldNotFoundException e) { if (this.failDstNotFound) { devent.deleteField(kv.getKey());
@Override public InternalEvent perform(InternalEvent ievent) { if (ievent == null || ievent.getEventObj() == null || ievent.getEventObj().getPayload() == null) { return ievent; value = ievent.getEventObj().getFieldAsString(fieldName); } catch (FieldNotFoundException e) { continue; ievent.getEventObj().setField(fieldName, value); } catch (FieldNotFoundException e) { throw new OperationException("failed to update original field in URL decode");
@Override public InternalEvent perform(InternalEvent ievent) { String payloadStr = ievent.getEventObj().getPayload().toString(); ievent.getEventObj().setPayload(payloadStr + this.appendStr); return ievent; } }
devent.setField(k, v); } catch (FieldNotFoundException e) { if (this.failDstNotFound) { devent.removeField(kv.getKey()); } catch (FieldNotFoundException e) { if (this.failSrcNotFound) {
ipStr = ievent.getEventObj().getFieldAsString(this.pathToIpAddress); } catch (FieldNotFoundException e) { if (!this.required) { ievent.getEventObj().setField(this.destFieldName, geo); } catch (FieldNotFoundException e) { throw new OperationException(e);
@Override protected void doSubstitution(InternalEvent ievent, DeserializedEvent devent) { try { devent.setField(this.key, this.value); } catch (FieldNotFoundException e) { if (this.failDstNotFound) { throw new OperationException(e); } } } }
@Override protected void doSubstitution(InternalEvent ievent, DeserializedEvent devent, Map<String, Object> nested) { Pair<String, Object> kv; try { kv = getFieldAndSource(devent, srcFields, false); } catch (FieldNotFoundException e) { if (this.failSrcNotFound) { throw new OperationException(e); } return; } nested.put(this.key, kv.getValue()); /* * Remove source field */ if (this.removeSrcField) { devent.deleteField(kv.getKey()); } }
@Override protected void doSubstitution(InternalEvent ievent, DeserializedEvent devent, Map<String, Object> nested) { Pair<String, Map<String, Object>> kv; try { kv = getRegexMatches(devent); } catch (FieldNotFoundException e) { if (this.failSrcNotFound) { throw new OperationException(e); } return; } nested.putAll(kv.getValue()); /* * Remove source field */ if (this.removeSrcField) { try { devent.removeField(kv.getKey()); } catch (FieldNotFoundException e) { if (this.failSrcNotFound) { throw new OperationException(e); } } } }
/** * Makes a new event by copying properties from another event. * * @param other event to copy */ private InternalEvent(InternalEvent other) { this.eventString = new String(other.getEventString()); this.context = other.context; this.eventSha1Hash = other.getEventSha1Hash(); this.arrivalTime = other.getArrivalTime(); this.eventTime = other.getEventTime(); this.serialized = other.getSerialized(); if (other.getPartitions() == null) { this.partitions = null; } else { this.partitions = new LinkedHashMap<String, String>(other.getPartitions()); } /* * We rely on the implementation to provide a deep copy here. */ if (other.getEventObj() != null) { this.eventObj = other.getEventObj().copy(); } /* * Note that this is a shallow copy of the metadata. Some metadata elements are reused across * multiple events within a function invocation. */ this.metadata.putAll(other.metadata); }
payload = ievent.getEventObj().getField(this.path); } catch (FieldNotFoundException e) { throw new OperationException(e);
@Override public InternalEvent perform(InternalEvent ievent) { if (ievent == null || ievent.getEventObj() == null || ievent.getEventObj().getPayload() == null) { return ievent; value = ievent.getEventObj().getFieldAsString(fieldName); } catch (FieldNotFoundException e) { continue; ievent.getEventObj().setField(fieldName, value); } catch (FieldNotFoundException e) { throw new OperationException("failed to update original field in URL decode");
devent.setField(k, v); } catch (FieldNotFoundException e) { if (this.failDstNotFound) { devent.removeField(kv.getKey()); } catch (FieldNotFoundException e) { if (this.failSrcNotFound) {
protected static Pair<String, Object> getFieldAndSource(DeserializedEvent devent, List<String> sourceFieldsNames, boolean asString) throws FieldNotFoundException { Object sourceValue = null; String foundSourceFieldName = null; for (String sourceFieldName : sourceFieldsNames) { try { if (asString) { sourceValue = devent.getFieldAsString(sourceFieldName); } else { sourceValue = devent.getField(sourceFieldName); } foundSourceFieldName = sourceFieldName; break; } catch (FieldNotFoundException e) { continue; } } if (sourceValue == null) { throw new FieldNotFoundException(); } return new ImmutablePair<String, Object>(foundSourceFieldName, sourceValue); } }
ipStr = ievent.getEventObj().getFieldAsString(this.pathToIpAddress); } catch (FieldNotFoundException e) { if (!this.required) { ievent.getEventObj().setField(this.destFieldName, geo); } catch (FieldNotFoundException e) { throw new OperationException(e);
@Override protected void doSubstitution(InternalEvent ievent, DeserializedEvent devent) { try { devent.setField(this.key, this.value); } catch (FieldNotFoundException e) { if (this.failDstNotFound) { throw new OperationException(e); } } } }
devent.setField(this.key, kv.getValue()); } catch (FieldNotFoundException e) { if (this.failDstNotFound) { devent.deleteField(kv.getKey());