Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id D06A2200B0F for ; Fri, 17 Jun 2016 15:39:01 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id CECB3160A61; Fri, 17 Jun 2016 13:39:01 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 2315A160A4C for ; Fri, 17 Jun 2016 15:39:00 +0200 (CEST) Received: (qmail 29622 invoked by uid 500); 17 Jun 2016 13:39:00 -0000 Mailing-List: contact dev-help@nifi.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@nifi.apache.org Delivered-To: mailing list dev@nifi.apache.org Received: (qmail 29608 invoked by uid 99); 17 Jun 2016 13:39:00 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 17 Jun 2016 13:39:00 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id E2BE1E049D; Fri, 17 Jun 2016 13:38:59 +0000 (UTC) From: brosander To: dev@nifi.apache.org Reply-To: dev@nifi.apache.org References: In-Reply-To: Subject: [GitHub] nifi pull request #525: NIFI-1976 - Windows Event Log native processor Content-Type: text/plain Message-Id: <20160617133859.E2BE1E049D@git1-us-west.apache.org> Date: Fri, 17 Jun 2016 13:38:59 +0000 (UTC) archived-at: Fri, 17 Jun 2016 13:39:02 -0000 Github user brosander commented on a diff in the pull request: https://github.com/apache/nifi/pull/525#discussion_r67511182 --- Diff: nifi-nar-bundles/nifi-windows-event-log-bundle/nifi-windows-event-log-processors/src/main/java/org/apache/nifi/processors/windows/event/log/EvtSubscribe.java --- @@ -0,0 +1,272 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.nifi.processors.windows.event.log; + +import com.google.common.annotations.VisibleForTesting; +import com.google.common.net.MediaType; +import com.sun.jna.platform.win32.Kernel32; +import com.sun.jna.platform.win32.WinNT; +import org.apache.commons.io.Charsets; +import org.apache.nifi.annotation.behavior.InputRequirement; +import org.apache.nifi.annotation.behavior.WritesAttribute; +import org.apache.nifi.annotation.behavior.WritesAttributes; +import org.apache.nifi.annotation.documentation.CapabilityDescription; +import org.apache.nifi.annotation.documentation.Tags; +import org.apache.nifi.annotation.lifecycle.OnScheduled; +import org.apache.nifi.annotation.lifecycle.OnStopped; +import org.apache.nifi.components.PropertyDescriptor; +import org.apache.nifi.components.ValidationContext; +import org.apache.nifi.components.ValidationResult; +import org.apache.nifi.flowfile.FlowFile; +import org.apache.nifi.flowfile.attributes.CoreAttributes; +import org.apache.nifi.processor.AbstractSessionFactoryProcessor; +import org.apache.nifi.processor.ProcessContext; +import org.apache.nifi.processor.ProcessSession; +import org.apache.nifi.processor.ProcessSessionFactory; +import org.apache.nifi.processor.Relationship; +import org.apache.nifi.processor.exception.ProcessException; +import org.apache.nifi.processor.util.StandardValidators; +import org.apache.nifi.processors.windows.event.log.jna.EventSubscribeXmlRenderingCallback; +import org.apache.nifi.processors.windows.event.log.jna.WEvtApi; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.HashSet; +import java.util.LinkedList; +import java.util.List; +import java.util.Queue; +import java.util.Set; +import java.util.concurrent.atomic.AtomicReference; + + +@InputRequirement(InputRequirement.Requirement.INPUT_FORBIDDEN) +@Tags({"ingest", "event", "windows"}) +@CapabilityDescription("Registers a Windows Event Log Subscribe Callback to receive FlowFiles from Events on Windows. These can be filtered via channel and XPath.") +@WritesAttributes({ + @WritesAttribute(attribute = "mime.type", description = "Will set a MIME type value of application/xml.") +}) +public class EvtSubscribe extends AbstractSessionFactoryProcessor { + public static final String DEFAULT_CHANNEL = "System"; + public static final String DEFAULT_XPATH = "*"; + public static final int DEFAULT_MAX_BUFFER = 1024 * 1024; + public static final int DEFAULT_MAX_QUEUE_SIZE = 1024; + + public static final PropertyDescriptor CHANNEL = new PropertyDescriptor.Builder() + .name("channel") + .displayName("Channel") + .required(true) + .defaultValue(DEFAULT_CHANNEL) + .description("The Windows Event Log Channel to listen to.") + .addValidator(StandardValidators.NON_EMPTY_VALIDATOR) + .build(); + + public static final PropertyDescriptor QUERY = new PropertyDescriptor.Builder() + .name("query") + .displayName("XPath Query") + .required(true) + .defaultValue(DEFAULT_XPATH) + .description("XPath Query to filter events. (See https://msdn.microsoft.com/en-us/library/windows/desktop/dd996910(v=vs.85).aspx for examples.)") + .addValidator(StandardValidators.NON_EMPTY_VALIDATOR) --- End diff -- @JPercivall I may not be reading it correctly but both EvaluateXPath and EvaluateXQuery appear to attempt to compile any dynamic properties they find in onTrigger(). I'm not seeing any other validation. --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastructure@apache.org or file a JIRA ticket with INFRA. ---