You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nifi.apache.org by jo...@apache.org on 2016/07/14 22:33:07 UTC
[01/10] nifi git commit: NIFI-1896 This closes #650. Refactored
nifi-api into nifi-framework-api and other locations. The nifi-api is
specific to that which is needed for intended extension points.
Repository: nifi
Updated Branches:
refs/heads/master 048ba5366 -> d1129706e
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-authorizer/pom.xml
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-authorizer/pom.xml b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-authorizer/pom.xml
index ee9f85a..ec1eee3 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-authorizer/pom.xml
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-authorizer/pom.xml
@@ -63,6 +63,10 @@
<dependencies>
<dependency>
<groupId>org.apache.nifi</groupId>
+ <artifactId>nifi-framework-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.nifi</groupId>
<artifactId>nifi-framework-core</artifactId>
</dependency>
<dependency>
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/pom.xml
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/pom.xml b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/pom.xml
index d8c3889..ed32625 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/pom.xml
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-documentation/pom.xml
@@ -28,6 +28,10 @@
</dependency>
<dependency>
<groupId>org.apache.nifi</groupId>
+ <artifactId>nifi-framework-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.nifi</groupId>
<artifactId>nifi-properties</artifactId>
</dependency>
<dependency>
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-file-authorizer/pom.xml
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-file-authorizer/pom.xml b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-file-authorizer/pom.xml
index c7fbb2c..8ea509c 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-file-authorizer/pom.xml
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-file-authorizer/pom.xml
@@ -79,6 +79,10 @@
</dependency>
<dependency>
<groupId>org.apache.nifi</groupId>
+ <artifactId>nifi-framework-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.nifi</groupId>
<artifactId>nifi-utils</artifactId>
</dependency>
<dependency>
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-authorization/pom.xml
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-authorization/pom.xml b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-authorization/pom.xml
index f1a6c28..59d5b2f 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-authorization/pom.xml
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-authorization/pom.xml
@@ -29,6 +29,10 @@
</dependency>
<dependency>
<groupId>org.apache.nifi</groupId>
+ <artifactId>nifi-framework-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.nifi</groupId>
<artifactId>nifi-expression-language</artifactId>
</dependency>
<dependency>
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/pom.xml
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/pom.xml b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/pom.xml
index 8a06467..f74d1ae 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/pom.xml
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/pom.xml
@@ -31,6 +31,10 @@
</dependency>
<dependency>
<groupId>org.apache.nifi</groupId>
+ <artifactId>nifi-framework-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.nifi</groupId>
<artifactId>nifi-properties</artifactId>
</dependency>
<dependency>
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/pom.xml
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/pom.xml b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/pom.xml
index 2d0f94b..d6d101c 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/pom.xml
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/pom.xml
@@ -40,6 +40,10 @@
</dependency>
<dependency>
<groupId>org.apache.nifi</groupId>
+ <artifactId>nifi-framework-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.nifi</groupId>
<artifactId>nifi-site-to-site-client</artifactId>
</dependency>
<dependency>
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/pom.xml
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/pom.xml b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/pom.xml
index 90d942c..3bc5360 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/pom.xml
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/pom.xml
@@ -34,6 +34,10 @@
</dependency>
<dependency>
<groupId>org.apache.nifi</groupId>
+ <artifactId>nifi-framework-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.nifi</groupId>
<artifactId>nifi-expression-language</artifactId>
</dependency>
<dependency>
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/FlowController.java
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/FlowController.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/FlowController.java
index 80b89dd..10d0b95 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/FlowController.java
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/FlowController.java
@@ -183,8 +183,8 @@ import org.apache.nifi.processor.Relationship;
import org.apache.nifi.processor.SimpleProcessLogger;
import org.apache.nifi.processor.StandardProcessorInitializationContext;
import org.apache.nifi.processor.StandardValidationContextFactory;
+import org.apache.nifi.provenance.ProvenanceRepository;
import org.apache.nifi.provenance.ProvenanceEventRecord;
-import org.apache.nifi.provenance.ProvenanceEventRepository;
import org.apache.nifi.provenance.ProvenanceEventType;
import org.apache.nifi.provenance.ProvenanceAuthorizableFactory;
import org.apache.nifi.provenance.StandardProvenanceEventRecord;
@@ -266,7 +266,7 @@ public class FlowController implements EventAccess, ControllerServiceProvider, R
private final ContentRepository contentRepository;
private final FlowFileRepository flowFileRepository;
private final FlowFileEventRepository flowFileEventRepository;
- private final ProvenanceEventRepository provenanceEventRepository;
+ private final ProvenanceRepository provenanceRepository;
private final BulletinRepository bulletinRepository;
private final StandardProcessScheduler processScheduler;
private final SnippetManager snippetManager;
@@ -449,8 +449,8 @@ public class FlowController implements EventAccess, ControllerServiceProvider, R
bulletinRepository = bulletinRepo;
try {
- this.provenanceEventRepository = createProvenanceRepository(properties);
- this.provenanceEventRepository.initialize(createEventReporter(bulletinRepository), authorizer, this);
+ this.provenanceRepository = createProvenanceRepository(properties);
+ this.provenanceRepository.initialize(createEventReporter(bulletinRepository), authorizer, this);
} catch (final Exception e) {
throw new RuntimeException("Unable to create Provenance Repository", e);
}
@@ -470,7 +470,7 @@ public class FlowController implements EventAccess, ControllerServiceProvider, R
processScheduler = new StandardProcessScheduler(this, encryptor, stateManagerProvider);
eventDrivenWorkerQueue = new EventDrivenWorkerQueue(false, false, processScheduler);
- final ProcessContextFactory contextFactory = new ProcessContextFactory(contentRepository, flowFileRepository, flowFileEventRepository, counterRepositoryRef.get(), provenanceEventRepository);
+ final ProcessContextFactory contextFactory = new ProcessContextFactory(contentRepository, flowFileRepository, flowFileEventRepository, counterRepositoryRef.get(), provenanceRepository);
processScheduler.setSchedulingAgent(SchedulingStrategy.EVENT_DRIVEN, new EventDrivenSchedulingAgent(
eventDrivenEngineRef.get(), this, stateManagerProvider, eventDrivenWorkerQueue, contextFactory, maxEventDrivenThreads.get(), encryptor));
@@ -521,7 +521,7 @@ public class FlowController implements EventAccess, ControllerServiceProvider, R
LOG.info("Not enabling RAW Socket Site-to-Site functionality because nifi.remote.input.socket.port is not set");
} else if (isSiteToSiteSecure && sslContext == null) {
LOG.error("Unable to create Secure Site-to-Site Listener because not all required Keystore/Truststore "
- + "Properties are set. Site-to-Site functionality will be disabled until this problem is has been fixed.");
+ + "Properties are set. Site-to-Site functionality will be disabled until this problem is has been fixed.");
} else {
// Register the SocketFlowFileServerProtocol as the appropriate resource for site-to-site Server Protocol
RemoteResourceManager.setServerProtocolImplementation(SocketFlowFileServerProtocol.RESOURCE_NAME, SocketFlowFileServerProtocol.class);
@@ -534,7 +534,7 @@ public class FlowController implements EventAccess, ControllerServiceProvider, R
externalSiteListeners.add(HttpRemoteSiteListener.getInstance());
}
- for(final RemoteSiteListener listener : externalSiteListeners) {
+ for (final RemoteSiteListener listener : externalSiteListeners) {
listener.setRootGroup(rootGroup);
}
@@ -672,7 +672,7 @@ public class FlowController implements EventAccess, ControllerServiceProvider, R
// ContentRepository to purge superfluous files
contentRepository.cleanup();
- for(final RemoteSiteListener listener : externalSiteListeners) {
+ for (final RemoteSiteListener listener : externalSiteListeners) {
listener.start();
}
@@ -807,7 +807,7 @@ public class FlowController implements EventAccess, ControllerServiceProvider, R
}
}
- private ProvenanceEventRepository createProvenanceRepository(final NiFiProperties properties) throws InstantiationException, IllegalAccessException, ClassNotFoundException {
+ private ProvenanceRepository createProvenanceRepository(final NiFiProperties properties) throws InstantiationException, IllegalAccessException, ClassNotFoundException {
final String implementationClassName = properties.getProperty(NiFiProperties.PROVENANCE_REPO_IMPLEMENTATION_CLASS, DEFAULT_PROVENANCE_REPO_IMPLEMENTATION);
if (implementationClassName == null) {
throw new RuntimeException("Cannot create Provenance Repository because the NiFi Properties is missing the following property: "
@@ -815,7 +815,7 @@ public class FlowController implements EventAccess, ControllerServiceProvider, R
}
try {
- return NarThreadContextClassLoader.createInstance(implementationClassName, ProvenanceEventRepository.class);
+ return NarThreadContextClassLoader.createInstance(implementationClassName, ProvenanceRepository.class);
} catch (final Exception e) {
throw new RuntimeException(e);
}
@@ -882,16 +882,16 @@ public class FlowController implements EventAccess, ControllerServiceProvider, R
}
return builder.id(requireNonNull(id).intern())
- .name(name == null ? null : name.intern())
- .relationships(relationships)
- .source(requireNonNull(source))
- .destination(destination)
- .swapManager(swapManager)
- .eventReporter(eventReporter)
- .resourceClaimManager(resourceClaimManager)
- .flowFileRepository(flowFileRepository)
- .provenanceRepository(provenanceEventRepository)
- .build();
+ .name(name == null ? null : name.intern())
+ .relationships(relationships)
+ .source(requireNonNull(source))
+ .destination(destination)
+ .swapManager(swapManager)
+ .eventReporter(eventReporter)
+ .resourceClaimManager(resourceClaimManager)
+ .flowFileRepository(flowFileRepository)
+ .provenanceRepository(provenanceRepository)
+ .build();
}
/**
@@ -1313,7 +1313,7 @@ public class FlowController implements EventAccess, ControllerServiceProvider, R
+ "will take an indeterminate amount of time to stop. Might need to kill the program manually.");
}
- for(final RemoteSiteListener listener : externalSiteListeners) {
+ for (final RemoteSiteListener listener : externalSiteListeners) {
listener.stop();
}
@@ -1325,9 +1325,9 @@ public class FlowController implements EventAccess, ControllerServiceProvider, R
contentRepository.shutdown();
}
- if (provenanceEventRepository != null) {
+ if (provenanceRepository != null) {
try {
- provenanceEventRepository.close();
+ provenanceRepository.close();
} catch (final IOException ioe) {
LOG.warn("There was a problem shutting down the Provenance Repository: " + ioe.toString());
if (LOG.isDebugEnabled()) {
@@ -1414,9 +1414,7 @@ public class FlowController implements EventAccess, ControllerServiceProvider, R
/**
* Updates the number of threads that can be simultaneously used for executing processors.
*
- * @param maxThreadCount
- *
- * This method must be called while holding the write lock!
+ * @param maxThreadCount This method must be called while holding the write lock!
*/
private void setMaxThreadCount(final int maxThreadCount, final FlowEngine engine, final AtomicInteger maxThreads) {
if (maxThreadCount < 1) {
@@ -1458,7 +1456,7 @@ public class FlowController implements EventAccess, ControllerServiceProvider, R
try {
rootGroup = group;
- for(final RemoteSiteListener listener : externalSiteListeners) {
+ for (final RemoteSiteListener listener : externalSiteListeners) {
listener.setRootGroup(rootGroup);
}
@@ -3496,7 +3494,7 @@ public class FlowController implements EventAccess, ControllerServiceProvider, R
.setDetails("Download of " + (direction == ContentDirection.INPUT ? "Input" : "Output") + " Content requested by " + requestor + " for Provenance Event " + provEvent.getEventId())
.build();
- provenanceEventRepository.registerEvent(sendEvent);
+ provenanceRepository.registerEvent(sendEvent);
return new LimitedInputStream(rawStream, size);
}
@@ -3542,7 +3540,7 @@ public class FlowController implements EventAccess, ControllerServiceProvider, R
}
final ProvenanceEventRecord sendEvent = sendEventBuilder.build();
- provenanceEventRepository.registerEvent(sendEvent);
+ provenanceRepository.registerEvent(sendEvent);
return stream;
}
@@ -3596,7 +3594,7 @@ public class FlowController implements EventAccess, ControllerServiceProvider, R
}
public ProvenanceEventRecord replayFlowFile(final long provenanceEventRecordId, final NiFiUser user) throws IOException {
- final ProvenanceEventRecord record = provenanceEventRepository.getEvent(provenanceEventRecordId, user);
+ final ProvenanceEventRecord record = provenanceRepository.getEvent(provenanceEventRecordId, user);
if (record == null) {
throw new IllegalStateException("Cannot find Provenance Event with ID " + provenanceEventRecordId);
}
@@ -3691,20 +3689,20 @@ public class FlowController implements EventAccess, ControllerServiceProvider, R
// Register a Provenance Event to indicate that we replayed the data.
final ProvenanceEventRecord replayEvent = new StandardProvenanceEventRecord.Builder()
- .setEventType(ProvenanceEventType.REPLAY)
- .addChildUuid(newFlowFileUUID)
- .addParentUuid(parentUUID)
- .setFlowFileUUID(parentUUID)
- .setAttributes(Collections.<String, String> emptyMap(), flowFileRecord.getAttributes())
- .setCurrentContentClaim(event.getContentClaimContainer(), event.getContentClaimSection(), event.getContentClaimIdentifier(), event.getContentClaimOffset(), event.getFileSize())
- .setDetails("Replay requested by " + user.getIdentity())
- .setEventTime(System.currentTimeMillis())
- .setFlowFileEntryDate(System.currentTimeMillis())
- .setLineageStartDate(event.getLineageStartDate())
- .setComponentType(event.getComponentType())
- .setComponentId(event.getComponentId())
- .build();
- provenanceEventRepository.registerEvent(replayEvent);
+ .setEventType(ProvenanceEventType.REPLAY)
+ .addChildUuid(newFlowFileUUID)
+ .addParentUuid(parentUUID)
+ .setFlowFileUUID(parentUUID)
+ .setAttributes(Collections.<String, String>emptyMap(), flowFileRecord.getAttributes())
+ .setCurrentContentClaim(event.getContentClaimContainer(), event.getContentClaimSection(), event.getContentClaimIdentifier(), event.getContentClaimOffset(), event.getFileSize())
+ .setDetails("Replay requested by " + user.getIdentity())
+ .setEventTime(System.currentTimeMillis())
+ .setFlowFileEntryDate(System.currentTimeMillis())
+ .setLineageStartDate(event.getLineageStartDate())
+ .setComponentType(event.getComponentType())
+ .setComponentId(event.getComponentId())
+ .build();
+ provenanceRepository.registerEvent(replayEvent);
// Update the FlowFile Repository to indicate that we have added the FlowFile to the flow
final StandardRepositoryRecord record = new StandardRepositoryRecord(queue, flowFileRecord);
@@ -3863,7 +3861,7 @@ public class FlowController implements EventAccess, ControllerServiceProvider, R
@Override
public List<ProvenanceEventRecord> getProvenanceEvents(final long firstEventId, final int maxRecords) throws IOException {
- return new ArrayList<>(provenanceEventRepository.getEvents(firstEventId, maxRecords));
+ return new ArrayList<>(provenanceRepository.getEvents(firstEventId, maxRecords));
}
@Override
@@ -3955,9 +3953,8 @@ public class FlowController implements EventAccess, ControllerServiceProvider, R
return controllerServiceProvider.getControllerServiceIdentifiers(serviceType, groupId);
}
- @Override
- public ProvenanceEventRepository getProvenanceRepository() {
- return provenanceEventRepository;
+ public ProvenanceRepository getProvenanceRepository() {
+ return provenanceRepository;
}
public StatusHistoryDTO getConnectionStatusHistory(final String connectionId) {
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/TestFlowController.java
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/TestFlowController.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/TestFlowController.java
index 03260f1..a2eeb58 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/TestFlowController.java
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/TestFlowController.java
@@ -31,7 +31,7 @@ import org.apache.nifi.controller.repository.FlowFileEventRepository;
import org.apache.nifi.controller.service.ControllerServiceNode;
import org.apache.nifi.encrypt.StringEncryptor;
import org.apache.nifi.processor.Relationship;
-import org.apache.nifi.provenance.MockProvenanceEventRepository;
+import org.apache.nifi.provenance.MockProvenanceRepository;
import org.apache.nifi.reporting.BulletinRepository;
import org.apache.nifi.util.NiFiProperties;
import org.junit.After;
@@ -67,7 +67,7 @@ public class TestFlowController {
final AuditService auditService = Mockito.mock(AuditService.class);
final StringEncryptor encryptor = StringEncryptor.createEncryptor();
final NiFiProperties properties = NiFiProperties.getInstance();
- properties.setProperty(NiFiProperties.PROVENANCE_REPO_IMPLEMENTATION_CLASS, MockProvenanceEventRepository.class.getName());
+ properties.setProperty(NiFiProperties.PROVENANCE_REPO_IMPLEMENTATION_CLASS, MockProvenanceRepository.class.getName());
properties.setProperty("nifi.remote.input.socket.port", "");
properties.setProperty("nifi.remote.input.secure", "");
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/repository/TestStandardProcessSession.java
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/repository/TestStandardProcessSession.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/repository/TestStandardProcessSession.java
index 23a170e..c1bcacd 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/repository/TestStandardProcessSession.java
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/repository/TestStandardProcessSession.java
@@ -75,7 +75,7 @@ import org.apache.nifi.processor.exception.ProcessException;
import org.apache.nifi.processor.io.InputStreamCallback;
import org.apache.nifi.processor.io.OutputStreamCallback;
import org.apache.nifi.processor.io.StreamCallback;
-import org.apache.nifi.provenance.MockProvenanceEventRepository;
+import org.apache.nifi.provenance.MockProvenanceRepository;
import org.apache.nifi.provenance.ProvenanceEventRecord;
import org.apache.nifi.provenance.ProvenanceEventRepository;
import org.apache.nifi.provenance.ProvenanceEventType;
@@ -138,7 +138,7 @@ public class TestStandardProcessSession {
System.setProperty("nifi.properties.file.path", "src/test/resources/nifi.properties");
final FlowFileEventRepository flowFileEventRepo = Mockito.mock(FlowFileEventRepository.class);
final CounterRepository counterRepo = Mockito.mock(CounterRepository.class);
- provenanceRepo = new MockProvenanceEventRepository();
+ provenanceRepo = new MockProvenanceRepository();
final Connection connection = Mockito.mock(Connection.class);
final ProcessScheduler processScheduler = Mockito.mock(ProcessScheduler.class);
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/scheduling/TestProcessorLifecycle.java
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/scheduling/TestProcessorLifecycle.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/scheduling/TestProcessorLifecycle.java
index 0933013..e5b3342 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/scheduling/TestProcessorLifecycle.java
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/scheduling/TestProcessorLifecycle.java
@@ -42,7 +42,7 @@ import org.apache.nifi.processor.ProcessContext;
import org.apache.nifi.processor.ProcessSession;
import org.apache.nifi.processor.Relationship;
import org.apache.nifi.processor.exception.ProcessException;
-import org.apache.nifi.provenance.MockProvenanceEventRepository;
+import org.apache.nifi.provenance.MockProvenanceRepository;
import org.apache.nifi.util.NiFiProperties;
import org.junit.After;
import org.junit.Before;
@@ -656,7 +656,7 @@ public class TestProcessorLifecycle {
*/
private FlowController buildFlowControllerForTest() throws Exception {
NiFiProperties properties = NiFiProperties.getInstance();
- properties.setProperty(NiFiProperties.PROVENANCE_REPO_IMPLEMENTATION_CLASS, MockProvenanceEventRepository.class.getName());
+ properties.setProperty(NiFiProperties.PROVENANCE_REPO_IMPLEMENTATION_CLASS, MockProvenanceRepository.class.getName());
properties.setProperty("nifi.remote.input.socket.port", "");
properties.setProperty("nifi.remote.input.secure", "");
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-nar-utils/pom.xml
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-nar-utils/pom.xml b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-nar-utils/pom.xml
index d3f830d..91339b3 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-nar-utils/pom.xml
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-nar-utils/pom.xml
@@ -30,5 +30,9 @@
<groupId>org.apache.nifi</groupId>
<artifactId>nifi-api</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.apache.nifi</groupId>
+ <artifactId>nifi-framework-api</artifactId>
+ </dependency>
</dependencies>
</project>
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-nar-utils/src/main/java/org/apache/nifi/nar/ExtensionManager.java
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-nar-utils/src/main/java/org/apache/nifi/nar/ExtensionManager.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-nar-utils/src/main/java/org/apache/nifi/nar/ExtensionManager.java
index f06012c..9355bbc 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-nar-utils/src/main/java/org/apache/nifi/nar/ExtensionManager.java
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-nar-utils/src/main/java/org/apache/nifi/nar/ExtensionManager.java
@@ -25,7 +25,7 @@ import org.apache.nifi.controller.repository.FlowFileSwapManager;
import org.apache.nifi.controller.status.history.ComponentStatusRepository;
import org.apache.nifi.flowfile.FlowFilePrioritizer;
import org.apache.nifi.processor.Processor;
-import org.apache.nifi.provenance.ProvenanceEventRepository;
+import org.apache.nifi.provenance.ProvenanceRepository;
import org.apache.nifi.reporting.ReportingTask;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -53,17 +53,17 @@ public class ExtensionManager {
private static final Map<String, ClassLoader> extensionClassloaderLookup = new HashMap<>();
static {
- definitionMap.put(Processor.class, new HashSet<Class>());
- definitionMap.put(FlowFilePrioritizer.class, new HashSet<Class>());
- definitionMap.put(ReportingTask.class, new HashSet<Class>());
- definitionMap.put(ControllerService.class, new HashSet<Class>());
- definitionMap.put(Authorizer.class, new HashSet<Class>());
- definitionMap.put(LoginIdentityProvider.class, new HashSet<Class>());
- definitionMap.put(ProvenanceEventRepository.class, new HashSet<Class>());
- definitionMap.put(ComponentStatusRepository.class, new HashSet<Class>());
- definitionMap.put(FlowFileRepository.class, new HashSet<Class>());
- definitionMap.put(FlowFileSwapManager.class, new HashSet<Class>());
- definitionMap.put(ContentRepository.class, new HashSet<Class>());
+ definitionMap.put(Processor.class, new HashSet<>());
+ definitionMap.put(FlowFilePrioritizer.class, new HashSet<>());
+ definitionMap.put(ReportingTask.class, new HashSet<>());
+ definitionMap.put(ControllerService.class, new HashSet<>());
+ definitionMap.put(Authorizer.class, new HashSet<>());
+ definitionMap.put(LoginIdentityProvider.class, new HashSet<>());
+ definitionMap.put(ProvenanceRepository.class, new HashSet<>());
+ definitionMap.put(ComponentStatusRepository.class, new HashSet<>());
+ definitionMap.put(FlowFileRepository.class, new HashSet<>());
+ definitionMap.put(FlowFileSwapManager.class, new HashSet<>());
+ definitionMap.put(ContentRepository.class, new HashSet<>());
}
/**
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-nar-utils/src/main/java/org/apache/nifi/nar/NarThreadContextClassLoader.java
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-nar-utils/src/main/java/org/apache/nifi/nar/NarThreadContextClassLoader.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-nar-utils/src/main/java/org/apache/nifi/nar/NarThreadContextClassLoader.java
index 93f73eb..381b54b 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-nar-utils/src/main/java/org/apache/nifi/nar/NarThreadContextClassLoader.java
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-nar-utils/src/main/java/org/apache/nifi/nar/NarThreadContextClassLoader.java
@@ -29,7 +29,7 @@ import org.apache.nifi.processor.Processor;
import org.apache.nifi.processor.io.InputStreamCallback;
import org.apache.nifi.processor.io.OutputStreamCallback;
import org.apache.nifi.processor.io.StreamCallback;
-import org.apache.nifi.provenance.ProvenanceEventRepository;
+import org.apache.nifi.provenance.ProvenanceRepository;
import org.apache.nifi.reporting.ReportingTask;
import java.io.IOException;
@@ -60,7 +60,7 @@ public class NarThreadContextClassLoader extends URLClassLoader {
narSpecificClasses.add(ControllerService.class);
narSpecificClasses.add(Authorizer.class);
narSpecificClasses.add(LoginIdentityProvider.class);
- narSpecificClasses.add(ProvenanceEventRepository.class);
+ narSpecificClasses.add(ProvenanceRepository.class);
narSpecificClasses.add(ComponentStatusRepository.class);
narSpecificClasses.add(FlowFileRepository.class);
narSpecificClasses.add(FlowFileSwapManager.class);
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-site-to-site/pom.xml
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-site-to-site/pom.xml b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-site-to-site/pom.xml
index 74ff797..aa00344 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-site-to-site/pom.xml
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-site-to-site/pom.xml
@@ -36,6 +36,10 @@
</dependency>
<dependency>
<groupId>org.apache.nifi</groupId>
+ <artifactId>nifi-framework-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.nifi</groupId>
<artifactId>nifi-properties</artifactId>
</dependency>
<dependency>
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-user-actions/pom.xml
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-user-actions/pom.xml b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-user-actions/pom.xml
index ee6d175..0a07235 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-user-actions/pom.xml
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-user-actions/pom.xml
@@ -27,5 +27,9 @@
<groupId>org.apache.nifi</groupId>
<artifactId>nifi-api</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.apache.nifi</groupId>
+ <artifactId>nifi-framework-api</artifactId>
+ </dependency>
</dependencies>
</project>
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-custom-ui-utilities/pom.xml
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-custom-ui-utilities/pom.xml b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-custom-ui-utilities/pom.xml
index e90220a..e5bd664 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-custom-ui-utilities/pom.xml
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-custom-ui-utilities/pom.xml
@@ -27,6 +27,10 @@
<artifactId>nifi-api</artifactId>
</dependency>
<dependency>
+ <groupId>org.apache.nifi</groupId>
+ <artifactId>nifi-framework-api</artifactId>
+ </dependency>
+ <dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
</dependency>
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-ui-extension/pom.xml
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-ui-extension/pom.xml b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-ui-extension/pom.xml
index 013c5c9..dd6a8ba 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-ui-extension/pom.xml
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-ui-extension/pom.xml
@@ -29,6 +29,10 @@
</dependency>
<dependency>
<groupId>org.apache.nifi</groupId>
+ <artifactId>nifi-framework-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.nifi</groupId>
<artifactId>nifi-user-actions</artifactId>
</dependency>
</dependencies>
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/pom.xml
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/pom.xml b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/pom.xml
index 38ce1a6..9024835 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/pom.xml
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/pom.xml
@@ -158,6 +158,11 @@
</dependency>
<dependency>
<groupId>org.apache.nifi</groupId>
+ <artifactId>nifi-framework-api</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.nifi</groupId>
<artifactId>nifi-nar-utils</artifactId>
</dependency>
<dependency>
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/controller/ControllerFacade.java
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/controller/ControllerFacade.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/controller/ControllerFacade.java
index afc3b2f..d9ae8ed 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/controller/ControllerFacade.java
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/controller/ControllerFacade.java
@@ -68,8 +68,8 @@ import org.apache.nifi.nar.NarCloseable;
import org.apache.nifi.processor.DataUnit;
import org.apache.nifi.processor.Processor;
import org.apache.nifi.processor.Relationship;
+import org.apache.nifi.provenance.ProvenanceRepository;
import org.apache.nifi.provenance.ProvenanceEventRecord;
-import org.apache.nifi.provenance.ProvenanceEventRepository;
import org.apache.nifi.provenance.SearchableFields;
import org.apache.nifi.provenance.lineage.ComputeLineageSubmission;
import org.apache.nifi.provenance.search.Query;
@@ -831,7 +831,7 @@ public class ControllerFacade implements Authorizable {
* @return the available options for searching provenance
*/
public ProvenanceOptionsDTO getProvenanceSearchOptions() {
- final ProvenanceEventRepository provenanceRepository = flowController.getProvenanceRepository();
+ final ProvenanceRepository provenanceRepository = flowController.getProvenanceRepository();
// create the search options dto
final ProvenanceOptionsDTO searchOptions = new ProvenanceOptionsDTO();
@@ -905,7 +905,7 @@ public class ControllerFacade implements Authorizable {
}
// submit the query to the provenance repository
- final ProvenanceEventRepository provenanceRepository = flowController.getProvenanceRepository();
+ final ProvenanceRepository provenanceRepository = flowController.getProvenanceRepository();
final QuerySubmission querySubmission = provenanceRepository.submitQuery(query, NiFiUserUtils.getNiFiUser());
// return the query with the results populated at this point
@@ -921,7 +921,7 @@ public class ControllerFacade implements Authorizable {
public ProvenanceDTO getProvenanceQuery(String provenanceId) {
try {
// get the query to the provenance repository
- final ProvenanceEventRepository provenanceRepository = flowController.getProvenanceRepository();
+ final ProvenanceRepository provenanceRepository = flowController.getProvenanceRepository();
final QuerySubmission querySubmission = provenanceRepository.retrieveQuerySubmission(provenanceId, NiFiUserUtils.getNiFiUser());
// ensure the query results could be found
@@ -1013,7 +1013,7 @@ public class ControllerFacade implements Authorizable {
final LineageRequestDTO requestDto = lineageDto.getRequest();
// get the provenance repo
- final ProvenanceEventRepository provenanceRepository = flowController.getProvenanceRepository();
+ final ProvenanceRepository provenanceRepository = flowController.getProvenanceRepository();
final ComputeLineageSubmission result;
// submit the event
@@ -1040,7 +1040,7 @@ public class ControllerFacade implements Authorizable {
*/
public LineageDTO getLineage(final String lineageId) {
// get the query to the provenance repository
- final ProvenanceEventRepository provenanceRepository = flowController.getProvenanceRepository();
+ final ProvenanceRepository provenanceRepository = flowController.getProvenanceRepository();
final ComputeLineageSubmission computeLineageSubmission = provenanceRepository.retrieveLineageSubmission(lineageId, NiFiUserUtils.getNiFiUser());
// ensure the submission was found
@@ -1058,7 +1058,7 @@ public class ControllerFacade implements Authorizable {
*/
public void deleteProvenanceQuery(final String provenanceId) {
// get the query to the provenance repository
- final ProvenanceEventRepository provenanceRepository = flowController.getProvenanceRepository();
+ final ProvenanceRepository provenanceRepository = flowController.getProvenanceRepository();
final QuerySubmission querySubmission = provenanceRepository.retrieveQuerySubmission(provenanceId, NiFiUserUtils.getNiFiUser());
if (querySubmission != null) {
querySubmission.cancel();
@@ -1072,7 +1072,7 @@ public class ControllerFacade implements Authorizable {
*/
public void deleteLineage(final String lineageId) {
// get the query to the provenance repository
- final ProvenanceEventRepository provenanceRepository = flowController.getProvenanceRepository();
+ final ProvenanceRepository provenanceRepository = flowController.getProvenanceRepository();
final ComputeLineageSubmission computeLineageSubmission = provenanceRepository.retrieveLineageSubmission(lineageId, NiFiUserUtils.getNiFiUser());
if (computeLineageSubmission != null) {
computeLineageSubmission.cancel();
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-content-viewer/pom.xml
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-content-viewer/pom.xml b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-content-viewer/pom.xml
index d66c4ca..4f23f02 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-content-viewer/pom.xml
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-content-viewer/pom.xml
@@ -33,6 +33,10 @@
</dependency>
<dependency>
<groupId>org.apache.nifi</groupId>
+ <artifactId>nifi-framework-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.nifi</groupId>
<artifactId>nifi-web-content-access</artifactId>
<scope>provided</scope>
</dependency>
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-optimistic-locking/pom.xml
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-optimistic-locking/pom.xml b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-optimistic-locking/pom.xml
index f38376b..df32b54 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-optimistic-locking/pom.xml
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-optimistic-locking/pom.xml
@@ -29,6 +29,10 @@
</dependency>
<dependency>
<groupId>org.apache.nifi</groupId>
+ <artifactId>nifi-framework-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.nifi</groupId>
<artifactId>nifi-administration</artifactId>
</dependency>
<dependency>
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-security/pom.xml
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-security/pom.xml b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-security/pom.xml
index 97a90d3..61ecc5e 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-security/pom.xml
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-security/pom.xml
@@ -71,6 +71,10 @@
</dependency>
<dependency>
<groupId>org.apache.nifi</groupId>
+ <artifactId>nifi-framework-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.nifi</groupId>
<artifactId>nifi-web-utils</artifactId>
</dependency>
<dependency>
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-nar-bundles/nifi-kerberos-iaa-providers-bundle/nifi-kerberos-iaa-providers/pom.xml
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-kerberos-iaa-providers-bundle/nifi-kerberos-iaa-providers/pom.xml b/nifi-nar-bundles/nifi-kerberos-iaa-providers-bundle/nifi-kerberos-iaa-providers/pom.xml
index 04ef8f0..0e16538 100644
--- a/nifi-nar-bundles/nifi-kerberos-iaa-providers-bundle/nifi-kerberos-iaa-providers/pom.xml
+++ b/nifi-nar-bundles/nifi-kerberos-iaa-providers-bundle/nifi-kerberos-iaa-providers/pom.xml
@@ -29,6 +29,10 @@
</dependency>
<dependency>
<groupId>org.apache.nifi</groupId>
+ <artifactId>nifi-framework-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.nifi</groupId>
<artifactId>nifi-utils</artifactId>
</dependency>
<dependency>
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-nar-bundles/nifi-ldap-iaa-providers-bundle/nifi-ldap-iaa-providers/pom.xml
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-ldap-iaa-providers-bundle/nifi-ldap-iaa-providers/pom.xml b/nifi-nar-bundles/nifi-ldap-iaa-providers-bundle/nifi-ldap-iaa-providers/pom.xml
index aafb4e3..de265e0 100644
--- a/nifi-nar-bundles/nifi-ldap-iaa-providers-bundle/nifi-ldap-iaa-providers/pom.xml
+++ b/nifi-nar-bundles/nifi-ldap-iaa-providers-bundle/nifi-ldap-iaa-providers/pom.xml
@@ -29,6 +29,10 @@
</dependency>
<dependency>
<groupId>org.apache.nifi</groupId>
+ <artifactId>nifi-framework-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.nifi</groupId>
<artifactId>nifi-utils</artifactId>
</dependency>
<dependency>
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-nar-bundles/nifi-media-bundle/nifi-image-viewer/pom.xml
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-media-bundle/nifi-image-viewer/pom.xml b/nifi-nar-bundles/nifi-media-bundle/nifi-image-viewer/pom.xml
index 71a6bd7..ca14748 100755
--- a/nifi-nar-bundles/nifi-media-bundle/nifi-image-viewer/pom.xml
+++ b/nifi-nar-bundles/nifi-media-bundle/nifi-image-viewer/pom.xml
@@ -33,6 +33,10 @@
<artifactId>nifi-api</artifactId>
</dependency>
<dependency>
+ <groupId>org.apache.nifi</groupId>
+ <artifactId>nifi-framework-api</artifactId>
+ </dependency>
+ <dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
</dependency>
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-nar-bundles/nifi-provenance-repository-bundle/nifi-persistent-provenance-repository/pom.xml
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-provenance-repository-bundle/nifi-persistent-provenance-repository/pom.xml b/nifi-nar-bundles/nifi-provenance-repository-bundle/nifi-persistent-provenance-repository/pom.xml
index a02f071..67a7310 100644
--- a/nifi-nar-bundles/nifi-provenance-repository-bundle/nifi-persistent-provenance-repository/pom.xml
+++ b/nifi-nar-bundles/nifi-provenance-repository-bundle/nifi-persistent-provenance-repository/pom.xml
@@ -28,6 +28,10 @@
</dependency>
<dependency>
<groupId>org.apache.nifi</groupId>
+ <artifactId>nifi-framework-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.nifi</groupId>
<artifactId>nifi-data-provenance-utils</artifactId>
</dependency>
<dependency>
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-nar-bundles/nifi-provenance-repository-bundle/nifi-persistent-provenance-repository/src/main/java/org/apache/nifi/provenance/PersistentProvenanceRepository.java
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-provenance-repository-bundle/nifi-persistent-provenance-repository/src/main/java/org/apache/nifi/provenance/PersistentProvenanceRepository.java b/nifi-nar-bundles/nifi-provenance-repository-bundle/nifi-persistent-provenance-repository/src/main/java/org/apache/nifi/provenance/PersistentProvenanceRepository.java
index bdeb218..e01c2b1 100644
--- a/nifi-nar-bundles/nifi-provenance-repository-bundle/nifi-persistent-provenance-repository/src/main/java/org/apache/nifi/provenance/PersistentProvenanceRepository.java
+++ b/nifi-nar-bundles/nifi-provenance-repository-bundle/nifi-persistent-provenance-repository/src/main/java/org/apache/nifi/provenance/PersistentProvenanceRepository.java
@@ -112,7 +112,7 @@ import java.util.concurrent.locks.ReentrantReadWriteLock;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
-public class PersistentProvenanceRepository implements ProvenanceEventRepository {
+public class PersistentProvenanceRepository implements ProvenanceRepository {
public static final String EVENT_CATEGORY = "Provenance Repository";
private static final String FILE_EXTENSION = ".prov";
@@ -2264,7 +2264,7 @@ public class PersistentProvenanceRepository implements ProvenanceEventRepository
throw new AccessDeniedException("Cannot retrieve Provenance Query Submission because " + user.getIdentity() + " is not the user who submitted the request");
}
- private ProvenanceEventRecord getEvent(final long id) throws IOException {
+ public ProvenanceEventRecord getEvent(final long id) throws IOException {
final List<ProvenanceEventRecord> records = getEvents(id, 1);
if (records.isEmpty()) {
return null;
@@ -2320,6 +2320,11 @@ public class PersistentProvenanceRepository implements ProvenanceEventRepository
return files;
}
+ @Override
+ public ProvenanceEventRepository getProvenanceEventRepository() {
+ return this;
+ }
+
/**
* Returns the Event ID of the first event in the given Provenance Event Log File.
*
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-nar-bundles/nifi-provenance-repository-bundle/nifi-persistent-provenance-repository/src/main/resources/META-INF/services/org.apache.nifi.provenance.ProvenanceEventRepository
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-provenance-repository-bundle/nifi-persistent-provenance-repository/src/main/resources/META-INF/services/org.apache.nifi.provenance.ProvenanceEventRepository b/nifi-nar-bundles/nifi-provenance-repository-bundle/nifi-persistent-provenance-repository/src/main/resources/META-INF/services/org.apache.nifi.provenance.ProvenanceEventRepository
deleted file mode 100644
index 78da70e..0000000
--- a/nifi-nar-bundles/nifi-provenance-repository-bundle/nifi-persistent-provenance-repository/src/main/resources/META-INF/services/org.apache.nifi.provenance.ProvenanceEventRepository
+++ /dev/null
@@ -1,15 +0,0 @@
-# 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.
-org.apache.nifi.provenance.PersistentProvenanceRepository
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-nar-bundles/nifi-provenance-repository-bundle/nifi-persistent-provenance-repository/src/main/resources/META-INF/services/org.apache.nifi.provenance.ProvenanceRepository
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-provenance-repository-bundle/nifi-persistent-provenance-repository/src/main/resources/META-INF/services/org.apache.nifi.provenance.ProvenanceRepository b/nifi-nar-bundles/nifi-provenance-repository-bundle/nifi-persistent-provenance-repository/src/main/resources/META-INF/services/org.apache.nifi.provenance.ProvenanceRepository
new file mode 100644
index 0000000..78da70e
--- /dev/null
+++ b/nifi-nar-bundles/nifi-provenance-repository-bundle/nifi-persistent-provenance-repository/src/main/resources/META-INF/services/org.apache.nifi.provenance.ProvenanceRepository
@@ -0,0 +1,15 @@
+# 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.
+org.apache.nifi.provenance.PersistentProvenanceRepository
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-nar-bundles/nifi-provenance-repository-bundle/nifi-volatile-provenance-repository/pom.xml
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-provenance-repository-bundle/nifi-volatile-provenance-repository/pom.xml b/nifi-nar-bundles/nifi-provenance-repository-bundle/nifi-volatile-provenance-repository/pom.xml
index f58f522..35a26e1 100644
--- a/nifi-nar-bundles/nifi-provenance-repository-bundle/nifi-volatile-provenance-repository/pom.xml
+++ b/nifi-nar-bundles/nifi-provenance-repository-bundle/nifi-volatile-provenance-repository/pom.xml
@@ -28,6 +28,10 @@
</dependency>
<dependency>
<groupId>org.apache.nifi</groupId>
+ <artifactId>nifi-framework-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.nifi</groupId>
<artifactId>nifi-data-provenance-utils</artifactId>
</dependency>
<dependency>
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-nar-bundles/nifi-provenance-repository-bundle/nifi-volatile-provenance-repository/src/main/java/org/apache/nifi/provenance/VolatileProvenanceRepository.java
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-provenance-repository-bundle/nifi-volatile-provenance-repository/src/main/java/org/apache/nifi/provenance/VolatileProvenanceRepository.java b/nifi-nar-bundles/nifi-provenance-repository-bundle/nifi-volatile-provenance-repository/src/main/java/org/apache/nifi/provenance/VolatileProvenanceRepository.java
index 7445c5d..b65d99d 100644
--- a/nifi-nar-bundles/nifi-provenance-repository-bundle/nifi-volatile-provenance-repository/src/main/java/org/apache/nifi/provenance/VolatileProvenanceRepository.java
+++ b/nifi-nar-bundles/nifi-provenance-repository-bundle/nifi-volatile-provenance-repository/src/main/java/org/apache/nifi/provenance/VolatileProvenanceRepository.java
@@ -62,7 +62,7 @@ import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;
import java.util.regex.Pattern;
-public class VolatileProvenanceRepository implements ProvenanceEventRepository {
+public class VolatileProvenanceRepository implements ProvenanceRepository {
// properties
public static final String BUFFER_SIZE = "nifi.provenance.repository.buffer.size";
@@ -124,6 +124,11 @@ public class VolatileProvenanceRepository implements ProvenanceEventRepository {
}
@Override
+ public ProvenanceEventRepository getProvenanceEventRepository() {
+ return this;
+ }
+
+ @Override
public ProvenanceEventBuilder eventBuilder() {
return new StandardProvenanceEventRecord.Builder();
}
@@ -176,7 +181,7 @@ public class VolatileProvenanceRepository implements ProvenanceEventRepository {
return records.isEmpty() ? null : records.get(0);
}
- private ProvenanceEventRecord getEvent(final long id) {
+ public ProvenanceEventRecord getEvent(final long id) {
final List<ProvenanceEventRecord> records = ringBuffer.getSelectedElements(new Filter<ProvenanceEventRecord>() {
@Override
public boolean select(final ProvenanceEventRecord event) {
@@ -187,7 +192,6 @@ public class VolatileProvenanceRepository implements ProvenanceEventRepository {
return records.isEmpty() ? null : records.get(0);
}
- @Override
public ProvenanceEventRecord getEvent(final long id, final NiFiUser user) {
final ProvenanceEventRecord event = getEvent(id);
if (event == null) {
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-nar-bundles/nifi-provenance-repository-bundle/nifi-volatile-provenance-repository/src/main/resources/META-INF/services/org.apache.nifi.provenance.ProvenanceEventRepository
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-provenance-repository-bundle/nifi-volatile-provenance-repository/src/main/resources/META-INF/services/org.apache.nifi.provenance.ProvenanceEventRepository b/nifi-nar-bundles/nifi-provenance-repository-bundle/nifi-volatile-provenance-repository/src/main/resources/META-INF/services/org.apache.nifi.provenance.ProvenanceEventRepository
deleted file mode 100644
index 700eb3e..0000000
--- a/nifi-nar-bundles/nifi-provenance-repository-bundle/nifi-volatile-provenance-repository/src/main/resources/META-INF/services/org.apache.nifi.provenance.ProvenanceEventRepository
+++ /dev/null
@@ -1,15 +0,0 @@
-# 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.
-org.apache.nifi.provenance.VolatileProvenanceRepository
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-nar-bundles/nifi-provenance-repository-bundle/nifi-volatile-provenance-repository/src/main/resources/META-INF/services/org.apache.nifi.provenance.ProvenanceRepository
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-provenance-repository-bundle/nifi-volatile-provenance-repository/src/main/resources/META-INF/services/org.apache.nifi.provenance.ProvenanceRepository b/nifi-nar-bundles/nifi-provenance-repository-bundle/nifi-volatile-provenance-repository/src/main/resources/META-INF/services/org.apache.nifi.provenance.ProvenanceRepository
new file mode 100644
index 0000000..700eb3e
--- /dev/null
+++ b/nifi-nar-bundles/nifi-provenance-repository-bundle/nifi-volatile-provenance-repository/src/main/resources/META-INF/services/org.apache.nifi.provenance.ProvenanceRepository
@@ -0,0 +1,15 @@
+# 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.
+org.apache.nifi.provenance.VolatileProvenanceRepository
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-nar-bundles/nifi-snmp-bundle/nifi-snmp-processors/src/test/java/org/apache/nifi/snmp/processors/GetSNMPTest.java
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-snmp-bundle/nifi-snmp-processors/src/test/java/org/apache/nifi/snmp/processors/GetSNMPTest.java b/nifi-nar-bundles/nifi-snmp-bundle/nifi-snmp-processors/src/test/java/org/apache/nifi/snmp/processors/GetSNMPTest.java
index 1d40e25..48be787 100644
--- a/nifi-nar-bundles/nifi-snmp-bundle/nifi-snmp-processors/src/test/java/org/apache/nifi/snmp/processors/GetSNMPTest.java
+++ b/nifi-nar-bundles/nifi-snmp-bundle/nifi-snmp-processors/src/test/java/org/apache/nifi/snmp/processors/GetSNMPTest.java
@@ -360,8 +360,10 @@ public class GetSNMPTest {
}
runner.run();
- Thread.sleep(200);
+ Thread.sleep(500);
+ // Assert that a file has been transferred before attempting to access
+ runner.assertTransferCount(GetSNMP.REL_SUCCESS, 1);
final MockFlowFile successFF = runner.getFlowFilesForRelationship(GetSNMP.REL_SUCCESS).get(0);
assertNotNull(successFF);
assertTrue(successFF.getAttributes().get(SNMPUtils.SNMP_PROP_PREFIX + sysDescr.toString() + SNMPUtils.SNMP_PROP_DELIMITER + "4").startsWith("SNMP4J-Agent"));
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-nar-bundles/nifi-standard-bundle/nifi-jolt-transform-json-ui/pom.xml
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-standard-bundle/nifi-jolt-transform-json-ui/pom.xml b/nifi-nar-bundles/nifi-standard-bundle/nifi-jolt-transform-json-ui/pom.xml
index a04432e..b70b52f 100644
--- a/nifi-nar-bundles/nifi-standard-bundle/nifi-jolt-transform-json-ui/pom.xml
+++ b/nifi-nar-bundles/nifi-standard-bundle/nifi-jolt-transform-json-ui/pom.xml
@@ -40,6 +40,11 @@ language governing permissions and limitations under the License. -->
</dependency>
<dependency>
<groupId>org.apache.nifi</groupId>
+ <artifactId>nifi-framework-api</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.nifi</groupId>
<artifactId>nifi-utils</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-content-viewer/pom.xml
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-content-viewer/pom.xml b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-content-viewer/pom.xml
index a40ba97..e1f2866 100644
--- a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-content-viewer/pom.xml
+++ b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-content-viewer/pom.xml
@@ -56,6 +56,10 @@
<artifactId>nifi-api</artifactId>
</dependency>
<dependency>
+ <groupId>org.apache.nifi</groupId>
+ <artifactId>nifi-framework-api</artifactId>
+ </dependency>
+ <dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
</dependency>
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-reporting-tasks/src/test/java/org/apache/nifi/controller/MonitorMemoryTest.java
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-reporting-tasks/src/test/java/org/apache/nifi/controller/MonitorMemoryTest.java b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-reporting-tasks/src/test/java/org/apache/nifi/controller/MonitorMemoryTest.java
index 1eb3334..824503a 100644
--- a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-reporting-tasks/src/test/java/org/apache/nifi/controller/MonitorMemoryTest.java
+++ b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-reporting-tasks/src/test/java/org/apache/nifi/controller/MonitorMemoryTest.java
@@ -20,7 +20,7 @@ import org.apache.commons.io.FileUtils;
import org.apache.nifi.admin.service.AuditService;
import org.apache.nifi.authorization.Authorizer;
import org.apache.nifi.controller.repository.FlowFileEventRepository;
-import org.apache.nifi.provenance.MockProvenanceEventRepository;
+import org.apache.nifi.provenance.MockProvenanceRepository;
import org.apache.nifi.util.CapturingLogger;
import org.apache.nifi.util.NiFiProperties;
import org.junit.After;
@@ -131,7 +131,7 @@ public class MonitorMemoryTest {
NiFiProperties properties = NiFiProperties.getInstance();
properties.setProperty(NiFiProperties.PROVENANCE_REPO_IMPLEMENTATION_CLASS,
- MockProvenanceEventRepository.class.getName());
+ MockProvenanceRepository.class.getName());
properties.setProperty("nifi.remote.input.socket.port", "");
properties.setProperty("nifi.remote.input.secure", "");
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-nar-bundles/nifi-update-attribute-bundle/nifi-update-attribute-ui/pom.xml
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-update-attribute-bundle/nifi-update-attribute-ui/pom.xml b/nifi-nar-bundles/nifi-update-attribute-bundle/nifi-update-attribute-ui/pom.xml
index 92153a9..4cfc2f1 100644
--- a/nifi-nar-bundles/nifi-update-attribute-bundle/nifi-update-attribute-ui/pom.xml
+++ b/nifi-nar-bundles/nifi-update-attribute-bundle/nifi-update-attribute-ui/pom.xml
@@ -39,6 +39,11 @@
</dependency>
<dependency>
<groupId>org.apache.nifi</groupId>
+ <artifactId>nifi-framework-api</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.nifi</groupId>
<artifactId>nifi-utils</artifactId>
<scope>provided</scope>
</dependency>
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-nar-bundles/pom.xml
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/pom.xml b/nifi-nar-bundles/pom.xml
index d554e03..945002f 100644
--- a/nifi-nar-bundles/pom.xml
+++ b/nifi-nar-bundles/pom.xml
@@ -135,6 +135,12 @@
</dependency>
<dependency>
<groupId>org.apache.nifi</groupId>
+ <artifactId>nifi-framework-api</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.nifi</groupId>
<artifactId>nifi-runtime</artifactId>
<version>1.0.0-SNAPSHOT</version>
<scope>provided</scope>
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index ac03bac..43455b8 100644
--- a/pom.xml
+++ b/pom.xml
@@ -25,6 +25,7 @@ language governing permissions and limitations under the License. -->
<modules>
<module>nifi-commons</module>
<module>nifi-api</module>
+ <module>nifi-framework-api</module>
<module>nifi-bootstrap</module>
<module>nifi-mock</module>
<module>nifi-nar-bundles</module>
@@ -793,6 +794,11 @@ language governing permissions and limitations under the License. -->
</dependency>
<dependency>
<groupId>org.apache.nifi</groupId>
+ <artifactId>nifi-framework-api</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.nifi</groupId>
<artifactId>nifi-utils</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>
[05/10] nifi git commit: NIFI-1896 This closes #650. Refactored
nifi-api into nifi-framework-api and other locations. The nifi-api is
specific to that which is needed for intended extension points.
Posted by jo...@apache.org.
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-framework-api/src/main/java/org/apache/nifi/authentication/exception/ProviderDestructionException.java
----------------------------------------------------------------------
diff --git a/nifi-framework-api/src/main/java/org/apache/nifi/authentication/exception/ProviderDestructionException.java b/nifi-framework-api/src/main/java/org/apache/nifi/authentication/exception/ProviderDestructionException.java
new file mode 100644
index 0000000..1e12146
--- /dev/null
+++ b/nifi-framework-api/src/main/java/org/apache/nifi/authentication/exception/ProviderDestructionException.java
@@ -0,0 +1,39 @@
+/*
+ * 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.authentication.exception;
+
+/**
+ * Represents the exceptional case when an AuthorityProvider fails destruction.
+ *
+ */
+public class ProviderDestructionException extends RuntimeException {
+
+ public ProviderDestructionException() {
+ }
+
+ public ProviderDestructionException(String msg) {
+ super(msg);
+ }
+
+ public ProviderDestructionException(Throwable cause) {
+ super(cause);
+ }
+
+ public ProviderDestructionException(String msg, Throwable cause) {
+ super(msg, cause);
+ }
+}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-framework-api/src/main/java/org/apache/nifi/authorization/AbstractPolicyBasedAuthorizer.java
----------------------------------------------------------------------
diff --git a/nifi-framework-api/src/main/java/org/apache/nifi/authorization/AbstractPolicyBasedAuthorizer.java b/nifi-framework-api/src/main/java/org/apache/nifi/authorization/AbstractPolicyBasedAuthorizer.java
new file mode 100644
index 0000000..8fbe0fb
--- /dev/null
+++ b/nifi-framework-api/src/main/java/org/apache/nifi/authorization/AbstractPolicyBasedAuthorizer.java
@@ -0,0 +1,552 @@
+/*
+ * 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.authorization;
+
+import org.apache.nifi.authorization.exception.AuthorizationAccessException;
+import org.apache.nifi.authorization.exception.AuthorizerCreationException;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.xml.sax.SAXException;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamWriter;
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.StringWriter;
+import java.nio.charset.StandardCharsets;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+import java.util.Set;
+
+/**
+ * An Authorizer that provides management of users, groups, and policies.
+ */
+public abstract class AbstractPolicyBasedAuthorizer implements Authorizer {
+
+ static final DocumentBuilderFactory DOCUMENT_BUILDER_FACTORY = DocumentBuilderFactory.newInstance();
+ static final XMLOutputFactory XML_OUTPUT_FACTORY = XMLOutputFactory.newInstance();
+
+ static final String USER_ELEMENT = "user";
+ static final String GROUP_USER_ELEMENT = "groupUser";
+ static final String GROUP_ELEMENT = "group";
+ static final String POLICY_ELEMENT = "policy";
+ static final String POLICY_USER_ELEMENT = "policyUser";
+ static final String POLICY_GROUP_ELEMENT = "policyGroup";
+ static final String IDENTIFIER_ATTR = "identifier";
+ static final String IDENTITY_ATTR = "identity";
+ static final String NAME_ATTR = "name";
+ static final String RESOURCE_ATTR = "resource";
+ static final String ACTIONS_ATTR = "actions";
+
+ public static final String EMPTY_FINGERPRINT = "EMPTY";
+
+ @Override
+ public final void onConfigured(final AuthorizerConfigurationContext configurationContext) throws AuthorizerCreationException {
+ doOnConfigured(configurationContext);
+
+ // ensure that only one policy per resource-action exists
+ for (AccessPolicy accessPolicy : getAccessPolicies()) {
+ if (policyExists(accessPolicy)) {
+ throw new AuthorizerCreationException("Found multiple policies for " + accessPolicy.getResource()
+ + " with " + accessPolicy.getAction());
+ }
+ }
+ }
+
+ /**
+ * Allows sub-classes to take action when onConfigured is called.
+ *
+ * @param configurationContext the configuration context
+ * @throws AuthorizerCreationException if an error occurs during onConfigured process
+ */
+ protected abstract void doOnConfigured(final AuthorizerConfigurationContext configurationContext) throws AuthorizerCreationException;
+
+ /**
+ * Checks if another policy exists with the same resource and action as the given policy.
+ *
+ * @param checkAccessPolicy an access policy being checked
+ * @return true if another access policy exists with the same resource and action, false otherwise
+ */
+ private boolean policyExists(final AccessPolicy checkAccessPolicy) {
+ for (AccessPolicy accessPolicy : getAccessPolicies()) {
+ if (!accessPolicy.getIdentifier().equals(checkAccessPolicy.getIdentifier())
+ && accessPolicy.getResource().equals(checkAccessPolicy.getResource())
+ && accessPolicy.getAction().equals(checkAccessPolicy.getAction())) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ @Override
+ public final AuthorizationResult authorize(AuthorizationRequest request) throws AuthorizationAccessException {
+ final UsersAndAccessPolicies usersAndAccessPolicies = getUsersAndAccessPolicies();
+ final String resourceIdentifier = request.getResource().getIdentifier();
+
+ final AccessPolicy policy = usersAndAccessPolicies.getAccessPolicy(resourceIdentifier, request.getAction());
+ if (policy == null) {
+ return AuthorizationResult.resourceNotFound();
+ }
+
+ final User user = usersAndAccessPolicies.getUser(request.getIdentity());
+ if (user == null) {
+ return AuthorizationResult.denied("Unknown user with identity " + request.getIdentity());
+ }
+
+ final Set<Group> userGroups = usersAndAccessPolicies.getGroups(user.getIdentity());
+ if (policy.getUsers().contains(user.getIdentifier()) || containsGroup(userGroups, policy)) {
+ return AuthorizationResult.approved();
+ }
+
+
+ return AuthorizationResult.denied();
+ }
+
+ /**
+ * Determines if the policy contains one of the user's groups.
+ *
+ * @param userGroups the set of the user's groups
+ * @param policy the policy
+ * @return true if one of the Groups in userGroups is contained in the policy
+ */
+ private boolean containsGroup(final Set<Group> userGroups, final AccessPolicy policy) {
+ if (userGroups.isEmpty() || policy.getGroups().isEmpty()) {
+ return false;
+ }
+
+ for (Group userGroup : userGroups) {
+ if (policy.getGroups().contains(userGroup.getIdentifier())) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ /**
+ * Adds a new group.
+ *
+ * @param group the Group to add
+ * @return the added Group
+ * @throws AuthorizationAccessException if there was an unexpected error performing the operation
+ */
+ public abstract Group addGroup(Group group) throws AuthorizationAccessException;
+
+ /**
+ * Retrieves a Group by id.
+ *
+ * @param identifier the identifier of the Group to retrieve
+ * @return the Group with the given identifier, or null if no matching group was found
+ * @throws AuthorizationAccessException if there was an unexpected error performing the operation
+ */
+ public abstract Group getGroup(String identifier) throws AuthorizationAccessException;
+
+ /**
+ * The group represented by the provided instance will be updated based on the provided instance.
+ *
+ * @param group an updated group instance
+ * @return the updated group instance, or null if no matching group was found
+ * @throws AuthorizationAccessException if there was an unexpected error performing the operation
+ */
+ public abstract Group updateGroup(Group group) throws AuthorizationAccessException;
+
+ /**
+ * Deletes the given group.
+ *
+ * @param group the group to delete
+ * @return the deleted group, or null if no matching group was found
+ * @throws AuthorizationAccessException if there was an unexpected error performing the operation
+ */
+ public abstract Group deleteGroup(Group group) throws AuthorizationAccessException;
+
+ /**
+ * Retrieves all groups.
+ *
+ * @return a list of groups
+ * @throws AuthorizationAccessException if there was an unexpected error performing the operation
+ */
+ public abstract Set<Group> getGroups() throws AuthorizationAccessException;
+
+
+ /**
+ * Adds the given user.
+ *
+ * @param user the user to add
+ * @return the user that was added
+ * @throws AuthorizationAccessException if there was an unexpected error performing the operation
+ */
+ public abstract User addUser(User user) throws AuthorizationAccessException;
+
+ /**
+ * Retrieves the user with the given identifier.
+ *
+ * @param identifier the id of the user to retrieve
+ * @return the user with the given id, or null if no matching user was found
+ * @throws AuthorizationAccessException if there was an unexpected error performing the operation
+ */
+ public abstract User getUser(String identifier) throws AuthorizationAccessException;
+
+ /**
+ * Retrieves the user with the given identity.
+ *
+ * @param identity the identity of the user to retrieve
+ * @return the user with the given identity, or null if no matching user was found
+ * @throws AuthorizationAccessException if there was an unexpected error performing the operation
+ */
+ public abstract User getUserByIdentity(String identity) throws AuthorizationAccessException;
+
+ /**
+ * The user represented by the provided instance will be updated based on the provided instance.
+ *
+ * @param user an updated user instance
+ * @return the updated user instance, or null if no matching user was found
+ * @throws AuthorizationAccessException if there was an unexpected error performing the operation
+ */
+ public abstract User updateUser(User user) throws AuthorizationAccessException;
+
+ /**
+ * Deletes the given user.
+ *
+ * @param user the user to delete
+ * @return the user that was deleted, or null if no matching user was found
+ * @throws AuthorizationAccessException if there was an unexpected error performing the operation
+ */
+ public abstract User deleteUser(User user) throws AuthorizationAccessException;
+
+ /**
+ * Retrieves all users.
+ *
+ * @return a list of users
+ * @throws AuthorizationAccessException if there was an unexpected error performing the operation
+ */
+ public abstract Set<User> getUsers() throws AuthorizationAccessException;
+
+ /**
+ * Adds the given policy ensuring that multiple policies can not be added for the same resource and action.
+ *
+ * @param accessPolicy the policy to add
+ * @return the policy that was added
+ * @throws AuthorizationAccessException if there was an unexpected error performing the operation
+ */
+ public final synchronized AccessPolicy addAccessPolicy(AccessPolicy accessPolicy) throws AuthorizationAccessException {
+ if (policyExists(accessPolicy)) {
+ throw new IllegalStateException("Found multiple policies for " + accessPolicy.getResource()
+ + " with " + accessPolicy.getAction());
+ }
+ return doAddAccessPolicy(accessPolicy);
+ }
+
+ /**
+ * Adds the given policy.
+ *
+ * @param accessPolicy the policy to add
+ * @return the policy that was added
+ * @throws AuthorizationAccessException if there was an unexpected error performing the operation
+ */
+ protected abstract AccessPolicy doAddAccessPolicy(AccessPolicy accessPolicy) throws AuthorizationAccessException;
+
+ /**
+ * Retrieves the policy with the given identifier.
+ *
+ * @param identifier the id of the policy to retrieve
+ * @return the policy with the given id, or null if no matching policy exists
+ * @throws AuthorizationAccessException if there was an unexpected error performing the operation
+ */
+ public abstract AccessPolicy getAccessPolicy(String identifier) throws AuthorizationAccessException;
+
+ /**
+ * The policy represented by the provided instance will be updated based on the provided instance.
+ *
+ * @param accessPolicy an updated policy
+ * @return the updated policy, or null if no matching policy was found
+ * @throws AuthorizationAccessException if there was an unexpected error performing the operation
+ */
+ public abstract AccessPolicy updateAccessPolicy(AccessPolicy accessPolicy) throws AuthorizationAccessException;
+
+ /**
+ * Deletes the given policy.
+ *
+ * @param policy the policy to delete
+ * @return the deleted policy, or null if no matching policy was found
+ * @throws AuthorizationAccessException if there was an unexpected error performing the operation
+ */
+ public abstract AccessPolicy deleteAccessPolicy(AccessPolicy policy) throws AuthorizationAccessException;
+
+ /**
+ * Retrieves all access policies.
+ *
+ * @return a list of policies
+ * @throws AuthorizationAccessException if there was an unexpected error performing the operation
+ */
+ public abstract Set<AccessPolicy> getAccessPolicies() throws AuthorizationAccessException;
+
+ /**
+ * Returns the UserAccessPolicies instance.
+ *
+ * @return the UserAccessPolicies instance
+ * @throws AuthorizationAccessException if there was an unexpected error performing the operation
+ */
+ public abstract UsersAndAccessPolicies getUsersAndAccessPolicies() throws AuthorizationAccessException;
+
+ /**
+ * Parses the fingerprint and adds any users, groups, and policies to the current Authorizer.
+ *
+ * @param fingerprint the fingerprint that was obtained from calling getFingerprint() on another Authorizer.
+ */
+ public final void inheritFingerprint(final String fingerprint) throws AuthorizationAccessException {
+ if (fingerprint == null || fingerprint.trim().isEmpty()) {
+ return;
+ }
+
+ final byte[] fingerprintBytes = fingerprint.getBytes(StandardCharsets.UTF_8);
+
+ try (final ByteArrayInputStream in = new ByteArrayInputStream(fingerprintBytes)) {
+ final DocumentBuilder docBuilder = DOCUMENT_BUILDER_FACTORY.newDocumentBuilder();
+ final Document document = docBuilder.parse(in);
+ final Element rootElement = document.getDocumentElement();
+
+ // parse all the users and add them to the current authorizer
+ NodeList userNodes = rootElement.getElementsByTagName(USER_ELEMENT);
+ for (int i=0; i < userNodes.getLength(); i++) {
+ Node userNode = userNodes.item(i);
+ User user = parseUser((Element) userNode);
+ addUser(user);
+ }
+
+ // parse all the groups and add them to the current authorizer
+ NodeList groupNodes = rootElement.getElementsByTagName(GROUP_ELEMENT);
+ for (int i=0; i < groupNodes.getLength(); i++) {
+ Node groupNode = groupNodes.item(i);
+ Group group = parseGroup((Element) groupNode);
+ addGroup(group);
+ }
+
+ // parse all the policies and add them to the current authorizer
+ NodeList policyNodes = rootElement.getElementsByTagName(POLICY_ELEMENT);
+ for (int i=0; i < policyNodes.getLength(); i++) {
+ Node policyNode = policyNodes.item(i);
+ AccessPolicy policy = parsePolicy((Element) policyNode);
+ addAccessPolicy(policy);
+ }
+
+ } catch (SAXException | ParserConfigurationException | IOException e) {
+ throw new AuthorizationAccessException("Unable to parse fingerprint", e);
+ }
+ }
+
+ private User parseUser(final Element element) {
+ final User.Builder builder = new User.Builder()
+ .identifier(element.getAttribute(IDENTIFIER_ATTR))
+ .identity(element.getAttribute(IDENTITY_ATTR));
+
+ return builder.build();
+ }
+
+ private Group parseGroup(final Element element) {
+ final Group.Builder builder = new Group.Builder()
+ .identifier(element.getAttribute(IDENTIFIER_ATTR))
+ .name(element.getAttribute(NAME_ATTR));
+
+ NodeList groupUsers = element.getElementsByTagName(GROUP_USER_ELEMENT);
+ for (int i=0; i < groupUsers.getLength(); i++) {
+ Element groupUserNode = (Element) groupUsers.item(i);
+ builder.addUser(groupUserNode.getAttribute(IDENTIFIER_ATTR));
+ }
+
+ return builder.build();
+ }
+
+ private AccessPolicy parsePolicy(final Element element) {
+ final AccessPolicy.Builder builder = new AccessPolicy.Builder()
+ .identifier(element.getAttribute(IDENTIFIER_ATTR))
+ .resource(element.getAttribute(RESOURCE_ATTR));
+
+ final String actions = element.getAttribute(ACTIONS_ATTR);
+ if (actions.equals(RequestAction.READ.name())) {
+ builder.action(RequestAction.READ);
+ } else if (actions.equals(RequestAction.WRITE.name())) {
+ builder.action(RequestAction.WRITE);
+ } else {
+ throw new IllegalStateException("Unknown Policy Action: " + actions);
+ }
+
+ NodeList policyUsers = element.getElementsByTagName(POLICY_USER_ELEMENT);
+ for (int i=0; i < policyUsers.getLength(); i++) {
+ Element policyUserNode = (Element) policyUsers.item(i);
+ builder.addUser(policyUserNode.getAttribute(IDENTIFIER_ATTR));
+ }
+
+ NodeList policyGroups = element.getElementsByTagName(POLICY_GROUP_ELEMENT);
+ for (int i=0; i < policyGroups.getLength(); i++) {
+ Element policyGroupNode = (Element) policyGroups.item(i);
+ builder.addGroup(policyGroupNode.getAttribute(IDENTIFIER_ATTR));
+ }
+
+ return builder.build();
+ }
+
+ /**
+ * Returns a fingerprint representing the authorizations managed by this authorizer. The fingerprint will be
+ * used for comparison to determine if two policy-based authorizers represent a compatible set of users,
+ * groups, and policies.
+ *
+ * @return the fingerprint for this Authorizer
+ */
+ public final String getFingerprint() throws AuthorizationAccessException {
+ final List<User> users = getSortedUsers();
+ final List<Group> groups = getSortedGroups();
+ final List<AccessPolicy> policies = getSortedAccessPolicies();
+
+ // when there are no users, groups, policies we want to always return a simple indicator so
+ // it can easily be determined when comparing fingerprints
+ if (users.isEmpty() && groups.isEmpty() && policies.isEmpty()) {
+ return EMPTY_FINGERPRINT;
+ }
+
+ XMLStreamWriter writer = null;
+ final StringWriter out = new StringWriter();
+ try {
+ writer = XML_OUTPUT_FACTORY.createXMLStreamWriter(out);
+ writer.writeStartDocument();
+ writer.writeStartElement("authorizations");
+
+ for (User user : users) {
+ writeUser(writer, user);
+ }
+ for (Group group : groups) {
+ writeGroup(writer, group);
+ }
+ for (AccessPolicy policy : policies) {
+ writePolicy(writer, policy);
+ }
+
+ writer.writeEndElement();
+ writer.writeEndDocument();
+ writer.flush();
+ } catch (XMLStreamException e) {
+ throw new AuthorizationAccessException("Unable to generate fingerprint", e);
+ } finally {
+ if (writer != null) {
+ try {
+ writer.close();
+ } catch (XMLStreamException e) {
+ // nothing to do here
+ }
+ }
+ }
+
+ return out.toString();
+ }
+
+ private void writeUser(final XMLStreamWriter writer, final User user) throws XMLStreamException {
+ writer.writeStartElement(USER_ELEMENT);
+ writer.writeAttribute(IDENTIFIER_ATTR, user.getIdentifier());
+ writer.writeAttribute(IDENTITY_ATTR, user.getIdentity());
+ writer.writeEndElement();
+ }
+
+ private void writeGroup(final XMLStreamWriter writer, final Group group) throws XMLStreamException {
+ List<String> users = new ArrayList<>(group.getUsers());
+ Collections.sort(users);
+
+ writer.writeStartElement(GROUP_ELEMENT);
+ writer.writeAttribute(IDENTIFIER_ATTR, group.getIdentifier());
+ writer.writeAttribute(NAME_ATTR, group.getName());
+
+ for (String user : users) {
+ writer.writeStartElement(GROUP_USER_ELEMENT);
+ writer.writeAttribute(IDENTIFIER_ATTR, user);
+ writer.writeEndElement();
+ }
+
+ writer.writeEndElement();
+ }
+
+ private void writePolicy(final XMLStreamWriter writer, final AccessPolicy policy) throws XMLStreamException {
+ // sort the users for the policy
+ List<String> policyUsers = new ArrayList<>(policy.getUsers());
+ Collections.sort(policyUsers);
+
+ // sort the groups for this policy
+ List<String> policyGroups = new ArrayList<>(policy.getGroups());
+ Collections.sort(policyGroups);
+
+ writer.writeStartElement(POLICY_ELEMENT);
+ writer.writeAttribute(IDENTIFIER_ATTR, policy.getIdentifier());
+ writer.writeAttribute(RESOURCE_ATTR, policy.getResource());
+ writer.writeAttribute(ACTIONS_ATTR, policy.getAction().name());
+
+ for (String policyUser : policyUsers) {
+ writer.writeStartElement(POLICY_USER_ELEMENT);
+ writer.writeAttribute(IDENTIFIER_ATTR, policyUser);
+ writer.writeEndElement();
+ }
+
+ for (String policyGroup : policyGroups) {
+ writer.writeStartElement(POLICY_GROUP_ELEMENT);
+ writer.writeAttribute(IDENTIFIER_ATTR, policyGroup);
+ writer.writeEndElement();
+ }
+
+ writer.writeEndElement();
+ }
+
+ private List<AccessPolicy> getSortedAccessPolicies() {
+ final List<AccessPolicy> policies = new ArrayList<>(getAccessPolicies());
+
+ Collections.sort(policies, new Comparator<AccessPolicy>() {
+ @Override
+ public int compare(AccessPolicy p1, AccessPolicy p2) {
+ return p1.getIdentifier().compareTo(p2.getIdentifier());
+ }
+ });
+ return policies;
+ }
+
+ private List<Group> getSortedGroups() {
+ final List<Group> groups = new ArrayList<>(getGroups());
+
+ Collections.sort(groups, new Comparator<Group>() {
+ @Override
+ public int compare(Group g1, Group g2) {
+ return g1.getIdentifier().compareTo(g2.getIdentifier());
+ }
+ });
+ return groups;
+ }
+
+ private List<User> getSortedUsers() {
+ final List<User> users = new ArrayList<>(getUsers());
+
+ Collections.sort(users, new Comparator<User>() {
+ @Override
+ public int compare(User u1, User u2) {
+ return u1.getIdentifier().compareTo(u2.getIdentifier());
+ }
+ });
+ return users;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-framework-api/src/main/java/org/apache/nifi/authorization/AccessDeniedException.java
----------------------------------------------------------------------
diff --git a/nifi-framework-api/src/main/java/org/apache/nifi/authorization/AccessDeniedException.java b/nifi-framework-api/src/main/java/org/apache/nifi/authorization/AccessDeniedException.java
new file mode 100644
index 0000000..8712d28
--- /dev/null
+++ b/nifi-framework-api/src/main/java/org/apache/nifi/authorization/AccessDeniedException.java
@@ -0,0 +1,39 @@
+/*
+ * 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.authorization;
+
+/**
+ * Represents any error that might occur while authorizing user requests.
+ */
+public class AccessDeniedException extends RuntimeException {
+ private static final long serialVersionUID = -5683444815269084134L;
+
+ public AccessDeniedException(Throwable cause) {
+ super(cause);
+ }
+
+ public AccessDeniedException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public AccessDeniedException(String message) {
+ super(message);
+ }
+
+ public AccessDeniedException() {
+ }
+}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-framework-api/src/main/java/org/apache/nifi/authorization/AccessPolicy.java
----------------------------------------------------------------------
diff --git a/nifi-framework-api/src/main/java/org/apache/nifi/authorization/AccessPolicy.java b/nifi-framework-api/src/main/java/org/apache/nifi/authorization/AccessPolicy.java
new file mode 100644
index 0000000..93cabb2
--- /dev/null
+++ b/nifi-framework-api/src/main/java/org/apache/nifi/authorization/AccessPolicy.java
@@ -0,0 +1,330 @@
+/*
+ * 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.authorization;
+
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Objects;
+import java.util.Set;
+
+/**
+ * Defines a policy for a set of userIdentifiers to perform a set of actions on a given resource.
+ */
+public class AccessPolicy {
+
+ private final String identifier;
+
+ private final String resource;
+
+ private final Set<String> users;
+
+ private final Set<String> groups;
+
+ private final RequestAction action;
+
+ private AccessPolicy(final Builder builder) {
+ this.identifier = builder.identifier;
+ this.resource = builder.resource;
+ this.action = builder.action;
+ this.users = Collections.unmodifiableSet(new HashSet<>(builder.users));
+ this.groups = Collections.unmodifiableSet(new HashSet<>(builder.groups));
+
+ if (this.identifier == null || this.identifier.trim().isEmpty()) {
+ throw new IllegalArgumentException("Identifier can not be null or empty");
+ }
+
+ if (this.resource == null) {
+ throw new IllegalArgumentException("Resource can not be null");
+ }
+
+ if (this.action == null) {
+ throw new IllegalArgumentException("Action can not be null");
+ }
+ }
+
+ /**
+ * @return the identifier for this policy
+ */
+ public String getIdentifier() {
+ return identifier;
+ }
+
+ /**
+ * @return the resource for this policy
+ */
+ public String getResource() {
+ return resource;
+ }
+
+ /**
+ * @return an unmodifiable set of user ids for this policy
+ */
+ public Set<String> getUsers() {
+ return users;
+ }
+
+ /**
+ * @return an unmodifiable set of group ids for this policy
+ */
+ public Set<String> getGroups() {
+ return groups;
+ }
+
+ /**
+ * @return the action for this policy
+ */
+ public RequestAction getAction() {
+ return action;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+
+ final AccessPolicy other = (AccessPolicy) obj;
+ return Objects.equals(this.identifier, other.identifier);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(this.identifier);
+ }
+
+ @Override
+ public String toString() {
+ return String.format("identifier[%s], resource[%s], users[%s], groups[%s], action[%s]",
+ getIdentifier(), getResource(), getUsers(), getGroups(), getAction());
+ }
+
+ /**
+ * Builder for Access Policies.
+ */
+ public static class Builder {
+
+ private String identifier;
+ private String resource;
+ private RequestAction action;
+ private Set<String> users = new HashSet<>();
+ private Set<String> groups = new HashSet<>();
+ private final boolean fromPolicy;
+
+ /**
+ * Default constructor for building a new AccessPolicy.
+ */
+ public Builder() {
+ this.fromPolicy = false;
+ }
+
+ /**
+ * Initializes the builder with the state of the provided policy. When using this constructor
+ * the identifier field of the builder can not be changed and will result in an IllegalStateException
+ * if attempting to do so.
+ *
+ * @param other the existing access policy to initialize from
+ */
+ public Builder(final AccessPolicy other) {
+ if (other == null) {
+ throw new IllegalArgumentException("Can not initialize builder with a null access policy");
+ }
+
+ this.identifier = other.getIdentifier();
+ this.resource = other.getResource();
+ this.action = other.getAction();
+ this.users.clear();
+ this.users.addAll(other.getUsers());
+ this.groups.clear();
+ this.groups.addAll(other.getGroups());
+ this.fromPolicy = true;
+ }
+
+ /**
+ * Sets the identifier of the builder.
+ *
+ * @param identifier the identifier to set
+ * @return the builder
+ * @throws IllegalStateException if this method is called when this builder was constructed from an existing Policy
+ */
+ public Builder identifier(final String identifier) {
+ if (fromPolicy) {
+ throw new IllegalStateException(
+ "Identifier can not be changed when initialized from an existing policy");
+ }
+
+ this.identifier = identifier;
+ return this;
+ }
+
+ /**
+ * Sets the resource of the builder.
+ *
+ * @param resource the resource to set
+ * @return the builder
+ */
+ public Builder resource(final String resource) {
+ this.resource = resource;
+ return this;
+ }
+
+ /**
+ * Adds all the users from the provided set to the builder's set of users.
+ *
+ * @param users the users to add
+ * @return the builder
+ */
+ public Builder addUsers(final Set<String> users) {
+ if (users != null) {
+ this.users.addAll(users);
+ }
+ return this;
+ }
+
+ /**
+ * Adds the given user to the builder's set of users.
+ *
+ * @param user the user to add
+ * @return the builder
+ */
+ public Builder addUser(final String user) {
+ if (user != null) {
+ this.users.add(user);
+ }
+ return this;
+ }
+
+ /**
+ * Removes all users in the provided set from the builder's set of users.
+ *
+ * @param users the users to remove
+ * @return the builder
+ */
+ public Builder removeUsers(final Set<String> users) {
+ if (users != null) {
+ this.users.removeAll(users);
+ }
+ return this;
+ }
+
+ /**
+ * Removes the provided user from the builder's set of users.
+ *
+ * @param user the user to remove
+ * @return the builder
+ */
+ public Builder removeUser(final String user) {
+ if (user != null) {
+ this.users.remove(user);
+ }
+ return this;
+ }
+
+ /**
+ * Clears the builder's set of users so that it is non-null and size == 0.
+ *
+ * @return the builder
+ */
+ public Builder clearUsers() {
+ this.users.clear();
+ return this;
+ }
+
+ /**
+ * Adds all the groups from the provided set to the builder's set of groups.
+ *
+ * @param groups the groups to add
+ * @return the builder
+ */
+ public Builder addGroups(final Set<String> groups) {
+ if (groups != null) {
+ this.groups.addAll(groups);
+ }
+ return this;
+ }
+
+ /**
+ * Adds the given group to the builder's set of groups.
+ *
+ * @param group the group to add
+ * @return the builder
+ */
+ public Builder addGroup(final String group) {
+ if (group != null) {
+ this.groups.add(group);
+ }
+ return this;
+ }
+
+ /**
+ * Removes all groups in the provided set from the builder's set of groups.
+ *
+ * @param groups the groups to remove
+ * @return the builder
+ */
+ public Builder removeGroups(final Set<String> groups) {
+ if (groups != null) {
+ this.groups.removeAll(groups);
+ }
+ return this;
+ }
+
+ /**
+ * Removes the provided groups from the builder's set of groups.
+ *
+ * @param group the group to remove
+ * @return the builder
+ */
+ public Builder removeGroup(final String group) {
+ if (group != null) {
+ this.groups.remove(group);
+ }
+ return this;
+ }
+
+ /**
+ * Clears the builder's set of groups so that it is non-null and size == 0.
+ *
+ * @return the builder
+ */
+ public Builder clearGroups() {
+ this.groups.clear();
+ return this;
+ }
+
+ /**
+ * Sets the action for this builder.
+ *
+ * @param action the action to set
+ * @return the builder
+ */
+ public Builder action(final RequestAction action) {
+ this.action = action;
+ return this;
+ }
+
+ /**
+ * @return a new AccessPolicy constructed from the state of the builder
+ */
+ public AccessPolicy build() {
+ return new AccessPolicy(this);
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-framework-api/src/main/java/org/apache/nifi/authorization/AuthorizationRequest.java
----------------------------------------------------------------------
diff --git a/nifi-framework-api/src/main/java/org/apache/nifi/authorization/AuthorizationRequest.java b/nifi-framework-api/src/main/java/org/apache/nifi/authorization/AuthorizationRequest.java
new file mode 100644
index 0000000..da0a276
--- /dev/null
+++ b/nifi-framework-api/src/main/java/org/apache/nifi/authorization/AuthorizationRequest.java
@@ -0,0 +1,171 @@
+/*
+ * 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.authorization;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Objects;
+
+/**
+ * Represents an authorization request for a given user/entity performing an action against a resource within some userContext.
+ */
+public class AuthorizationRequest {
+
+ private final Resource resource;
+ private final String identity;
+ private final RequestAction action;
+ private final boolean isAccessAttempt;
+ private final boolean isAnonymous;
+ private final Map<String, String> userContext;
+ private final Map<String, String> resourceContext;
+
+ private AuthorizationRequest(final Builder builder) {
+ Objects.requireNonNull(builder.resource, "The resource is required when creating an authorization request");
+ Objects.requireNonNull(builder.action, "The action is required when creating an authorization request");
+ Objects.requireNonNull(builder.isAccessAttempt, "Whether this request is an access attempt is request");
+ Objects.requireNonNull(builder.isAnonymous, "Whether this request is being performed by an anonymous user is required");
+
+ this.resource = builder.resource;
+ this.identity = builder.identity;
+ this.action = builder.action;
+ this.isAccessAttempt = builder.isAccessAttempt;
+ this.isAnonymous = builder.isAnonymous;
+ this.userContext = builder.userContext == null ? null : Collections.unmodifiableMap(builder.userContext);
+ this.resourceContext = builder.resourceContext == null ? null : Collections.unmodifiableMap(builder.resourceContext);
+ }
+
+ /**
+ * The Resource being authorized. Not null.
+ *
+ * @return The resource
+ */
+ public Resource getResource() {
+ return resource;
+ }
+
+ /**
+ * The identity accessing the Resource. May be null if the user could not authenticate.
+ *
+ * @return The identity
+ */
+ public String getIdentity() {
+ return identity;
+ }
+
+ /**
+ * Whether this is a direct access attempt of the Resource if if it's being checked as part of another response.
+ *
+ * @return if this is a direct access attempt
+ */
+ public boolean isAccessAttempt() {
+ return isAccessAttempt;
+ }
+
+ /**
+ * Whether the entity accessing is anonymous.
+ *
+ * @return whether the entity is anonymous
+ */
+ public boolean isAnonymous() {
+ return isAnonymous;
+ }
+
+ /**
+ * The action being taken against the Resource. Not null.
+ *
+ * @return The action
+ */
+ public RequestAction getAction() {
+ return action;
+ }
+
+ /**
+ * The userContext of the user request to make additional access decisions. May be null.
+ *
+ * @return The userContext of the user request
+ */
+ public Map<String, String> getUserContext() {
+ return userContext;
+ }
+
+ /**
+ * The event attributes to make additional access decisions for provenance events. May be null.
+ *
+ * @return The event attributes
+ */
+ public Map<String, String> getResourceContext() {
+ return resourceContext;
+ }
+
+ /**
+ * AuthorizationRequest builder.
+ */
+ public static final class Builder {
+
+ private Resource resource;
+ private String identity;
+ private Boolean isAnonymous;
+ private Boolean isAccessAttempt;
+ private RequestAction action;
+ private Map<String, String> userContext;
+ private Map<String, String> resourceContext;
+
+ public Builder resource(final Resource resource) {
+ this.resource = resource;
+ return this;
+ }
+
+ public Builder identity(final String identity) {
+ this.identity = identity;
+ return this;
+ }
+
+ public Builder anonymous(final Boolean isAnonymous) {
+ this.isAnonymous = isAnonymous;
+ return this;
+ }
+
+ public Builder accessAttempt(final Boolean isAccessAttempt) {
+ this.isAccessAttempt = isAccessAttempt;
+ return this;
+ }
+
+ public Builder action(final RequestAction action) {
+ this.action = action;
+ return this;
+ }
+
+ public Builder userContext(final Map<String, String> userContext) {
+ if (userContext != null) {
+ this.userContext = new HashMap<>(userContext);
+ }
+ return this;
+ }
+
+ public Builder resourceContext(final Map<String, String> resourceContext) {
+ if (resourceContext != null) {
+ this.resourceContext = new HashMap<>(resourceContext);
+ }
+ return this;
+ }
+
+ public AuthorizationRequest build() {
+ return new AuthorizationRequest(this);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-framework-api/src/main/java/org/apache/nifi/authorization/AuthorizationResult.java
----------------------------------------------------------------------
diff --git a/nifi-framework-api/src/main/java/org/apache/nifi/authorization/AuthorizationResult.java b/nifi-framework-api/src/main/java/org/apache/nifi/authorization/AuthorizationResult.java
new file mode 100644
index 0000000..a3f520c
--- /dev/null
+++ b/nifi-framework-api/src/main/java/org/apache/nifi/authorization/AuthorizationResult.java
@@ -0,0 +1,99 @@
+/*
+ * 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.authorization;
+
+/**
+ * Represents a decision whether authorization is granted.
+ */
+public class AuthorizationResult {
+
+ public enum Result {
+ Approved,
+ Denied,
+ ResourceNotFound
+ }
+
+ private static final AuthorizationResult APPROVED = new AuthorizationResult(Result.Approved, null);
+ private static final AuthorizationResult RESOURCE_NOT_FOUND = new AuthorizationResult(Result.ResourceNotFound, null);
+
+ private final Result result;
+ private final String explanation;
+
+ /**
+ * Creates a new AuthorizationResult with the specified result and explanation.
+ *
+ * @param result of the authorization
+ * @param explanation for the authorization attempt
+ */
+ private AuthorizationResult(Result result, String explanation) {
+ if (Result.Denied.equals(result) && explanation == null) {
+ throw new IllegalArgumentException("An explanation is required when the authorization request is denied.");
+ }
+
+ this.result = result;
+ this.explanation = explanation;
+ }
+
+ /**
+ * @return Whether or not the request is approved
+ */
+ public Result getResult() {
+ return result;
+ }
+
+ /**
+ * @return If the request is denied, the reason why. Null otherwise
+ */
+ public String getExplanation() {
+ return explanation;
+ }
+
+ /**
+ * @return a new approved AuthorizationResult
+ */
+ public static AuthorizationResult approved() {
+ return APPROVED;
+ }
+
+ /**
+ * Resource not found will indicate that there are no specific authorization rules for this resource.
+ * @return a new resource not found AuthorizationResult
+ */
+ public static AuthorizationResult resourceNotFound() {
+ return RESOURCE_NOT_FOUND;
+ }
+
+ /**
+ * Creates a new denied AuthorizationResult with a message indicating 'Access is denied'.
+ *
+ * @return a new denied AuthorizationResult
+ */
+ public static AuthorizationResult denied() {
+ return denied("Access is denied");
+ }
+
+ /**
+ * Creates a new denied AuthorizationResult with the specified explanation.
+ *
+ * @param explanation for why it was denied
+ * @return a new denied AuthorizationResult with the specified explanation
+ * @throws IllegalArgumentException if explanation is null
+ */
+ public static AuthorizationResult denied(String explanation) {
+ return new AuthorizationResult(Result.Denied, explanation);
+ }
+}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-framework-api/src/main/java/org/apache/nifi/authorization/Authorizer.java
----------------------------------------------------------------------
diff --git a/nifi-framework-api/src/main/java/org/apache/nifi/authorization/Authorizer.java b/nifi-framework-api/src/main/java/org/apache/nifi/authorization/Authorizer.java
new file mode 100644
index 0000000..cb8c7f1
--- /dev/null
+++ b/nifi-framework-api/src/main/java/org/apache/nifi/authorization/Authorizer.java
@@ -0,0 +1,59 @@
+/*
+ * 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.authorization;
+
+import org.apache.nifi.authorization.exception.AuthorizationAccessException;
+import org.apache.nifi.authorization.exception.AuthorizerCreationException;
+import org.apache.nifi.authorization.exception.AuthorizerDestructionException;
+
+/**
+ * Authorizes user requests.
+ */
+public interface Authorizer {
+
+ /**
+ * Determines if the specified user/entity is authorized to access the specified resource within the given context.
+ *
+ * @param request The authorization request
+ * @return the authorization result
+ * @throws AuthorizationAccessException if unable to access the policies
+ */
+ AuthorizationResult authorize(AuthorizationRequest request) throws AuthorizationAccessException;
+
+ /**
+ * Called immediately after instance creation for implementers to perform additional setup
+ *
+ * @param initializationContext in which to initialize
+ */
+ void initialize(AuthorizerInitializationContext initializationContext) throws AuthorizerCreationException;
+
+ /**
+ * Called to configure the Authorizer.
+ *
+ * @param configurationContext at the time of configuration
+ * @throws AuthorizerCreationException for any issues configuring the provider
+ */
+ void onConfigured(AuthorizerConfigurationContext configurationContext) throws AuthorizerCreationException;
+
+ /**
+ * Called immediately before instance destruction for implementers to release resources.
+ *
+ * @throws AuthorizerDestructionException If pre-destruction fails.
+ */
+ void preDestruction() throws AuthorizerDestructionException;
+
+}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-framework-api/src/main/java/org/apache/nifi/authorization/AuthorizerConfigurationContext.java
----------------------------------------------------------------------
diff --git a/nifi-framework-api/src/main/java/org/apache/nifi/authorization/AuthorizerConfigurationContext.java b/nifi-framework-api/src/main/java/org/apache/nifi/authorization/AuthorizerConfigurationContext.java
new file mode 100644
index 0000000..3721ab4
--- /dev/null
+++ b/nifi-framework-api/src/main/java/org/apache/nifi/authorization/AuthorizerConfigurationContext.java
@@ -0,0 +1,50 @@
+/*
+ * 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.authorization;
+
+import org.apache.nifi.components.PropertyValue;
+
+import java.util.Map;
+
+/**
+ *
+ */
+public interface AuthorizerConfigurationContext {
+
+ /**
+ * @return identifier for the authorizer
+ */
+ String getIdentifier();
+
+ /**
+ * Retrieves all properties the component currently understands regardless
+ * of whether a value has been set for them or not. If no value is present
+ * then its value is null and thus any registered default for the property
+ * descriptor applies.
+ *
+ * @return Map of all properties
+ */
+ Map<String, String> getProperties();
+
+ /**
+ * @param property to lookup the descriptor and value of
+ * @return the value the component currently understands for the given
+ * PropertyDescriptor. This method does not substitute default
+ * PropertyDescriptor values, so the value returned will be null if not set
+ */
+ PropertyValue getProperty(String property);
+}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-framework-api/src/main/java/org/apache/nifi/authorization/AuthorizerInitializationContext.java
----------------------------------------------------------------------
diff --git a/nifi-framework-api/src/main/java/org/apache/nifi/authorization/AuthorizerInitializationContext.java b/nifi-framework-api/src/main/java/org/apache/nifi/authorization/AuthorizerInitializationContext.java
new file mode 100644
index 0000000..4b3d77c
--- /dev/null
+++ b/nifi-framework-api/src/main/java/org/apache/nifi/authorization/AuthorizerInitializationContext.java
@@ -0,0 +1,37 @@
+/*
+ * 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.authorization;
+
+/**
+ * Initialization content for Authorizers.
+ */
+public interface AuthorizerInitializationContext {
+
+ /**
+ * The identifier of the Authorizer.
+ *
+ * @return The identifier
+ */
+ public String getIdentifier();
+
+ /**
+ * The lookup for accessing other configured Authorizers.
+ *
+ * @return The Authorizer lookup
+ */
+ public AuthorizerLookup getAuthorizerLookup();
+}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-framework-api/src/main/java/org/apache/nifi/authorization/AuthorizerLookup.java
----------------------------------------------------------------------
diff --git a/nifi-framework-api/src/main/java/org/apache/nifi/authorization/AuthorizerLookup.java b/nifi-framework-api/src/main/java/org/apache/nifi/authorization/AuthorizerLookup.java
new file mode 100644
index 0000000..9669976
--- /dev/null
+++ b/nifi-framework-api/src/main/java/org/apache/nifi/authorization/AuthorizerLookup.java
@@ -0,0 +1,31 @@
+/*
+ * 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.authorization;
+
+/**
+ *
+ */
+public interface AuthorizerLookup {
+
+ /**
+ * Looks up the Authorizer with the specified identifier
+ *
+ * @param identifier The identifier of the Authorizer
+ * @return The Authorizer
+ */
+ Authorizer getAuthorizer(String identifier);
+}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-framework-api/src/main/java/org/apache/nifi/authorization/Group.java
----------------------------------------------------------------------
diff --git a/nifi-framework-api/src/main/java/org/apache/nifi/authorization/Group.java b/nifi-framework-api/src/main/java/org/apache/nifi/authorization/Group.java
new file mode 100644
index 0000000..7db619a
--- /dev/null
+++ b/nifi-framework-api/src/main/java/org/apache/nifi/authorization/Group.java
@@ -0,0 +1,226 @@
+/*
+ * 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.authorization;
+
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Objects;
+import java.util.Set;
+
+/**
+ * A group that users can belong to.
+ */
+public class Group { // TODO rename to UserGroup
+
+ private final String identifier;
+
+ private final String name;
+
+ private final Set<String> users;
+
+ private Group(final Builder builder) {
+ this.identifier = builder.identifier;
+ this.name = builder.name;
+ this.users = Collections.unmodifiableSet(new HashSet<>(builder.users));
+
+ if (this.identifier == null || this.identifier.trim().isEmpty()) {
+ throw new IllegalArgumentException("Identifier can not be null or empty");
+ }
+
+ if (this.name == null || this.name.trim().isEmpty()) {
+ throw new IllegalArgumentException("Name can not be null or empty");
+ }
+ }
+
+ /**
+ * @return the identifier of the group
+ */
+ public String getIdentifier() {
+ return identifier;
+ }
+
+ /**
+ * @return the name of the group
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * @return an unmodifiable set of user identifiers that belong to this group
+ */
+ public Set<String> getUsers() {
+ return users;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+
+ final Group other = (Group) obj;
+ return Objects.equals(this.identifier, other.identifier);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(this.identifier);
+ }
+
+ @Override
+ public String toString() {
+ return String.format("identifier[%s], name[%s]", getIdentifier(), getName());
+ }
+
+
+ /**
+ * Builder for creating Groups.
+ */
+ public static class Builder {
+
+ private String identifier;
+ private String name;
+ private Set<String> users = new HashSet<>();
+ private final boolean fromGroup;
+
+ public Builder() {
+ this.fromGroup = false;
+ }
+
+ /**
+ * Initializes the builder with the state of the provided group. When using this constructor
+ * the identifier field of the builder can not be changed and will result in an IllegalStateException
+ * if attempting to do so.
+ *
+ * @param other the existing access policy to initialize from
+ */
+ public Builder(final Group other) {
+ if (other == null) {
+ throw new IllegalArgumentException("Provided group can not be null");
+ }
+
+ this.identifier = other.getIdentifier();
+ this.name = other.getName();
+ this.users.clear();
+ this.users.addAll(other.getUsers());
+ this.fromGroup = true;
+ }
+
+ /**
+ * Sets the identifier of the builder.
+ *
+ * @param identifier the identifier
+ * @return the builder
+ * @throws IllegalStateException if this method is called when this builder was constructed from an existing Group
+ */
+ public Builder identifier(final String identifier) {
+ if (fromGroup) {
+ throw new IllegalStateException(
+ "Identifier can not be changed when initialized from an existing group");
+ }
+
+ this.identifier = identifier;
+ return this;
+ }
+
+ /**
+ * Sets the name of the builder.
+ *
+ * @param name the name
+ * @return the builder
+ */
+ public Builder name(final String name) {
+ this.name = name;
+ return this;
+ }
+
+ /**
+ * Adds all users from the provided set to the builder's set of users.
+ *
+ * @param users a set of users to add
+ * @return the builder
+ */
+ public Builder addUsers(final Set<String> users) {
+ if (users != null) {
+ this.users.addAll(users);
+ }
+ return this;
+ }
+
+ /**
+ * Adds the given user to the builder's set of users.
+ *
+ * @param user the user to add
+ * @return the builder
+ */
+ public Builder addUser(final String user) {
+ if (user != null) {
+ this.users.add(user);
+ }
+ return this;
+ }
+
+ /**
+ * Removes the given user from the builder's set of users.
+ *
+ * @param user the user to remove
+ * @return the builder
+ */
+ public Builder removeUser(final String user) {
+ if (user != null) {
+ this.users.remove(user);
+ }
+ return this;
+ }
+
+ /**
+ * Removes all users from the provided set from the builder's set of users.
+ *
+ * @param users the users to remove
+ * @return the builder
+ */
+ public Builder removeUsers(final Set<String> users) {
+ if (users != null) {
+ this.users.removeAll(users);
+ }
+ return this;
+ }
+
+ /**
+ * Clears the builder's set of users so that users is non-null with size 0.
+ *
+ * @return the builder
+ */
+ public Builder clearUsers() {
+ this.users.clear();
+ return this;
+ }
+
+ /**
+ * @return a new Group constructed from the state of the builder
+ */
+ public Group build() {
+ return new Group(this);
+ }
+
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-framework-api/src/main/java/org/apache/nifi/authorization/RequestAction.java
----------------------------------------------------------------------
diff --git a/nifi-framework-api/src/main/java/org/apache/nifi/authorization/RequestAction.java b/nifi-framework-api/src/main/java/org/apache/nifi/authorization/RequestAction.java
new file mode 100644
index 0000000..3e28a67
--- /dev/null
+++ b/nifi-framework-api/src/main/java/org/apache/nifi/authorization/RequestAction.java
@@ -0,0 +1,46 @@
+/*
+ * 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.authorization;
+
+/**
+ * Actions a user/entity can take on a resource.
+ */
+public enum RequestAction {
+ READ("read"),
+ WRITE("write");
+
+ private String value;
+
+ RequestAction(String value) {
+ this.value = value;
+ }
+
+ @Override
+ public String toString() {
+ return value.toLowerCase();
+ }
+
+ public static RequestAction valueOfValue(final String action) {
+ if (RequestAction.READ.toString().equals(action)) {
+ return RequestAction.READ;
+ } else if (RequestAction.WRITE.toString().equals(action)) {
+ return RequestAction.WRITE;
+ } else {
+ throw new IllegalArgumentException("Action must be one of [" + READ.toString() + ", " + WRITE.toString() + "]");
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-framework-api/src/main/java/org/apache/nifi/authorization/Resource.java
----------------------------------------------------------------------
diff --git a/nifi-framework-api/src/main/java/org/apache/nifi/authorization/Resource.java b/nifi-framework-api/src/main/java/org/apache/nifi/authorization/Resource.java
new file mode 100644
index 0000000..661b326
--- /dev/null
+++ b/nifi-framework-api/src/main/java/org/apache/nifi/authorization/Resource.java
@@ -0,0 +1,37 @@
+/*
+ * 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.authorization;
+
+/**
+ * Resource in an authorization request.
+ */
+public interface Resource {
+
+ /**
+ * The identifier for this resource.
+ *
+ * @return identifier for this resource
+ */
+ String getIdentifier();
+
+ /**
+ * The name of this resource. May be null.
+ *
+ * @return name of this resource
+ */
+ String getName();
+}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-framework-api/src/main/java/org/apache/nifi/authorization/User.java
----------------------------------------------------------------------
diff --git a/nifi-framework-api/src/main/java/org/apache/nifi/authorization/User.java b/nifi-framework-api/src/main/java/org/apache/nifi/authorization/User.java
new file mode 100644
index 0000000..371241b
--- /dev/null
+++ b/nifi-framework-api/src/main/java/org/apache/nifi/authorization/User.java
@@ -0,0 +1,151 @@
+/*
+ * 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.authorization;
+
+import java.util.Objects;
+
+/**
+ * A user to create authorization policies for.
+ */
+public class User {
+
+ private final String identifier;
+
+ private final String identity;
+
+ private User(final Builder builder) {
+ this.identifier = builder.identifier;
+ this.identity = builder.identity;
+
+ if (identifier == null || identifier.trim().isEmpty()) {
+ throw new IllegalArgumentException("Identifier can not be null or empty");
+ }
+
+ if (identity == null || identity.trim().isEmpty()) {
+ throw new IllegalArgumentException("Identity can not be null or empty");
+ }
+
+ }
+
+ /**
+ * @return the identifier of the user
+ */
+ public String getIdentifier() {
+ return identifier;
+ }
+
+ /**
+ * @return the identity string of the user
+ */
+ public String getIdentity() {
+ return identity;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+
+ final User other = (User) obj;
+ return Objects.equals(this.identifier, other.identifier);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(this.identifier);
+ }
+
+ @Override
+ public String toString() {
+ return String.format("identifier[%s], identity[%s]", getIdentifier(), getIdentity());
+ }
+
+ /**
+ * Builder for Users.
+ */
+ public static class Builder {
+
+ private String identifier;
+ private String identity;
+ private final boolean fromUser;
+
+ /**
+ * Default constructor for building a new User.
+ */
+ public Builder() {
+ this.fromUser = false;
+ }
+
+ /**
+ * Initializes the builder with the state of the provided user. When using this constructor
+ * the identifier field of the builder can not be changed and will result in an IllegalStateException
+ * if attempting to do so.
+ *
+ * @param other the existing user to initialize from
+ */
+ public Builder(final User other) {
+ if (other == null) {
+ throw new IllegalArgumentException("Provided user can not be null");
+ }
+
+ this.identifier = other.getIdentifier();
+ this.identity = other.getIdentity();
+ this.fromUser = true;
+ }
+
+ /**
+ * Sets the identifier of the builder.
+ *
+ * @param identifier the identifier to set
+ * @return the builder
+ * @throws IllegalStateException if this method is called when this builder was constructed from an existing User
+ */
+ public Builder identifier(final String identifier) {
+ if (fromUser) {
+ throw new IllegalStateException(
+ "Identifier can not be changed when initialized from an existing user");
+ }
+
+ this.identifier = identifier;
+ return this;
+ }
+
+ /**
+ * Sets the identity of the builder.
+ *
+ * @param identity the identity to set
+ * @return the builder
+ */
+ public Builder identity(final String identity) {
+ this.identity = identity;
+ return this;
+ }
+
+ /**
+ * @return a new User constructed from the state of the builder
+ */
+ public User build() {
+ return new User(this);
+ }
+
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-framework-api/src/main/java/org/apache/nifi/authorization/UserContextKeys.java
----------------------------------------------------------------------
diff --git a/nifi-framework-api/src/main/java/org/apache/nifi/authorization/UserContextKeys.java b/nifi-framework-api/src/main/java/org/apache/nifi/authorization/UserContextKeys.java
new file mode 100644
index 0000000..fca4b74
--- /dev/null
+++ b/nifi-framework-api/src/main/java/org/apache/nifi/authorization/UserContextKeys.java
@@ -0,0 +1,26 @@
+/*
+ * 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.authorization;
+
+/**
+ * Constants for keys that can be passed in the AuthorizationRequest user context Map.
+ */
+public enum UserContextKeys {
+
+ CLIENT_ADDRESS;
+
+}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-framework-api/src/main/java/org/apache/nifi/authorization/UsersAndAccessPolicies.java
----------------------------------------------------------------------
diff --git a/nifi-framework-api/src/main/java/org/apache/nifi/authorization/UsersAndAccessPolicies.java b/nifi-framework-api/src/main/java/org/apache/nifi/authorization/UsersAndAccessPolicies.java
new file mode 100644
index 0000000..552b753
--- /dev/null
+++ b/nifi-framework-api/src/main/java/org/apache/nifi/authorization/UsersAndAccessPolicies.java
@@ -0,0 +1,52 @@
+/*
+ * 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.authorization;
+
+import java.util.Set;
+
+/**
+ * A holder object to provide atomic access to policies for a given resource and users by
+ * identity. Implementations must ensure consistent access to the data backing this instance.
+ */
+public interface UsersAndAccessPolicies {
+
+ /**
+ * Retrieves the set of access policies for a given resource and action.
+ *
+ * @param resourceIdentifier the resource identifier to retrieve policies for
+ * @param action the action to retrieve policies for
+ * @return the access policy for the given resource and action
+ */
+ public AccessPolicy getAccessPolicy(final String resourceIdentifier, final RequestAction action);
+
+ /**
+ * Retrieves a user by an identity string.
+ *
+ * @param identity the identity of the user to retrieve
+ * @return the user with the given identity
+ */
+ public User getUser(final String identity);
+
+ /**
+ * Retrieves the groups for a given user identity.
+ *
+ * @param userIdentity a user identity
+ * @return the set of groups for the given user identity
+ */
+ public Set<Group> getGroups(final String userIdentity);
+
+}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-framework-api/src/main/java/org/apache/nifi/authorization/annotation/AuthorizerContext.java
----------------------------------------------------------------------
diff --git a/nifi-framework-api/src/main/java/org/apache/nifi/authorization/annotation/AuthorizerContext.java b/nifi-framework-api/src/main/java/org/apache/nifi/authorization/annotation/AuthorizerContext.java
new file mode 100644
index 0000000..b0d3f83
--- /dev/null
+++ b/nifi-framework-api/src/main/java/org/apache/nifi/authorization/annotation/AuthorizerContext.java
@@ -0,0 +1,35 @@
+/*
+ * 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.authorization.annotation;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ *
+ *
+ */
+@Documented
+@Target({ElementType.FIELD, ElementType.METHOD})
+@Retention(RetentionPolicy.RUNTIME)
+@Inherited
+public @interface AuthorizerContext {
+}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-framework-api/src/main/java/org/apache/nifi/authorization/exception/AuthorizationAccessException.java
----------------------------------------------------------------------
diff --git a/nifi-framework-api/src/main/java/org/apache/nifi/authorization/exception/AuthorizationAccessException.java b/nifi-framework-api/src/main/java/org/apache/nifi/authorization/exception/AuthorizationAccessException.java
new file mode 100644
index 0000000..8b22d45
--- /dev/null
+++ b/nifi-framework-api/src/main/java/org/apache/nifi/authorization/exception/AuthorizationAccessException.java
@@ -0,0 +1,32 @@
+/*
+ * 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.authorization.exception;
+
+/**
+ * Represents the case when an authorization decision could not be made because the Authorizer was unable to access the underlying data store.
+ */
+public class AuthorizationAccessException extends RuntimeException {
+
+ public AuthorizationAccessException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public AuthorizationAccessException(String message) {
+ super(message);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-framework-api/src/main/java/org/apache/nifi/authorization/exception/AuthorizerCreationException.java
----------------------------------------------------------------------
diff --git a/nifi-framework-api/src/main/java/org/apache/nifi/authorization/exception/AuthorizerCreationException.java b/nifi-framework-api/src/main/java/org/apache/nifi/authorization/exception/AuthorizerCreationException.java
new file mode 100644
index 0000000..4264202
--- /dev/null
+++ b/nifi-framework-api/src/main/java/org/apache/nifi/authorization/exception/AuthorizerCreationException.java
@@ -0,0 +1,39 @@
+/*
+ * 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.authorization.exception;
+
+/**
+ * Represents the exceptional case when an Authorizer fails instantiation.
+ *
+ */
+public class AuthorizerCreationException extends RuntimeException {
+
+ public AuthorizerCreationException() {
+ }
+
+ public AuthorizerCreationException(String msg) {
+ super(msg);
+ }
+
+ public AuthorizerCreationException(Throwable cause) {
+ super(cause);
+ }
+
+ public AuthorizerCreationException(String msg, Throwable cause) {
+ super(msg, cause);
+ }
+}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-framework-api/src/main/java/org/apache/nifi/authorization/exception/AuthorizerDestructionException.java
----------------------------------------------------------------------
diff --git a/nifi-framework-api/src/main/java/org/apache/nifi/authorization/exception/AuthorizerDestructionException.java b/nifi-framework-api/src/main/java/org/apache/nifi/authorization/exception/AuthorizerDestructionException.java
new file mode 100644
index 0000000..852eca1
--- /dev/null
+++ b/nifi-framework-api/src/main/java/org/apache/nifi/authorization/exception/AuthorizerDestructionException.java
@@ -0,0 +1,39 @@
+/*
+ * 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.authorization.exception;
+
+/**
+ * Represents the exceptional case when an Authorizer fails destruction.
+ *
+ */
+public class AuthorizerDestructionException extends RuntimeException {
+
+ public AuthorizerDestructionException() {
+ }
+
+ public AuthorizerDestructionException(String msg) {
+ super(msg);
+ }
+
+ public AuthorizerDestructionException(Throwable cause) {
+ super(cause);
+ }
+
+ public AuthorizerDestructionException(String msg, Throwable cause) {
+ super(msg, cause);
+ }
+}
[06/10] nifi git commit: NIFI-1896 This closes #650. Refactored
nifi-api into nifi-framework-api and other locations. The nifi-api is
specific to that which is needed for intended extension points.
Posted by jo...@apache.org.
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-api/src/main/java/org/apache/nifi/web/NiFiWebRequestContext.java
----------------------------------------------------------------------
diff --git a/nifi-api/src/main/java/org/apache/nifi/web/NiFiWebRequestContext.java b/nifi-api/src/main/java/org/apache/nifi/web/NiFiWebRequestContext.java
deleted file mode 100644
index 9dd44ab..0000000
--- a/nifi-api/src/main/java/org/apache/nifi/web/NiFiWebRequestContext.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * 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.web;
-
-/**
- * Contextual details required to make a request from a UI extension.
- */
-public interface NiFiWebRequestContext {
-
- /**
- * @return the type of UI extension is making the request
- */
- UiExtensionType getExtensionType();
-
- /**
- * The request protocol scheme (http or https). When scheme is https, the
- * X509Certificate can be used for subsequent remote requests.
- *
- * @return the protocol scheme
- */
- String getScheme();
-
- /**
- * The id of the component.
- *
- * @return the ID
- */
- String getId();
-
- /**
- * Returns the proxied entities chain. The format of the chain is as
- * follows:
- *
- * <code>
- * <CN=original-proxied-entity><CN=first-proxy><CN=second-proxy>...
- * </code>
- *
- * @return the proxied entities chain or null if no chain
- */
- String getProxiedEntitiesChain();
-
-}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-api/src/main/java/org/apache/nifi/web/ResourceNotFoundException.java
----------------------------------------------------------------------
diff --git a/nifi-api/src/main/java/org/apache/nifi/web/ResourceNotFoundException.java b/nifi-api/src/main/java/org/apache/nifi/web/ResourceNotFoundException.java
deleted file mode 100644
index b2f2e57..0000000
--- a/nifi-api/src/main/java/org/apache/nifi/web/ResourceNotFoundException.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * 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.web;
-
-/**
- * Exception indicating that the desired resource was not found.
- */
-@SuppressWarnings("serial")
-public class ResourceNotFoundException extends RuntimeException {
-
- public ResourceNotFoundException(String message) {
- super(message);
- }
-
- public ResourceNotFoundException(String message, Throwable cause) {
- super(message, cause);
- }
-}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-api/src/main/java/org/apache/nifi/web/Revision.java
----------------------------------------------------------------------
diff --git a/nifi-api/src/main/java/org/apache/nifi/web/Revision.java b/nifi-api/src/main/java/org/apache/nifi/web/Revision.java
deleted file mode 100644
index d768faa..0000000
--- a/nifi-api/src/main/java/org/apache/nifi/web/Revision.java
+++ /dev/null
@@ -1,129 +0,0 @@
-/*
- * 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.web;
-
-import java.io.Serializable;
-
-/**
- * A model object representing a revision. Equality is defined as matching
- * component ID and either a matching version number or matching non-empty client IDs.
- *
- * @Immutable
- * @Threadsafe
- */
-public class Revision implements Serializable {
- private static final long serialVersionUID = 988658790374170022L;
-
- /**
- * the version number
- */
- private final Long version;
-
- /**
- * the client ID
- */
- private final String clientId;
-
- /**
- * the ID of the component that this revision belongs to, or <code>null</code> if
- * the revision is not attached to any component but rather is attached to the entire
- * data flow.
- */
- private final String componentId;
-
- public Revision(Long version, String clientId, String componentId) {
- if (version == null) {
- throw new IllegalArgumentException("The revision must be specified.");
- }
- if (componentId == null) {
- throw new IllegalArgumentException("The componentId must be specified.");
- }
-
- this.version = version;
- this.clientId = clientId;
- this.componentId = componentId;
- }
-
- public String getClientId() {
- return clientId;
- }
-
- public Long getVersion() {
- return version;
- }
-
- public String getComponentId() {
- return componentId;
- }
-
- /**
- * Returns a new Revision that has the same Client ID and Component ID as this one
- * but with a larger version
- *
- * @return the updated Revision
- */
- public Revision incrementRevision(final String clientId) {
- return new Revision(version + 1, clientId, componentId);
- }
-
- @Override
- public boolean equals(final Object obj) {
- if (obj == null) {
- return false;
- }
- if (obj == this) {
- return true;
- }
-
- if ((obj instanceof Revision) == false) {
- return false;
- }
-
- Revision thatRevision = (Revision) obj;
- // ensure that component ID's are the same (including null)
- if (thatRevision.getComponentId() == null && getComponentId() != null) {
- return false;
- }
- if (thatRevision.getComponentId() != null && getComponentId() == null) {
- return false;
- }
- if (thatRevision.getComponentId() != null && !thatRevision.getComponentId().equals(getComponentId())) {
- return false;
- }
-
- if (this.version != null && this.version.equals(thatRevision.version)) {
- return true;
- } else {
- return clientId != null && !clientId.trim().isEmpty() && clientId.equals(thatRevision.getClientId());
- }
-
- }
-
- @Override
- public int hashCode() {
- int hash = 5;
- hash = 59 * hash + (this.componentId != null ? this.componentId.hashCode() : 0);
- hash = 59 * hash + (this.version != null ? this.version.hashCode() : 0);
- hash = 59 * hash + (this.clientId != null ? this.clientId.hashCode() : 0);
- return hash;
- }
-
- @Override
- public String toString() {
- return "[" + version + ", " + clientId + ", " + componentId + ']';
- }
-}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-api/src/main/java/org/apache/nifi/web/UiExtensionType.java
----------------------------------------------------------------------
diff --git a/nifi-api/src/main/java/org/apache/nifi/web/UiExtensionType.java b/nifi-api/src/main/java/org/apache/nifi/web/UiExtensionType.java
deleted file mode 100644
index e3b0f8a..0000000
--- a/nifi-api/src/main/java/org/apache/nifi/web/UiExtensionType.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * 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.web;
-
-/**
- * Types of UI extensions. Since a UI extension could support multiple types of
- * custom UIs it will need to include the type so the framework can appropriate
- * understand and process the request (recording actions in the audit database,
- * replicating a request throughout the cluster to the appropriate endpoints,
- * etc).
- */
-public enum UiExtensionType {
-
- ContentViewer,
- ProcessorConfiguration,
- ControllerServiceConfiguration,
- ReportingTaskConfiguration
-}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-api/src/main/java/org/apache/nifi/web/ViewableContent.java
----------------------------------------------------------------------
diff --git a/nifi-api/src/main/java/org/apache/nifi/web/ViewableContent.java b/nifi-api/src/main/java/org/apache/nifi/web/ViewableContent.java
deleted file mode 100644
index d506b5d..0000000
--- a/nifi-api/src/main/java/org/apache/nifi/web/ViewableContent.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * 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.web;
-
-import java.io.IOException;
-import java.io.InputStream;
-
-/**
- * Interface for obtaining content from the NiFi content repository.
- */
-public interface ViewableContent {
-
- public static final String CONTENT_REQUEST_ATTRIBUTE = "org.apache.nifi.web.content";
-
- public enum DisplayMode {
-
- Original,
- Formatted,
- Hex;
- }
-
- /**
- * @return stream to the viewable content. The data stream can only be read once
- * so an extension can call this method or getContent
- */
- InputStream getContentStream();
-
- /**
- * @return the content as a string. The data stream can only be read once so an
- * extension can call this method or getContentStream
- * @throws java.io.IOException if unable to read content
- */
- String getContent() throws IOException;
-
- /**
- * @return the desired display mode. If the mode is Hex the framework will
- * handle generating the mark up. The only values that an extension will see
- * is Original or Formatted
- */
- DisplayMode getDisplayMode();
-
- /**
- * @return contents file name
- */
- String getFileName();
-
- /**
- * @return mime type of the content, value is lowercase and stripped of all parameters if there were any
- */
- String getContentType();
-
- /**
- * @return unchanged mime type of the content
- */
- String getRawContentType();
-
-}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-api/src/test/java/org/apache/nifi/authorization/TestAbstractPolicyBasedAuthorizer.java
----------------------------------------------------------------------
diff --git a/nifi-api/src/test/java/org/apache/nifi/authorization/TestAbstractPolicyBasedAuthorizer.java b/nifi-api/src/test/java/org/apache/nifi/authorization/TestAbstractPolicyBasedAuthorizer.java
deleted file mode 100644
index b173d3d..0000000
--- a/nifi-api/src/test/java/org/apache/nifi/authorization/TestAbstractPolicyBasedAuthorizer.java
+++ /dev/null
@@ -1,447 +0,0 @@
-/*
- * 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.authorization;
-
-import org.apache.nifi.authorization.exception.AuthorizationAccessException;
-import org.apache.nifi.authorization.exception.AuthorizerCreationException;
-import org.apache.nifi.authorization.exception.AuthorizerDestructionException;
-import org.junit.Assert;
-import org.junit.Test;
-import org.mockito.Mockito;
-
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.LinkedHashSet;
-import java.util.Set;
-
-import static org.junit.Assert.assertEquals;
-import static org.mockito.Mockito.when;
-
-public class TestAbstractPolicyBasedAuthorizer {
-
- static final Resource TEST_RESOURCE = new Resource() {
- @Override
- public String getIdentifier() {
- return "1";
- }
-
- @Override
- public String getName() {
- return "resource1";
- }
- };
-
- @Test
- public void testApproveBasedOnUser() {
- AbstractPolicyBasedAuthorizer authorizer = Mockito.mock(AbstractPolicyBasedAuthorizer.class);
- UsersAndAccessPolicies usersAndAccessPolicies = Mockito.mock(UsersAndAccessPolicies.class);
- when(authorizer.getUsersAndAccessPolicies()).thenReturn(usersAndAccessPolicies);
-
- final String userIdentifier = "userIdentifier1";
- final String userIdentity = "userIdentity1";
-
- final AccessPolicy policy = new AccessPolicy.Builder()
- .identifier("1")
- .resource(TEST_RESOURCE.getIdentifier())
- .addUser(userIdentifier)
- .action(RequestAction.READ)
- .build();
-
- when(usersAndAccessPolicies.getAccessPolicy(TEST_RESOURCE.getIdentifier(), RequestAction.READ)).thenReturn(policy);
-
- final User user = new User.Builder()
- .identity(userIdentity)
- .identifier(userIdentifier)
- .build();
-
- when(usersAndAccessPolicies.getUser(userIdentity)).thenReturn(user);
-
- final AuthorizationRequest request = new AuthorizationRequest.Builder()
- .identity(userIdentity)
- .resource(TEST_RESOURCE)
- .action(RequestAction.READ)
- .accessAttempt(true)
- .anonymous(false)
- .build();
-
- assertEquals(AuthorizationResult.approved(), authorizer.authorize(request));
- }
-
- @Test
- public void testApprovedBasedOnGroup() {
- AbstractPolicyBasedAuthorizer authorizer = Mockito.mock(AbstractPolicyBasedAuthorizer.class);
- UsersAndAccessPolicies usersAndAccessPolicies = Mockito.mock(UsersAndAccessPolicies.class);
- when(authorizer.getUsersAndAccessPolicies()).thenReturn(usersAndAccessPolicies);
-
- final String userIdentifier = "userIdentifier1";
- final String userIdentity = "userIdentity1";
- final String groupIdentifier = "groupIdentifier1";
-
- final AccessPolicy policy = new AccessPolicy.Builder()
- .identifier("1")
- .resource(TEST_RESOURCE.getIdentifier())
- .addGroup(groupIdentifier)
- .action(RequestAction.READ)
- .build();
-
- when(usersAndAccessPolicies.getAccessPolicy(TEST_RESOURCE.getIdentifier(), RequestAction.READ)).thenReturn(policy);
-
- final User user = new User.Builder()
- .identity(userIdentity)
- .identifier(userIdentifier)
- .build();
-
- when(usersAndAccessPolicies.getUser(userIdentity)).thenReturn(user);
-
- final Group group = new Group.Builder()
- .identifier(groupIdentifier)
- .name(groupIdentifier)
- .addUser(user.getIdentifier())
- .build();
-
- when(usersAndAccessPolicies.getGroups(userIdentity)).thenReturn(Collections.singleton(group));
-
- final AuthorizationRequest request = new AuthorizationRequest.Builder()
- .identity(userIdentity)
- .resource(TEST_RESOURCE)
- .action(RequestAction.READ)
- .accessAttempt(true)
- .anonymous(false)
- .build();
-
- assertEquals(AuthorizationResult.approved(), authorizer.authorize(request));
- }
-
- @Test
- public void testDeny() {
- AbstractPolicyBasedAuthorizer authorizer = Mockito.mock(AbstractPolicyBasedAuthorizer.class);
- UsersAndAccessPolicies usersAndAccessPolicies = Mockito.mock(UsersAndAccessPolicies.class);
- when(authorizer.getUsersAndAccessPolicies()).thenReturn(usersAndAccessPolicies);
-
- final String userIdentifier = "userIdentifier1";
- final String userIdentity = "userIdentity1";
-
- final AccessPolicy policy = new AccessPolicy.Builder()
- .identifier("1")
- .resource(TEST_RESOURCE.getIdentifier())
- .addUser("NOT_USER_1")
- .action(RequestAction.READ)
- .build();
-
- when(usersAndAccessPolicies.getAccessPolicy(TEST_RESOURCE.getIdentifier(), RequestAction.READ)).thenReturn(policy);
-
- final User user = new User.Builder()
- .identity(userIdentity)
- .identifier(userIdentifier)
- .build();
-
- when(usersAndAccessPolicies.getUser(userIdentity)).thenReturn(user);
-
- final AuthorizationRequest request = new AuthorizationRequest.Builder()
- .identity(userIdentity)
- .resource(TEST_RESOURCE)
- .action(RequestAction.READ)
- .accessAttempt(true)
- .anonymous(false)
- .build();
-
- assertEquals(AuthorizationResult.denied().getResult(), authorizer.authorize(request).getResult());
- }
-
- @Test
- public void testResourceNotFound() {
- AbstractPolicyBasedAuthorizer authorizer = Mockito.mock(AbstractPolicyBasedAuthorizer.class);
- UsersAndAccessPolicies usersAndAccessPolicies = Mockito.mock(UsersAndAccessPolicies.class);
- when(authorizer.getUsersAndAccessPolicies()).thenReturn(usersAndAccessPolicies);
-
- when(usersAndAccessPolicies.getAccessPolicy(TEST_RESOURCE.getIdentifier(), RequestAction.READ)).thenReturn(null);
-
- final AuthorizationRequest request = new AuthorizationRequest.Builder()
- .identity("userIdentity")
- .resource(TEST_RESOURCE)
- .action(RequestAction.READ)
- .accessAttempt(true)
- .anonymous(false)
- .build();
-
- assertEquals(AuthorizationResult.resourceNotFound(), authorizer.authorize(request));
- }
-
- @Test
- public void testGetFingerprint() {
- // create the users, groups, and policies
-
- User user1 = new User.Builder().identifier("user-id-1").identity("user-1").build();
- User user2 = new User.Builder().identifier("user-id-2").identity("user-2").build();
-
- Group group1 = new Group.Builder().identifier("group-id-1").name("group-1").addUser(user1.getIdentifier()).build();
- Group group2 = new Group.Builder().identifier("group-id-2").name("group-2").addUser(user2.getIdentifier()).build();
-
- AccessPolicy policy1 = new AccessPolicy.Builder()
- .identifier("policy-id-1")
- .resource("resource1")
- .action(RequestAction.READ)
- .addUser(user1.getIdentifier())
- .addUser(user2.getIdentifier())
- .build();
-
- AccessPolicy policy2 = new AccessPolicy.Builder()
- .identifier("policy-id-2")
- .resource("resource2")
- .action(RequestAction.READ)
- .addGroup(group1.getIdentifier())
- .addGroup(group2.getIdentifier())
- .addUser(user1.getIdentifier())
- .addUser(user2.getIdentifier())
- .build();
-
- // create the first Authorizer
-
- Set<Group> groups1 = new LinkedHashSet<>();
- groups1.add(group1);
- groups1.add(group2);
-
- Set<User> users1 = new LinkedHashSet<>();
- users1.add(user1);
- users1.add(user2);
-
- Set<AccessPolicy> policies1 = new LinkedHashSet<>();
- policies1.add(policy1);
- policies1.add(policy2);
-
- AbstractPolicyBasedAuthorizer authorizer1 = Mockito.mock(AbstractPolicyBasedAuthorizer.class);
- when(authorizer1.getGroups()).thenReturn(groups1);
- when(authorizer1.getUsers()).thenReturn(users1);
- when(authorizer1.getAccessPolicies()).thenReturn(policies1);
-
- // create the second Authorizer
-
- Set<Group> groups2 = new LinkedHashSet<>();
- groups2.add(group2);
- groups2.add(group1);
-
- Set<User> users2 = new LinkedHashSet<>();
- users2.add(user2);
- users2.add(user1);
-
- Set<AccessPolicy> policies2 = new LinkedHashSet<>();
- policies2.add(policy2);
- policies2.add(policy1);
-
- AbstractPolicyBasedAuthorizer authorizer2 = Mockito.mock(AbstractPolicyBasedAuthorizer.class);
- when(authorizer2.getGroups()).thenReturn(groups2);
- when(authorizer2.getUsers()).thenReturn(users2);
- when(authorizer2.getAccessPolicies()).thenReturn(policies2);
-
- // compare the fingerprints
-
- assertEquals(authorizer1.getFingerprint(), authorizer2.getFingerprint());
-
- System.out.println(authorizer1.getFingerprint());
- }
-
- @Test
- public void testInheritFingerprint() {
-
- User user1 = new User.Builder().identifier("user-id-1").identity("user-1").build();
- User user2 = new User.Builder().identifier("user-id-2").identity("user-2").build();
-
- Group group1 = new Group.Builder().identifier("group-id-1").name("group-1").addUser(user1.getIdentifier()).build();
- Group group2 = new Group.Builder().identifier("group-id-2").name("group-2").build();
-
- AccessPolicy policy1 = new AccessPolicy.Builder()
- .identifier("policy-id-1")
- .resource("resource1")
- .action(RequestAction.READ)
- .addUser(user1.getIdentifier())
- .addUser(user2.getIdentifier())
- .build();
-
- AccessPolicy policy2 = new AccessPolicy.Builder()
- .identifier("policy-id-2")
- .resource("resource2")
- .action(RequestAction.READ)
- .addGroup(group1.getIdentifier())
- .addGroup(group2.getIdentifier())
- .addUser(user1.getIdentifier())
- .addUser(user2.getIdentifier())
- .build();
-
- // create the first Authorizer
-
- Set<Group> groups1 = new LinkedHashSet<>();
- groups1.add(group1);
- groups1.add(group2);
-
- Set<User> users1 = new LinkedHashSet<>();
- users1.add(user1);
- users1.add(user2);
-
- Set<AccessPolicy> policies1 = new LinkedHashSet<>();
- policies1.add(policy1);
- policies1.add(policy2);
-
- AbstractPolicyBasedAuthorizer authorizer1 = Mockito.mock(AbstractPolicyBasedAuthorizer.class);
- when(authorizer1.getGroups()).thenReturn(groups1);
- when(authorizer1.getUsers()).thenReturn(users1);
- when(authorizer1.getAccessPolicies()).thenReturn(policies1);
-
- final String fingerprint1 = authorizer1.getFingerprint();
-
- // make a second authorizer using the memory-backed implementation so we can inherit the fingerprint
- // and then compute a new fingerprint to compare them
- AbstractPolicyBasedAuthorizer authorizer2 = new MemoryPolicyBasedAuthorizer();
- authorizer2.inheritFingerprint(fingerprint1);
-
- // computer the fingerprint of the second authorizer and it should be the same as the first
- final String fingerprint2 = authorizer2.getFingerprint();
- assertEquals(fingerprint1, fingerprint2);
-
- // all the sets should be equal now after inheriting
- assertEquals(authorizer1.getUsers(), authorizer2.getUsers());
- assertEquals(authorizer1.getGroups(), authorizer2.getGroups());
- assertEquals(authorizer1.getAccessPolicies(), authorizer2.getAccessPolicies());
- }
-
- @Test
- public void testEmptyAuthorizer() {
- AbstractPolicyBasedAuthorizer authorizer = Mockito.mock(AbstractPolicyBasedAuthorizer.class);
- when(authorizer.getGroups()).thenReturn(new HashSet<Group>());
- when(authorizer.getUsers()).thenReturn(new HashSet<User>());
- when(authorizer.getAccessPolicies()).thenReturn(new HashSet<AccessPolicy>());
-
- final String fingerprint = authorizer.getFingerprint();
- Assert.assertNotNull(fingerprint);
- Assert.assertTrue(fingerprint.length() > 0);
- }
-
- /**
- * An AbstractPolicyBasedAuthorizer that stores everything in memory.
- */
- private static final class MemoryPolicyBasedAuthorizer extends AbstractPolicyBasedAuthorizer {
-
- private Set<Group> groups = new HashSet<>();
- private Set<User> users = new HashSet<>();
- private Set<AccessPolicy> policies = new HashSet<>();
-
- @Override
- public Group addGroup(Group group) throws AuthorizationAccessException {
- groups.add(group);
- return group;
- }
-
- @Override
- public Group getGroup(String identifier) throws AuthorizationAccessException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public Group updateGroup(Group group) throws AuthorizationAccessException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public Group deleteGroup(Group group) throws AuthorizationAccessException {
- groups.remove(group);
- return group;
- }
-
- @Override
- public Set<Group> getGroups() throws AuthorizationAccessException {
- return groups;
- }
-
- @Override
- public User addUser(User user) throws AuthorizationAccessException {
- users.add(user);
- return user;
- }
-
- @Override
- public User getUser(String identifier) throws AuthorizationAccessException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public User getUserByIdentity(String identity) throws AuthorizationAccessException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public User updateUser(User user) throws AuthorizationAccessException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public User deleteUser(User user) throws AuthorizationAccessException {
- users.remove(user);
- return user;
- }
-
- @Override
- public Set<User> getUsers() throws AuthorizationAccessException {
- return users;
- }
-
- @Override
- protected AccessPolicy doAddAccessPolicy(AccessPolicy accessPolicy) throws AuthorizationAccessException {
- policies.add(accessPolicy);
- return accessPolicy;
- }
-
- @Override
- public AccessPolicy getAccessPolicy(String identifier) throws AuthorizationAccessException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public AccessPolicy updateAccessPolicy(AccessPolicy accessPolicy) throws AuthorizationAccessException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public AccessPolicy deleteAccessPolicy(AccessPolicy policy) throws AuthorizationAccessException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public Set<AccessPolicy> getAccessPolicies() throws AuthorizationAccessException {
- return policies;
- }
-
- @Override
- public UsersAndAccessPolicies getUsersAndAccessPolicies() throws AuthorizationAccessException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void initialize(AuthorizerInitializationContext initializationContext) throws AuthorizerCreationException {
-
- }
-
- @Override
- public void doOnConfigured(AuthorizerConfigurationContext configurationContext) throws AuthorizerCreationException {
-
- }
-
- @Override
- public void preDestruction() throws AuthorizerDestructionException {
-
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-api/src/test/java/org/apache/nifi/authorization/TestAccessPolicy.java
----------------------------------------------------------------------
diff --git a/nifi-api/src/test/java/org/apache/nifi/authorization/TestAccessPolicy.java b/nifi-api/src/test/java/org/apache/nifi/authorization/TestAccessPolicy.java
deleted file mode 100644
index c8a4452..0000000
--- a/nifi-api/src/test/java/org/apache/nifi/authorization/TestAccessPolicy.java
+++ /dev/null
@@ -1,240 +0,0 @@
-/*
- * 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.authorization;
-
-import org.junit.Test;
-
-import java.util.HashSet;
-import java.util.Set;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-public class TestAccessPolicy {
-
- static final String TEST_RESOURCE = "1";
-
- @Test
- public void testSimpleCreation() {
- final String identifier = "1";
- final String user1 = "user1";
- final String user2 = "user2";
- final RequestAction action = RequestAction.READ;
-
- final AccessPolicy policy = new AccessPolicy.Builder()
- .identifier(identifier)
- .resource(TEST_RESOURCE)
- .addUser(user1)
- .addUser(user2)
- .action(action)
- .build();
-
- assertEquals(identifier, policy.getIdentifier());
-
- assertNotNull(policy.getResource());
- assertEquals(TEST_RESOURCE, policy.getResource());
-
- assertNotNull(policy.getUsers());
- assertEquals(2, policy.getUsers().size());
- assertTrue(policy.getUsers().contains(user1));
- assertTrue(policy.getUsers().contains(user2));
-
- assertNotNull(policy.getAction());
- assertEquals(RequestAction.READ, policy.getAction());
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void testMissingIdentifier() {
- new AccessPolicy.Builder()
- .resource(TEST_RESOURCE)
- .addUser("user1")
- .action(RequestAction.READ)
- .build();
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void testMissingResource() {
- new AccessPolicy.Builder()
- .identifier("1")
- .addUser("user1")
- .action(RequestAction.READ)
- .build();
- }
-
- @Test
- public void testMissingUsersAndGroups() {
- final AccessPolicy policy = new AccessPolicy.Builder()
- .identifier("1")
- .resource(TEST_RESOURCE)
- .action(RequestAction.READ)
- .build();
-
- assertNotNull(policy);
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void testMissingActions() {
- new AccessPolicy.Builder()
- .identifier("1")
- .resource(TEST_RESOURCE)
- .addUser("user1")
- .build();
- }
-
- @Test
- public void testFromPolicy() {
- final String identifier = "1";
- final String user1 = "user1";
- final String user2 = "user2";
- final String group1 = "group1";
- final String group2 = "group2";
- final RequestAction action = RequestAction.READ;
-
- final AccessPolicy policy = new AccessPolicy.Builder()
- .identifier(identifier)
- .resource(TEST_RESOURCE)
- .addUser(user1)
- .addUser(user2)
- .addGroup(group1)
- .addGroup(group2)
- .action(action)
- .build();
-
- assertEquals(identifier, policy.getIdentifier());
-
- assertNotNull(policy.getResource());
- assertEquals(TEST_RESOURCE, policy.getResource());
-
- assertNotNull(policy.getUsers());
- assertEquals(2, policy.getUsers().size());
- assertTrue(policy.getUsers().contains(user1));
- assertTrue(policy.getUsers().contains(user2));
-
- assertNotNull(policy.getGroups());
- assertEquals(2, policy.getGroups().size());
- assertTrue(policy.getGroups().contains(group1));
- assertTrue(policy.getGroups().contains(group2));
-
- assertNotNull(policy.getAction());
- assertEquals(RequestAction.READ, policy.getAction());
-
- final AccessPolicy policy2 = new AccessPolicy.Builder(policy).build();
- assertEquals(policy.getIdentifier(), policy2.getIdentifier());
- assertEquals(policy.getResource(), policy2.getResource());
- assertEquals(policy.getUsers(), policy2.getUsers());
- assertEquals(policy.getAction(), policy2.getAction());
- }
-
- @Test(expected = IllegalStateException.class)
- public void testFromPolicyAndChangeIdentifier() {
- final AccessPolicy policy = new AccessPolicy.Builder()
- .identifier("1")
- .resource(TEST_RESOURCE)
- .addUser("user1")
- .action(RequestAction.READ)
- .build();
-
- new AccessPolicy.Builder(policy).identifier("2").build();
- }
-
- @Test
- public void testAddRemoveClearUsers() {
- final AccessPolicy.Builder builder = new AccessPolicy.Builder()
- .identifier("1")
- .resource(TEST_RESOURCE)
- .addUser("user1")
- .action(RequestAction.READ);
-
- final AccessPolicy policy1 = builder.build();
- assertEquals(1, policy1.getUsers().size());
- assertTrue(policy1.getUsers().contains("user1"));
-
- final Set<String> moreEntities = new HashSet<>();
- moreEntities.add("user2");
- moreEntities.add("user3");
- moreEntities.add("user4");
-
- final AccessPolicy policy2 = builder.addUsers(moreEntities).build();
- assertEquals(4, policy2.getUsers().size());
- assertTrue(policy2.getUsers().contains("user1"));
- assertTrue(policy2.getUsers().contains("user2"));
- assertTrue(policy2.getUsers().contains("user3"));
- assertTrue(policy2.getUsers().contains("user4"));
-
- final AccessPolicy policy3 = builder.removeUser("user3").build();
- assertEquals(3, policy3.getUsers().size());
- assertTrue(policy3.getUsers().contains("user1"));
- assertTrue(policy3.getUsers().contains("user2"));
- assertTrue(policy3.getUsers().contains("user4"));
-
- final Set<String> removeEntities = new HashSet<>();
- removeEntities.add("user1");
- removeEntities.add("user4");
-
- final AccessPolicy policy4 = builder.removeUsers(removeEntities).build();
- assertEquals(1, policy4.getUsers().size());
- assertTrue(policy4.getUsers().contains("user2"));
-
-
- final AccessPolicy policy5 = builder.clearUsers().build();
- assertEquals(0, policy5.getUsers().size());
- }
-
- @Test
- public void testAddRemoveClearGroups() {
- final AccessPolicy.Builder builder = new AccessPolicy.Builder()
- .identifier("1")
- .resource(TEST_RESOURCE)
- .addGroup("group1")
- .action(RequestAction.READ);
-
- final AccessPolicy policy1 = builder.build();
- assertEquals(1, policy1.getGroups().size());
- assertTrue(policy1.getGroups().contains("group1"));
-
- final Set<String> moreGroups = new HashSet<>();
- moreGroups.add("group2");
- moreGroups.add("group3");
- moreGroups.add("group4");
-
- final AccessPolicy policy2 = builder.addGroups(moreGroups).build();
- assertEquals(4, policy2.getGroups().size());
- assertTrue(policy2.getGroups().contains("group1"));
- assertTrue(policy2.getGroups().contains("group2"));
- assertTrue(policy2.getGroups().contains("group3"));
- assertTrue(policy2.getGroups().contains("group4"));
-
- final AccessPolicy policy3 = builder.removeGroup("group3").build();
- assertEquals(3, policy3.getGroups().size());
- assertTrue(policy3.getGroups().contains("group1"));
- assertTrue(policy3.getGroups().contains("group2"));
- assertTrue(policy3.getGroups().contains("group4"));
-
- final Set<String> removeGroups = new HashSet<>();
- removeGroups.add("group1");
- removeGroups.add("group4");
-
- final AccessPolicy policy4 = builder.removeGroups(removeGroups).build();
- assertEquals(1, policy4.getGroups().size());
- assertTrue(policy4.getGroups().contains("group2"));
-
- final AccessPolicy policy5 = builder.clearGroups().build();
- assertEquals(0, policy5.getUsers().size());
- }
-
-}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-api/src/test/java/org/apache/nifi/authorization/TestGroup.java
----------------------------------------------------------------------
diff --git a/nifi-api/src/test/java/org/apache/nifi/authorization/TestGroup.java b/nifi-api/src/test/java/org/apache/nifi/authorization/TestGroup.java
deleted file mode 100644
index 8ccdba5..0000000
--- a/nifi-api/src/test/java/org/apache/nifi/authorization/TestGroup.java
+++ /dev/null
@@ -1,169 +0,0 @@
-/*
- * 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.authorization;
-
-import org.junit.Test;
-
-import java.util.HashSet;
-import java.util.Set;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-public class TestGroup {
-
- @Test
- public void testSimpleCreation() {
- final String id = "1";
- final String name = "group1";
- final String user1 = "user1";
- final String user2 = "user2";
-
- final Group group = new Group.Builder()
- .identifier(id)
- .name(name)
- .addUser(user1)
- .addUser(user2)
- .build();
-
- assertEquals(id, group.getIdentifier());
- assertEquals(name, group.getName());
-
- assertNotNull(group.getUsers());
- assertEquals(2, group.getUsers().size());
- assertTrue(group.getUsers().contains(user1));
- assertTrue(group.getUsers().contains(user2));
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void testMissingId() {
- new Group.Builder()
- .name("group1")
- .addUser("user1")
- .addUser("user2")
- .build();
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void testMissingName() {
- new Group.Builder()
- .identifier("1")
- .addUser("user1")
- .addUser("user2")
- .build();
- }
-
- @Test
- public void testMissingUsers() {
- final String id = "1";
- final String name = "group1";
-
- final Group group = new Group.Builder()
- .identifier(id)
- .name(name)
- .build();
-
- assertEquals(id, group.getIdentifier());
- assertEquals(name, group.getName());
-
- assertNotNull(group.getUsers());
- assertEquals(0, group.getUsers().size());
- }
-
- @Test
- public void testFromGroup() {
- final String id = "1";
- final String name = "group1";
- final String user1 = "user1";
- final String user2 = "user2";
-
- final Group group1 = new Group.Builder()
- .identifier(id)
- .name(name)
- .addUser(user1)
- .addUser(user2)
- .build();
-
- assertEquals(id, group1.getIdentifier());
- assertEquals(name, group1.getName());
-
- assertNotNull(group1.getUsers());
- assertEquals(2, group1.getUsers().size());
- assertTrue(group1.getUsers().contains(user1));
- assertTrue(group1.getUsers().contains(user2));
-
- final Group group2 = new Group.Builder(group1).build();
- assertEquals(group1.getIdentifier(), group2.getIdentifier());
- assertEquals(group1.getName(), group2.getName());
- assertEquals(group1.getUsers(), group2.getUsers());
- }
-
- @Test(expected = IllegalStateException.class)
- public void testFromGroupAndChangeIdentifier() {
- final Group group1 = new Group.Builder()
- .identifier("1")
- .name("group1")
- .addUser("user1")
- .build();
-
- new Group.Builder(group1).identifier("2").build();
- }
-
- @Test
- public void testAddRemoveClearUsers() {
- final Group.Builder builder = new Group.Builder()
- .identifier("1")
- .name("group1")
- .addUser("user1");
-
- final Group group1 = builder.build();
- assertNotNull(group1.getUsers());
- assertEquals(1, group1.getUsers().size());
- assertTrue(group1.getUsers().contains("user1"));
-
- final Set<String> moreUsers = new HashSet<>();
- moreUsers.add("user2");
- moreUsers.add("user3");
- moreUsers.add("user4");
-
- final Group group2 = builder.addUsers(moreUsers).build();
- assertEquals(4, group2.getUsers().size());
- assertTrue(group2.getUsers().contains("user1"));
- assertTrue(group2.getUsers().contains("user2"));
- assertTrue(group2.getUsers().contains("user3"));
- assertTrue(group2.getUsers().contains("user4"));
-
- final Group group3 = builder.removeUser("user2").build();
- assertEquals(3, group3.getUsers().size());
- assertTrue(group3.getUsers().contains("user1"));
- assertTrue(group3.getUsers().contains("user3"));
- assertTrue(group3.getUsers().contains("user4"));
-
- final Set<String> removeUsers = new HashSet<>();
- removeUsers.add("user1");
- removeUsers.add("user4");
-
- final Group group4 = builder.removeUsers(removeUsers).build();
- assertEquals(1, group4.getUsers().size());
- assertTrue(group4.getUsers().contains("user3"));
-
- final Group group5 = builder.clearUsers().build();
- assertEquals(0, group5.getUsers().size());
- }
-
-}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-api/src/test/java/org/apache/nifi/authorization/TestUser.java
----------------------------------------------------------------------
diff --git a/nifi-api/src/test/java/org/apache/nifi/authorization/TestUser.java b/nifi-api/src/test/java/org/apache/nifi/authorization/TestUser.java
deleted file mode 100644
index 04b1ab1..0000000
--- a/nifi-api/src/test/java/org/apache/nifi/authorization/TestUser.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * 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.authorization;
-
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-
-public class TestUser {
-
- @Test
- public void testSimpleCreation() {
- final String identifier = "1";
- final String identity = "user1";
- final String group1 = "group1";
- final String group2 = "group2";
-
- final User user = new User.Builder()
- .identifier(identifier)
- .identity(identity)
- .build();
-
- assertEquals(identifier, user.getIdentifier());
- assertEquals(identity, user.getIdentity());
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void testMissingIdentifier() {
- new User.Builder()
- .identity("user1")
- .build();
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void testMissingIdentity() {
- new User.Builder()
- .identifier("1")
- .build();
- }
-
- @Test
- public void testFromUser() {
- final String identifier = "1";
- final String identity = "user1";
- final String group1 = "group1";
- final String group2 = "group2";
-
- final User user = new User.Builder()
- .identifier(identifier)
- .identity(identity)
- .build();
-
- assertEquals(identifier, user.getIdentifier());
- assertEquals(identity, user.getIdentity());
-
- final User user2 = new User.Builder(user).build();
- assertEquals(user.getIdentifier(), user2.getIdentifier());
- assertEquals(user.getIdentity(), user2.getIdentity());
- }
-
- @Test(expected = IllegalStateException.class)
- public void testFromUserAndChangeIdentifier() {
- final User user = new User.Builder()
- .identifier("1")
- .identity("user1")
- .build();
-
- new User.Builder(user).identifier("2").build();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-api/src/test/java/org/apache/nifi/web/TestRevision.java
----------------------------------------------------------------------
diff --git a/nifi-api/src/test/java/org/apache/nifi/web/TestRevision.java b/nifi-api/src/test/java/org/apache/nifi/web/TestRevision.java
deleted file mode 100644
index 6d513fd..0000000
--- a/nifi-api/src/test/java/org/apache/nifi/web/TestRevision.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * 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.web;
-
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-
-/**
- *
- */
-public class TestRevision {
-
- @Test(expected = IllegalArgumentException.class)
- public void testNullVersion() throws Exception {
- new Revision(null, "client-id", "component-id");
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void testNullComponentId() throws Exception {
- new Revision(0l, "client-id", null);
- }
-
- @Test
- public void testIncrementRevision() throws Exception {
- final String clientId = "client-id";
- final String componentId = "component-id";
- final Revision revision = new Revision(0l, clientId, componentId);
- final Revision updatedRevision = revision.incrementRevision(clientId);
- assertEquals(1, updatedRevision.getVersion().longValue());
- assertEquals(clientId, updatedRevision.getClientId());
- assertEquals(componentId, updatedRevision.getComponentId());
- }
-
- @Test
- public void testIncrementRevisionNewClient() throws Exception {
- final String clientId = "client-id";
- final String newClientId = "new-client-id";
- final String componentId = "component-id";
- final Revision revision = new Revision(0l, clientId, componentId);
- final Revision updatedRevision = revision.incrementRevision(newClientId);
- assertEquals(1, updatedRevision.getVersion().longValue());
- assertEquals(newClientId, updatedRevision.getClientId());
- assertEquals(componentId, updatedRevision.getComponentId());
- }
-
-}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-assembly/pom.xml
----------------------------------------------------------------------
diff --git a/nifi-assembly/pom.xml b/nifi-assembly/pom.xml
index 146df7d..e2b8595 100644
--- a/nifi-assembly/pom.xml
+++ b/nifi-assembly/pom.xml
@@ -82,6 +82,10 @@ language governing permissions and limitations under the License. -->
</dependency>
<dependency>
<groupId>org.apache.nifi</groupId>
+ <artifactId>nifi-framework-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.nifi</groupId>
<artifactId>nifi-runtime</artifactId>
</dependency>
<dependency>
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-commons/nifi-data-provenance-utils/pom.xml
----------------------------------------------------------------------
diff --git a/nifi-commons/nifi-data-provenance-utils/pom.xml b/nifi-commons/nifi-data-provenance-utils/pom.xml
index e379541..b1413c5 100644
--- a/nifi-commons/nifi-data-provenance-utils/pom.xml
+++ b/nifi-commons/nifi-data-provenance-utils/pom.xml
@@ -28,6 +28,10 @@
</dependency>
<dependency>
<groupId>org.apache.nifi</groupId>
+ <artifactId>nifi-framework-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.nifi</groupId>
<artifactId>nifi-utils</artifactId>
</dependency>
</dependencies>
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-commons/nifi-site-to-site-client/pom.xml
----------------------------------------------------------------------
diff --git a/nifi-commons/nifi-site-to-site-client/pom.xml b/nifi-commons/nifi-site-to-site-client/pom.xml
index 4bd0913..63e5c12 100644
--- a/nifi-commons/nifi-site-to-site-client/pom.xml
+++ b/nifi-commons/nifi-site-to-site-client/pom.xml
@@ -31,6 +31,10 @@
</dependency>
<dependency>
<groupId>org.apache.nifi</groupId>
+ <artifactId>nifi-framework-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.nifi</groupId>
<artifactId>nifi-utils</artifactId>
</dependency>
<dependency>
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-framework-api/pom.xml
----------------------------------------------------------------------
diff --git a/nifi-framework-api/pom.xml b/nifi-framework-api/pom.xml
new file mode 100644
index 0000000..5ece11b
--- /dev/null
+++ b/nifi-framework-api/pom.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.nifi</groupId>
+ <artifactId>nifi</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ </parent>
+ <artifactId>nifi-framework-api</artifactId>
+ <packaging>jar</packaging>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.nifi</groupId>
+ <artifactId>nifi-api</artifactId>
+ </dependency>
+ </dependencies>
+</project>
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-framework-api/src/main/java/org/apache/nifi/action/component/details/ExtensionDetails.java
----------------------------------------------------------------------
diff --git a/nifi-framework-api/src/main/java/org/apache/nifi/action/component/details/ExtensionDetails.java b/nifi-framework-api/src/main/java/org/apache/nifi/action/component/details/ExtensionDetails.java
new file mode 100644
index 0000000..5726c1b
--- /dev/null
+++ b/nifi-framework-api/src/main/java/org/apache/nifi/action/component/details/ExtensionDetails.java
@@ -0,0 +1,26 @@
+/*
+ * 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.action.component.details;
+
+/**
+ * Provides details of an extension on an Action.
+ */
+public interface ExtensionDetails extends ComponentDetails {
+
+ String getType();
+
+}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-framework-api/src/main/java/org/apache/nifi/action/component/details/RemoteProcessGroupDetails.java
----------------------------------------------------------------------
diff --git a/nifi-framework-api/src/main/java/org/apache/nifi/action/component/details/RemoteProcessGroupDetails.java b/nifi-framework-api/src/main/java/org/apache/nifi/action/component/details/RemoteProcessGroupDetails.java
new file mode 100644
index 0000000..62f8628
--- /dev/null
+++ b/nifi-framework-api/src/main/java/org/apache/nifi/action/component/details/RemoteProcessGroupDetails.java
@@ -0,0 +1,26 @@
+/*
+ * 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.action.component.details;
+
+/**
+ * Provides details of a remote process group to an Action.
+ */
+public interface RemoteProcessGroupDetails extends ComponentDetails {
+
+ String getUri();
+
+}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-framework-api/src/main/java/org/apache/nifi/action/details/ConfigureDetails.java
----------------------------------------------------------------------
diff --git a/nifi-framework-api/src/main/java/org/apache/nifi/action/details/ConfigureDetails.java b/nifi-framework-api/src/main/java/org/apache/nifi/action/details/ConfigureDetails.java
new file mode 100644
index 0000000..ff8db40
--- /dev/null
+++ b/nifi-framework-api/src/main/java/org/apache/nifi/action/details/ConfigureDetails.java
@@ -0,0 +1,30 @@
+/*
+ * 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.action.details;
+
+/**
+ * Provides details about a configure action.
+ */
+public interface ConfigureDetails extends ActionDetails {
+
+ String getName();
+
+ String getPreviousValue();
+
+ String getValue();
+
+}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-framework-api/src/main/java/org/apache/nifi/action/details/ConnectDetails.java
----------------------------------------------------------------------
diff --git a/nifi-framework-api/src/main/java/org/apache/nifi/action/details/ConnectDetails.java b/nifi-framework-api/src/main/java/org/apache/nifi/action/details/ConnectDetails.java
new file mode 100644
index 0000000..3c8c91b
--- /dev/null
+++ b/nifi-framework-api/src/main/java/org/apache/nifi/action/details/ConnectDetails.java
@@ -0,0 +1,40 @@
+/*
+ * 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.action.details;
+
+import org.apache.nifi.action.Component;
+
+/**
+ * Provides details about a connect action.
+ */
+public interface ConnectDetails extends ActionDetails {
+
+ String getSourceId();
+
+ String getSourceName();
+
+ Component getSourceType();
+
+ String getDestinationId();
+
+ String getDestinationName();
+
+ Component getDestinationType();
+
+ String getRelationship();
+
+}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-framework-api/src/main/java/org/apache/nifi/action/details/MoveDetails.java
----------------------------------------------------------------------
diff --git a/nifi-framework-api/src/main/java/org/apache/nifi/action/details/MoveDetails.java b/nifi-framework-api/src/main/java/org/apache/nifi/action/details/MoveDetails.java
new file mode 100644
index 0000000..0533b3b
--- /dev/null
+++ b/nifi-framework-api/src/main/java/org/apache/nifi/action/details/MoveDetails.java
@@ -0,0 +1,30 @@
+/*
+ * 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.action.details;
+
+/**
+ * Provides details about a move action.
+ */
+public interface MoveDetails extends ActionDetails {
+ String getGroup();
+
+ String getGroupId();
+
+ String getPreviousGroup();
+
+ String getPreviousGroupId();
+}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-framework-api/src/main/java/org/apache/nifi/action/details/PurgeDetails.java
----------------------------------------------------------------------
diff --git a/nifi-framework-api/src/main/java/org/apache/nifi/action/details/PurgeDetails.java b/nifi-framework-api/src/main/java/org/apache/nifi/action/details/PurgeDetails.java
new file mode 100644
index 0000000..57bc57e
--- /dev/null
+++ b/nifi-framework-api/src/main/java/org/apache/nifi/action/details/PurgeDetails.java
@@ -0,0 +1,28 @@
+/*
+ * 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.action.details;
+
+import java.util.Date;
+
+/**
+ * Provides details about a purge action.
+ */
+public interface PurgeDetails extends ActionDetails {
+
+ Date getEndDate();
+
+}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-framework-api/src/main/java/org/apache/nifi/authentication/AuthenticationResponse.java
----------------------------------------------------------------------
diff --git a/nifi-framework-api/src/main/java/org/apache/nifi/authentication/AuthenticationResponse.java b/nifi-framework-api/src/main/java/org/apache/nifi/authentication/AuthenticationResponse.java
new file mode 100644
index 0000000..e9999fc
--- /dev/null
+++ b/nifi-framework-api/src/main/java/org/apache/nifi/authentication/AuthenticationResponse.java
@@ -0,0 +1,65 @@
+/*
+ * 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.authentication;
+
+/**
+ * Authentication response for a user login attempt.
+ */
+public class AuthenticationResponse {
+
+ private final String identity;
+ private final String username;
+ private final long expiration;
+ private final String issuer;
+
+ /**
+ * Creates an authentication response. The username and how long the authentication is valid in milliseconds
+ *
+ * @param identity The user identity
+ * @param username The username
+ * @param expiration The expiration in milliseconds
+ * @param issuer The issuer of the token
+ */
+ public AuthenticationResponse(final String identity, final String username, final long expiration, final String issuer) {
+ this.identity = identity;
+ this.username = username;
+ this.expiration = expiration;
+ this.issuer = issuer;
+ }
+
+ public String getIdentity() {
+ return identity;
+ }
+
+ public String getUsername() {
+ return username;
+ }
+
+ public String getIssuer() {
+ return issuer;
+ }
+
+ /**
+ * Returns the expiration of a given authentication in milliseconds.
+ *
+ * @return The expiration in milliseconds
+ */
+ public long getExpiration() {
+ return expiration;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-framework-api/src/main/java/org/apache/nifi/authentication/LoginCredentials.java
----------------------------------------------------------------------
diff --git a/nifi-framework-api/src/main/java/org/apache/nifi/authentication/LoginCredentials.java b/nifi-framework-api/src/main/java/org/apache/nifi/authentication/LoginCredentials.java
new file mode 100644
index 0000000..afb7827
--- /dev/null
+++ b/nifi-framework-api/src/main/java/org/apache/nifi/authentication/LoginCredentials.java
@@ -0,0 +1,39 @@
+/*
+ * 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.authentication;
+
+/**
+ * Login credentials for a user.
+ */
+public class LoginCredentials {
+
+ private final String username;
+ private final String password;
+
+ public LoginCredentials(String username, String password) {
+ this.username = username;
+ this.password = password;
+ }
+
+ public String getUsername() {
+ return username;
+ }
+
+ public String getPassword() {
+ return password;
+ }
+}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-framework-api/src/main/java/org/apache/nifi/authentication/LoginIdentityProvider.java
----------------------------------------------------------------------
diff --git a/nifi-framework-api/src/main/java/org/apache/nifi/authentication/LoginIdentityProvider.java b/nifi-framework-api/src/main/java/org/apache/nifi/authentication/LoginIdentityProvider.java
new file mode 100644
index 0000000..145bdb4
--- /dev/null
+++ b/nifi-framework-api/src/main/java/org/apache/nifi/authentication/LoginIdentityProvider.java
@@ -0,0 +1,61 @@
+/*
+ * 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.authentication;
+
+import org.apache.nifi.authentication.exception.IdentityAccessException;
+import org.apache.nifi.authentication.exception.InvalidLoginCredentialsException;
+import org.apache.nifi.authentication.exception.ProviderCreationException;
+import org.apache.nifi.authentication.exception.ProviderDestructionException;
+
+/**
+ * Identity provider that is able to authentication a user with username/password credentials.
+ */
+public interface LoginIdentityProvider {
+
+ /**
+ * Authenticates the specified login credentials.
+ *
+ * @param credentials the credentials
+ * @return The authentication response
+ * @throws InvalidLoginCredentialsException The login credentials were invalid
+ * @throws IdentityAccessException Unable to register the user due to an issue accessing the underlying storage
+ */
+ AuthenticationResponse authenticate(LoginCredentials credentials) throws InvalidLoginCredentialsException, IdentityAccessException;
+
+ /**
+ * Called immediately after instance creation for implementers to perform additional setup
+ *
+ * @param initializationContext in which to initialize
+ * @throws ProviderCreationException Unable to initialize
+ */
+ void initialize(LoginIdentityProviderInitializationContext initializationContext) throws ProviderCreationException;
+
+ /**
+ * Called to configure the AuthorityProvider.
+ *
+ * @param configurationContext at the time of configuration
+ * @throws ProviderCreationException for any issues configuring the provider
+ */
+ void onConfigured(LoginIdentityProviderConfigurationContext configurationContext) throws ProviderCreationException;
+
+ /**
+ * Called immediately before instance destruction for implementers to release resources.
+ *
+ * @throws ProviderDestructionException If pre-destruction fails.
+ */
+ void preDestruction() throws ProviderDestructionException;
+}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-framework-api/src/main/java/org/apache/nifi/authentication/LoginIdentityProviderConfigurationContext.java
----------------------------------------------------------------------
diff --git a/nifi-framework-api/src/main/java/org/apache/nifi/authentication/LoginIdentityProviderConfigurationContext.java b/nifi-framework-api/src/main/java/org/apache/nifi/authentication/LoginIdentityProviderConfigurationContext.java
new file mode 100644
index 0000000..6fe61fc
--- /dev/null
+++ b/nifi-framework-api/src/main/java/org/apache/nifi/authentication/LoginIdentityProviderConfigurationContext.java
@@ -0,0 +1,48 @@
+/*
+ * 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.authentication;
+
+import java.util.Map;
+
+/**
+ *
+ */
+public interface LoginIdentityProviderConfigurationContext {
+
+ /**
+ * @return identifier for the authority provider
+ */
+ String getIdentifier();
+
+ /**
+ * Retrieves all properties the component currently understands regardless
+ * of whether a value has been set for them or not. If no value is present
+ * then its value is null and thus any registered default for the property
+ * descriptor applies.
+ *
+ * @return Map of all properties
+ */
+ Map<String, String> getProperties();
+
+ /**
+ * @param property to lookup the descriptor and value of
+ * @return the value the component currently understands for the given
+ * PropertyDescriptor. This method does not substitute default
+ * PropertyDescriptor values, so the value returned will be null if not set
+ */
+ String getProperty(String property);
+}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-framework-api/src/main/java/org/apache/nifi/authentication/LoginIdentityProviderInitializationContext.java
----------------------------------------------------------------------
diff --git a/nifi-framework-api/src/main/java/org/apache/nifi/authentication/LoginIdentityProviderInitializationContext.java b/nifi-framework-api/src/main/java/org/apache/nifi/authentication/LoginIdentityProviderInitializationContext.java
new file mode 100644
index 0000000..7aa72a7
--- /dev/null
+++ b/nifi-framework-api/src/main/java/org/apache/nifi/authentication/LoginIdentityProviderInitializationContext.java
@@ -0,0 +1,27 @@
+/*
+ * 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.authentication;
+
+/**
+ *
+ */
+public interface LoginIdentityProviderInitializationContext {
+
+ public String getIdentifier();
+
+ public LoginIdentityProviderLookup getAuthorityProviderLookup();
+}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-framework-api/src/main/java/org/apache/nifi/authentication/LoginIdentityProviderLookup.java
----------------------------------------------------------------------
diff --git a/nifi-framework-api/src/main/java/org/apache/nifi/authentication/LoginIdentityProviderLookup.java b/nifi-framework-api/src/main/java/org/apache/nifi/authentication/LoginIdentityProviderLookup.java
new file mode 100644
index 0000000..3cd0ba7
--- /dev/null
+++ b/nifi-framework-api/src/main/java/org/apache/nifi/authentication/LoginIdentityProviderLookup.java
@@ -0,0 +1,25 @@
+/*
+ * 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.authentication;
+
+/**
+ *
+ */
+public interface LoginIdentityProviderLookup {
+
+ LoginIdentityProvider getLoginIdentityProvider(String identifier);
+}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-framework-api/src/main/java/org/apache/nifi/authentication/annotation/LoginIdentityProviderContext.java
----------------------------------------------------------------------
diff --git a/nifi-framework-api/src/main/java/org/apache/nifi/authentication/annotation/LoginIdentityProviderContext.java b/nifi-framework-api/src/main/java/org/apache/nifi/authentication/annotation/LoginIdentityProviderContext.java
new file mode 100644
index 0000000..88df259
--- /dev/null
+++ b/nifi-framework-api/src/main/java/org/apache/nifi/authentication/annotation/LoginIdentityProviderContext.java
@@ -0,0 +1,35 @@
+/*
+ * 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.authentication.annotation;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ *
+ *
+ */
+@Documented
+@Target({ElementType.FIELD, ElementType.METHOD})
+@Retention(RetentionPolicy.RUNTIME)
+@Inherited
+public @interface LoginIdentityProviderContext {
+}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-framework-api/src/main/java/org/apache/nifi/authentication/exception/IdentityAccessException.java
----------------------------------------------------------------------
diff --git a/nifi-framework-api/src/main/java/org/apache/nifi/authentication/exception/IdentityAccessException.java b/nifi-framework-api/src/main/java/org/apache/nifi/authentication/exception/IdentityAccessException.java
new file mode 100644
index 0000000..b68c675
--- /dev/null
+++ b/nifi-framework-api/src/main/java/org/apache/nifi/authentication/exception/IdentityAccessException.java
@@ -0,0 +1,33 @@
+/*
+ * 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.authentication.exception;
+
+/**
+ * Represents the case when the identity could not be confirmed because it was unable
+ * to access the backing store.
+ */
+public class IdentityAccessException extends RuntimeException {
+
+ public IdentityAccessException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public IdentityAccessException(String message) {
+ super(message);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-framework-api/src/main/java/org/apache/nifi/authentication/exception/InvalidLoginCredentialsException.java
----------------------------------------------------------------------
diff --git a/nifi-framework-api/src/main/java/org/apache/nifi/authentication/exception/InvalidLoginCredentialsException.java b/nifi-framework-api/src/main/java/org/apache/nifi/authentication/exception/InvalidLoginCredentialsException.java
new file mode 100644
index 0000000..fbfa324
--- /dev/null
+++ b/nifi-framework-api/src/main/java/org/apache/nifi/authentication/exception/InvalidLoginCredentialsException.java
@@ -0,0 +1,33 @@
+/*
+ * 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.authentication.exception;
+
+/**
+ * Represents the case when the identity could not be confirmed because the
+ * login credentials were invalid.
+ */
+public class InvalidLoginCredentialsException extends RuntimeException {
+
+ public InvalidLoginCredentialsException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public InvalidLoginCredentialsException(String message) {
+ super(message);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-framework-api/src/main/java/org/apache/nifi/authentication/exception/ProviderCreationException.java
----------------------------------------------------------------------
diff --git a/nifi-framework-api/src/main/java/org/apache/nifi/authentication/exception/ProviderCreationException.java b/nifi-framework-api/src/main/java/org/apache/nifi/authentication/exception/ProviderCreationException.java
new file mode 100644
index 0000000..b352787
--- /dev/null
+++ b/nifi-framework-api/src/main/java/org/apache/nifi/authentication/exception/ProviderCreationException.java
@@ -0,0 +1,39 @@
+/*
+ * 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.authentication.exception;
+
+/**
+ * Represents the exceptional case when an AuthorityProvider fails instantiated.
+ *
+ */
+public class ProviderCreationException extends RuntimeException {
+
+ public ProviderCreationException() {
+ }
+
+ public ProviderCreationException(String msg) {
+ super(msg);
+ }
+
+ public ProviderCreationException(Throwable cause) {
+ super(cause);
+ }
+
+ public ProviderCreationException(String msg, Throwable cause) {
+ super(msg, cause);
+ }
+}
[04/10] nifi git commit: NIFI-1896 This closes #650. Refactored
nifi-api into nifi-framework-api and other locations. The nifi-api is
specific to that which is needed for intended extension points.
Posted by jo...@apache.org.
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-framework-api/src/main/java/org/apache/nifi/authorization/resource/Authorizable.java
----------------------------------------------------------------------
diff --git a/nifi-framework-api/src/main/java/org/apache/nifi/authorization/resource/Authorizable.java b/nifi-framework-api/src/main/java/org/apache/nifi/authorization/resource/Authorizable.java
new file mode 100644
index 0000000..7cb21ae
--- /dev/null
+++ b/nifi-framework-api/src/main/java/org/apache/nifi/authorization/resource/Authorizable.java
@@ -0,0 +1,173 @@
+/*
+ * 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.authorization.resource;
+
+import org.apache.nifi.authorization.AccessDeniedException;
+import org.apache.nifi.authorization.AuthorizationRequest;
+import org.apache.nifi.authorization.AuthorizationResult;
+import org.apache.nifi.authorization.AuthorizationResult.Result;
+import org.apache.nifi.authorization.Authorizer;
+import org.apache.nifi.authorization.RequestAction;
+import org.apache.nifi.authorization.Resource;
+import org.apache.nifi.authorization.UserContextKeys;
+import org.apache.nifi.authorization.user.NiFiUser;
+
+import java.util.Map;
+import java.util.HashMap;
+
+public interface Authorizable {
+
+ /**
+ * The parent for this Authorizable. May be null.
+ *
+ * @return the parent authorizable or null
+ */
+ Authorizable getParentAuthorizable();
+
+ /**
+ * The Resource for this Authorizable.
+ *
+ * @return the parent resource
+ */
+ Resource getResource();
+
+ /**
+ * Returns whether the current user is authorized for the specified action on the specified resource. This
+ * method does not imply the user is directly attempting to access the specified resource. If the user is
+ * attempting a direct access use Authorizable.authorize().
+ *
+ * @param authorizer authorizer
+ * @param action action
+ * @return is authorized
+ */
+ default boolean isAuthorized(Authorizer authorizer, RequestAction action, NiFiUser user) {
+ return Result.Approved.equals(checkAuthorization(authorizer, action, user).getResult());
+ }
+
+ /**
+ * Returns the result of an authorization request for the specified user for the specified action on the specified
+ * resource. This method does not imply the user is directly attempting to access the specified resource. If the user is
+ * attempting a direct access use Authorizable.authorize().
+ *
+ * @param authorizer authorizer
+ * @param action action
+ * @param user user
+ * @return is authorized
+ */
+ default AuthorizationResult checkAuthorization(Authorizer authorizer, RequestAction action, NiFiUser user, Map<String, String> resourceContext) {
+ final Map<String,String> userContext;
+ if (user.getClientAddress() != null && !user.getClientAddress().trim().isEmpty()) {
+ userContext = new HashMap<>();
+ userContext.put(UserContextKeys.CLIENT_ADDRESS.name(), user.getClientAddress());
+ } else {
+ userContext = null;
+ }
+
+ // build the request
+ final AuthorizationRequest request = new AuthorizationRequest.Builder()
+ .identity(user.getIdentity())
+ .anonymous(user.isAnonymous())
+ .accessAttempt(false)
+ .action(action)
+ .resource(getResource())
+ .resourceContext(resourceContext)
+ .userContext(userContext)
+ .build();
+
+ // perform the authorization
+ final AuthorizationResult result = authorizer.authorize(request);
+
+ // verify the results
+ if (Result.ResourceNotFound.equals(result.getResult())) {
+ final Authorizable parent = getParentAuthorizable();
+ if (parent == null) {
+ return AuthorizationResult.denied();
+ } else {
+ return parent.checkAuthorization(authorizer, action, user);
+ }
+ } else {
+ return result;
+ }
+ }
+
+ /**
+ * Returns the result of an authorization request for the specified user for the specified action on the specified
+ * resource. This method does not imply the user is directly attempting to access the specified resource. If the user is
+ * attempting a direct access use Authorizable.authorize().
+ *
+ * @param authorizer authorizer
+ * @param action action
+ * @param user user
+ * @return is authorized
+ */
+ default AuthorizationResult checkAuthorization(Authorizer authorizer, RequestAction action, NiFiUser user) {
+ return checkAuthorization(authorizer, action, user, null);
+ }
+
+ /**
+ * Authorizes the current user for the specified action on the specified resource. This method does imply the user is
+ * directly accessing the specified resource.
+ *
+ * @param authorizer authorizer
+ * @param action action
+ * @param user user
+ * @param resourceContext resource context
+ */
+ default void authorize(Authorizer authorizer, RequestAction action, NiFiUser user, Map<String, String> resourceContext) throws AccessDeniedException {
+ final Map<String,String> userContext;
+ if (user.getClientAddress() != null && !user.getClientAddress().trim().isEmpty()) {
+ userContext = new HashMap<>();
+ userContext.put(UserContextKeys.CLIENT_ADDRESS.name(), user.getClientAddress());
+ } else {
+ userContext = null;
+ }
+
+ final AuthorizationRequest request = new AuthorizationRequest.Builder()
+ .identity(user.getIdentity())
+ .anonymous(user.isAnonymous())
+ .accessAttempt(true)
+ .action(action)
+ .resource(getResource())
+ .resourceContext(resourceContext)
+ .userContext(userContext)
+ .build();
+
+ final AuthorizationResult result = authorizer.authorize(request);
+ if (Result.ResourceNotFound.equals(result.getResult())) {
+ final Authorizable parent = getParentAuthorizable();
+ if (parent == null) {
+ throw new AccessDeniedException("Access is denied");
+ } else {
+ parent.authorize(authorizer, action, user);
+ }
+ } else if (Result.Denied.equals(result.getResult())) {
+ throw new AccessDeniedException(result.getExplanation());
+ }
+ }
+
+ /**
+ * Authorizes the current user for the specified action on the specified resource. This method does imply the user is
+ * directly accessing the specified resource.
+ *
+ * @param authorizer authorizer
+ * @param action action
+ * @param user user
+ */
+ default void authorize(Authorizer authorizer, RequestAction action, NiFiUser user) throws AccessDeniedException {
+ authorize(authorizer, action, user, null);
+ }
+}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-framework-api/src/main/java/org/apache/nifi/authorization/user/NiFiUser.java
----------------------------------------------------------------------
diff --git a/nifi-framework-api/src/main/java/org/apache/nifi/authorization/user/NiFiUser.java b/nifi-framework-api/src/main/java/org/apache/nifi/authorization/user/NiFiUser.java
new file mode 100644
index 0000000..c450bc4
--- /dev/null
+++ b/nifi-framework-api/src/main/java/org/apache/nifi/authorization/user/NiFiUser.java
@@ -0,0 +1,45 @@
+/*
+ * 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.authorization.user;
+
+/**
+ * A representation of a NiFi user that has logged into the application
+ */
+public interface NiFiUser {
+
+ /**
+ * @return the unique identity of this user
+ */
+ String getIdentity();
+
+ /**
+ * @return the next user in the proxied entities chain, or <code>null</code> if no more users exist in the chain.
+ */
+ NiFiUser getChain();
+
+ /**
+ * @return <code>true</code> if the user is the unauthenticated Anonymous user
+ */
+ boolean isAnonymous();
+
+ /**
+ * @return the address of the client that made the request which created this user
+ */
+ String getClientAddress();
+
+}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-framework-api/src/main/java/org/apache/nifi/components/state/StateProvider.java
----------------------------------------------------------------------
diff --git a/nifi-framework-api/src/main/java/org/apache/nifi/components/state/StateProvider.java b/nifi-framework-api/src/main/java/org/apache/nifi/components/state/StateProvider.java
new file mode 100644
index 0000000..e1e4352
--- /dev/null
+++ b/nifi-framework-api/src/main/java/org/apache/nifi/components/state/StateProvider.java
@@ -0,0 +1,133 @@
+/*
+ * 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.components.state;
+
+import java.io.IOException;
+import java.util.Map;
+
+import org.apache.nifi.components.ConfigurableComponent;
+
+/**
+ * <p>
+ * Provides a mechanism by which components can store and retrieve state. Depending on the Provider, the state
+ * may be stored locally, or it may be stored on a remote resource.
+ * </p>
+ *
+ * <p>
+ * Which implementation should be used for local and clustered state is configured in the NiFi properties file.
+ * It is therefore possible to provide custom implementations of this interface. Note, however, that this interface
+ * is new as of version 0.5.0 of Apache NiFi and may not be considered "stable" as of yet. Therefore, it is subject
+ * to change without notice, so providing custom implementations is cautioned against until the API becomes more stable.
+ * </p>
+ *
+ * @since 0.5.0
+ */
+public interface StateProvider extends ConfigurableComponent {
+
+ /**
+ * Initializes the StateProvider so that it is capable of being used. This method will be called
+ * once before any of the other methods are called and will not be called again until the {@link #shutdown()}
+ * method has been called
+ *
+ * @param context the initialization context that can be used to prepare the state provider for use
+ */
+ void initialize(StateProviderInitializationContext context) throws IOException;
+
+ /**
+ * Shuts down the StateProvider and cleans up any resources held by it. Once this method has returned, the
+ * StateProvider may be initialized once again via the {@link #initialize(StateProviderInitializationContext)} method.
+ */
+ void shutdown();
+
+ /**
+ * Updates the value of the component's state, setting the new value to the
+ * given state
+ *
+ * @param state the value to change the state to
+ * @param componentId the id of the component for which state is being set
+ *
+ * @throws IOException if unable to communicate with the underlying storage mechanism
+ */
+ void setState(Map<String, String> state, String componentId) throws IOException;
+
+
+ /**
+ * Returns the currently configured state for the component. The returned StateMap will never be null.
+ * The version of the StateMap will be -1 and the state will contain no key/value pairs if the state has never been set.
+ *
+ * @param componentId the id of the component for which state is to be retrieved
+ * @return the currently configured value for the component's state
+ *
+ * @throws IOException if unable to communicate with the underlying storage mechanism
+ */
+ StateMap getState(String componentId) throws IOException;
+
+
+ /**
+ * Updates the value of the component's state to the new value if and only if the value currently
+ * is the same as the given oldValue.
+ *
+ * @param oldValue the old value to compare against
+ * @param newValue the new value to use if and only if the state's value is the same as the given oldValue
+ * @param componentId the id of the component for which state is being retrieved
+ * @return <code>true</code> if the state was updated to the new value, <code>false</code> if the state's value was not
+ * equal to oldValue
+ *
+ * @throws IOException if unable to communicate with the underlying storage mechanism
+ */
+ boolean replace(StateMap oldValue, Map<String, String> newValue, String componentId) throws IOException;
+
+ /**
+ * Removes all values from the component's state that is stored using the given scope
+ *
+ * @param componentId the id of the component for which state is being cleared
+ *
+ * @throws IOException if unable to communicate with the underlying storage mechanism
+ */
+ void clear(String componentId) throws IOException;
+
+ /**
+ * This method is called whenever a component is removed from the NiFi instance. This allows the State Provider to
+ * perform tasks when a component is removed in order to clean up resources that may be associated with that component
+ *
+ * @param componentId the ID of the component that was added to the NiFi instance
+ * @throws IOException if unable to perform the necessary cleanup
+ */
+ void onComponentRemoved(String componentId) throws IOException;
+
+ /**
+ * Notifies the state provider that it should begin servicing requests to store and retrieve state
+ */
+ void enable();
+
+ /**
+ * Notifies the state provider that it should stop servicing requests to store and retrieve state and instead throw a ProviderDisabledException if any request is made to do so
+ */
+ void disable();
+
+ /**
+ * @return <code>true</code> if the provider is enabled, <code>false</code> otherwise.
+ */
+ boolean isEnabled();
+
+ /**
+ * Provides a listing of {@link Scope}s supported by the StateProvider
+ * @return the {@link Scope}s supported by the configuration
+ */
+ Scope[] getSupportedScopes();
+}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-framework-api/src/main/java/org/apache/nifi/components/state/StateProviderInitializationContext.java
----------------------------------------------------------------------
diff --git a/nifi-framework-api/src/main/java/org/apache/nifi/components/state/StateProviderInitializationContext.java b/nifi-framework-api/src/main/java/org/apache/nifi/components/state/StateProviderInitializationContext.java
new file mode 100644
index 0000000..aaf5490
--- /dev/null
+++ b/nifi-framework-api/src/main/java/org/apache/nifi/components/state/StateProviderInitializationContext.java
@@ -0,0 +1,56 @@
+/*
+ * 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.components.state;
+
+import java.util.Map;
+
+import javax.net.ssl.SSLContext;
+
+import org.apache.nifi.components.PropertyDescriptor;
+import org.apache.nifi.components.PropertyValue;
+
+/**
+ * This interface defines an initialization context that is passed to a {@link StateProvider} when it
+ * is initialized.
+ */
+public interface StateProviderInitializationContext {
+ /**
+ * @return the identifier if the StateProvider
+ */
+ String getIdentifier();
+
+ /**
+ * @return a Map of Property Descriptors to their configured values
+ */
+ Map<PropertyDescriptor, PropertyValue> getProperties();
+
+ /**
+ * Returns the configured value for the given property
+ *
+ * @param property the property to retrieve the value for
+ *
+ * @return the configured value for the property.
+ */
+ PropertyValue getProperty(PropertyDescriptor property);
+
+ /**
+ * @return the SSL Context that should be used to communicate with remote resources,
+ * or <code>null</code> if no SSLContext has been configured
+ */
+ SSLContext getSSLContext();
+}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-framework-api/src/main/java/org/apache/nifi/controller/Snippet.java
----------------------------------------------------------------------
diff --git a/nifi-framework-api/src/main/java/org/apache/nifi/controller/Snippet.java b/nifi-framework-api/src/main/java/org/apache/nifi/controller/Snippet.java
new file mode 100644
index 0000000..702b7cd
--- /dev/null
+++ b/nifi-framework-api/src/main/java/org/apache/nifi/controller/Snippet.java
@@ -0,0 +1,83 @@
+/*
+ * 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.controller;
+
+import org.apache.nifi.web.Revision;
+
+import java.util.Map;
+
+/**
+ * A Snippet represents a segment of the flow
+ */
+public interface Snippet {
+
+ /**
+ * @return id of this snippet
+ */
+ public String getId();
+
+ /**
+ * @return parent group id of the components in this snippet
+ */
+ public String getParentGroupId();
+
+ /**
+ * @return connections in this snippet
+ */
+ public Map<String, Revision> getConnections();
+
+ /**
+ * @return funnels in this snippet
+ */
+ public Map<String, Revision> getFunnels();
+
+ /**
+ * @return input ports in this snippet
+ */
+ public Map<String, Revision> getInputPorts();
+
+ /**
+ * @return output ports in this snippet
+ */
+ public Map<String, Revision> getOutputPorts();
+
+ /**
+ * @return labels in this snippet
+ */
+ public Map<String, Revision> getLabels();
+
+ /**
+ * @return the identifiers of all ProcessGroups in this Snippet
+ */
+ public Map<String, Revision> getProcessGroups();
+
+ /**
+ * @return the identifiers of all Processors in this Snippet
+ */
+ public Map<String, Revision> getProcessors();
+
+ /**
+ * @return the identifiers of all RemoteProcessGroups in this Snippet
+ */
+ public Map<String, Revision> getRemoteProcessGroups();
+
+ /**
+ * @return Determines if this snippet is empty
+ */
+ public boolean isEmpty();
+
+}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-framework-api/src/main/java/org/apache/nifi/controller/Triggerable.java
----------------------------------------------------------------------
diff --git a/nifi-framework-api/src/main/java/org/apache/nifi/controller/Triggerable.java b/nifi-framework-api/src/main/java/org/apache/nifi/controller/Triggerable.java
new file mode 100644
index 0000000..4b3149b
--- /dev/null
+++ b/nifi-framework-api/src/main/java/org/apache/nifi/controller/Triggerable.java
@@ -0,0 +1,117 @@
+/*
+ * 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.controller;
+
+import java.util.concurrent.TimeUnit;
+
+import org.apache.nifi.processor.ProcessContext;
+import org.apache.nifi.processor.ProcessSession;
+import org.apache.nifi.processor.ProcessSessionFactory;
+import org.apache.nifi.processor.exception.ProcessException;
+
+public interface Triggerable {
+
+ public static final long MINIMUM_SCHEDULING_NANOS = 30000L;
+
+ /**
+ * <p>
+ * The method called when this processor is triggered to operate by the
+ * controller. This method may be called concurrently from different
+ * threads. When this method is called depends on how this processor is
+ * configured within a controller to be triggered (timing or event
+ * based).</p>
+ *
+ * <p>
+ * The processor may commit, roll back, or allow the framework to
+ * automatically manage the session. If the sessions are to be managed by
+ * the framework (recommended) then what it will do depends on several
+ * factors. If the method call returns due to an exception then the session
+ * will be rolled back. If the method returns normally then the session will
+ * be committed or the framework may use the session again for another
+ * processor down stream</p>
+ *
+ * @param context in which the component is triggered
+ * @param sessionFactory used to generate {@link ProcessSession}s to use for
+ * operating on flow files within the repository
+ *
+ * @throws ProcessException if processing did not complete normally though
+ * indicates the problem is an understood potential outcome of processing.
+ * The controller/caller will handle these exceptions gracefully such as
+ * logging, etc.. If another type of exception is allowed to propagate the
+ * controller may no longer trigger this processor to operate as this would
+ * indicate a probable coding defect.
+ */
+ void onTrigger(ProcessContext context, ProcessSessionFactory sessionFactory) throws ProcessException;
+
+ /**
+ * Determines the number of concurrent tasks that may be running for this
+ * <code>Triggerable</code>.
+ *
+ * @param taskCount a number of concurrent tasks this processor may have
+ * running
+ * @throws IllegalArgumentException if the given value is less than 1
+ */
+ void setMaxConcurrentTasks(int taskCount);
+
+ /**
+ * @return the number of tasks that may execute concurrently for this
+ * <code>Triggerable</code>.
+ */
+ int getMaxConcurrentTasks();
+
+ /**
+ * Indicates the {@link ScheduledState} of this <code>Triggerable</code>. A
+ * value of stopped does NOT indicate that the <code>Triggerable</code> has
+ * no active threads, only that it is not currently scheduled to be given
+ * any more threads. To determine whether or not the
+ * <code>Triggerable</code> has any active threads, see
+ * {@link ProcessScheduler#getActiveThreadCount(nifi.connectable.Connectable)}.
+ *
+ * @return the schedule state
+ */
+ ScheduledState getScheduledState();
+
+ /**
+ * Indicates whether or not this <code>Triggerable</code> is "running". It
+ * is considered "running" if it is scheduled to run OR if it is no longer
+ * scheduled to be given threads but the remaining threads from the last
+ * invocation of {@link #onTrigger(ProcessContext, ProcessSessionFactory)}
+ * have not yet returned
+ *
+ * @return true if running;false otherwise
+ */
+ boolean isRunning();
+
+ /**
+ * @param timeUnit for the scheduling period of the component
+ * @return the amount of time between each scheduling period
+ */
+ long getSchedulingPeriod(TimeUnit timeUnit);
+
+ /**
+ * @return a string representation of the time between each scheduling
+ * period
+ */
+ String getSchedulingPeriod();
+
+ /**
+ * Updates how often this Triggerable should be triggered to run
+ *
+ * @param schedulingPeriod to set
+ */
+ void setScheduldingPeriod(String schedulingPeriod);
+}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-framework-api/src/main/java/org/apache/nifi/controller/queue/DropFlowFileState.java
----------------------------------------------------------------------
diff --git a/nifi-framework-api/src/main/java/org/apache/nifi/controller/queue/DropFlowFileState.java b/nifi-framework-api/src/main/java/org/apache/nifi/controller/queue/DropFlowFileState.java
new file mode 100644
index 0000000..0f258b0
--- /dev/null
+++ b/nifi-framework-api/src/main/java/org/apache/nifi/controller/queue/DropFlowFileState.java
@@ -0,0 +1,57 @@
+/*
+ * 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.controller.queue;
+
+/**
+ * Represents the state that a Drop FlowFile request is in
+ */
+public enum DropFlowFileState {
+
+ WAITING_FOR_LOCK("Waiting for destination component to complete its action"),
+ DROPPING_FLOWFILES("Dropping FlowFiles from queue"),
+ FAILURE("Failed"),
+ CANCELED("Canceled by user"),
+ COMPLETE("Completed successfully");
+
+ private final String description;
+
+ private DropFlowFileState(final String description) {
+ this.description = description;
+ }
+
+ @Override
+ public String toString() {
+ return description;
+ }
+
+ /**
+ * @param description string form of drop flow file state
+ * @return the matching DropFlowFileState or null if the description doesn't match
+ */
+ public static DropFlowFileState valueOfDescription(String description) {
+ DropFlowFileState desiredState = null;
+
+ for (DropFlowFileState state : values()) {
+ if (state.toString().equals(description)) {
+ desiredState = state;
+ break;
+ }
+ }
+
+ return desiredState;
+ }
+}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-framework-api/src/main/java/org/apache/nifi/controller/queue/DropFlowFileStatus.java
----------------------------------------------------------------------
diff --git a/nifi-framework-api/src/main/java/org/apache/nifi/controller/queue/DropFlowFileStatus.java b/nifi-framework-api/src/main/java/org/apache/nifi/controller/queue/DropFlowFileStatus.java
new file mode 100644
index 0000000..737fbe3
--- /dev/null
+++ b/nifi-framework-api/src/main/java/org/apache/nifi/controller/queue/DropFlowFileStatus.java
@@ -0,0 +1,78 @@
+/*
+ * 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.controller.queue;
+
+/**
+ * Represents the status of a Drop FlowFile Request that has been issued to
+ * a {@link FlowFileQueue}. When a queue is requested to drop its FlowFiles,
+ * that process may be rather lengthy in the case of a poorly behaving
+ * FlowFileRepository or if the destination Processor is polling from the
+ * queue using a filter that is misbehaving. As a result, the dropping of
+ * FlowFiles is performed asynchronously.
+ *
+ * This status object provides information about how far along in the process
+ * we currently are and information about the success or failure of the
+ * operation.
+ */
+public interface DropFlowFileStatus {
+
+ /**
+ * @return the identifier of the request to drop FlowFiles from the queue
+ */
+ String getRequestIdentifier();
+
+ /**
+ * @return the date/time (in milliseconds since epoch) at which the request to
+ * drop the FlowFiles from a queue was submitted
+ */
+ long getRequestSubmissionTime();
+
+ /**
+ * @return the date/time (in milliseconds since epoch) at which the status of the
+ * request was last updated
+ */
+ long getLastUpdated();
+
+ /**
+ * @return the size of the queue when the drop request was issued or <code>null</code> if
+ * it is not yet known, which can happen if the {@link DropFlowFileState} is
+ * {@link DropFlowFileState#WAITING_FOR_LOCK}.
+ */
+ QueueSize getOriginalSize();
+
+ /**
+ * @return the current size of the queue or <code>null</code> if it is not yet known
+ */
+ QueueSize getCurrentSize();
+
+ /**
+ * @return a QueueSize representing the number of FlowFiles that have been dropped for this request
+ * and the aggregate size of those FlowFiles
+ */
+ QueueSize getDroppedSize();
+
+ /**
+ * @return the current state of the operation
+ */
+ DropFlowFileState getState();
+
+ /**
+ * @return the reason that the state is set to a Failure state, or <code>null</code> if the state is not {@link DropFlowFileState#FAILURE}.
+ */
+ String getFailureReason();
+}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-framework-api/src/main/java/org/apache/nifi/controller/queue/FlowFileQueue.java
----------------------------------------------------------------------
diff --git a/nifi-framework-api/src/main/java/org/apache/nifi/controller/queue/FlowFileQueue.java b/nifi-framework-api/src/main/java/org/apache/nifi/controller/queue/FlowFileQueue.java
new file mode 100644
index 0000000..7948ecb
--- /dev/null
+++ b/nifi-framework-api/src/main/java/org/apache/nifi/controller/queue/FlowFileQueue.java
@@ -0,0 +1,275 @@
+/*
+ * 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.controller.queue;
+
+import java.io.IOException;
+import java.util.Collection;
+import java.util.List;
+import java.util.Queue;
+import java.util.Set;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.nifi.controller.repository.FlowFileRecord;
+import org.apache.nifi.controller.repository.SwapSummary;
+import org.apache.nifi.flowfile.FlowFilePrioritizer;
+import org.apache.nifi.processor.FlowFileFilter;
+
+public interface FlowFileQueue {
+
+ /**
+ * @return the unique identifier for this FlowFileQueue
+ */
+ String getIdentifier();
+
+ /**
+ * @return list of processing priorities for this queue
+ */
+ List<FlowFilePrioritizer> getPriorities();
+
+ /**
+ * Reads any Swap Files that belong to this queue and returns a summary of what is swapped out.
+ * This will be called only during NiFi startup as an initialization step. This
+ * method is then responsible for returning a FlowFileSummary of the FlowFiles that are swapped
+ * out, or <code>null</code> if no FlowFiles are swapped out for this queue.
+ *
+ * @return a SwapSummary that describes the FlowFiles that exist in the queue but are swapped out.
+ */
+ SwapSummary recoverSwappedFlowFiles();
+
+ /**
+ * Destroys any Swap Files that exist for this queue without updating the FlowFile Repository
+ * or Provenance Repository. This is done only on startup in the case of non-persistent
+ * repositories. In the case of non-persistent repositories, we may still have Swap Files because
+ * we may still need to overflow the FlowFiles from heap onto disk, even though we don't want to keep
+ * the FlowFiles on restart.
+ */
+ void purgeSwapFiles();
+
+ /**
+ * Resets the comparator used by this queue to maintain order.
+ *
+ * @param newPriorities the ordered list of prioritizers to use to determine
+ * order within this queue.
+ * @throws NullPointerException if arg is null
+ */
+ void setPriorities(List<FlowFilePrioritizer> newPriorities);
+
+ /**
+ * Establishes this queue's preferred maximum work load.
+ *
+ * @param maxQueueSize the maximum number of flow files this processor
+ * recommends having in its work queue at any one time
+ */
+ void setBackPressureObjectThreshold(long maxQueueSize);
+
+ /**
+ * @return maximum number of flow files that should be queued up at any one
+ * time
+ */
+ long getBackPressureObjectThreshold();
+
+ /**
+ * @param maxDataSize Establishes this queue's preferred maximum data size.
+ */
+ void setBackPressureDataSizeThreshold(String maxDataSize);
+
+ /**
+ * @return maximum data size that should be queued up at any one time
+ */
+ String getBackPressureDataSizeThreshold();
+
+ QueueSize size();
+
+ /**
+ * @return true if no items queue; false otherwise
+ */
+ boolean isEmpty();
+
+ /**
+ * @return <code>true</code> if the queue is empty or contains only FlowFiles that already are being processed
+ * by others, <code>false</code> if the queue contains at least one FlowFile that is available for processing,
+ * regardless of whether that FlowFile(s) is in-memory or swapped out.
+ */
+ boolean isActiveQueueEmpty();
+
+ /**
+ * Returns a QueueSize that represents all FlowFiles that are 'unacknowledged'. A FlowFile
+ * is considered to be unacknowledged if it has been pulled from the queue by some component
+ * but the session that pulled the FlowFile has not yet been committed or rolled back.
+ *
+ * @return a QueueSize that represents all FlowFiles that are 'unacknowledged'.
+ */
+ QueueSize getUnacknowledgedQueueSize();
+
+ void acknowledge(FlowFileRecord flowFile);
+
+ void acknowledge(Collection<FlowFileRecord> flowFiles);
+
+ /**
+ * @return true if maximum queue size has been reached or exceeded; false
+ * otherwise
+ */
+ boolean isFull();
+
+ /**
+ * places the given file into the queue
+ *
+ * @param file to place into queue
+ */
+ void put(FlowFileRecord file);
+
+ /**
+ * places the given files into the queue
+ *
+ * @param files to place into queue
+ */
+ void putAll(Collection<FlowFileRecord> files);
+
+ /**
+ * @param expiredRecords expired records
+ * @return the next flow file on the queue; null if empty
+ */
+ FlowFileRecord poll(Set<FlowFileRecord> expiredRecords);
+
+ /**
+ * @param maxResults limits how many results can be polled
+ * @param expiredRecords for expired records
+ * @return the next flow files on the queue up to the max results; null if
+ * empty
+ */
+ List<FlowFileRecord> poll(int maxResults, Set<FlowFileRecord> expiredRecords);
+
+ /**
+ * Drains flow files from the given source queue into the given destination
+ * list.
+ *
+ * @param sourceQueue queue to drain from
+ * @param destination Collection to drain to
+ * @param maxResults max number to drain
+ * @param expiredRecords for expired records
+ * @return size (bytes) of flow files drained from queue
+ */
+ long drainQueue(Queue<FlowFileRecord> sourceQueue, List<FlowFileRecord> destination, int maxResults, Set<FlowFileRecord> expiredRecords);
+
+ List<FlowFileRecord> poll(FlowFileFilter filter, Set<FlowFileRecord> expiredRecords);
+
+ String getFlowFileExpiration();
+
+ int getFlowFileExpiration(TimeUnit timeUnit);
+
+ void setFlowFileExpiration(String flowExpirationPeriod);
+
+ /**
+ * Initiates a request to drop all FlowFiles in this queue. This method returns
+ * a DropFlowFileStatus that can be used to determine the current state of the request.
+ * Additionally, the DropFlowFileStatus provides a request identifier that can then be
+ * passed to the {@link #getDropFlowFileStatus(String)} and {@link #cancelDropFlowFileStatus(String)}
+ * methods in order to obtain the status later or cancel a request
+ *
+ * @param requestIdentifier the identifier of the Drop FlowFile Request
+ * @param requestor the entity that is requesting that the FlowFiles be dropped; this will be
+ * included in the Provenance Events that are generated.
+ *
+ * @return the status of the drop request.
+ */
+ DropFlowFileStatus dropFlowFiles(String requestIdentifier, String requestor);
+
+ /**
+ * Returns the current status of a Drop FlowFile Request that was initiated via the
+ * {@link #dropFlowFiles()} method that has the given identifier
+ *
+ * @param requestIdentifier the identifier of the Drop FlowFile Request
+ * @return the status for the request with the given identifier, or <code>null</code> if no
+ * request status exists with that identifier
+ */
+ DropFlowFileStatus getDropFlowFileStatus(String requestIdentifier);
+
+ /**
+ * Cancels the request to drop FlowFiles that has the given identifier. After this method is called, the request
+ * will no longer be known by this queue, so subsequent calls to {@link #getDropFlowFileStatus(String)} or
+ * {@link #cancelDropFlowFileRequest(String)} will return <code>null</code>
+ *
+ * @param requestIdentifier the identifier of the Drop FlowFile Request
+ * @return the status for the request with the given identifier after it has been canceled, or <code>null</code> if no
+ * request status exists with that identifier
+ */
+ DropFlowFileStatus cancelDropFlowFileRequest(String requestIdentifier);
+
+ /**
+ * <p>
+ * Initiates a request to obtain a listing of FlowFiles in this queue. This method returns a
+ * ListFlowFileStatus that can be used to obtain information about the FlowFiles that exist
+ * within the queue. Additionally, the ListFlowFileStatus provides a request identifier that
+ * can then be passed to the {@link #getListFlowFileStatus(String)}. The listing of FlowFiles
+ * will be returned ordered by the position of the FlowFile in the queue.
+ * </p>
+ *
+ * <p>
+ * Note that if maxResults is larger than the size of the "active queue" (i.e., the un-swapped queued,
+ * FlowFiles that are swapped out will not be returned.)
+ * </p>
+ *
+ * @param requestIdentifier the identifier of the List FlowFile Request
+ * @param maxResults the maximum number of FlowFileSummary objects to add to the ListFlowFileStatus
+ *
+ * @return the status for the request
+ *
+ * @throws IllegalStateException if either the source or the destination of the connection to which this queue belongs
+ * is currently running.
+ */
+ ListFlowFileStatus listFlowFiles(String requestIdentifier, int maxResults);
+
+ /**
+ * Returns the current status of a List FlowFile Request that was initiated via the {@link #listFlowFiles(String)}
+ * method that has the given identifier
+ *
+ * @param requestIdentifier the identifier of the Drop FlowFile Request
+ * @return the current status of the List FlowFile Request with the given identifier or <code>null</code> if no
+ * request status exists with that identifier
+ */
+ ListFlowFileStatus getListFlowFileStatus(String requestIdentifier);
+
+ /**
+ * Cancels the request to list FlowFiles that has the given identifier. After this method is called, the request
+ * will no longer be known by this queue, so subsequent calls to {@link #getListFlowFileStatus(String)} or
+ * {@link #cancelListFlowFileRequest(String)} will return <code>null</code>
+ *
+ * @param requestIdentifier the identifier of the Drop FlowFile Request
+ * @return the current status of the List FlowFile Request with the given identifier or <code>null</code> if no
+ * request status exists with that identifier
+ */
+ ListFlowFileStatus cancelListFlowFileRequest(String requestIdentifier);
+
+ /**
+ * Returns the FlowFile with the given UUID or <code>null</code> if no FlowFile can be found in this queue
+ * with the given UUID
+ *
+ * @param flowFileUuid the UUID of the FlowFile to retrieve
+ * @return the FlowFile with the given UUID or <code>null</code> if no FlowFile can be found in this queue
+ * with the given UUID
+ *
+ * @throws IOException if unable to read FlowFiles that are stored on some external device
+ */
+ FlowFileRecord getFlowFile(String flowFileUuid) throws IOException;
+
+ /**
+ * Ensures that a listing can be performed on the queue
+ *
+ * @throws IllegalStateException if the queue is not in a state in which a listing can be performed
+ */
+ void verifyCanList() throws IllegalStateException;
+}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-framework-api/src/main/java/org/apache/nifi/controller/queue/FlowFileSummary.java
----------------------------------------------------------------------
diff --git a/nifi-framework-api/src/main/java/org/apache/nifi/controller/queue/FlowFileSummary.java b/nifi-framework-api/src/main/java/org/apache/nifi/controller/queue/FlowFileSummary.java
new file mode 100644
index 0000000..b7207f2
--- /dev/null
+++ b/nifi-framework-api/src/main/java/org/apache/nifi/controller/queue/FlowFileSummary.java
@@ -0,0 +1,59 @@
+/*
+ * 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.controller.queue;
+
+/**
+ * A summary of a FlowFile that can be used to represent a "high level" view of FlowFile
+ * without providing all of the information available.
+ */
+public interface FlowFileSummary {
+ /**
+ * @return the UUID of the FlowFile
+ */
+ String getUuid();
+
+ /**
+ * @return the value of the 'filename' attribute
+ */
+ String getFilename();
+
+ /**
+ * @return the current position of the FlowFile in the queue based on the prioritizers selected
+ */
+ int getPosition();
+
+ /**
+ * @return the size of the FlowFile in bytes
+ */
+ long getSize();
+
+ /**
+ * @return the timestamp (in milliseconds since epoch) at which the FlowFile was added to the queue
+ */
+ long getLastQueuedTime();
+
+ /**
+ * @return the timestamp (in milliseconds since epoch) at which the FlowFile's greatest ancestor entered the flow
+ */
+ long getLineageStartDate();
+
+ /**
+ * @return <code>true</code> if the FlowFile is penalized, <code>false</code> otherwise
+ */
+ boolean isPenalized();
+}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-framework-api/src/main/java/org/apache/nifi/controller/queue/ListFlowFileState.java
----------------------------------------------------------------------
diff --git a/nifi-framework-api/src/main/java/org/apache/nifi/controller/queue/ListFlowFileState.java b/nifi-framework-api/src/main/java/org/apache/nifi/controller/queue/ListFlowFileState.java
new file mode 100644
index 0000000..eb417aa
--- /dev/null
+++ b/nifi-framework-api/src/main/java/org/apache/nifi/controller/queue/ListFlowFileState.java
@@ -0,0 +1,57 @@
+/*
+ * 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.controller.queue;
+
+/**
+ * Represents the state that a List FlowFile Request is in
+ */
+public enum ListFlowFileState {
+ WAITING_FOR_LOCK("Waiting for other queue requests to complete"),
+ CALCULATING_LIST("Calculating list of FlowFiles"),
+ FAILURE("Failed"),
+ CANCELED("Canceled by user"),
+ COMPLETE("Completed successfully");
+
+ private final String description;
+
+ private ListFlowFileState(final String description) {
+ this.description = description;
+ }
+
+ @Override
+ public String toString() {
+ return description;
+ }
+
+ /**
+ * @param description string form of list flow file state
+ * @return the matching ListFlowFileState or <code>null</code> if the description doesn't match
+ */
+ public static ListFlowFileState valueOfDescription(String description) {
+ ListFlowFileState desiredState = null;
+
+ for (ListFlowFileState state : values()) {
+ if (state.toString().equals(description)) {
+ desiredState = state;
+ break;
+ }
+ }
+
+ return desiredState;
+ }
+}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-framework-api/src/main/java/org/apache/nifi/controller/queue/ListFlowFileStatus.java
----------------------------------------------------------------------
diff --git a/nifi-framework-api/src/main/java/org/apache/nifi/controller/queue/ListFlowFileStatus.java b/nifi-framework-api/src/main/java/org/apache/nifi/controller/queue/ListFlowFileStatus.java
new file mode 100644
index 0000000..e3cc337
--- /dev/null
+++ b/nifi-framework-api/src/main/java/org/apache/nifi/controller/queue/ListFlowFileStatus.java
@@ -0,0 +1,70 @@
+/*
+ * 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.controller.queue;
+
+import java.util.List;
+
+public interface ListFlowFileStatus {
+
+ /**
+ * @return the maximum number of FlowFile Summary objects that should be returned
+ */
+ int getMaxResults();
+
+ /**
+ * @return the identifier of the request to drop FlowFiles from the queue
+ */
+ String getRequestIdentifier();
+
+ /**
+ * @return the date/time (in milliseconds since epoch) at which the request to
+ * drop the FlowFiles from a queue was submitted
+ */
+ long getRequestSubmissionTime();
+
+ /**
+ * @return the date/time (in milliseconds since epoch) at which the status of the
+ * request was last updated
+ */
+ long getLastUpdated();
+
+ /**
+ * @return the current state of the operation
+ */
+ ListFlowFileState getState();
+
+ /**
+ * @return the reason that the state is set to a Failure state, or <code>null</code> if the state is not {@link ListFlowFileStatus#FAILURE}.
+ */
+ String getFailureReason();
+
+ /**
+ * @return the current size of the queue
+ */
+ QueueSize getQueueSize();
+
+ /**
+ * @return a List of FlowFileSummary objects
+ */
+ List<FlowFileSummary> getFlowFileSummaries();
+
+ /**
+ * @return the percentage (an integer between 0 and 100, inclusive) of how close the request is to being completed
+ */
+ int getCompletionPercentage();
+}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-framework-api/src/main/java/org/apache/nifi/controller/queue/SortColumn.java
----------------------------------------------------------------------
diff --git a/nifi-framework-api/src/main/java/org/apache/nifi/controller/queue/SortColumn.java b/nifi-framework-api/src/main/java/org/apache/nifi/controller/queue/SortColumn.java
new file mode 100644
index 0000000..30d285c
--- /dev/null
+++ b/nifi-framework-api/src/main/java/org/apache/nifi/controller/queue/SortColumn.java
@@ -0,0 +1,108 @@
+/*
+ * 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.controller.queue;
+
+import java.util.Comparator;
+
+/**
+ * Specifies which column to sort on when performing a Listing of FlowFiles via
+ * {@link FlowFileQueue#listFlowFiles(String, SortColumn, SortDirection)}
+ */
+public enum SortColumn implements Comparator<FlowFileSummary> {
+ /**
+ * Sort based on the current position in the queue
+ */
+ QUEUE_POSITION (new Comparator<FlowFileSummary>() {
+ @Override
+ public int compare(final FlowFileSummary o1, final FlowFileSummary o2) {
+ return Integer.compare(o1.getPosition(), o2.getPosition());
+ }
+ }),
+
+ /**
+ * Sort based on the UUID of the FlowFile
+ */
+ FLOWFILE_UUID (new Comparator<FlowFileSummary>() {
+ @Override
+ public int compare(final FlowFileSummary o1, final FlowFileSummary o2) {
+ return o1.getUuid().compareTo(o2.getUuid());
+ }
+ }),
+
+ /**
+ * Sort based on the 'filename' attribute of the FlowFile
+ */
+ FILENAME (new Comparator<FlowFileSummary>() {
+ @Override
+ public int compare(final FlowFileSummary o1, final FlowFileSummary o2) {
+ return o1.getFilename().compareTo(o2.getFilename());
+ }
+ }),
+
+ /**
+ * Sort based on the size of the FlowFile
+ */
+ FLOWFILE_SIZE(new Comparator<FlowFileSummary>() {
+ @Override
+ public int compare(final FlowFileSummary o1, final FlowFileSummary o2) {
+ return Long.compare(o1.getSize(), o2.getSize());
+ }
+ }),
+
+ /**
+ * Sort based on how long the FlowFile has been sitting in the queue
+ */
+ QUEUED_DURATION (new Comparator<FlowFileSummary>() {
+ @Override
+ public int compare(final FlowFileSummary o1, final FlowFileSummary o2) {
+ return -Long.compare(o1.getLastQueuedTime(), o2.getLastQueuedTime());
+ }
+ }),
+
+ /**
+ * Sort based on the age of the FlowFile. I.e., the time at which the FlowFile's
+ * "greatest ancestor" entered the flow
+ */
+ FLOWFILE_AGE (new Comparator<FlowFileSummary>() {
+ @Override
+ public int compare(final FlowFileSummary o1, final FlowFileSummary o2) {
+ return Long.compare(o1.getLineageStartDate(), o2.getLineageStartDate());
+ }
+ }),
+
+ /**
+ * Sort based on when the FlowFile's penalization ends
+ */
+ PENALIZATION (new Comparator<FlowFileSummary>() {
+ @Override
+ public int compare(final FlowFileSummary o1, final FlowFileSummary o2) {
+ return Boolean.compare(o1.isPenalized(), o2.isPenalized());
+ }
+ });
+
+ private final Comparator<FlowFileSummary> comparator;
+
+ private SortColumn(final Comparator<FlowFileSummary> comparator) {
+ this.comparator = comparator;
+ }
+
+ @Override
+ public int compare(final FlowFileSummary o1, final FlowFileSummary o2) {
+ return comparator.compare(o1, o2);
+ }
+}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-framework-api/src/main/java/org/apache/nifi/controller/queue/SortDirection.java
----------------------------------------------------------------------
diff --git a/nifi-framework-api/src/main/java/org/apache/nifi/controller/queue/SortDirection.java b/nifi-framework-api/src/main/java/org/apache/nifi/controller/queue/SortDirection.java
new file mode 100644
index 0000000..129e748
--- /dev/null
+++ b/nifi-framework-api/src/main/java/org/apache/nifi/controller/queue/SortDirection.java
@@ -0,0 +1,37 @@
+/*
+ * 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.controller.queue;
+
+/**
+ * Specifies the order in which FlowFiles should be sorted when performing a listing of
+ * FlowFiles via the {@link FlowFileQueue#listFlowFiles(String, SortColumn, SortDirection)}
+ * method
+ */
+public enum SortDirection {
+ /**
+ * FlowFiles should be sorted such that the FlowFile with the lowest value for the Sort Column
+ * should occur first in the listing.
+ */
+ ASCENDING,
+
+ /**
+ * FlowFiles should be sorted such that the FlowFile with the largest value for the Sort Column
+ * should occur first in the listing.
+ */
+ DESCENDING;
+}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-framework-api/src/main/java/org/apache/nifi/controller/repository/ContentRepository.java
----------------------------------------------------------------------
diff --git a/nifi-framework-api/src/main/java/org/apache/nifi/controller/repository/ContentRepository.java b/nifi-framework-api/src/main/java/org/apache/nifi/controller/repository/ContentRepository.java
new file mode 100644
index 0000000..b1ea87c
--- /dev/null
+++ b/nifi-framework-api/src/main/java/org/apache/nifi/controller/repository/ContentRepository.java
@@ -0,0 +1,277 @@
+/*
+ * 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.controller.repository;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.nio.file.Path;
+import java.util.Collection;
+import java.util.Set;
+
+import org.apache.nifi.controller.repository.claim.ContentClaim;
+import org.apache.nifi.controller.repository.claim.ResourceClaimManager;
+
+/**
+ * Defines the capabilities of a content repository. Append options are not
+ * available on the methods but a merge capability is provided which between
+ * that and creating new claims a merge is available.
+ *
+ */
+public interface ContentRepository {
+
+ /**
+ * Initializes the Content Repository, providing to it the
+ * ContentClaimManager that is to be used for interacting with Content
+ * Claims
+ *
+ * @param claimManager to handle claims
+ * @throws java.io.IOException if unable to init
+ */
+ void initialize(ResourceClaimManager claimManager) throws IOException;
+
+ /**
+ * Shuts down the Content Repository, freeing any resources that may be
+ * held. This is called when an administrator shuts down NiFi.
+ */
+ void shutdown();
+
+ /**
+ * @return the names of all Containers that exist for this Content
+ * Repository
+ */
+ Set<String> getContainerNames();
+
+ /**
+ * @param containerName name of container to check capacity on
+ * @return the maximum number of bytes that can be stored in the storage
+ * mechanism that backs the container with the given name
+ * @throws java.io.IOException if unable to check capacity
+ * @throws IllegalArgumentException if no container exists with the given
+ * name
+ */
+ long getContainerCapacity(String containerName) throws IOException;
+
+ /**
+ * @param containerName to check space on
+ * @return the number of bytes available to be used used by the storage
+ * mechanism that backs the container with the given name
+ * @throws java.io.IOException if unable to check space
+ * @throws IllegalArgumentException if no container exists with the given
+ * name
+ */
+ long getContainerUsableSpace(String containerName) throws IOException;
+
+ /**
+ * Creates a new content claim
+ *
+ * @param lossTolerant indicates whether the content for the new claim is
+ * loss tolerant. If true the repository might choose more volatile storage
+ * options which could increase performance for a tradeoff with reliability
+ * @return newly created claim
+ * @throws java.io.IOException if unable to create claim
+ */
+ ContentClaim create(boolean lossTolerant) throws IOException;
+
+ /**
+ * Increments the number of claimants for the given claim
+ *
+ * @param claim to increment
+ * @return the number of claimants after incrementing
+ */
+ int incrementClaimaintCount(ContentClaim claim);
+
+ /**
+ * Obtains the current number of claimants for the given claim
+ *
+ * @param claim to get count of
+ * @return the number of claimants
+ */
+ int getClaimantCount(ContentClaim claim);
+
+ /**
+ * Reduces the number of claimants for the given claim. Even if the given
+ * claim is null or content cannot be found or removed no exception will be
+ * thrown.
+ *
+ * @param claim to decrement
+ * @return new claimant count for the given claim
+ */
+ int decrementClaimantCount(ContentClaim claim);
+
+ /**
+ * Removes the content indicated by the given claim
+ *
+ * @param claim to remove
+ *
+ * @return a boolean indicating whether or not the destruction of the claim
+ * was successful
+ */
+ boolean remove(ContentClaim claim);
+
+ /**
+ * Clones the content for the given content claim and returns content claim
+ * of the new object
+ *
+ * @param original to clone
+ * @param lossTolerant if can be place in a loss tolerant repository
+ * @return new claim
+ * @throws IOException if an IO error occurs. Any content written to the new
+ * destination prior to the error will be destroyed
+ */
+ ContentClaim clone(ContentClaim original, boolean lossTolerant) throws IOException;
+
+ /**
+ * Creates a new content item that is the merger in iteration order of all
+ * content for the given claims
+ *
+ * @return the size of the destination
+ * @param claims the claims to merge which will be combined in order of
+ * collection iteration
+ * @param destination the claim to write the merged content to
+ * @param header if supplied will be prepended to the output
+ * @param footer if supplied will be appended to the output
+ * @param demarcator if supplied will be placed in between each merged
+ * object
+ * @throws IOException if unable to merge
+ * @throws IllegalArgumentException if the given destination is included in
+ * the given claims
+ */
+ long merge(Collection<ContentClaim> claims, ContentClaim destination, byte[] header, byte[] footer, byte[] demarcator) throws IOException;
+
+ /**
+ * Imports content from the given path creating a new content object and
+ * claim within the repository.
+ *
+ * @return the size of the claim
+ * @param content to import from
+ * @param claim the claim to write imported content to
+ * @throws IOException if failure to read given content
+ */
+ long importFrom(Path content, ContentClaim claim) throws IOException;
+
+ /**
+ * Imports content from the given stream creating a new content object and
+ * claim within the repository.
+ *
+ * @return the size of the claim
+ * @param content to import from
+ * @param claim the claim to write imported content to
+ * @throws IOException if unable to read content
+ */
+ long importFrom(InputStream content, ContentClaim claim) throws IOException;
+
+ /**
+ * Exports the content of the given claim to the given destination.
+ *
+ * @return the size of the destination or the claim
+ * @param claim to export from
+ * @param destination where to export data
+ * @param append if true appends to the destination; false overwrites
+ * @throws IOException if an IO error occurs. The state of the content for
+ * the given destination is unknown and callers should consider whether they
+ * should clean up any partially created paths
+ */
+ long exportTo(ContentClaim claim, Path destination, boolean append) throws IOException;
+
+ /**
+ * Exports the content of the given claim to the given destination.
+ *
+ * @return the size of the destination or the claim
+ * @param claim to export from
+ * @param destination where to export data
+ * @param append if true appends to the destination; false overwrites
+ * @param offset the offset at which the claim should start being copied
+ * @param length the number of bytes to copy
+ * @throws IOException if an IO error occurs. The state of the content for
+ * the given destination is unknown and callers should consider whether they
+ * should clean up any partially created paths
+ */
+ long exportTo(ContentClaim claim, Path destination, boolean append, long offset, long length) throws IOException;
+
+ /**
+ * Exports the content of the given claim to the given destination.
+ *
+ * @return the size of the claim
+ * @param claim to export from
+ * @param destination where to export data
+ * @throws IOException if an IO error occurs.
+ */
+ long exportTo(ContentClaim claim, OutputStream destination) throws IOException;
+
+ /**
+ * Exports a subset of the content of the given claim, starting at offset
+ * and copying length bytes, to the given destination.
+ *
+ * @return the number of bytes copied
+ * @param claim to export from
+ * @param destination where to export data
+ * @param offset the offset into the claim at which the copy should begin
+ * @param length the number of bytes to copy
+ * @throws IOException if an IO error occurs.
+ */
+ long exportTo(ContentClaim claim, OutputStream destination, long offset, long length) throws IOException;
+
+ /**
+ * @param claim to get size of
+ * @return size in bytes of content for given claim
+ * @throws IOException if size check failed
+ */
+ long size(ContentClaim claim) throws IOException;
+
+ /**
+ * Provides access to the input stream for the given claim
+ *
+ * @param claim to read from
+ * @return InputStream over the content of the given claim
+ * @throws IOException if unable to read
+ */
+ InputStream read(ContentClaim claim) throws IOException;
+
+ /**
+ * Obtains an OutputStream to the content for the given claim.
+ *
+ * @param claim to write to
+ * @return the stream to write to
+ * @throws IOException if unable to obtain stream
+ */
+ OutputStream write(ContentClaim claim) throws IOException;
+
+ /**
+ * Purges the contents of the repository, as if the repository were newly
+ * created.
+ */
+ void purge();
+
+ /**
+ * Performs any cleanup actions that may need to be taken upon system
+ * restart. For example, if content was partially written to the repository
+ * before the restart, the repository is given a chance to handle this data
+ */
+ void cleanup();
+
+ /**
+ * @param contentClaim the Content Claim to check
+ * @return Returns a boolean indicating whether or not the content specified
+ * by the given claim can be read, regardless of whether the content has
+ * been archived or not. If the ContentRepository does not implement
+ * archiving capabilities, this method will return <code>false</code>
+ *
+ * @throws IOException if unable to determine accessibility
+ */
+ boolean isAccessible(ContentClaim contentClaim) throws IOException;
+}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-framework-api/src/main/java/org/apache/nifi/controller/repository/FlowFileRecord.java
----------------------------------------------------------------------
diff --git a/nifi-framework-api/src/main/java/org/apache/nifi/controller/repository/FlowFileRecord.java b/nifi-framework-api/src/main/java/org/apache/nifi/controller/repository/FlowFileRecord.java
new file mode 100644
index 0000000..b358cd9
--- /dev/null
+++ b/nifi-framework-api/src/main/java/org/apache/nifi/controller/repository/FlowFileRecord.java
@@ -0,0 +1,48 @@
+/*
+ * 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.controller.repository;
+
+import org.apache.nifi.controller.repository.claim.ContentClaim;
+import org.apache.nifi.flowfile.FlowFile;
+
+/**
+ * <code>FlowFileRecord</code> is a sub-interface of <code>FlowFile</code> and
+ * is used to provide additional information about FlowFiles that provide
+ * valuable information to the framework but should be hidden from components
+ */
+public interface FlowFileRecord extends FlowFile {
+
+ /**
+ * @return the time (in millis since epoch) at which this FlowFile should no
+ * longer be penalized
+ */
+ long getPenaltyExpirationMillis();
+
+ /**
+ * @return the {@link ContentClaim} that holds the FlowFile's content
+ */
+ ContentClaim getContentClaim();
+
+ /**
+ * @return the byte offset into the {@link ContentClaim} at which the
+ * FlowFile's content occurs. This mechanism allows multiple FlowFiles to
+ * have the same ContentClaim, which can be significantly more efficient for
+ * some implementations of
+ * {@link org.apache.nifi.controller.repository.ContentRepository ContentRepository}
+ */
+ long getContentClaimOffset();
+}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-framework-api/src/main/java/org/apache/nifi/controller/repository/FlowFileRepository.java
----------------------------------------------------------------------
diff --git a/nifi-framework-api/src/main/java/org/apache/nifi/controller/repository/FlowFileRepository.java b/nifi-framework-api/src/main/java/org/apache/nifi/controller/repository/FlowFileRepository.java
new file mode 100644
index 0000000..906cbe2
--- /dev/null
+++ b/nifi-framework-api/src/main/java/org/apache/nifi/controller/repository/FlowFileRepository.java
@@ -0,0 +1,123 @@
+/*
+ * 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.controller.repository;
+
+import java.io.Closeable;
+import java.io.IOException;
+import java.util.Collection;
+import java.util.List;
+
+import org.apache.nifi.controller.queue.FlowFileQueue;
+import org.apache.nifi.controller.repository.claim.ResourceClaimManager;
+
+/**
+ * Implementations must be thread safe
+ *
+ */
+public interface FlowFileRepository extends Closeable {
+
+ /**
+ * Initializes the Content Repository, providing to it the
+ * ContentClaimManager that is to be used for interacting with Content
+ * Claims
+ *
+ * @param claimManager for handling claims
+ * @throws java.io.IOException if unable to initialize repository
+ */
+ void initialize(ResourceClaimManager claimManager) throws IOException;
+
+ /**
+ * @return the maximum number of bytes that can be stored in the underlying
+ * storage mechanism
+ *
+ * @throws IOException if computing capacity fails
+ */
+ long getStorageCapacity() throws IOException;
+
+ /**
+ * @return the number of bytes currently available for use by the underlying
+ * storage mechanism
+ *
+ * @throws IOException if computing usable space fails
+ */
+ long getUsableStorageSpace() throws IOException;
+
+ /**
+ * Updates the repository with the given RepositoryRecords.
+ *
+ * @param records the records to update the repository with
+ * @throws java.io.IOException if update fails
+ */
+ void updateRepository(Collection<RepositoryRecord> records) throws IOException;
+
+ /**
+ * Loads all flow files found within the repository, establishes the content
+ * claims and their reference count
+ *
+ * @param queueProvider the provider of FlowFile Queues into which the
+ * FlowFiles should be enqueued
+ * @param minimumSequenceNumber specifies the minimum value that should be
+ * returned by a call to {@link #getNextFlowFileSequence()}
+ *
+ * @return index of highest flow file identifier
+ * @throws IOException if load fails
+ */
+ long loadFlowFiles(QueueProvider queueProvider, long minimumSequenceNumber) throws IOException;
+
+ /**
+ * @return <code>true</code> if the Repository is volatile (i.e., its data
+ * is lost upon application restart), <code>false</code> otherwise
+ */
+ boolean isVolatile();
+
+ /**
+ * @return the next ID in sequence for creating <code>FlowFile</code>s.
+ */
+ long getNextFlowFileSequence();
+
+ /**
+ * @return the max ID of all <code>FlowFile</code>s that currently exist in
+ * the repository.
+ * @throws IOException if computing max identifier fails
+ */
+ long getMaxFlowFileIdentifier() throws IOException;
+
+ /**
+ * Updates the Repository to indicate that the given FlowFileRecords were
+ * Swapped Out of memory
+ *
+ * @param swappedOut the FlowFiles that were swapped out of memory
+ * @param flowFileQueue the queue that the FlowFiles belong to
+ * @param swapLocation the location to which the FlowFiles were swapped
+ *
+ * @throws IOException if swap fails
+ */
+ void swapFlowFilesOut(List<FlowFileRecord> swappedOut, FlowFileQueue flowFileQueue, String swapLocation) throws IOException;
+
+ /**
+ * Updates the Repository to indicate that the given FlowFileRecpords were
+ * Swapped In to memory
+ *
+ * @param swapLocation the location (e.g., a filename) from which FlowFiles
+ * were recovered
+ * @param flowFileRecords the records that were swapped in
+ * @param flowFileQueue the queue that the FlowFiles belong to
+ *
+ * @throws IOException if swap fails
+ */
+ void swapFlowFilesIn(String swapLocation, List<FlowFileRecord> flowFileRecords, FlowFileQueue flowFileQueue) throws IOException;
+}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-framework-api/src/main/java/org/apache/nifi/controller/repository/FlowFileSwapManager.java
----------------------------------------------------------------------
diff --git a/nifi-framework-api/src/main/java/org/apache/nifi/controller/repository/FlowFileSwapManager.java b/nifi-framework-api/src/main/java/org/apache/nifi/controller/repository/FlowFileSwapManager.java
new file mode 100644
index 0000000..7092a6f
--- /dev/null
+++ b/nifi-framework-api/src/main/java/org/apache/nifi/controller/repository/FlowFileSwapManager.java
@@ -0,0 +1,105 @@
+/*
+ * 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.controller.repository;
+
+import java.io.IOException;
+import java.util.List;
+
+import org.apache.nifi.controller.queue.FlowFileQueue;
+
+/**
+ * Defines a mechanism by which FlowFiles can be move into external storage or
+ * memory so that they can be removed from the Java heap and vice-versa
+ */
+// TODO: This needs to be refactored into two different mechanisms, one that is responsible for doing
+// framework-y types of things, such as updating the repositories, and another that is responsible
+// for serializing and deserializing FlowFiles to external storage.
+public interface FlowFileSwapManager {
+
+ /**
+ * Initializes the Swap Manager, providing a {@link SwapManagerInitializationContext} so that the
+ * Swap Manager has access to all of the components necessary to perform its functions
+ *
+ * @param initializationContext the context the provides the swap manager with access to the
+ * resources that it needs to perform its functions
+ */
+ void initialize(SwapManagerInitializationContext initializationContext);
+
+ /**
+ * Swaps out the given FlowFiles that belong to the queue with the given identifier.
+ *
+ * @param flowFiles the FlowFiles to swap out to external storage
+ * @param flowFileQueue the queue that the FlowFiles belong to
+ * @return the location of the externally stored swap file
+ *
+ * @throws IOException if unable to swap the FlowFiles out
+ */
+ String swapOut(List<FlowFileRecord> flowFiles, FlowFileQueue flowFileQueue) throws IOException;
+
+ /**
+ * Recovers the FlowFiles from the swap file that lives at the given location. This action
+ * provides a view of the FlowFiles but does not actively swap them in, meaning that the swap file
+ * at the given location remains in that location and the FlowFile Repository is not updated.
+ *
+ * @param swapLocation the location of the swap file
+ * @param flowFileQueue the queue that the FlowFiles belong to
+ * @return a SwapContents that includes the FlowFiles that live at the given swap location
+ *
+ * @throws IOException if unable to recover the FlowFiles from the given location
+ */
+ SwapContents peek(String swapLocation, FlowFileQueue flowFileQueue) throws IncompleteSwapFileException, IOException;
+
+ /**
+ * Recovers the FlowFiles from the swap file that lives at the given location and belongs
+ * to the FlowFile Queue with the given identifier. The FlowFile Repository is then updated
+ * and the swap file is permanently removed from the external storage
+ *
+ * @param swapLocation the location of the swap file
+ * @param flowFileQueue the queue to which the FlowFiles belong
+ *
+ * @return a SwapContents that includes FlowFiles that are stored in the given location
+ *
+ * @throws IOException if unable to recover the FlowFiles from the given location or update the
+ * FlowFileRepository
+ */
+ SwapContents swapIn(String swapLocation, FlowFileQueue flowFileQueue) throws IncompleteSwapFileException, IOException;
+
+ /**
+ * Determines swap files that exist for the given FlowFileQueue
+ *
+ * @param flowFileQueue the queue for which the FlowFiles should be recovered
+ *
+ * @return all swap locations that have been identified for the given queue, in the order that they should
+ * be swapped back in
+ */
+ List<String> recoverSwapLocations(FlowFileQueue flowFileQueue) throws IOException;
+
+ /**
+ * Parses the contents of the swap file at the given location and provides a SwapSummary that provides
+ * pertinent information about the information stored within the swap file
+ *
+ * @param swapLocation the location of the swap file
+ * @return a SwapSummary that provides information about what is contained within the swap file
+ * @throws IOException if unable to read or parse the swap file
+ */
+ SwapSummary getSwapSummary(String swapLocation) throws IOException;
+
+ /**
+ * Purge all known Swap Files without updating FlowFileRepository or Provenance Repository
+ */
+ void purge();
+}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-framework-api/src/main/java/org/apache/nifi/controller/repository/IncompleteSwapFileException.java
----------------------------------------------------------------------
diff --git a/nifi-framework-api/src/main/java/org/apache/nifi/controller/repository/IncompleteSwapFileException.java b/nifi-framework-api/src/main/java/org/apache/nifi/controller/repository/IncompleteSwapFileException.java
new file mode 100644
index 0000000..4408f02
--- /dev/null
+++ b/nifi-framework-api/src/main/java/org/apache/nifi/controller/repository/IncompleteSwapFileException.java
@@ -0,0 +1,45 @@
+/*
+ * 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.controller.repository;
+
+import java.io.EOFException;
+
+/**
+ * Signals that a Swap File could not be complete read in/parsed because the data was
+ * not all present
+ */
+public class IncompleteSwapFileException extends EOFException {
+ private static final long serialVersionUID = -6818558584430076898L;
+
+ private final String swapLocation;
+ private final SwapContents partialContents;
+
+ public IncompleteSwapFileException(final String swapLocation, final SwapContents partialContents) {
+ super();
+ this.swapLocation = swapLocation;
+ this.partialContents = partialContents;
+ }
+
+ public String getSwapLocation() {
+ return swapLocation;
+ }
+
+ public SwapContents getPartialContents() {
+ return partialContents;
+ }
+}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-framework-api/src/main/java/org/apache/nifi/controller/repository/QueueProvider.java
----------------------------------------------------------------------
diff --git a/nifi-framework-api/src/main/java/org/apache/nifi/controller/repository/QueueProvider.java b/nifi-framework-api/src/main/java/org/apache/nifi/controller/repository/QueueProvider.java
new file mode 100644
index 0000000..95d9f2e
--- /dev/null
+++ b/nifi-framework-api/src/main/java/org/apache/nifi/controller/repository/QueueProvider.java
@@ -0,0 +1,33 @@
+/*
+ * 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.controller.repository;
+
+import java.util.Collection;
+
+import org.apache.nifi.controller.queue.FlowFileQueue;
+
+/**
+ * Provides a collection of <code>FlowFileQueue</code>s that represents all
+ * queues in the current flow
+ */
+public interface QueueProvider {
+
+ /**
+ * @return all <code>FlowFileQueue</code>s that currently exist in the flow
+ */
+ Collection<FlowFileQueue> getAllQueues();
+}
[09/10] nifi git commit: NIFI-1896 This closes #650. Refactored
nifi-api into nifi-framework-api and other locations. The nifi-api is
specific to that which is needed for intended extension points.
Posted by jo...@apache.org.
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-api/src/main/java/org/apache/nifi/authorization/AccessPolicy.java
----------------------------------------------------------------------
diff --git a/nifi-api/src/main/java/org/apache/nifi/authorization/AccessPolicy.java b/nifi-api/src/main/java/org/apache/nifi/authorization/AccessPolicy.java
deleted file mode 100644
index 93cabb2..0000000
--- a/nifi-api/src/main/java/org/apache/nifi/authorization/AccessPolicy.java
+++ /dev/null
@@ -1,330 +0,0 @@
-/*
- * 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.authorization;
-
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Objects;
-import java.util.Set;
-
-/**
- * Defines a policy for a set of userIdentifiers to perform a set of actions on a given resource.
- */
-public class AccessPolicy {
-
- private final String identifier;
-
- private final String resource;
-
- private final Set<String> users;
-
- private final Set<String> groups;
-
- private final RequestAction action;
-
- private AccessPolicy(final Builder builder) {
- this.identifier = builder.identifier;
- this.resource = builder.resource;
- this.action = builder.action;
- this.users = Collections.unmodifiableSet(new HashSet<>(builder.users));
- this.groups = Collections.unmodifiableSet(new HashSet<>(builder.groups));
-
- if (this.identifier == null || this.identifier.trim().isEmpty()) {
- throw new IllegalArgumentException("Identifier can not be null or empty");
- }
-
- if (this.resource == null) {
- throw new IllegalArgumentException("Resource can not be null");
- }
-
- if (this.action == null) {
- throw new IllegalArgumentException("Action can not be null");
- }
- }
-
- /**
- * @return the identifier for this policy
- */
- public String getIdentifier() {
- return identifier;
- }
-
- /**
- * @return the resource for this policy
- */
- public String getResource() {
- return resource;
- }
-
- /**
- * @return an unmodifiable set of user ids for this policy
- */
- public Set<String> getUsers() {
- return users;
- }
-
- /**
- * @return an unmodifiable set of group ids for this policy
- */
- public Set<String> getGroups() {
- return groups;
- }
-
- /**
- * @return the action for this policy
- */
- public RequestAction getAction() {
- return action;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj == null) {
- return false;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
-
- final AccessPolicy other = (AccessPolicy) obj;
- return Objects.equals(this.identifier, other.identifier);
- }
-
- @Override
- public int hashCode() {
- return Objects.hashCode(this.identifier);
- }
-
- @Override
- public String toString() {
- return String.format("identifier[%s], resource[%s], users[%s], groups[%s], action[%s]",
- getIdentifier(), getResource(), getUsers(), getGroups(), getAction());
- }
-
- /**
- * Builder for Access Policies.
- */
- public static class Builder {
-
- private String identifier;
- private String resource;
- private RequestAction action;
- private Set<String> users = new HashSet<>();
- private Set<String> groups = new HashSet<>();
- private final boolean fromPolicy;
-
- /**
- * Default constructor for building a new AccessPolicy.
- */
- public Builder() {
- this.fromPolicy = false;
- }
-
- /**
- * Initializes the builder with the state of the provided policy. When using this constructor
- * the identifier field of the builder can not be changed and will result in an IllegalStateException
- * if attempting to do so.
- *
- * @param other the existing access policy to initialize from
- */
- public Builder(final AccessPolicy other) {
- if (other == null) {
- throw new IllegalArgumentException("Can not initialize builder with a null access policy");
- }
-
- this.identifier = other.getIdentifier();
- this.resource = other.getResource();
- this.action = other.getAction();
- this.users.clear();
- this.users.addAll(other.getUsers());
- this.groups.clear();
- this.groups.addAll(other.getGroups());
- this.fromPolicy = true;
- }
-
- /**
- * Sets the identifier of the builder.
- *
- * @param identifier the identifier to set
- * @return the builder
- * @throws IllegalStateException if this method is called when this builder was constructed from an existing Policy
- */
- public Builder identifier(final String identifier) {
- if (fromPolicy) {
- throw new IllegalStateException(
- "Identifier can not be changed when initialized from an existing policy");
- }
-
- this.identifier = identifier;
- return this;
- }
-
- /**
- * Sets the resource of the builder.
- *
- * @param resource the resource to set
- * @return the builder
- */
- public Builder resource(final String resource) {
- this.resource = resource;
- return this;
- }
-
- /**
- * Adds all the users from the provided set to the builder's set of users.
- *
- * @param users the users to add
- * @return the builder
- */
- public Builder addUsers(final Set<String> users) {
- if (users != null) {
- this.users.addAll(users);
- }
- return this;
- }
-
- /**
- * Adds the given user to the builder's set of users.
- *
- * @param user the user to add
- * @return the builder
- */
- public Builder addUser(final String user) {
- if (user != null) {
- this.users.add(user);
- }
- return this;
- }
-
- /**
- * Removes all users in the provided set from the builder's set of users.
- *
- * @param users the users to remove
- * @return the builder
- */
- public Builder removeUsers(final Set<String> users) {
- if (users != null) {
- this.users.removeAll(users);
- }
- return this;
- }
-
- /**
- * Removes the provided user from the builder's set of users.
- *
- * @param user the user to remove
- * @return the builder
- */
- public Builder removeUser(final String user) {
- if (user != null) {
- this.users.remove(user);
- }
- return this;
- }
-
- /**
- * Clears the builder's set of users so that it is non-null and size == 0.
- *
- * @return the builder
- */
- public Builder clearUsers() {
- this.users.clear();
- return this;
- }
-
- /**
- * Adds all the groups from the provided set to the builder's set of groups.
- *
- * @param groups the groups to add
- * @return the builder
- */
- public Builder addGroups(final Set<String> groups) {
- if (groups != null) {
- this.groups.addAll(groups);
- }
- return this;
- }
-
- /**
- * Adds the given group to the builder's set of groups.
- *
- * @param group the group to add
- * @return the builder
- */
- public Builder addGroup(final String group) {
- if (group != null) {
- this.groups.add(group);
- }
- return this;
- }
-
- /**
- * Removes all groups in the provided set from the builder's set of groups.
- *
- * @param groups the groups to remove
- * @return the builder
- */
- public Builder removeGroups(final Set<String> groups) {
- if (groups != null) {
- this.groups.removeAll(groups);
- }
- return this;
- }
-
- /**
- * Removes the provided groups from the builder's set of groups.
- *
- * @param group the group to remove
- * @return the builder
- */
- public Builder removeGroup(final String group) {
- if (group != null) {
- this.groups.remove(group);
- }
- return this;
- }
-
- /**
- * Clears the builder's set of groups so that it is non-null and size == 0.
- *
- * @return the builder
- */
- public Builder clearGroups() {
- this.groups.clear();
- return this;
- }
-
- /**
- * Sets the action for this builder.
- *
- * @param action the action to set
- * @return the builder
- */
- public Builder action(final RequestAction action) {
- this.action = action;
- return this;
- }
-
- /**
- * @return a new AccessPolicy constructed from the state of the builder
- */
- public AccessPolicy build() {
- return new AccessPolicy(this);
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-api/src/main/java/org/apache/nifi/authorization/AuthorizationRequest.java
----------------------------------------------------------------------
diff --git a/nifi-api/src/main/java/org/apache/nifi/authorization/AuthorizationRequest.java b/nifi-api/src/main/java/org/apache/nifi/authorization/AuthorizationRequest.java
deleted file mode 100644
index da0a276..0000000
--- a/nifi-api/src/main/java/org/apache/nifi/authorization/AuthorizationRequest.java
+++ /dev/null
@@ -1,171 +0,0 @@
-/*
- * 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.authorization;
-
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Objects;
-
-/**
- * Represents an authorization request for a given user/entity performing an action against a resource within some userContext.
- */
-public class AuthorizationRequest {
-
- private final Resource resource;
- private final String identity;
- private final RequestAction action;
- private final boolean isAccessAttempt;
- private final boolean isAnonymous;
- private final Map<String, String> userContext;
- private final Map<String, String> resourceContext;
-
- private AuthorizationRequest(final Builder builder) {
- Objects.requireNonNull(builder.resource, "The resource is required when creating an authorization request");
- Objects.requireNonNull(builder.action, "The action is required when creating an authorization request");
- Objects.requireNonNull(builder.isAccessAttempt, "Whether this request is an access attempt is request");
- Objects.requireNonNull(builder.isAnonymous, "Whether this request is being performed by an anonymous user is required");
-
- this.resource = builder.resource;
- this.identity = builder.identity;
- this.action = builder.action;
- this.isAccessAttempt = builder.isAccessAttempt;
- this.isAnonymous = builder.isAnonymous;
- this.userContext = builder.userContext == null ? null : Collections.unmodifiableMap(builder.userContext);
- this.resourceContext = builder.resourceContext == null ? null : Collections.unmodifiableMap(builder.resourceContext);
- }
-
- /**
- * The Resource being authorized. Not null.
- *
- * @return The resource
- */
- public Resource getResource() {
- return resource;
- }
-
- /**
- * The identity accessing the Resource. May be null if the user could not authenticate.
- *
- * @return The identity
- */
- public String getIdentity() {
- return identity;
- }
-
- /**
- * Whether this is a direct access attempt of the Resource if if it's being checked as part of another response.
- *
- * @return if this is a direct access attempt
- */
- public boolean isAccessAttempt() {
- return isAccessAttempt;
- }
-
- /**
- * Whether the entity accessing is anonymous.
- *
- * @return whether the entity is anonymous
- */
- public boolean isAnonymous() {
- return isAnonymous;
- }
-
- /**
- * The action being taken against the Resource. Not null.
- *
- * @return The action
- */
- public RequestAction getAction() {
- return action;
- }
-
- /**
- * The userContext of the user request to make additional access decisions. May be null.
- *
- * @return The userContext of the user request
- */
- public Map<String, String> getUserContext() {
- return userContext;
- }
-
- /**
- * The event attributes to make additional access decisions for provenance events. May be null.
- *
- * @return The event attributes
- */
- public Map<String, String> getResourceContext() {
- return resourceContext;
- }
-
- /**
- * AuthorizationRequest builder.
- */
- public static final class Builder {
-
- private Resource resource;
- private String identity;
- private Boolean isAnonymous;
- private Boolean isAccessAttempt;
- private RequestAction action;
- private Map<String, String> userContext;
- private Map<String, String> resourceContext;
-
- public Builder resource(final Resource resource) {
- this.resource = resource;
- return this;
- }
-
- public Builder identity(final String identity) {
- this.identity = identity;
- return this;
- }
-
- public Builder anonymous(final Boolean isAnonymous) {
- this.isAnonymous = isAnonymous;
- return this;
- }
-
- public Builder accessAttempt(final Boolean isAccessAttempt) {
- this.isAccessAttempt = isAccessAttempt;
- return this;
- }
-
- public Builder action(final RequestAction action) {
- this.action = action;
- return this;
- }
-
- public Builder userContext(final Map<String, String> userContext) {
- if (userContext != null) {
- this.userContext = new HashMap<>(userContext);
- }
- return this;
- }
-
- public Builder resourceContext(final Map<String, String> resourceContext) {
- if (resourceContext != null) {
- this.resourceContext = new HashMap<>(resourceContext);
- }
- return this;
- }
-
- public AuthorizationRequest build() {
- return new AuthorizationRequest(this);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-api/src/main/java/org/apache/nifi/authorization/AuthorizationResult.java
----------------------------------------------------------------------
diff --git a/nifi-api/src/main/java/org/apache/nifi/authorization/AuthorizationResult.java b/nifi-api/src/main/java/org/apache/nifi/authorization/AuthorizationResult.java
deleted file mode 100644
index a3f520c..0000000
--- a/nifi-api/src/main/java/org/apache/nifi/authorization/AuthorizationResult.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * 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.authorization;
-
-/**
- * Represents a decision whether authorization is granted.
- */
-public class AuthorizationResult {
-
- public enum Result {
- Approved,
- Denied,
- ResourceNotFound
- }
-
- private static final AuthorizationResult APPROVED = new AuthorizationResult(Result.Approved, null);
- private static final AuthorizationResult RESOURCE_NOT_FOUND = new AuthorizationResult(Result.ResourceNotFound, null);
-
- private final Result result;
- private final String explanation;
-
- /**
- * Creates a new AuthorizationResult with the specified result and explanation.
- *
- * @param result of the authorization
- * @param explanation for the authorization attempt
- */
- private AuthorizationResult(Result result, String explanation) {
- if (Result.Denied.equals(result) && explanation == null) {
- throw new IllegalArgumentException("An explanation is required when the authorization request is denied.");
- }
-
- this.result = result;
- this.explanation = explanation;
- }
-
- /**
- * @return Whether or not the request is approved
- */
- public Result getResult() {
- return result;
- }
-
- /**
- * @return If the request is denied, the reason why. Null otherwise
- */
- public String getExplanation() {
- return explanation;
- }
-
- /**
- * @return a new approved AuthorizationResult
- */
- public static AuthorizationResult approved() {
- return APPROVED;
- }
-
- /**
- * Resource not found will indicate that there are no specific authorization rules for this resource.
- * @return a new resource not found AuthorizationResult
- */
- public static AuthorizationResult resourceNotFound() {
- return RESOURCE_NOT_FOUND;
- }
-
- /**
- * Creates a new denied AuthorizationResult with a message indicating 'Access is denied'.
- *
- * @return a new denied AuthorizationResult
- */
- public static AuthorizationResult denied() {
- return denied("Access is denied");
- }
-
- /**
- * Creates a new denied AuthorizationResult with the specified explanation.
- *
- * @param explanation for why it was denied
- * @return a new denied AuthorizationResult with the specified explanation
- * @throws IllegalArgumentException if explanation is null
- */
- public static AuthorizationResult denied(String explanation) {
- return new AuthorizationResult(Result.Denied, explanation);
- }
-}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-api/src/main/java/org/apache/nifi/authorization/Authorizer.java
----------------------------------------------------------------------
diff --git a/nifi-api/src/main/java/org/apache/nifi/authorization/Authorizer.java b/nifi-api/src/main/java/org/apache/nifi/authorization/Authorizer.java
deleted file mode 100644
index cb8c7f1..0000000
--- a/nifi-api/src/main/java/org/apache/nifi/authorization/Authorizer.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * 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.authorization;
-
-import org.apache.nifi.authorization.exception.AuthorizationAccessException;
-import org.apache.nifi.authorization.exception.AuthorizerCreationException;
-import org.apache.nifi.authorization.exception.AuthorizerDestructionException;
-
-/**
- * Authorizes user requests.
- */
-public interface Authorizer {
-
- /**
- * Determines if the specified user/entity is authorized to access the specified resource within the given context.
- *
- * @param request The authorization request
- * @return the authorization result
- * @throws AuthorizationAccessException if unable to access the policies
- */
- AuthorizationResult authorize(AuthorizationRequest request) throws AuthorizationAccessException;
-
- /**
- * Called immediately after instance creation for implementers to perform additional setup
- *
- * @param initializationContext in which to initialize
- */
- void initialize(AuthorizerInitializationContext initializationContext) throws AuthorizerCreationException;
-
- /**
- * Called to configure the Authorizer.
- *
- * @param configurationContext at the time of configuration
- * @throws AuthorizerCreationException for any issues configuring the provider
- */
- void onConfigured(AuthorizerConfigurationContext configurationContext) throws AuthorizerCreationException;
-
- /**
- * Called immediately before instance destruction for implementers to release resources.
- *
- * @throws AuthorizerDestructionException If pre-destruction fails.
- */
- void preDestruction() throws AuthorizerDestructionException;
-
-}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-api/src/main/java/org/apache/nifi/authorization/AuthorizerConfigurationContext.java
----------------------------------------------------------------------
diff --git a/nifi-api/src/main/java/org/apache/nifi/authorization/AuthorizerConfigurationContext.java b/nifi-api/src/main/java/org/apache/nifi/authorization/AuthorizerConfigurationContext.java
deleted file mode 100644
index 3721ab4..0000000
--- a/nifi-api/src/main/java/org/apache/nifi/authorization/AuthorizerConfigurationContext.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * 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.authorization;
-
-import org.apache.nifi.components.PropertyValue;
-
-import java.util.Map;
-
-/**
- *
- */
-public interface AuthorizerConfigurationContext {
-
- /**
- * @return identifier for the authorizer
- */
- String getIdentifier();
-
- /**
- * Retrieves all properties the component currently understands regardless
- * of whether a value has been set for them or not. If no value is present
- * then its value is null and thus any registered default for the property
- * descriptor applies.
- *
- * @return Map of all properties
- */
- Map<String, String> getProperties();
-
- /**
- * @param property to lookup the descriptor and value of
- * @return the value the component currently understands for the given
- * PropertyDescriptor. This method does not substitute default
- * PropertyDescriptor values, so the value returned will be null if not set
- */
- PropertyValue getProperty(String property);
-}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-api/src/main/java/org/apache/nifi/authorization/AuthorizerInitializationContext.java
----------------------------------------------------------------------
diff --git a/nifi-api/src/main/java/org/apache/nifi/authorization/AuthorizerInitializationContext.java b/nifi-api/src/main/java/org/apache/nifi/authorization/AuthorizerInitializationContext.java
deleted file mode 100644
index 4b3d77c..0000000
--- a/nifi-api/src/main/java/org/apache/nifi/authorization/AuthorizerInitializationContext.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * 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.authorization;
-
-/**
- * Initialization content for Authorizers.
- */
-public interface AuthorizerInitializationContext {
-
- /**
- * The identifier of the Authorizer.
- *
- * @return The identifier
- */
- public String getIdentifier();
-
- /**
- * The lookup for accessing other configured Authorizers.
- *
- * @return The Authorizer lookup
- */
- public AuthorizerLookup getAuthorizerLookup();
-}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-api/src/main/java/org/apache/nifi/authorization/AuthorizerLookup.java
----------------------------------------------------------------------
diff --git a/nifi-api/src/main/java/org/apache/nifi/authorization/AuthorizerLookup.java b/nifi-api/src/main/java/org/apache/nifi/authorization/AuthorizerLookup.java
deleted file mode 100644
index 9669976..0000000
--- a/nifi-api/src/main/java/org/apache/nifi/authorization/AuthorizerLookup.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * 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.authorization;
-
-/**
- *
- */
-public interface AuthorizerLookup {
-
- /**
- * Looks up the Authorizer with the specified identifier
- *
- * @param identifier The identifier of the Authorizer
- * @return The Authorizer
- */
- Authorizer getAuthorizer(String identifier);
-}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-api/src/main/java/org/apache/nifi/authorization/Group.java
----------------------------------------------------------------------
diff --git a/nifi-api/src/main/java/org/apache/nifi/authorization/Group.java b/nifi-api/src/main/java/org/apache/nifi/authorization/Group.java
deleted file mode 100644
index 7db619a..0000000
--- a/nifi-api/src/main/java/org/apache/nifi/authorization/Group.java
+++ /dev/null
@@ -1,226 +0,0 @@
-/*
- * 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.authorization;
-
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Objects;
-import java.util.Set;
-
-/**
- * A group that users can belong to.
- */
-public class Group { // TODO rename to UserGroup
-
- private final String identifier;
-
- private final String name;
-
- private final Set<String> users;
-
- private Group(final Builder builder) {
- this.identifier = builder.identifier;
- this.name = builder.name;
- this.users = Collections.unmodifiableSet(new HashSet<>(builder.users));
-
- if (this.identifier == null || this.identifier.trim().isEmpty()) {
- throw new IllegalArgumentException("Identifier can not be null or empty");
- }
-
- if (this.name == null || this.name.trim().isEmpty()) {
- throw new IllegalArgumentException("Name can not be null or empty");
- }
- }
-
- /**
- * @return the identifier of the group
- */
- public String getIdentifier() {
- return identifier;
- }
-
- /**
- * @return the name of the group
- */
- public String getName() {
- return name;
- }
-
- /**
- * @return an unmodifiable set of user identifiers that belong to this group
- */
- public Set<String> getUsers() {
- return users;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj == null) {
- return false;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
-
- final Group other = (Group) obj;
- return Objects.equals(this.identifier, other.identifier);
- }
-
- @Override
- public int hashCode() {
- return Objects.hashCode(this.identifier);
- }
-
- @Override
- public String toString() {
- return String.format("identifier[%s], name[%s]", getIdentifier(), getName());
- }
-
-
- /**
- * Builder for creating Groups.
- */
- public static class Builder {
-
- private String identifier;
- private String name;
- private Set<String> users = new HashSet<>();
- private final boolean fromGroup;
-
- public Builder() {
- this.fromGroup = false;
- }
-
- /**
- * Initializes the builder with the state of the provided group. When using this constructor
- * the identifier field of the builder can not be changed and will result in an IllegalStateException
- * if attempting to do so.
- *
- * @param other the existing access policy to initialize from
- */
- public Builder(final Group other) {
- if (other == null) {
- throw new IllegalArgumentException("Provided group can not be null");
- }
-
- this.identifier = other.getIdentifier();
- this.name = other.getName();
- this.users.clear();
- this.users.addAll(other.getUsers());
- this.fromGroup = true;
- }
-
- /**
- * Sets the identifier of the builder.
- *
- * @param identifier the identifier
- * @return the builder
- * @throws IllegalStateException if this method is called when this builder was constructed from an existing Group
- */
- public Builder identifier(final String identifier) {
- if (fromGroup) {
- throw new IllegalStateException(
- "Identifier can not be changed when initialized from an existing group");
- }
-
- this.identifier = identifier;
- return this;
- }
-
- /**
- * Sets the name of the builder.
- *
- * @param name the name
- * @return the builder
- */
- public Builder name(final String name) {
- this.name = name;
- return this;
- }
-
- /**
- * Adds all users from the provided set to the builder's set of users.
- *
- * @param users a set of users to add
- * @return the builder
- */
- public Builder addUsers(final Set<String> users) {
- if (users != null) {
- this.users.addAll(users);
- }
- return this;
- }
-
- /**
- * Adds the given user to the builder's set of users.
- *
- * @param user the user to add
- * @return the builder
- */
- public Builder addUser(final String user) {
- if (user != null) {
- this.users.add(user);
- }
- return this;
- }
-
- /**
- * Removes the given user from the builder's set of users.
- *
- * @param user the user to remove
- * @return the builder
- */
- public Builder removeUser(final String user) {
- if (user != null) {
- this.users.remove(user);
- }
- return this;
- }
-
- /**
- * Removes all users from the provided set from the builder's set of users.
- *
- * @param users the users to remove
- * @return the builder
- */
- public Builder removeUsers(final Set<String> users) {
- if (users != null) {
- this.users.removeAll(users);
- }
- return this;
- }
-
- /**
- * Clears the builder's set of users so that users is non-null with size 0.
- *
- * @return the builder
- */
- public Builder clearUsers() {
- this.users.clear();
- return this;
- }
-
- /**
- * @return a new Group constructed from the state of the builder
- */
- public Group build() {
- return new Group(this);
- }
-
- }
-
-}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-api/src/main/java/org/apache/nifi/authorization/RequestAction.java
----------------------------------------------------------------------
diff --git a/nifi-api/src/main/java/org/apache/nifi/authorization/RequestAction.java b/nifi-api/src/main/java/org/apache/nifi/authorization/RequestAction.java
deleted file mode 100644
index 3e28a67..0000000
--- a/nifi-api/src/main/java/org/apache/nifi/authorization/RequestAction.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * 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.authorization;
-
-/**
- * Actions a user/entity can take on a resource.
- */
-public enum RequestAction {
- READ("read"),
- WRITE("write");
-
- private String value;
-
- RequestAction(String value) {
- this.value = value;
- }
-
- @Override
- public String toString() {
- return value.toLowerCase();
- }
-
- public static RequestAction valueOfValue(final String action) {
- if (RequestAction.READ.toString().equals(action)) {
- return RequestAction.READ;
- } else if (RequestAction.WRITE.toString().equals(action)) {
- return RequestAction.WRITE;
- } else {
- throw new IllegalArgumentException("Action must be one of [" + READ.toString() + ", " + WRITE.toString() + "]");
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-api/src/main/java/org/apache/nifi/authorization/Resource.java
----------------------------------------------------------------------
diff --git a/nifi-api/src/main/java/org/apache/nifi/authorization/Resource.java b/nifi-api/src/main/java/org/apache/nifi/authorization/Resource.java
deleted file mode 100644
index 661b326..0000000
--- a/nifi-api/src/main/java/org/apache/nifi/authorization/Resource.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * 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.authorization;
-
-/**
- * Resource in an authorization request.
- */
-public interface Resource {
-
- /**
- * The identifier for this resource.
- *
- * @return identifier for this resource
- */
- String getIdentifier();
-
- /**
- * The name of this resource. May be null.
- *
- * @return name of this resource
- */
- String getName();
-}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-api/src/main/java/org/apache/nifi/authorization/User.java
----------------------------------------------------------------------
diff --git a/nifi-api/src/main/java/org/apache/nifi/authorization/User.java b/nifi-api/src/main/java/org/apache/nifi/authorization/User.java
deleted file mode 100644
index 371241b..0000000
--- a/nifi-api/src/main/java/org/apache/nifi/authorization/User.java
+++ /dev/null
@@ -1,151 +0,0 @@
-/*
- * 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.authorization;
-
-import java.util.Objects;
-
-/**
- * A user to create authorization policies for.
- */
-public class User {
-
- private final String identifier;
-
- private final String identity;
-
- private User(final Builder builder) {
- this.identifier = builder.identifier;
- this.identity = builder.identity;
-
- if (identifier == null || identifier.trim().isEmpty()) {
- throw new IllegalArgumentException("Identifier can not be null or empty");
- }
-
- if (identity == null || identity.trim().isEmpty()) {
- throw new IllegalArgumentException("Identity can not be null or empty");
- }
-
- }
-
- /**
- * @return the identifier of the user
- */
- public String getIdentifier() {
- return identifier;
- }
-
- /**
- * @return the identity string of the user
- */
- public String getIdentity() {
- return identity;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj == null) {
- return false;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
-
- final User other = (User) obj;
- return Objects.equals(this.identifier, other.identifier);
- }
-
- @Override
- public int hashCode() {
- return Objects.hashCode(this.identifier);
- }
-
- @Override
- public String toString() {
- return String.format("identifier[%s], identity[%s]", getIdentifier(), getIdentity());
- }
-
- /**
- * Builder for Users.
- */
- public static class Builder {
-
- private String identifier;
- private String identity;
- private final boolean fromUser;
-
- /**
- * Default constructor for building a new User.
- */
- public Builder() {
- this.fromUser = false;
- }
-
- /**
- * Initializes the builder with the state of the provided user. When using this constructor
- * the identifier field of the builder can not be changed and will result in an IllegalStateException
- * if attempting to do so.
- *
- * @param other the existing user to initialize from
- */
- public Builder(final User other) {
- if (other == null) {
- throw new IllegalArgumentException("Provided user can not be null");
- }
-
- this.identifier = other.getIdentifier();
- this.identity = other.getIdentity();
- this.fromUser = true;
- }
-
- /**
- * Sets the identifier of the builder.
- *
- * @param identifier the identifier to set
- * @return the builder
- * @throws IllegalStateException if this method is called when this builder was constructed from an existing User
- */
- public Builder identifier(final String identifier) {
- if (fromUser) {
- throw new IllegalStateException(
- "Identifier can not be changed when initialized from an existing user");
- }
-
- this.identifier = identifier;
- return this;
- }
-
- /**
- * Sets the identity of the builder.
- *
- * @param identity the identity to set
- * @return the builder
- */
- public Builder identity(final String identity) {
- this.identity = identity;
- return this;
- }
-
- /**
- * @return a new User constructed from the state of the builder
- */
- public User build() {
- return new User(this);
- }
-
- }
-
-}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-api/src/main/java/org/apache/nifi/authorization/UserContextKeys.java
----------------------------------------------------------------------
diff --git a/nifi-api/src/main/java/org/apache/nifi/authorization/UserContextKeys.java b/nifi-api/src/main/java/org/apache/nifi/authorization/UserContextKeys.java
deleted file mode 100644
index fca4b74..0000000
--- a/nifi-api/src/main/java/org/apache/nifi/authorization/UserContextKeys.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * 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.authorization;
-
-/**
- * Constants for keys that can be passed in the AuthorizationRequest user context Map.
- */
-public enum UserContextKeys {
-
- CLIENT_ADDRESS;
-
-}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-api/src/main/java/org/apache/nifi/authorization/UsersAndAccessPolicies.java
----------------------------------------------------------------------
diff --git a/nifi-api/src/main/java/org/apache/nifi/authorization/UsersAndAccessPolicies.java b/nifi-api/src/main/java/org/apache/nifi/authorization/UsersAndAccessPolicies.java
deleted file mode 100644
index 552b753..0000000
--- a/nifi-api/src/main/java/org/apache/nifi/authorization/UsersAndAccessPolicies.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * 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.authorization;
-
-import java.util.Set;
-
-/**
- * A holder object to provide atomic access to policies for a given resource and users by
- * identity. Implementations must ensure consistent access to the data backing this instance.
- */
-public interface UsersAndAccessPolicies {
-
- /**
- * Retrieves the set of access policies for a given resource and action.
- *
- * @param resourceIdentifier the resource identifier to retrieve policies for
- * @param action the action to retrieve policies for
- * @return the access policy for the given resource and action
- */
- public AccessPolicy getAccessPolicy(final String resourceIdentifier, final RequestAction action);
-
- /**
- * Retrieves a user by an identity string.
- *
- * @param identity the identity of the user to retrieve
- * @return the user with the given identity
- */
- public User getUser(final String identity);
-
- /**
- * Retrieves the groups for a given user identity.
- *
- * @param userIdentity a user identity
- * @return the set of groups for the given user identity
- */
- public Set<Group> getGroups(final String userIdentity);
-
-}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-api/src/main/java/org/apache/nifi/authorization/annotation/AuthorizerContext.java
----------------------------------------------------------------------
diff --git a/nifi-api/src/main/java/org/apache/nifi/authorization/annotation/AuthorizerContext.java b/nifi-api/src/main/java/org/apache/nifi/authorization/annotation/AuthorizerContext.java
deleted file mode 100644
index b0d3f83..0000000
--- a/nifi-api/src/main/java/org/apache/nifi/authorization/annotation/AuthorizerContext.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * 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.authorization.annotation;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Inherited;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- *
- *
- */
-@Documented
-@Target({ElementType.FIELD, ElementType.METHOD})
-@Retention(RetentionPolicy.RUNTIME)
-@Inherited
-public @interface AuthorizerContext {
-}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-api/src/main/java/org/apache/nifi/authorization/exception/AuthorizationAccessException.java
----------------------------------------------------------------------
diff --git a/nifi-api/src/main/java/org/apache/nifi/authorization/exception/AuthorizationAccessException.java b/nifi-api/src/main/java/org/apache/nifi/authorization/exception/AuthorizationAccessException.java
deleted file mode 100644
index 8b22d45..0000000
--- a/nifi-api/src/main/java/org/apache/nifi/authorization/exception/AuthorizationAccessException.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * 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.authorization.exception;
-
-/**
- * Represents the case when an authorization decision could not be made because the Authorizer was unable to access the underlying data store.
- */
-public class AuthorizationAccessException extends RuntimeException {
-
- public AuthorizationAccessException(String message, Throwable cause) {
- super(message, cause);
- }
-
- public AuthorizationAccessException(String message) {
- super(message);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-api/src/main/java/org/apache/nifi/authorization/exception/AuthorizerCreationException.java
----------------------------------------------------------------------
diff --git a/nifi-api/src/main/java/org/apache/nifi/authorization/exception/AuthorizerCreationException.java b/nifi-api/src/main/java/org/apache/nifi/authorization/exception/AuthorizerCreationException.java
deleted file mode 100644
index 4264202..0000000
--- a/nifi-api/src/main/java/org/apache/nifi/authorization/exception/AuthorizerCreationException.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * 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.authorization.exception;
-
-/**
- * Represents the exceptional case when an Authorizer fails instantiation.
- *
- */
-public class AuthorizerCreationException extends RuntimeException {
-
- public AuthorizerCreationException() {
- }
-
- public AuthorizerCreationException(String msg) {
- super(msg);
- }
-
- public AuthorizerCreationException(Throwable cause) {
- super(cause);
- }
-
- public AuthorizerCreationException(String msg, Throwable cause) {
- super(msg, cause);
- }
-}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-api/src/main/java/org/apache/nifi/authorization/exception/AuthorizerDestructionException.java
----------------------------------------------------------------------
diff --git a/nifi-api/src/main/java/org/apache/nifi/authorization/exception/AuthorizerDestructionException.java b/nifi-api/src/main/java/org/apache/nifi/authorization/exception/AuthorizerDestructionException.java
deleted file mode 100644
index 852eca1..0000000
--- a/nifi-api/src/main/java/org/apache/nifi/authorization/exception/AuthorizerDestructionException.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * 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.authorization.exception;
-
-/**
- * Represents the exceptional case when an Authorizer fails destruction.
- *
- */
-public class AuthorizerDestructionException extends RuntimeException {
-
- public AuthorizerDestructionException() {
- }
-
- public AuthorizerDestructionException(String msg) {
- super(msg);
- }
-
- public AuthorizerDestructionException(Throwable cause) {
- super(cause);
- }
-
- public AuthorizerDestructionException(String msg, Throwable cause) {
- super(msg, cause);
- }
-}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-api/src/main/java/org/apache/nifi/authorization/resource/Authorizable.java
----------------------------------------------------------------------
diff --git a/nifi-api/src/main/java/org/apache/nifi/authorization/resource/Authorizable.java b/nifi-api/src/main/java/org/apache/nifi/authorization/resource/Authorizable.java
deleted file mode 100644
index 7cb21ae..0000000
--- a/nifi-api/src/main/java/org/apache/nifi/authorization/resource/Authorizable.java
+++ /dev/null
@@ -1,173 +0,0 @@
-/*
- * 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.authorization.resource;
-
-import org.apache.nifi.authorization.AccessDeniedException;
-import org.apache.nifi.authorization.AuthorizationRequest;
-import org.apache.nifi.authorization.AuthorizationResult;
-import org.apache.nifi.authorization.AuthorizationResult.Result;
-import org.apache.nifi.authorization.Authorizer;
-import org.apache.nifi.authorization.RequestAction;
-import org.apache.nifi.authorization.Resource;
-import org.apache.nifi.authorization.UserContextKeys;
-import org.apache.nifi.authorization.user.NiFiUser;
-
-import java.util.Map;
-import java.util.HashMap;
-
-public interface Authorizable {
-
- /**
- * The parent for this Authorizable. May be null.
- *
- * @return the parent authorizable or null
- */
- Authorizable getParentAuthorizable();
-
- /**
- * The Resource for this Authorizable.
- *
- * @return the parent resource
- */
- Resource getResource();
-
- /**
- * Returns whether the current user is authorized for the specified action on the specified resource. This
- * method does not imply the user is directly attempting to access the specified resource. If the user is
- * attempting a direct access use Authorizable.authorize().
- *
- * @param authorizer authorizer
- * @param action action
- * @return is authorized
- */
- default boolean isAuthorized(Authorizer authorizer, RequestAction action, NiFiUser user) {
- return Result.Approved.equals(checkAuthorization(authorizer, action, user).getResult());
- }
-
- /**
- * Returns the result of an authorization request for the specified user for the specified action on the specified
- * resource. This method does not imply the user is directly attempting to access the specified resource. If the user is
- * attempting a direct access use Authorizable.authorize().
- *
- * @param authorizer authorizer
- * @param action action
- * @param user user
- * @return is authorized
- */
- default AuthorizationResult checkAuthorization(Authorizer authorizer, RequestAction action, NiFiUser user, Map<String, String> resourceContext) {
- final Map<String,String> userContext;
- if (user.getClientAddress() != null && !user.getClientAddress().trim().isEmpty()) {
- userContext = new HashMap<>();
- userContext.put(UserContextKeys.CLIENT_ADDRESS.name(), user.getClientAddress());
- } else {
- userContext = null;
- }
-
- // build the request
- final AuthorizationRequest request = new AuthorizationRequest.Builder()
- .identity(user.getIdentity())
- .anonymous(user.isAnonymous())
- .accessAttempt(false)
- .action(action)
- .resource(getResource())
- .resourceContext(resourceContext)
- .userContext(userContext)
- .build();
-
- // perform the authorization
- final AuthorizationResult result = authorizer.authorize(request);
-
- // verify the results
- if (Result.ResourceNotFound.equals(result.getResult())) {
- final Authorizable parent = getParentAuthorizable();
- if (parent == null) {
- return AuthorizationResult.denied();
- } else {
- return parent.checkAuthorization(authorizer, action, user);
- }
- } else {
- return result;
- }
- }
-
- /**
- * Returns the result of an authorization request for the specified user for the specified action on the specified
- * resource. This method does not imply the user is directly attempting to access the specified resource. If the user is
- * attempting a direct access use Authorizable.authorize().
- *
- * @param authorizer authorizer
- * @param action action
- * @param user user
- * @return is authorized
- */
- default AuthorizationResult checkAuthorization(Authorizer authorizer, RequestAction action, NiFiUser user) {
- return checkAuthorization(authorizer, action, user, null);
- }
-
- /**
- * Authorizes the current user for the specified action on the specified resource. This method does imply the user is
- * directly accessing the specified resource.
- *
- * @param authorizer authorizer
- * @param action action
- * @param user user
- * @param resourceContext resource context
- */
- default void authorize(Authorizer authorizer, RequestAction action, NiFiUser user, Map<String, String> resourceContext) throws AccessDeniedException {
- final Map<String,String> userContext;
- if (user.getClientAddress() != null && !user.getClientAddress().trim().isEmpty()) {
- userContext = new HashMap<>();
- userContext.put(UserContextKeys.CLIENT_ADDRESS.name(), user.getClientAddress());
- } else {
- userContext = null;
- }
-
- final AuthorizationRequest request = new AuthorizationRequest.Builder()
- .identity(user.getIdentity())
- .anonymous(user.isAnonymous())
- .accessAttempt(true)
- .action(action)
- .resource(getResource())
- .resourceContext(resourceContext)
- .userContext(userContext)
- .build();
-
- final AuthorizationResult result = authorizer.authorize(request);
- if (Result.ResourceNotFound.equals(result.getResult())) {
- final Authorizable parent = getParentAuthorizable();
- if (parent == null) {
- throw new AccessDeniedException("Access is denied");
- } else {
- parent.authorize(authorizer, action, user);
- }
- } else if (Result.Denied.equals(result.getResult())) {
- throw new AccessDeniedException(result.getExplanation());
- }
- }
-
- /**
- * Authorizes the current user for the specified action on the specified resource. This method does imply the user is
- * directly accessing the specified resource.
- *
- * @param authorizer authorizer
- * @param action action
- * @param user user
- */
- default void authorize(Authorizer authorizer, RequestAction action, NiFiUser user) throws AccessDeniedException {
- authorize(authorizer, action, user, null);
- }
-}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-api/src/main/java/org/apache/nifi/authorization/user/NiFiUser.java
----------------------------------------------------------------------
diff --git a/nifi-api/src/main/java/org/apache/nifi/authorization/user/NiFiUser.java b/nifi-api/src/main/java/org/apache/nifi/authorization/user/NiFiUser.java
deleted file mode 100644
index c450bc4..0000000
--- a/nifi-api/src/main/java/org/apache/nifi/authorization/user/NiFiUser.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * 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.authorization.user;
-
-/**
- * A representation of a NiFi user that has logged into the application
- */
-public interface NiFiUser {
-
- /**
- * @return the unique identity of this user
- */
- String getIdentity();
-
- /**
- * @return the next user in the proxied entities chain, or <code>null</code> if no more users exist in the chain.
- */
- NiFiUser getChain();
-
- /**
- * @return <code>true</code> if the user is the unauthenticated Anonymous user
- */
- boolean isAnonymous();
-
- /**
- * @return the address of the client that made the request which created this user
- */
- String getClientAddress();
-
-}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-api/src/main/java/org/apache/nifi/components/PropertyValue.java
----------------------------------------------------------------------
diff --git a/nifi-api/src/main/java/org/apache/nifi/components/PropertyValue.java b/nifi-api/src/main/java/org/apache/nifi/components/PropertyValue.java
index 72dcc2a..edaddd7 100644
--- a/nifi-api/src/main/java/org/apache/nifi/components/PropertyValue.java
+++ b/nifi-api/src/main/java/org/apache/nifi/components/PropertyValue.java
@@ -36,41 +36,41 @@ public interface PropertyValue {
/**
* @return the raw property value as a string
*/
- public String getValue();
+ String getValue();
/**
* @return an integer representation of the property value, or
* <code>null</code> if not set
* @throws NumberFormatException if not able to parse
*/
- public Integer asInteger();
+ Integer asInteger();
/**
* @return a Long representation of the property value, or <code>null</code>
* if not set
* @throws NumberFormatException if not able to parse
*/
- public Long asLong();
+ Long asLong();
/**
* @return a Boolean representation of the property value, or
* <code>null</code> if not set
*/
- public Boolean asBoolean();
+ Boolean asBoolean();
/**
* @return a Float representation of the property value, or
* <code>null</code> if not set
* @throws NumberFormatException if not able to parse
*/
- public Float asFloat();
+ Float asFloat();
/**
* @return a Double representation of the property value, of
* <code>null</code> if not set
* @throws NumberFormatException if not able to parse
*/
- public Double asDouble();
+ Double asDouble();
/**
* @param timeUnit specifies the TimeUnit to convert the time duration into
@@ -78,7 +78,7 @@ public interface PropertyValue {
* in terms of the specified TimeUnit; if the property is not set, returns
* <code>null</code>
*/
- public Long asTimePeriod(TimeUnit timeUnit);
+ Long asTimePeriod(TimeUnit timeUnit);
/**
*
@@ -87,14 +87,14 @@ public interface PropertyValue {
* in terms of the specified DataUnit; if hte property is not set, returns
* <code>null</code>
*/
- public Double asDataSize(DataUnit dataUnit);
+ Double asDataSize(DataUnit dataUnit);
/**
* @return the ControllerService whose identifier is the raw value of
* <code>this</code>, or <code>null</code> if either the value is not set or
* the value does not identify a ControllerService
*/
- public ControllerService asControllerService();
+ ControllerService asControllerService();
/**
* @param <T> the generic type of the controller service
@@ -110,14 +110,14 @@ public interface PropertyValue {
* <code>serviceType</code> or if <code>serviceType</code> references a
* class that is not an interface
*/
- public <T extends ControllerService> T asControllerService(Class<T> serviceType) throws IllegalArgumentException;
+ <T extends ControllerService> T asControllerService(Class<T> serviceType) throws IllegalArgumentException;
/**
* @return <code>true</code> if the user has configured a value, or if the
* {@link PropertyDescriptor} for the associated property has a default
* value, <code>false</code> otherwise
*/
- public boolean isSet();
+ boolean isSet();
/**
* <p>
@@ -132,7 +132,7 @@ public interface PropertyValue {
* @throws ProcessException if the Expression cannot be compiled or evaluating
* the Expression against the given attributes causes an Exception to be thrown
*/
- public PropertyValue evaluateAttributeExpressions() throws ProcessException;
+ PropertyValue evaluateAttributeExpressions() throws ProcessException;
/**
* <p>
@@ -148,7 +148,7 @@ public interface PropertyValue {
* @throws ProcessException if the Expression cannot be compiled or evaluating the Expression against
* the given attributes causes an Exception to be thrown
*/
- public PropertyValue evaluateAttributeExpressions(Map<String, String> attributes) throws ProcessException;
+ PropertyValue evaluateAttributeExpressions(Map<String, String> attributes) throws ProcessException;
/**
* <p>
@@ -167,7 +167,7 @@ public interface PropertyValue {
* @throws ProcessException if the Expression cannot be compiled or evaluating the Expression against
* the given attributes causes an Exception to be thrown
*/
- public PropertyValue evaluateAttributeExpressions(Map<String, String> attributes, AttributeValueDecorator decorator) throws ProcessException;
+ PropertyValue evaluateAttributeExpressions(Map<String, String> attributes, AttributeValueDecorator decorator) throws ProcessException;
/**
* <p>
@@ -183,7 +183,7 @@ public interface PropertyValue {
* @throws ProcessException if the Expression cannot be compiled or evaluating
* the Expression against the given attributes causes an Exception to be thrown
*/
- public PropertyValue evaluateAttributeExpressions(FlowFile flowFile) throws ProcessException;
+ PropertyValue evaluateAttributeExpressions(FlowFile flowFile) throws ProcessException;
/**
* <p>
@@ -202,7 +202,7 @@ public interface PropertyValue {
* @throws ProcessException if the Expression cannot be compiled or evaluating
* the Expression against the given attributes causes an Exception to be thrown
*/
- public PropertyValue evaluateAttributeExpressions(FlowFile flowFile, Map<String, String> additionalAttributes) throws ProcessException;
+ PropertyValue evaluateAttributeExpressions(FlowFile flowFile, Map<String, String> additionalAttributes) throws ProcessException;
/**
* <p>
@@ -222,7 +222,7 @@ public interface PropertyValue {
* @throws ProcessException if the Expression cannot be compiled or evaluating
* the Expression against the given attributes causes an Exception to be thrown
*/
- public PropertyValue evaluateAttributeExpressions(FlowFile flowFile, Map<String, String> additionalAttributes, AttributeValueDecorator decorator) throws ProcessException;
+ PropertyValue evaluateAttributeExpressions(FlowFile flowFile, Map<String, String> additionalAttributes, AttributeValueDecorator decorator) throws ProcessException;
/**
* <p>
@@ -240,7 +240,7 @@ public interface PropertyValue {
* @throws ProcessException if the Expression cannot be compiled or evaluating
* the Expression against the given attributes causes an Exception to be thrown
*/
- public PropertyValue evaluateAttributeExpressions(AttributeValueDecorator decorator) throws ProcessException;
+ PropertyValue evaluateAttributeExpressions(AttributeValueDecorator decorator) throws ProcessException;
/**
* <p>
@@ -260,5 +260,5 @@ public interface PropertyValue {
* @throws ProcessException if the Expression cannot be compiled or evaluating
* the Expression against the given attributes causes an Exception to be thrown
*/
- public PropertyValue evaluateAttributeExpressions(FlowFile flowFile, AttributeValueDecorator decorator) throws ProcessException;
+ PropertyValue evaluateAttributeExpressions(FlowFile flowFile, AttributeValueDecorator decorator) throws ProcessException;
}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-api/src/main/java/org/apache/nifi/components/state/StateProvider.java
----------------------------------------------------------------------
diff --git a/nifi-api/src/main/java/org/apache/nifi/components/state/StateProvider.java b/nifi-api/src/main/java/org/apache/nifi/components/state/StateProvider.java
deleted file mode 100644
index e1e4352..0000000
--- a/nifi-api/src/main/java/org/apache/nifi/components/state/StateProvider.java
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- * 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.components.state;
-
-import java.io.IOException;
-import java.util.Map;
-
-import org.apache.nifi.components.ConfigurableComponent;
-
-/**
- * <p>
- * Provides a mechanism by which components can store and retrieve state. Depending on the Provider, the state
- * may be stored locally, or it may be stored on a remote resource.
- * </p>
- *
- * <p>
- * Which implementation should be used for local and clustered state is configured in the NiFi properties file.
- * It is therefore possible to provide custom implementations of this interface. Note, however, that this interface
- * is new as of version 0.5.0 of Apache NiFi and may not be considered "stable" as of yet. Therefore, it is subject
- * to change without notice, so providing custom implementations is cautioned against until the API becomes more stable.
- * </p>
- *
- * @since 0.5.0
- */
-public interface StateProvider extends ConfigurableComponent {
-
- /**
- * Initializes the StateProvider so that it is capable of being used. This method will be called
- * once before any of the other methods are called and will not be called again until the {@link #shutdown()}
- * method has been called
- *
- * @param context the initialization context that can be used to prepare the state provider for use
- */
- void initialize(StateProviderInitializationContext context) throws IOException;
-
- /**
- * Shuts down the StateProvider and cleans up any resources held by it. Once this method has returned, the
- * StateProvider may be initialized once again via the {@link #initialize(StateProviderInitializationContext)} method.
- */
- void shutdown();
-
- /**
- * Updates the value of the component's state, setting the new value to the
- * given state
- *
- * @param state the value to change the state to
- * @param componentId the id of the component for which state is being set
- *
- * @throws IOException if unable to communicate with the underlying storage mechanism
- */
- void setState(Map<String, String> state, String componentId) throws IOException;
-
-
- /**
- * Returns the currently configured state for the component. The returned StateMap will never be null.
- * The version of the StateMap will be -1 and the state will contain no key/value pairs if the state has never been set.
- *
- * @param componentId the id of the component for which state is to be retrieved
- * @return the currently configured value for the component's state
- *
- * @throws IOException if unable to communicate with the underlying storage mechanism
- */
- StateMap getState(String componentId) throws IOException;
-
-
- /**
- * Updates the value of the component's state to the new value if and only if the value currently
- * is the same as the given oldValue.
- *
- * @param oldValue the old value to compare against
- * @param newValue the new value to use if and only if the state's value is the same as the given oldValue
- * @param componentId the id of the component for which state is being retrieved
- * @return <code>true</code> if the state was updated to the new value, <code>false</code> if the state's value was not
- * equal to oldValue
- *
- * @throws IOException if unable to communicate with the underlying storage mechanism
- */
- boolean replace(StateMap oldValue, Map<String, String> newValue, String componentId) throws IOException;
-
- /**
- * Removes all values from the component's state that is stored using the given scope
- *
- * @param componentId the id of the component for which state is being cleared
- *
- * @throws IOException if unable to communicate with the underlying storage mechanism
- */
- void clear(String componentId) throws IOException;
-
- /**
- * This method is called whenever a component is removed from the NiFi instance. This allows the State Provider to
- * perform tasks when a component is removed in order to clean up resources that may be associated with that component
- *
- * @param componentId the ID of the component that was added to the NiFi instance
- * @throws IOException if unable to perform the necessary cleanup
- */
- void onComponentRemoved(String componentId) throws IOException;
-
- /**
- * Notifies the state provider that it should begin servicing requests to store and retrieve state
- */
- void enable();
-
- /**
- * Notifies the state provider that it should stop servicing requests to store and retrieve state and instead throw a ProviderDisabledException if any request is made to do so
- */
- void disable();
-
- /**
- * @return <code>true</code> if the provider is enabled, <code>false</code> otherwise.
- */
- boolean isEnabled();
-
- /**
- * Provides a listing of {@link Scope}s supported by the StateProvider
- * @return the {@link Scope}s supported by the configuration
- */
- Scope[] getSupportedScopes();
-}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-api/src/main/java/org/apache/nifi/components/state/StateProviderInitializationContext.java
----------------------------------------------------------------------
diff --git a/nifi-api/src/main/java/org/apache/nifi/components/state/StateProviderInitializationContext.java b/nifi-api/src/main/java/org/apache/nifi/components/state/StateProviderInitializationContext.java
deleted file mode 100644
index aaf5490..0000000
--- a/nifi-api/src/main/java/org/apache/nifi/components/state/StateProviderInitializationContext.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * 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.components.state;
-
-import java.util.Map;
-
-import javax.net.ssl.SSLContext;
-
-import org.apache.nifi.components.PropertyDescriptor;
-import org.apache.nifi.components.PropertyValue;
-
-/**
- * This interface defines an initialization context that is passed to a {@link StateProvider} when it
- * is initialized.
- */
-public interface StateProviderInitializationContext {
- /**
- * @return the identifier if the StateProvider
- */
- String getIdentifier();
-
- /**
- * @return a Map of Property Descriptors to their configured values
- */
- Map<PropertyDescriptor, PropertyValue> getProperties();
-
- /**
- * Returns the configured value for the given property
- *
- * @param property the property to retrieve the value for
- *
- * @return the configured value for the property.
- */
- PropertyValue getProperty(PropertyDescriptor property);
-
- /**
- * @return the SSL Context that should be used to communicate with remote resources,
- * or <code>null</code> if no SSLContext has been configured
- */
- SSLContext getSSLContext();
-}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-api/src/main/java/org/apache/nifi/components/state/exception/StateTooLargeException.java
----------------------------------------------------------------------
diff --git a/nifi-api/src/main/java/org/apache/nifi/components/state/exception/StateTooLargeException.java b/nifi-api/src/main/java/org/apache/nifi/components/state/exception/StateTooLargeException.java
index 99546ae..5461b40 100644
--- a/nifi-api/src/main/java/org/apache/nifi/components/state/exception/StateTooLargeException.java
+++ b/nifi-api/src/main/java/org/apache/nifi/components/state/exception/StateTooLargeException.java
@@ -17,6 +17,8 @@
package org.apache.nifi.components.state.exception;
+import org.apache.nifi.components.state.StateManager;
+
import java.io.IOException;
/**
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-api/src/main/java/org/apache/nifi/controller/Snippet.java
----------------------------------------------------------------------
diff --git a/nifi-api/src/main/java/org/apache/nifi/controller/Snippet.java b/nifi-api/src/main/java/org/apache/nifi/controller/Snippet.java
deleted file mode 100644
index 702b7cd..0000000
--- a/nifi-api/src/main/java/org/apache/nifi/controller/Snippet.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * 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.controller;
-
-import org.apache.nifi.web.Revision;
-
-import java.util.Map;
-
-/**
- * A Snippet represents a segment of the flow
- */
-public interface Snippet {
-
- /**
- * @return id of this snippet
- */
- public String getId();
-
- /**
- * @return parent group id of the components in this snippet
- */
- public String getParentGroupId();
-
- /**
- * @return connections in this snippet
- */
- public Map<String, Revision> getConnections();
-
- /**
- * @return funnels in this snippet
- */
- public Map<String, Revision> getFunnels();
-
- /**
- * @return input ports in this snippet
- */
- public Map<String, Revision> getInputPorts();
-
- /**
- * @return output ports in this snippet
- */
- public Map<String, Revision> getOutputPorts();
-
- /**
- * @return labels in this snippet
- */
- public Map<String, Revision> getLabels();
-
- /**
- * @return the identifiers of all ProcessGroups in this Snippet
- */
- public Map<String, Revision> getProcessGroups();
-
- /**
- * @return the identifiers of all Processors in this Snippet
- */
- public Map<String, Revision> getProcessors();
-
- /**
- * @return the identifiers of all RemoteProcessGroups in this Snippet
- */
- public Map<String, Revision> getRemoteProcessGroups();
-
- /**
- * @return Determines if this snippet is empty
- */
- public boolean isEmpty();
-
-}
[02/10] nifi git commit: NIFI-1896 This closes #650. Refactored
nifi-api into nifi-framework-api and other locations. The nifi-api is
specific to that which is needed for intended extension points.
Posted by jo...@apache.org.
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-framework-api/src/main/java/org/apache/nifi/web/ComponentDescriptor.java
----------------------------------------------------------------------
diff --git a/nifi-framework-api/src/main/java/org/apache/nifi/web/ComponentDescriptor.java b/nifi-framework-api/src/main/java/org/apache/nifi/web/ComponentDescriptor.java
new file mode 100644
index 0000000..9412ee1
--- /dev/null
+++ b/nifi-framework-api/src/main/java/org/apache/nifi/web/ComponentDescriptor.java
@@ -0,0 +1,93 @@
+/*
+ * 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.web;
+
+import java.util.Map;
+
+public class ComponentDescriptor {
+
+ private final String name;
+ private final String displayName;
+ private final String description;
+ private final String defaultValue;
+ private final Map<String,String> allowableValues;
+
+ private ComponentDescriptor(Builder builder){
+ this.name = builder.name;
+ this.displayName = builder.displayName;
+ this.description = builder.description;
+ this.defaultValue = builder.defaultValue;
+ this.allowableValues = builder.allowableValues;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public String getDisplayName() {
+ return displayName;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public String getDefaultValue() {
+ return defaultValue;
+ }
+
+ public Map<String,String> getAllowableValues() {
+ return allowableValues;
+ }
+
+ public static final class Builder{
+ private String name;
+ private String displayName;
+ private String description;
+ private String defaultValue;
+ private Map<String,String> allowableValues;
+
+ public Builder name(String name){
+ this.name = name;
+ return this;
+ }
+
+ public Builder displayName(String displayName){
+ this.displayName = displayName;
+ return this;
+ }
+
+ public Builder description(String description){
+ this.description = description;
+ return this;
+ }
+
+ public Builder defaultValue(String defaultValue){
+ this.defaultValue = defaultValue;
+ return this;
+ }
+
+ public Builder allowableValues(Map<String,String> allowableValues){
+ this.allowableValues = allowableValues;
+ return this;
+ }
+
+ public ComponentDescriptor build(){
+ return new ComponentDescriptor(this);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-framework-api/src/main/java/org/apache/nifi/web/ComponentDetails.java
----------------------------------------------------------------------
diff --git a/nifi-framework-api/src/main/java/org/apache/nifi/web/ComponentDetails.java b/nifi-framework-api/src/main/java/org/apache/nifi/web/ComponentDetails.java
new file mode 100644
index 0000000..9d163e4
--- /dev/null
+++ b/nifi-framework-api/src/main/java/org/apache/nifi/web/ComponentDetails.java
@@ -0,0 +1,163 @@
+/*
+ * 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.web;
+
+import java.util.Collection;
+import java.util.Map;
+
+/**
+ * Details about a given component. Contains configuration and current
+ * validation errors.
+ */
+public class ComponentDetails {
+
+ private final String id;
+ private final String name;
+ private final String type;
+ private final String state;
+ private final String annotationData;
+ private final Map<String, String> properties;
+ private final Map<String, ComponentDescriptor> descriptors;
+
+ private final Collection<String> validationErrors;
+
+ private ComponentDetails(final Builder builder) {
+ this.id = builder.id;
+ this.name = builder.name;
+ this.type = builder.type;
+ this.state = builder.state;
+ this.annotationData = builder.annotationData;
+ this.properties = builder.properties;
+ this.descriptors = builder.descriptors;
+ this.validationErrors = builder.validationErrors;
+
+ }
+
+ /**
+ * @return component id
+ */
+ public String getId() {
+ return id;
+ }
+
+ /**
+ * @return component name
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * @return component type
+ */
+ public String getType() {
+ return type;
+ }
+
+ /**
+ * @return component state
+ */
+ public String getState() {
+ return state;
+ }
+
+ /**
+ * @return component's annotation data
+ */
+ public String getAnnotationData() {
+ return annotationData;
+ }
+
+ /**
+ * @return Mapping of component properties
+ */
+ public Map<String, String> getProperties() {
+ return properties;
+ }
+
+
+ /**
+ * @return Mapping of component descriptors
+ */
+ public Map<String,ComponentDescriptor> getDescriptors(){
+ return descriptors;
+ }
+
+ /**
+ * @return Current validation errors for the component
+ */
+ public Collection<String> getValidationErrors() {
+ return validationErrors;
+ }
+
+ public static final class Builder {
+
+ private String id;
+ private String name;
+ private String type;
+ private String state;
+ private String annotationData;
+ private Map<String, String> properties;
+ private Map<String,ComponentDescriptor> descriptors;
+
+ private Collection<String> validationErrors;
+
+ public Builder id(final String id) {
+ this.id = id;
+ return this;
+ }
+
+ public Builder name(final String name) {
+ this.name = name;
+ return this;
+ }
+
+ public Builder type(final String type) {
+ this.type = type;
+ return this;
+ }
+
+ public Builder state(final String state) {
+ this.state = state;
+ return this;
+ }
+
+ public Builder annotationData(final String annotationData) {
+ this.annotationData = annotationData;
+ return this;
+ }
+
+ public Builder properties(final Map<String, String> properties) {
+ this.properties = properties;
+ return this;
+ }
+
+ public Builder validateErrors(final Collection<String> validationErrors) {
+ this.validationErrors = validationErrors;
+ return this;
+ }
+
+ public Builder descriptors(final Map<String,ComponentDescriptor> descriptors){
+ this.descriptors = descriptors;
+ return this;
+ }
+
+ public ComponentDetails build() {
+ return new ComponentDetails(this);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-framework-api/src/main/java/org/apache/nifi/web/ConfigurationAction.java
----------------------------------------------------------------------
diff --git a/nifi-framework-api/src/main/java/org/apache/nifi/web/ConfigurationAction.java b/nifi-framework-api/src/main/java/org/apache/nifi/web/ConfigurationAction.java
new file mode 100644
index 0000000..96f2abf
--- /dev/null
+++ b/nifi-framework-api/src/main/java/org/apache/nifi/web/ConfigurationAction.java
@@ -0,0 +1,125 @@
+/*
+ * 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.web;
+
+/**
+ * An action that represents the configuration of a component.
+ */
+public class ConfigurationAction {
+
+ private final String id;
+ private final String name;
+ private final String type;
+ private final String field;
+ private final String previousValue;
+ private final String value;
+
+ private ConfigurationAction(final Builder builder) {
+ this.id = builder.id;
+ this.name = builder.name;
+ this.type = builder.type;
+ this.field = builder.field;
+ this.previousValue = builder.previousValue;
+ this.value = builder.value;
+ }
+
+ /**
+ * @return id of the component being modified
+ */
+ public String getId() {
+ return id;
+ }
+
+ /**
+ * @return name of the component being modified
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * @return type of the component being modified
+ */
+ public String getType() {
+ return type;
+ }
+
+ /**
+ * @return the name of the field, property, etc that has been modified
+ */
+ public String getField() {
+ return field;
+ }
+
+ /**
+ * @return the previous value
+ */
+ public String getPreviousValue() {
+ return previousValue;
+ }
+
+ /**
+ * @return the new value
+ */
+ public String getValue() {
+ return value;
+ }
+
+ public static class Builder {
+
+ private String id;
+ private String name;
+ private String type;
+ private String field;
+ private String previousValue;
+ private String value;
+
+ public Builder id(final String id) {
+ this.id = id;
+ return this;
+ }
+
+ public Builder name(final String name) {
+ this.name = name;
+ return this;
+ }
+
+ public Builder type(final String type) {
+ this.type = type;
+ return this;
+ }
+
+ public Builder field(final String field) {
+ this.field = field;
+ return this;
+ }
+
+ public Builder previousValue(final String previousValue) {
+ this.previousValue = previousValue;
+ return this;
+ }
+
+ public Builder value(final String value) {
+ this.value = value;
+ return this;
+ }
+
+ public ConfigurationAction build() {
+ return new ConfigurationAction(this);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-framework-api/src/main/java/org/apache/nifi/web/InvalidRevisionException.java
----------------------------------------------------------------------
diff --git a/nifi-framework-api/src/main/java/org/apache/nifi/web/InvalidRevisionException.java b/nifi-framework-api/src/main/java/org/apache/nifi/web/InvalidRevisionException.java
new file mode 100644
index 0000000..8e04f69
--- /dev/null
+++ b/nifi-framework-api/src/main/java/org/apache/nifi/web/InvalidRevisionException.java
@@ -0,0 +1,33 @@
+/*
+ * 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.web;
+
+/**
+ * Exception indicating that the client has included an old revision in their
+ * request.
+ */
+@SuppressWarnings("serial")
+public class InvalidRevisionException extends RuntimeException {
+
+ public InvalidRevisionException(String message) {
+ super(message);
+ }
+
+ public InvalidRevisionException(String message, Throwable cause) {
+ super(message, cause);
+ }
+}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-framework-api/src/main/java/org/apache/nifi/web/NiFiWebConfigurationContext.java
----------------------------------------------------------------------
diff --git a/nifi-framework-api/src/main/java/org/apache/nifi/web/NiFiWebConfigurationContext.java b/nifi-framework-api/src/main/java/org/apache/nifi/web/NiFiWebConfigurationContext.java
new file mode 100644
index 0000000..5082af2
--- /dev/null
+++ b/nifi-framework-api/src/main/java/org/apache/nifi/web/NiFiWebConfigurationContext.java
@@ -0,0 +1,99 @@
+/*
+ * 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.web;
+
+import org.apache.nifi.controller.ControllerService;
+
+import java.util.Collection;
+import java.util.Map;
+
+/**
+ * NiFi web context providing limited access to dataflow configuration for
+ * component custom UIs.
+ */
+public interface NiFiWebConfigurationContext {
+
+ /**
+ * @param serviceIdentifier of the controller service
+ * @param componentId the id of the component that is referencing the controller service
+ * @return the ControllerService for the specified identifier. If a
+ * corresponding service cannot be found, null is returned. If this NiFi is
+ * clustered, the only services available will be those those availability
+ * is NCM only
+ */
+ ControllerService getControllerService(String serviceIdentifier, String componentId);
+
+ /**
+ * Provides a mechanism for custom UIs to save actions to appear in NiFi
+ * configuration history. Note all fields within each Action must be
+ * populated. Null values will result in a failure to insert the audit
+ * record. Since the saving to these actions is separate from the actual
+ * configuration change, a failure to insert here will just generate a
+ * warning log message. The recording of these actions typically happens
+ * after a configuration change is applied. Since those changes have already
+ * been applied to the flow, we cannot revert them because of a failure to
+ * insert an audit record.
+ *
+ * @param requestContext context of the request
+ * @param actions to save
+ * @throws IllegalArgumentException When the requestContext isn't fully
+ * populated or isn't appropriate for the given request
+ */
+ void saveActions(NiFiWebRequestContext requestContext, Collection<ConfigurationAction> actions);
+
+ /**
+ * @return the current user identity. The value may be a DN, an email, a username, or any string that identities the user. Returns null if no user is found
+ */
+ String getCurrentUserIdentity();
+
+ /**
+ * Sets the annotation data for the underlying component.
+ *
+ * @param configurationContext config context
+ * @param annotationData the data
+ * @param properties component properties
+ * @return the configuration for the underlying component
+ * @throws ResourceNotFoundException if the underlying component does not
+ * exit
+ * @throws InvalidRevisionException if a revision other than the current
+ * revision is given
+ * @throws ClusterRequestException if the annotation data was unable to be
+ * set for the underlying component. This exception will only be thrown when
+ * operating in a cluster.
+ * @throws IllegalArgumentException When the requestContext isn't fully
+ * populated or isn't appropriate for the given request
+ */
+ ComponentDetails updateComponent(NiFiWebConfigurationRequestContext configurationContext, String annotationData, Map<String, String> properties)
+ throws ResourceNotFoundException, InvalidRevisionException, ClusterRequestException;
+
+
+ /**
+ * Gets the details for the underlying component (including configuration,
+ * validation errors, and annotation data).
+ *
+ * @param requestContext context of request
+ * @return the configuration for the underlying component
+ * @throws ResourceNotFoundException if the underlying component does not
+ * exit
+ * @throws ClusterRequestException if the underlying component was unable to
+ * be retrieved from the cluster. This exception will only be thrown when
+ * operating in a cluster.
+ * @throws IllegalArgumentException When the requestContext isn't fully
+ * populated or isn't appropriate for the given request
+ */
+ ComponentDetails getComponentDetails(NiFiWebRequestContext requestContext) throws ResourceNotFoundException, ClusterRequestException;
+}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-framework-api/src/main/java/org/apache/nifi/web/NiFiWebConfigurationRequestContext.java
----------------------------------------------------------------------
diff --git a/nifi-framework-api/src/main/java/org/apache/nifi/web/NiFiWebConfigurationRequestContext.java b/nifi-framework-api/src/main/java/org/apache/nifi/web/NiFiWebConfigurationRequestContext.java
new file mode 100644
index 0000000..c75d9dc
--- /dev/null
+++ b/nifi-framework-api/src/main/java/org/apache/nifi/web/NiFiWebConfigurationRequestContext.java
@@ -0,0 +1,32 @@
+/*
+ * 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.web;
+
+/**
+ * Contextual details required to make a configuration request from a UI
+ * extension.
+ */
+public interface NiFiWebConfigurationRequestContext extends NiFiWebRequestContext {
+
+ /**
+ * The revision to include in the request.
+ *
+ * @return the revision
+ */
+ Revision getRevision();
+
+}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-framework-api/src/main/java/org/apache/nifi/web/NiFiWebRequestContext.java
----------------------------------------------------------------------
diff --git a/nifi-framework-api/src/main/java/org/apache/nifi/web/NiFiWebRequestContext.java b/nifi-framework-api/src/main/java/org/apache/nifi/web/NiFiWebRequestContext.java
new file mode 100644
index 0000000..9dd44ab
--- /dev/null
+++ b/nifi-framework-api/src/main/java/org/apache/nifi/web/NiFiWebRequestContext.java
@@ -0,0 +1,56 @@
+/*
+ * 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.web;
+
+/**
+ * Contextual details required to make a request from a UI extension.
+ */
+public interface NiFiWebRequestContext {
+
+ /**
+ * @return the type of UI extension is making the request
+ */
+ UiExtensionType getExtensionType();
+
+ /**
+ * The request protocol scheme (http or https). When scheme is https, the
+ * X509Certificate can be used for subsequent remote requests.
+ *
+ * @return the protocol scheme
+ */
+ String getScheme();
+
+ /**
+ * The id of the component.
+ *
+ * @return the ID
+ */
+ String getId();
+
+ /**
+ * Returns the proxied entities chain. The format of the chain is as
+ * follows:
+ *
+ * <code>
+ * <CN=original-proxied-entity><CN=first-proxy><CN=second-proxy>...
+ * </code>
+ *
+ * @return the proxied entities chain or null if no chain
+ */
+ String getProxiedEntitiesChain();
+
+}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-framework-api/src/main/java/org/apache/nifi/web/ResourceNotFoundException.java
----------------------------------------------------------------------
diff --git a/nifi-framework-api/src/main/java/org/apache/nifi/web/ResourceNotFoundException.java b/nifi-framework-api/src/main/java/org/apache/nifi/web/ResourceNotFoundException.java
new file mode 100644
index 0000000..b2f2e57
--- /dev/null
+++ b/nifi-framework-api/src/main/java/org/apache/nifi/web/ResourceNotFoundException.java
@@ -0,0 +1,32 @@
+/*
+ * 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.web;
+
+/**
+ * Exception indicating that the desired resource was not found.
+ */
+@SuppressWarnings("serial")
+public class ResourceNotFoundException extends RuntimeException {
+
+ public ResourceNotFoundException(String message) {
+ super(message);
+ }
+
+ public ResourceNotFoundException(String message, Throwable cause) {
+ super(message, cause);
+ }
+}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-framework-api/src/main/java/org/apache/nifi/web/Revision.java
----------------------------------------------------------------------
diff --git a/nifi-framework-api/src/main/java/org/apache/nifi/web/Revision.java b/nifi-framework-api/src/main/java/org/apache/nifi/web/Revision.java
new file mode 100644
index 0000000..d768faa
--- /dev/null
+++ b/nifi-framework-api/src/main/java/org/apache/nifi/web/Revision.java
@@ -0,0 +1,129 @@
+/*
+ * 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.web;
+
+import java.io.Serializable;
+
+/**
+ * A model object representing a revision. Equality is defined as matching
+ * component ID and either a matching version number or matching non-empty client IDs.
+ *
+ * @Immutable
+ * @Threadsafe
+ */
+public class Revision implements Serializable {
+ private static final long serialVersionUID = 988658790374170022L;
+
+ /**
+ * the version number
+ */
+ private final Long version;
+
+ /**
+ * the client ID
+ */
+ private final String clientId;
+
+ /**
+ * the ID of the component that this revision belongs to, or <code>null</code> if
+ * the revision is not attached to any component but rather is attached to the entire
+ * data flow.
+ */
+ private final String componentId;
+
+ public Revision(Long version, String clientId, String componentId) {
+ if (version == null) {
+ throw new IllegalArgumentException("The revision must be specified.");
+ }
+ if (componentId == null) {
+ throw new IllegalArgumentException("The componentId must be specified.");
+ }
+
+ this.version = version;
+ this.clientId = clientId;
+ this.componentId = componentId;
+ }
+
+ public String getClientId() {
+ return clientId;
+ }
+
+ public Long getVersion() {
+ return version;
+ }
+
+ public String getComponentId() {
+ return componentId;
+ }
+
+ /**
+ * Returns a new Revision that has the same Client ID and Component ID as this one
+ * but with a larger version
+ *
+ * @return the updated Revision
+ */
+ public Revision incrementRevision(final String clientId) {
+ return new Revision(version + 1, clientId, componentId);
+ }
+
+ @Override
+ public boolean equals(final Object obj) {
+ if (obj == null) {
+ return false;
+ }
+ if (obj == this) {
+ return true;
+ }
+
+ if ((obj instanceof Revision) == false) {
+ return false;
+ }
+
+ Revision thatRevision = (Revision) obj;
+ // ensure that component ID's are the same (including null)
+ if (thatRevision.getComponentId() == null && getComponentId() != null) {
+ return false;
+ }
+ if (thatRevision.getComponentId() != null && getComponentId() == null) {
+ return false;
+ }
+ if (thatRevision.getComponentId() != null && !thatRevision.getComponentId().equals(getComponentId())) {
+ return false;
+ }
+
+ if (this.version != null && this.version.equals(thatRevision.version)) {
+ return true;
+ } else {
+ return clientId != null && !clientId.trim().isEmpty() && clientId.equals(thatRevision.getClientId());
+ }
+
+ }
+
+ @Override
+ public int hashCode() {
+ int hash = 5;
+ hash = 59 * hash + (this.componentId != null ? this.componentId.hashCode() : 0);
+ hash = 59 * hash + (this.version != null ? this.version.hashCode() : 0);
+ hash = 59 * hash + (this.clientId != null ? this.clientId.hashCode() : 0);
+ return hash;
+ }
+
+ @Override
+ public String toString() {
+ return "[" + version + ", " + clientId + ", " + componentId + ']';
+ }
+}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-framework-api/src/main/java/org/apache/nifi/web/UiExtensionType.java
----------------------------------------------------------------------
diff --git a/nifi-framework-api/src/main/java/org/apache/nifi/web/UiExtensionType.java b/nifi-framework-api/src/main/java/org/apache/nifi/web/UiExtensionType.java
new file mode 100644
index 0000000..e3b0f8a
--- /dev/null
+++ b/nifi-framework-api/src/main/java/org/apache/nifi/web/UiExtensionType.java
@@ -0,0 +1,32 @@
+/*
+ * 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.web;
+
+/**
+ * Types of UI extensions. Since a UI extension could support multiple types of
+ * custom UIs it will need to include the type so the framework can appropriate
+ * understand and process the request (recording actions in the audit database,
+ * replicating a request throughout the cluster to the appropriate endpoints,
+ * etc).
+ */
+public enum UiExtensionType {
+
+ ContentViewer,
+ ProcessorConfiguration,
+ ControllerServiceConfiguration,
+ ReportingTaskConfiguration
+}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-framework-api/src/main/java/org/apache/nifi/web/ViewableContent.java
----------------------------------------------------------------------
diff --git a/nifi-framework-api/src/main/java/org/apache/nifi/web/ViewableContent.java b/nifi-framework-api/src/main/java/org/apache/nifi/web/ViewableContent.java
new file mode 100644
index 0000000..d506b5d
--- /dev/null
+++ b/nifi-framework-api/src/main/java/org/apache/nifi/web/ViewableContent.java
@@ -0,0 +1,71 @@
+/*
+ * 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.web;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+/**
+ * Interface for obtaining content from the NiFi content repository.
+ */
+public interface ViewableContent {
+
+ public static final String CONTENT_REQUEST_ATTRIBUTE = "org.apache.nifi.web.content";
+
+ public enum DisplayMode {
+
+ Original,
+ Formatted,
+ Hex;
+ }
+
+ /**
+ * @return stream to the viewable content. The data stream can only be read once
+ * so an extension can call this method or getContent
+ */
+ InputStream getContentStream();
+
+ /**
+ * @return the content as a string. The data stream can only be read once so an
+ * extension can call this method or getContentStream
+ * @throws java.io.IOException if unable to read content
+ */
+ String getContent() throws IOException;
+
+ /**
+ * @return the desired display mode. If the mode is Hex the framework will
+ * handle generating the mark up. The only values that an extension will see
+ * is Original or Formatted
+ */
+ DisplayMode getDisplayMode();
+
+ /**
+ * @return contents file name
+ */
+ String getFileName();
+
+ /**
+ * @return mime type of the content, value is lowercase and stripped of all parameters if there were any
+ */
+ String getContentType();
+
+ /**
+ * @return unchanged mime type of the content
+ */
+ String getRawContentType();
+
+}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-framework-api/src/test/java/org/apache/nifi/authorization/TestAbstractPolicyBasedAuthorizer.java
----------------------------------------------------------------------
diff --git a/nifi-framework-api/src/test/java/org/apache/nifi/authorization/TestAbstractPolicyBasedAuthorizer.java b/nifi-framework-api/src/test/java/org/apache/nifi/authorization/TestAbstractPolicyBasedAuthorizer.java
new file mode 100644
index 0000000..b173d3d
--- /dev/null
+++ b/nifi-framework-api/src/test/java/org/apache/nifi/authorization/TestAbstractPolicyBasedAuthorizer.java
@@ -0,0 +1,447 @@
+/*
+ * 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.authorization;
+
+import org.apache.nifi.authorization.exception.AuthorizationAccessException;
+import org.apache.nifi.authorization.exception.AuthorizerCreationException;
+import org.apache.nifi.authorization.exception.AuthorizerDestructionException;
+import org.junit.Assert;
+import org.junit.Test;
+import org.mockito.Mockito;
+
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.LinkedHashSet;
+import java.util.Set;
+
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Mockito.when;
+
+public class TestAbstractPolicyBasedAuthorizer {
+
+ static final Resource TEST_RESOURCE = new Resource() {
+ @Override
+ public String getIdentifier() {
+ return "1";
+ }
+
+ @Override
+ public String getName() {
+ return "resource1";
+ }
+ };
+
+ @Test
+ public void testApproveBasedOnUser() {
+ AbstractPolicyBasedAuthorizer authorizer = Mockito.mock(AbstractPolicyBasedAuthorizer.class);
+ UsersAndAccessPolicies usersAndAccessPolicies = Mockito.mock(UsersAndAccessPolicies.class);
+ when(authorizer.getUsersAndAccessPolicies()).thenReturn(usersAndAccessPolicies);
+
+ final String userIdentifier = "userIdentifier1";
+ final String userIdentity = "userIdentity1";
+
+ final AccessPolicy policy = new AccessPolicy.Builder()
+ .identifier("1")
+ .resource(TEST_RESOURCE.getIdentifier())
+ .addUser(userIdentifier)
+ .action(RequestAction.READ)
+ .build();
+
+ when(usersAndAccessPolicies.getAccessPolicy(TEST_RESOURCE.getIdentifier(), RequestAction.READ)).thenReturn(policy);
+
+ final User user = new User.Builder()
+ .identity(userIdentity)
+ .identifier(userIdentifier)
+ .build();
+
+ when(usersAndAccessPolicies.getUser(userIdentity)).thenReturn(user);
+
+ final AuthorizationRequest request = new AuthorizationRequest.Builder()
+ .identity(userIdentity)
+ .resource(TEST_RESOURCE)
+ .action(RequestAction.READ)
+ .accessAttempt(true)
+ .anonymous(false)
+ .build();
+
+ assertEquals(AuthorizationResult.approved(), authorizer.authorize(request));
+ }
+
+ @Test
+ public void testApprovedBasedOnGroup() {
+ AbstractPolicyBasedAuthorizer authorizer = Mockito.mock(AbstractPolicyBasedAuthorizer.class);
+ UsersAndAccessPolicies usersAndAccessPolicies = Mockito.mock(UsersAndAccessPolicies.class);
+ when(authorizer.getUsersAndAccessPolicies()).thenReturn(usersAndAccessPolicies);
+
+ final String userIdentifier = "userIdentifier1";
+ final String userIdentity = "userIdentity1";
+ final String groupIdentifier = "groupIdentifier1";
+
+ final AccessPolicy policy = new AccessPolicy.Builder()
+ .identifier("1")
+ .resource(TEST_RESOURCE.getIdentifier())
+ .addGroup(groupIdentifier)
+ .action(RequestAction.READ)
+ .build();
+
+ when(usersAndAccessPolicies.getAccessPolicy(TEST_RESOURCE.getIdentifier(), RequestAction.READ)).thenReturn(policy);
+
+ final User user = new User.Builder()
+ .identity(userIdentity)
+ .identifier(userIdentifier)
+ .build();
+
+ when(usersAndAccessPolicies.getUser(userIdentity)).thenReturn(user);
+
+ final Group group = new Group.Builder()
+ .identifier(groupIdentifier)
+ .name(groupIdentifier)
+ .addUser(user.getIdentifier())
+ .build();
+
+ when(usersAndAccessPolicies.getGroups(userIdentity)).thenReturn(Collections.singleton(group));
+
+ final AuthorizationRequest request = new AuthorizationRequest.Builder()
+ .identity(userIdentity)
+ .resource(TEST_RESOURCE)
+ .action(RequestAction.READ)
+ .accessAttempt(true)
+ .anonymous(false)
+ .build();
+
+ assertEquals(AuthorizationResult.approved(), authorizer.authorize(request));
+ }
+
+ @Test
+ public void testDeny() {
+ AbstractPolicyBasedAuthorizer authorizer = Mockito.mock(AbstractPolicyBasedAuthorizer.class);
+ UsersAndAccessPolicies usersAndAccessPolicies = Mockito.mock(UsersAndAccessPolicies.class);
+ when(authorizer.getUsersAndAccessPolicies()).thenReturn(usersAndAccessPolicies);
+
+ final String userIdentifier = "userIdentifier1";
+ final String userIdentity = "userIdentity1";
+
+ final AccessPolicy policy = new AccessPolicy.Builder()
+ .identifier("1")
+ .resource(TEST_RESOURCE.getIdentifier())
+ .addUser("NOT_USER_1")
+ .action(RequestAction.READ)
+ .build();
+
+ when(usersAndAccessPolicies.getAccessPolicy(TEST_RESOURCE.getIdentifier(), RequestAction.READ)).thenReturn(policy);
+
+ final User user = new User.Builder()
+ .identity(userIdentity)
+ .identifier(userIdentifier)
+ .build();
+
+ when(usersAndAccessPolicies.getUser(userIdentity)).thenReturn(user);
+
+ final AuthorizationRequest request = new AuthorizationRequest.Builder()
+ .identity(userIdentity)
+ .resource(TEST_RESOURCE)
+ .action(RequestAction.READ)
+ .accessAttempt(true)
+ .anonymous(false)
+ .build();
+
+ assertEquals(AuthorizationResult.denied().getResult(), authorizer.authorize(request).getResult());
+ }
+
+ @Test
+ public void testResourceNotFound() {
+ AbstractPolicyBasedAuthorizer authorizer = Mockito.mock(AbstractPolicyBasedAuthorizer.class);
+ UsersAndAccessPolicies usersAndAccessPolicies = Mockito.mock(UsersAndAccessPolicies.class);
+ when(authorizer.getUsersAndAccessPolicies()).thenReturn(usersAndAccessPolicies);
+
+ when(usersAndAccessPolicies.getAccessPolicy(TEST_RESOURCE.getIdentifier(), RequestAction.READ)).thenReturn(null);
+
+ final AuthorizationRequest request = new AuthorizationRequest.Builder()
+ .identity("userIdentity")
+ .resource(TEST_RESOURCE)
+ .action(RequestAction.READ)
+ .accessAttempt(true)
+ .anonymous(false)
+ .build();
+
+ assertEquals(AuthorizationResult.resourceNotFound(), authorizer.authorize(request));
+ }
+
+ @Test
+ public void testGetFingerprint() {
+ // create the users, groups, and policies
+
+ User user1 = new User.Builder().identifier("user-id-1").identity("user-1").build();
+ User user2 = new User.Builder().identifier("user-id-2").identity("user-2").build();
+
+ Group group1 = new Group.Builder().identifier("group-id-1").name("group-1").addUser(user1.getIdentifier()).build();
+ Group group2 = new Group.Builder().identifier("group-id-2").name("group-2").addUser(user2.getIdentifier()).build();
+
+ AccessPolicy policy1 = new AccessPolicy.Builder()
+ .identifier("policy-id-1")
+ .resource("resource1")
+ .action(RequestAction.READ)
+ .addUser(user1.getIdentifier())
+ .addUser(user2.getIdentifier())
+ .build();
+
+ AccessPolicy policy2 = new AccessPolicy.Builder()
+ .identifier("policy-id-2")
+ .resource("resource2")
+ .action(RequestAction.READ)
+ .addGroup(group1.getIdentifier())
+ .addGroup(group2.getIdentifier())
+ .addUser(user1.getIdentifier())
+ .addUser(user2.getIdentifier())
+ .build();
+
+ // create the first Authorizer
+
+ Set<Group> groups1 = new LinkedHashSet<>();
+ groups1.add(group1);
+ groups1.add(group2);
+
+ Set<User> users1 = new LinkedHashSet<>();
+ users1.add(user1);
+ users1.add(user2);
+
+ Set<AccessPolicy> policies1 = new LinkedHashSet<>();
+ policies1.add(policy1);
+ policies1.add(policy2);
+
+ AbstractPolicyBasedAuthorizer authorizer1 = Mockito.mock(AbstractPolicyBasedAuthorizer.class);
+ when(authorizer1.getGroups()).thenReturn(groups1);
+ when(authorizer1.getUsers()).thenReturn(users1);
+ when(authorizer1.getAccessPolicies()).thenReturn(policies1);
+
+ // create the second Authorizer
+
+ Set<Group> groups2 = new LinkedHashSet<>();
+ groups2.add(group2);
+ groups2.add(group1);
+
+ Set<User> users2 = new LinkedHashSet<>();
+ users2.add(user2);
+ users2.add(user1);
+
+ Set<AccessPolicy> policies2 = new LinkedHashSet<>();
+ policies2.add(policy2);
+ policies2.add(policy1);
+
+ AbstractPolicyBasedAuthorizer authorizer2 = Mockito.mock(AbstractPolicyBasedAuthorizer.class);
+ when(authorizer2.getGroups()).thenReturn(groups2);
+ when(authorizer2.getUsers()).thenReturn(users2);
+ when(authorizer2.getAccessPolicies()).thenReturn(policies2);
+
+ // compare the fingerprints
+
+ assertEquals(authorizer1.getFingerprint(), authorizer2.getFingerprint());
+
+ System.out.println(authorizer1.getFingerprint());
+ }
+
+ @Test
+ public void testInheritFingerprint() {
+
+ User user1 = new User.Builder().identifier("user-id-1").identity("user-1").build();
+ User user2 = new User.Builder().identifier("user-id-2").identity("user-2").build();
+
+ Group group1 = new Group.Builder().identifier("group-id-1").name("group-1").addUser(user1.getIdentifier()).build();
+ Group group2 = new Group.Builder().identifier("group-id-2").name("group-2").build();
+
+ AccessPolicy policy1 = new AccessPolicy.Builder()
+ .identifier("policy-id-1")
+ .resource("resource1")
+ .action(RequestAction.READ)
+ .addUser(user1.getIdentifier())
+ .addUser(user2.getIdentifier())
+ .build();
+
+ AccessPolicy policy2 = new AccessPolicy.Builder()
+ .identifier("policy-id-2")
+ .resource("resource2")
+ .action(RequestAction.READ)
+ .addGroup(group1.getIdentifier())
+ .addGroup(group2.getIdentifier())
+ .addUser(user1.getIdentifier())
+ .addUser(user2.getIdentifier())
+ .build();
+
+ // create the first Authorizer
+
+ Set<Group> groups1 = new LinkedHashSet<>();
+ groups1.add(group1);
+ groups1.add(group2);
+
+ Set<User> users1 = new LinkedHashSet<>();
+ users1.add(user1);
+ users1.add(user2);
+
+ Set<AccessPolicy> policies1 = new LinkedHashSet<>();
+ policies1.add(policy1);
+ policies1.add(policy2);
+
+ AbstractPolicyBasedAuthorizer authorizer1 = Mockito.mock(AbstractPolicyBasedAuthorizer.class);
+ when(authorizer1.getGroups()).thenReturn(groups1);
+ when(authorizer1.getUsers()).thenReturn(users1);
+ when(authorizer1.getAccessPolicies()).thenReturn(policies1);
+
+ final String fingerprint1 = authorizer1.getFingerprint();
+
+ // make a second authorizer using the memory-backed implementation so we can inherit the fingerprint
+ // and then compute a new fingerprint to compare them
+ AbstractPolicyBasedAuthorizer authorizer2 = new MemoryPolicyBasedAuthorizer();
+ authorizer2.inheritFingerprint(fingerprint1);
+
+ // computer the fingerprint of the second authorizer and it should be the same as the first
+ final String fingerprint2 = authorizer2.getFingerprint();
+ assertEquals(fingerprint1, fingerprint2);
+
+ // all the sets should be equal now after inheriting
+ assertEquals(authorizer1.getUsers(), authorizer2.getUsers());
+ assertEquals(authorizer1.getGroups(), authorizer2.getGroups());
+ assertEquals(authorizer1.getAccessPolicies(), authorizer2.getAccessPolicies());
+ }
+
+ @Test
+ public void testEmptyAuthorizer() {
+ AbstractPolicyBasedAuthorizer authorizer = Mockito.mock(AbstractPolicyBasedAuthorizer.class);
+ when(authorizer.getGroups()).thenReturn(new HashSet<Group>());
+ when(authorizer.getUsers()).thenReturn(new HashSet<User>());
+ when(authorizer.getAccessPolicies()).thenReturn(new HashSet<AccessPolicy>());
+
+ final String fingerprint = authorizer.getFingerprint();
+ Assert.assertNotNull(fingerprint);
+ Assert.assertTrue(fingerprint.length() > 0);
+ }
+
+ /**
+ * An AbstractPolicyBasedAuthorizer that stores everything in memory.
+ */
+ private static final class MemoryPolicyBasedAuthorizer extends AbstractPolicyBasedAuthorizer {
+
+ private Set<Group> groups = new HashSet<>();
+ private Set<User> users = new HashSet<>();
+ private Set<AccessPolicy> policies = new HashSet<>();
+
+ @Override
+ public Group addGroup(Group group) throws AuthorizationAccessException {
+ groups.add(group);
+ return group;
+ }
+
+ @Override
+ public Group getGroup(String identifier) throws AuthorizationAccessException {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public Group updateGroup(Group group) throws AuthorizationAccessException {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public Group deleteGroup(Group group) throws AuthorizationAccessException {
+ groups.remove(group);
+ return group;
+ }
+
+ @Override
+ public Set<Group> getGroups() throws AuthorizationAccessException {
+ return groups;
+ }
+
+ @Override
+ public User addUser(User user) throws AuthorizationAccessException {
+ users.add(user);
+ return user;
+ }
+
+ @Override
+ public User getUser(String identifier) throws AuthorizationAccessException {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public User getUserByIdentity(String identity) throws AuthorizationAccessException {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public User updateUser(User user) throws AuthorizationAccessException {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public User deleteUser(User user) throws AuthorizationAccessException {
+ users.remove(user);
+ return user;
+ }
+
+ @Override
+ public Set<User> getUsers() throws AuthorizationAccessException {
+ return users;
+ }
+
+ @Override
+ protected AccessPolicy doAddAccessPolicy(AccessPolicy accessPolicy) throws AuthorizationAccessException {
+ policies.add(accessPolicy);
+ return accessPolicy;
+ }
+
+ @Override
+ public AccessPolicy getAccessPolicy(String identifier) throws AuthorizationAccessException {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public AccessPolicy updateAccessPolicy(AccessPolicy accessPolicy) throws AuthorizationAccessException {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public AccessPolicy deleteAccessPolicy(AccessPolicy policy) throws AuthorizationAccessException {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public Set<AccessPolicy> getAccessPolicies() throws AuthorizationAccessException {
+ return policies;
+ }
+
+ @Override
+ public UsersAndAccessPolicies getUsersAndAccessPolicies() throws AuthorizationAccessException {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void initialize(AuthorizerInitializationContext initializationContext) throws AuthorizerCreationException {
+
+ }
+
+ @Override
+ public void doOnConfigured(AuthorizerConfigurationContext configurationContext) throws AuthorizerCreationException {
+
+ }
+
+ @Override
+ public void preDestruction() throws AuthorizerDestructionException {
+
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-framework-api/src/test/java/org/apache/nifi/authorization/TestAccessPolicy.java
----------------------------------------------------------------------
diff --git a/nifi-framework-api/src/test/java/org/apache/nifi/authorization/TestAccessPolicy.java b/nifi-framework-api/src/test/java/org/apache/nifi/authorization/TestAccessPolicy.java
new file mode 100644
index 0000000..c8a4452
--- /dev/null
+++ b/nifi-framework-api/src/test/java/org/apache/nifi/authorization/TestAccessPolicy.java
@@ -0,0 +1,240 @@
+/*
+ * 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.authorization;
+
+import org.junit.Test;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+public class TestAccessPolicy {
+
+ static final String TEST_RESOURCE = "1";
+
+ @Test
+ public void testSimpleCreation() {
+ final String identifier = "1";
+ final String user1 = "user1";
+ final String user2 = "user2";
+ final RequestAction action = RequestAction.READ;
+
+ final AccessPolicy policy = new AccessPolicy.Builder()
+ .identifier(identifier)
+ .resource(TEST_RESOURCE)
+ .addUser(user1)
+ .addUser(user2)
+ .action(action)
+ .build();
+
+ assertEquals(identifier, policy.getIdentifier());
+
+ assertNotNull(policy.getResource());
+ assertEquals(TEST_RESOURCE, policy.getResource());
+
+ assertNotNull(policy.getUsers());
+ assertEquals(2, policy.getUsers().size());
+ assertTrue(policy.getUsers().contains(user1));
+ assertTrue(policy.getUsers().contains(user2));
+
+ assertNotNull(policy.getAction());
+ assertEquals(RequestAction.READ, policy.getAction());
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void testMissingIdentifier() {
+ new AccessPolicy.Builder()
+ .resource(TEST_RESOURCE)
+ .addUser("user1")
+ .action(RequestAction.READ)
+ .build();
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void testMissingResource() {
+ new AccessPolicy.Builder()
+ .identifier("1")
+ .addUser("user1")
+ .action(RequestAction.READ)
+ .build();
+ }
+
+ @Test
+ public void testMissingUsersAndGroups() {
+ final AccessPolicy policy = new AccessPolicy.Builder()
+ .identifier("1")
+ .resource(TEST_RESOURCE)
+ .action(RequestAction.READ)
+ .build();
+
+ assertNotNull(policy);
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void testMissingActions() {
+ new AccessPolicy.Builder()
+ .identifier("1")
+ .resource(TEST_RESOURCE)
+ .addUser("user1")
+ .build();
+ }
+
+ @Test
+ public void testFromPolicy() {
+ final String identifier = "1";
+ final String user1 = "user1";
+ final String user2 = "user2";
+ final String group1 = "group1";
+ final String group2 = "group2";
+ final RequestAction action = RequestAction.READ;
+
+ final AccessPolicy policy = new AccessPolicy.Builder()
+ .identifier(identifier)
+ .resource(TEST_RESOURCE)
+ .addUser(user1)
+ .addUser(user2)
+ .addGroup(group1)
+ .addGroup(group2)
+ .action(action)
+ .build();
+
+ assertEquals(identifier, policy.getIdentifier());
+
+ assertNotNull(policy.getResource());
+ assertEquals(TEST_RESOURCE, policy.getResource());
+
+ assertNotNull(policy.getUsers());
+ assertEquals(2, policy.getUsers().size());
+ assertTrue(policy.getUsers().contains(user1));
+ assertTrue(policy.getUsers().contains(user2));
+
+ assertNotNull(policy.getGroups());
+ assertEquals(2, policy.getGroups().size());
+ assertTrue(policy.getGroups().contains(group1));
+ assertTrue(policy.getGroups().contains(group2));
+
+ assertNotNull(policy.getAction());
+ assertEquals(RequestAction.READ, policy.getAction());
+
+ final AccessPolicy policy2 = new AccessPolicy.Builder(policy).build();
+ assertEquals(policy.getIdentifier(), policy2.getIdentifier());
+ assertEquals(policy.getResource(), policy2.getResource());
+ assertEquals(policy.getUsers(), policy2.getUsers());
+ assertEquals(policy.getAction(), policy2.getAction());
+ }
+
+ @Test(expected = IllegalStateException.class)
+ public void testFromPolicyAndChangeIdentifier() {
+ final AccessPolicy policy = new AccessPolicy.Builder()
+ .identifier("1")
+ .resource(TEST_RESOURCE)
+ .addUser("user1")
+ .action(RequestAction.READ)
+ .build();
+
+ new AccessPolicy.Builder(policy).identifier("2").build();
+ }
+
+ @Test
+ public void testAddRemoveClearUsers() {
+ final AccessPolicy.Builder builder = new AccessPolicy.Builder()
+ .identifier("1")
+ .resource(TEST_RESOURCE)
+ .addUser("user1")
+ .action(RequestAction.READ);
+
+ final AccessPolicy policy1 = builder.build();
+ assertEquals(1, policy1.getUsers().size());
+ assertTrue(policy1.getUsers().contains("user1"));
+
+ final Set<String> moreEntities = new HashSet<>();
+ moreEntities.add("user2");
+ moreEntities.add("user3");
+ moreEntities.add("user4");
+
+ final AccessPolicy policy2 = builder.addUsers(moreEntities).build();
+ assertEquals(4, policy2.getUsers().size());
+ assertTrue(policy2.getUsers().contains("user1"));
+ assertTrue(policy2.getUsers().contains("user2"));
+ assertTrue(policy2.getUsers().contains("user3"));
+ assertTrue(policy2.getUsers().contains("user4"));
+
+ final AccessPolicy policy3 = builder.removeUser("user3").build();
+ assertEquals(3, policy3.getUsers().size());
+ assertTrue(policy3.getUsers().contains("user1"));
+ assertTrue(policy3.getUsers().contains("user2"));
+ assertTrue(policy3.getUsers().contains("user4"));
+
+ final Set<String> removeEntities = new HashSet<>();
+ removeEntities.add("user1");
+ removeEntities.add("user4");
+
+ final AccessPolicy policy4 = builder.removeUsers(removeEntities).build();
+ assertEquals(1, policy4.getUsers().size());
+ assertTrue(policy4.getUsers().contains("user2"));
+
+
+ final AccessPolicy policy5 = builder.clearUsers().build();
+ assertEquals(0, policy5.getUsers().size());
+ }
+
+ @Test
+ public void testAddRemoveClearGroups() {
+ final AccessPolicy.Builder builder = new AccessPolicy.Builder()
+ .identifier("1")
+ .resource(TEST_RESOURCE)
+ .addGroup("group1")
+ .action(RequestAction.READ);
+
+ final AccessPolicy policy1 = builder.build();
+ assertEquals(1, policy1.getGroups().size());
+ assertTrue(policy1.getGroups().contains("group1"));
+
+ final Set<String> moreGroups = new HashSet<>();
+ moreGroups.add("group2");
+ moreGroups.add("group3");
+ moreGroups.add("group4");
+
+ final AccessPolicy policy2 = builder.addGroups(moreGroups).build();
+ assertEquals(4, policy2.getGroups().size());
+ assertTrue(policy2.getGroups().contains("group1"));
+ assertTrue(policy2.getGroups().contains("group2"));
+ assertTrue(policy2.getGroups().contains("group3"));
+ assertTrue(policy2.getGroups().contains("group4"));
+
+ final AccessPolicy policy3 = builder.removeGroup("group3").build();
+ assertEquals(3, policy3.getGroups().size());
+ assertTrue(policy3.getGroups().contains("group1"));
+ assertTrue(policy3.getGroups().contains("group2"));
+ assertTrue(policy3.getGroups().contains("group4"));
+
+ final Set<String> removeGroups = new HashSet<>();
+ removeGroups.add("group1");
+ removeGroups.add("group4");
+
+ final AccessPolicy policy4 = builder.removeGroups(removeGroups).build();
+ assertEquals(1, policy4.getGroups().size());
+ assertTrue(policy4.getGroups().contains("group2"));
+
+ final AccessPolicy policy5 = builder.clearGroups().build();
+ assertEquals(0, policy5.getUsers().size());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-framework-api/src/test/java/org/apache/nifi/authorization/TestGroup.java
----------------------------------------------------------------------
diff --git a/nifi-framework-api/src/test/java/org/apache/nifi/authorization/TestGroup.java b/nifi-framework-api/src/test/java/org/apache/nifi/authorization/TestGroup.java
new file mode 100644
index 0000000..8ccdba5
--- /dev/null
+++ b/nifi-framework-api/src/test/java/org/apache/nifi/authorization/TestGroup.java
@@ -0,0 +1,169 @@
+/*
+ * 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.authorization;
+
+import org.junit.Test;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+public class TestGroup {
+
+ @Test
+ public void testSimpleCreation() {
+ final String id = "1";
+ final String name = "group1";
+ final String user1 = "user1";
+ final String user2 = "user2";
+
+ final Group group = new Group.Builder()
+ .identifier(id)
+ .name(name)
+ .addUser(user1)
+ .addUser(user2)
+ .build();
+
+ assertEquals(id, group.getIdentifier());
+ assertEquals(name, group.getName());
+
+ assertNotNull(group.getUsers());
+ assertEquals(2, group.getUsers().size());
+ assertTrue(group.getUsers().contains(user1));
+ assertTrue(group.getUsers().contains(user2));
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void testMissingId() {
+ new Group.Builder()
+ .name("group1")
+ .addUser("user1")
+ .addUser("user2")
+ .build();
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void testMissingName() {
+ new Group.Builder()
+ .identifier("1")
+ .addUser("user1")
+ .addUser("user2")
+ .build();
+ }
+
+ @Test
+ public void testMissingUsers() {
+ final String id = "1";
+ final String name = "group1";
+
+ final Group group = new Group.Builder()
+ .identifier(id)
+ .name(name)
+ .build();
+
+ assertEquals(id, group.getIdentifier());
+ assertEquals(name, group.getName());
+
+ assertNotNull(group.getUsers());
+ assertEquals(0, group.getUsers().size());
+ }
+
+ @Test
+ public void testFromGroup() {
+ final String id = "1";
+ final String name = "group1";
+ final String user1 = "user1";
+ final String user2 = "user2";
+
+ final Group group1 = new Group.Builder()
+ .identifier(id)
+ .name(name)
+ .addUser(user1)
+ .addUser(user2)
+ .build();
+
+ assertEquals(id, group1.getIdentifier());
+ assertEquals(name, group1.getName());
+
+ assertNotNull(group1.getUsers());
+ assertEquals(2, group1.getUsers().size());
+ assertTrue(group1.getUsers().contains(user1));
+ assertTrue(group1.getUsers().contains(user2));
+
+ final Group group2 = new Group.Builder(group1).build();
+ assertEquals(group1.getIdentifier(), group2.getIdentifier());
+ assertEquals(group1.getName(), group2.getName());
+ assertEquals(group1.getUsers(), group2.getUsers());
+ }
+
+ @Test(expected = IllegalStateException.class)
+ public void testFromGroupAndChangeIdentifier() {
+ final Group group1 = new Group.Builder()
+ .identifier("1")
+ .name("group1")
+ .addUser("user1")
+ .build();
+
+ new Group.Builder(group1).identifier("2").build();
+ }
+
+ @Test
+ public void testAddRemoveClearUsers() {
+ final Group.Builder builder = new Group.Builder()
+ .identifier("1")
+ .name("group1")
+ .addUser("user1");
+
+ final Group group1 = builder.build();
+ assertNotNull(group1.getUsers());
+ assertEquals(1, group1.getUsers().size());
+ assertTrue(group1.getUsers().contains("user1"));
+
+ final Set<String> moreUsers = new HashSet<>();
+ moreUsers.add("user2");
+ moreUsers.add("user3");
+ moreUsers.add("user4");
+
+ final Group group2 = builder.addUsers(moreUsers).build();
+ assertEquals(4, group2.getUsers().size());
+ assertTrue(group2.getUsers().contains("user1"));
+ assertTrue(group2.getUsers().contains("user2"));
+ assertTrue(group2.getUsers().contains("user3"));
+ assertTrue(group2.getUsers().contains("user4"));
+
+ final Group group3 = builder.removeUser("user2").build();
+ assertEquals(3, group3.getUsers().size());
+ assertTrue(group3.getUsers().contains("user1"));
+ assertTrue(group3.getUsers().contains("user3"));
+ assertTrue(group3.getUsers().contains("user4"));
+
+ final Set<String> removeUsers = new HashSet<>();
+ removeUsers.add("user1");
+ removeUsers.add("user4");
+
+ final Group group4 = builder.removeUsers(removeUsers).build();
+ assertEquals(1, group4.getUsers().size());
+ assertTrue(group4.getUsers().contains("user3"));
+
+ final Group group5 = builder.clearUsers().build();
+ assertEquals(0, group5.getUsers().size());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-framework-api/src/test/java/org/apache/nifi/authorization/TestUser.java
----------------------------------------------------------------------
diff --git a/nifi-framework-api/src/test/java/org/apache/nifi/authorization/TestUser.java b/nifi-framework-api/src/test/java/org/apache/nifi/authorization/TestUser.java
new file mode 100644
index 0000000..04b1ab1
--- /dev/null
+++ b/nifi-framework-api/src/test/java/org/apache/nifi/authorization/TestUser.java
@@ -0,0 +1,85 @@
+/*
+ * 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.authorization;
+
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+public class TestUser {
+
+ @Test
+ public void testSimpleCreation() {
+ final String identifier = "1";
+ final String identity = "user1";
+ final String group1 = "group1";
+ final String group2 = "group2";
+
+ final User user = new User.Builder()
+ .identifier(identifier)
+ .identity(identity)
+ .build();
+
+ assertEquals(identifier, user.getIdentifier());
+ assertEquals(identity, user.getIdentity());
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void testMissingIdentifier() {
+ new User.Builder()
+ .identity("user1")
+ .build();
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void testMissingIdentity() {
+ new User.Builder()
+ .identifier("1")
+ .build();
+ }
+
+ @Test
+ public void testFromUser() {
+ final String identifier = "1";
+ final String identity = "user1";
+ final String group1 = "group1";
+ final String group2 = "group2";
+
+ final User user = new User.Builder()
+ .identifier(identifier)
+ .identity(identity)
+ .build();
+
+ assertEquals(identifier, user.getIdentifier());
+ assertEquals(identity, user.getIdentity());
+
+ final User user2 = new User.Builder(user).build();
+ assertEquals(user.getIdentifier(), user2.getIdentifier());
+ assertEquals(user.getIdentity(), user2.getIdentity());
+ }
+
+ @Test(expected = IllegalStateException.class)
+ public void testFromUserAndChangeIdentifier() {
+ final User user = new User.Builder()
+ .identifier("1")
+ .identity("user1")
+ .build();
+
+ new User.Builder(user).identifier("2").build();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-framework-api/src/test/java/org/apache/nifi/web/TestRevision.java
----------------------------------------------------------------------
diff --git a/nifi-framework-api/src/test/java/org/apache/nifi/web/TestRevision.java b/nifi-framework-api/src/test/java/org/apache/nifi/web/TestRevision.java
new file mode 100644
index 0000000..6d513fd
--- /dev/null
+++ b/nifi-framework-api/src/test/java/org/apache/nifi/web/TestRevision.java
@@ -0,0 +1,61 @@
+/*
+ * 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.web;
+
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+/**
+ *
+ */
+public class TestRevision {
+
+ @Test(expected = IllegalArgumentException.class)
+ public void testNullVersion() throws Exception {
+ new Revision(null, "client-id", "component-id");
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void testNullComponentId() throws Exception {
+ new Revision(0l, "client-id", null);
+ }
+
+ @Test
+ public void testIncrementRevision() throws Exception {
+ final String clientId = "client-id";
+ final String componentId = "component-id";
+ final Revision revision = new Revision(0l, clientId, componentId);
+ final Revision updatedRevision = revision.incrementRevision(clientId);
+ assertEquals(1, updatedRevision.getVersion().longValue());
+ assertEquals(clientId, updatedRevision.getClientId());
+ assertEquals(componentId, updatedRevision.getComponentId());
+ }
+
+ @Test
+ public void testIncrementRevisionNewClient() throws Exception {
+ final String clientId = "client-id";
+ final String newClientId = "new-client-id";
+ final String componentId = "component-id";
+ final Revision revision = new Revision(0l, clientId, componentId);
+ final Revision updatedRevision = revision.incrementRevision(newClientId);
+ assertEquals(1, updatedRevision.getVersion().longValue());
+ assertEquals(newClientId, updatedRevision.getClientId());
+ assertEquals(componentId, updatedRevision.getComponentId());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-mock/pom.xml
----------------------------------------------------------------------
diff --git a/nifi-mock/pom.xml b/nifi-mock/pom.xml
index dd15fef..53f29ff 100644
--- a/nifi-mock/pom.xml
+++ b/nifi-mock/pom.xml
@@ -28,6 +28,10 @@
</dependency>
<dependency>
<groupId>org.apache.nifi</groupId>
+ <artifactId>nifi-framework-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.nifi</groupId>
<artifactId>nifi-utils</artifactId>
</dependency>
<dependency>
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-mock/src/main/java/org/apache/nifi/provenance/MockProvenanceEventRepository.java
----------------------------------------------------------------------
diff --git a/nifi-mock/src/main/java/org/apache/nifi/provenance/MockProvenanceEventRepository.java b/nifi-mock/src/main/java/org/apache/nifi/provenance/MockProvenanceEventRepository.java
deleted file mode 100644
index dc71ed5..0000000
--- a/nifi-mock/src/main/java/org/apache/nifi/provenance/MockProvenanceEventRepository.java
+++ /dev/null
@@ -1,139 +0,0 @@
-/*
- * 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.provenance;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.concurrent.atomic.AtomicLong;
-
-import org.apache.nifi.authorization.Authorizer;
-import org.apache.nifi.authorization.user.NiFiUser;
-import org.apache.nifi.events.EventReporter;
-import org.apache.nifi.provenance.lineage.ComputeLineageSubmission;
-import org.apache.nifi.provenance.search.Query;
-import org.apache.nifi.provenance.search.QuerySubmission;
-import org.apache.nifi.provenance.search.SearchableField;
-
-public class MockProvenanceEventRepository implements ProvenanceEventRepository {
-
- private final List<ProvenanceEventRecord> records = new ArrayList<>();
- private final AtomicLong idGenerator = new AtomicLong(0L);
-
- @Override
- public void registerEvents(final Iterable<ProvenanceEventRecord> events) {
- for (final ProvenanceEventRecord event : events) {
- registerEvent(event);
- }
- }
-
- @Override
- public void registerEvent(final ProvenanceEventRecord event) {
- final StandardProvenanceEventRecord newRecord;
- if (event instanceof StandardProvenanceEventRecord) {
- newRecord = (StandardProvenanceEventRecord) event;
- } else {
- newRecord = new StandardProvenanceEventRecord.Builder().fromEvent(event).build();
- }
- newRecord.setEventId(idGenerator.getAndIncrement());
-
- records.add(newRecord);
- }
-
- @Override
- public void initialize(EventReporter eventReporter, Authorizer authorizer, ProvenanceAuthorizableFactory resourceFactory) throws IOException {
-
- }
-
- @Override
- public List<ProvenanceEventRecord> getEvents(long firstRecordId, int maxRecords) throws IOException {
- if (firstRecordId > records.size()) {
- return Collections.emptyList();
- }
-
- return records.subList((int) firstRecordId, Math.min(records.size(), (int) (firstRecordId + maxRecords)));
- }
-
- @Override
- public List<ProvenanceEventRecord> getEvents(long firstRecordId, int maxRecords, NiFiUser user) throws IOException {
- return getEvents(firstRecordId, maxRecords);
- }
-
- @Override
- public Long getMaxEventId() {
- return Long.valueOf(records.size() - 1);
- }
-
- @Override
- public QuerySubmission submitQuery(Query query, NiFiUser user) {
- throw new UnsupportedOperationException("MockProvenanceEventRepository does not support querying");
- }
-
- @Override
- public QuerySubmission retrieveQuerySubmission(String queryIdentifier, NiFiUser user) {
- throw new UnsupportedOperationException("MockProvenanceEventRepository does not support querying");
- }
-
- @Override
- public ComputeLineageSubmission submitLineageComputation(String flowFileUuid, NiFiUser user) {
- throw new UnsupportedOperationException("MockProvenanceEventRepository does not support Lineage Computation");
- }
-
- @Override
- public ComputeLineageSubmission retrieveLineageSubmission(String lineageIdentifier, NiFiUser user) {
- throw new UnsupportedOperationException("MockProvenanceEventRepository does not support Lineage Computation");
- }
-
- @Override
- public ProvenanceEventRecord getEvent(long id, NiFiUser user) throws IOException {
- if (id > records.size()) {
- return null;
- }
-
- return records.get((int) id);
- }
-
- @Override
- public ComputeLineageSubmission submitExpandParents(long eventId, NiFiUser user) {
- throw new UnsupportedOperationException("MockProvenanceEventRepository does not support Lineage Computation");
- }
-
- @Override
- public ComputeLineageSubmission submitExpandChildren(long eventId, NiFiUser user) {
- throw new UnsupportedOperationException("MockProvenanceEventRepository does not support Lineage Computation");
- }
-
- @Override
- public void close() throws IOException {
- }
-
- @Override
- public List<SearchableField> getSearchableFields() {
- return Collections.emptyList();
- }
-
- @Override
- public List<SearchableField> getSearchableAttributes() {
- return Collections.emptyList();
- }
-
- @Override
- public ProvenanceEventBuilder eventBuilder() {
- return new StandardProvenanceEventRecord.Builder();
- }
-}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-mock/src/main/java/org/apache/nifi/provenance/MockProvenanceRepository.java
----------------------------------------------------------------------
diff --git a/nifi-mock/src/main/java/org/apache/nifi/provenance/MockProvenanceRepository.java b/nifi-mock/src/main/java/org/apache/nifi/provenance/MockProvenanceRepository.java
new file mode 100644
index 0000000..a13a338
--- /dev/null
+++ b/nifi-mock/src/main/java/org/apache/nifi/provenance/MockProvenanceRepository.java
@@ -0,0 +1,149 @@
+/*
+ * 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.provenance;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.concurrent.atomic.AtomicLong;
+
+import org.apache.nifi.authorization.Authorizer;
+import org.apache.nifi.authorization.user.NiFiUser;
+import org.apache.nifi.events.EventReporter;
+import org.apache.nifi.provenance.lineage.ComputeLineageSubmission;
+import org.apache.nifi.provenance.search.Query;
+import org.apache.nifi.provenance.search.QuerySubmission;
+import org.apache.nifi.provenance.search.SearchableField;
+
+public class MockProvenanceRepository implements ProvenanceRepository {
+
+ private final List<ProvenanceEventRecord> records = new ArrayList<>();
+ private final AtomicLong idGenerator = new AtomicLong(0L);
+
+ @Override
+ public void registerEvents(final Iterable<ProvenanceEventRecord> events) {
+ for (final ProvenanceEventRecord event : events) {
+ registerEvent(event);
+ }
+ }
+
+ @Override
+ public void registerEvent(final ProvenanceEventRecord event) {
+ final StandardProvenanceEventRecord newRecord;
+ if (event instanceof StandardProvenanceEventRecord) {
+ newRecord = (StandardProvenanceEventRecord) event;
+ } else {
+ newRecord = new StandardProvenanceEventRecord.Builder().fromEvent(event).build();
+ }
+ newRecord.setEventId(idGenerator.getAndIncrement());
+
+ records.add(newRecord);
+ }
+
+ @Override
+ public void initialize(EventReporter eventReporter, Authorizer authorizer, ProvenanceAuthorizableFactory resourceFactory) throws IOException {
+
+ }
+
+ @Override
+ public List<ProvenanceEventRecord> getEvents(long firstRecordId, int maxRecords) throws IOException {
+ if (firstRecordId > records.size()) {
+ return Collections.emptyList();
+ }
+
+ return records.subList((int) firstRecordId, Math.min(records.size(), (int) (firstRecordId + maxRecords)));
+ }
+
+ @Override
+ public List<ProvenanceEventRecord> getEvents(long firstRecordId, int maxRecords, NiFiUser user) throws IOException {
+ return getEvents(firstRecordId, maxRecords);
+ }
+
+ @Override
+ public Long getMaxEventId() {
+ return Long.valueOf(records.size() - 1);
+ }
+
+ @Override
+ public ProvenanceEventRecord getEvent(long id) throws IOException {
+ return null;
+ }
+
+ @Override
+ public QuerySubmission submitQuery(Query query, NiFiUser user) {
+ throw new UnsupportedOperationException("MockProvenanceRepository does not support querying");
+ }
+
+ @Override
+ public QuerySubmission retrieveQuerySubmission(String queryIdentifier, NiFiUser user) {
+ throw new UnsupportedOperationException("MockProvenanceRepository does not support querying");
+ }
+
+ @Override
+ public ComputeLineageSubmission submitLineageComputation(String flowFileUuid, NiFiUser user) {
+ throw new UnsupportedOperationException("MockProvenanceRepository does not support Lineage Computation");
+ }
+
+ @Override
+ public ComputeLineageSubmission retrieveLineageSubmission(String lineageIdentifier, NiFiUser user) {
+ throw new UnsupportedOperationException("MockProvenanceRepository does not support Lineage Computation");
+ }
+
+ @Override
+ public ProvenanceEventRecord getEvent(long id, NiFiUser user) throws IOException {
+ if (id > records.size()) {
+ return null;
+ }
+
+ return records.get((int) id);
+ }
+
+ @Override
+ public ComputeLineageSubmission submitExpandParents(long eventId, NiFiUser user) {
+ throw new UnsupportedOperationException("MockProvenanceRepository does not support Lineage Computation");
+ }
+
+ @Override
+ public ComputeLineageSubmission submitExpandChildren(long eventId, NiFiUser user) {
+ throw new UnsupportedOperationException("MockProvenanceRepository does not support Lineage Computation");
+ }
+
+ @Override
+ public void close() throws IOException {
+ }
+
+ @Override
+ public List<SearchableField> getSearchableFields() {
+ return Collections.emptyList();
+ }
+
+ @Override
+ public List<SearchableField> getSearchableAttributes() {
+ return Collections.emptyList();
+ }
+
+ @Override
+ public ProvenanceEventBuilder eventBuilder() {
+ return new StandardProvenanceEventRecord.Builder();
+ }
+
+ @Override
+ public ProvenanceEventRepository getProvenanceEventRepository() {
+ return this;
+ }
+}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-mock/src/main/java/org/apache/nifi/util/MockEventAccess.java
----------------------------------------------------------------------
diff --git a/nifi-mock/src/main/java/org/apache/nifi/util/MockEventAccess.java b/nifi-mock/src/main/java/org/apache/nifi/util/MockEventAccess.java
index 8b3bf25..5c9a0ed 100644
--- a/nifi-mock/src/main/java/org/apache/nifi/util/MockEventAccess.java
+++ b/nifi-mock/src/main/java/org/apache/nifi/util/MockEventAccess.java
@@ -65,7 +65,6 @@ public class MockEventAccess implements EventAccess {
this.provenanceRecords.add(record);
}
- @Override
public ProvenanceEventRepository getProvenanceRepository() {
return null;
}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/pom.xml
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/pom.xml b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/pom.xml
index 2aac209..5383803 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/pom.xml
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/pom.xml
@@ -32,6 +32,10 @@
</dependency>
<dependency>
<groupId>org.apache.nifi</groupId>
+ <artifactId>nifi-framework-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.nifi</groupId>
<artifactId>nifi-framework-core-api</artifactId>
</dependency>
<dependency>
[03/10] nifi git commit: NIFI-1896 This closes #650. Refactored
nifi-api into nifi-framework-api and other locations. The nifi-api is
specific to that which is needed for intended extension points.
Posted by jo...@apache.org.
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-framework-api/src/main/java/org/apache/nifi/controller/repository/RepositoryRecord.java
----------------------------------------------------------------------
diff --git a/nifi-framework-api/src/main/java/org/apache/nifi/controller/repository/RepositoryRecord.java b/nifi-framework-api/src/main/java/org/apache/nifi/controller/repository/RepositoryRecord.java
new file mode 100644
index 0000000..09202c0
--- /dev/null
+++ b/nifi-framework-api/src/main/java/org/apache/nifi/controller/repository/RepositoryRecord.java
@@ -0,0 +1,82 @@
+/*
+ * 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.controller.repository;
+
+import org.apache.nifi.controller.queue.FlowFileQueue;
+import org.apache.nifi.controller.repository.claim.ContentClaim;
+
+/**
+ * Represents an abstraction of a FlowFile that can be used to track changing
+ * state of a FlowFile so that transactionality with repositories can exist
+ */
+public interface RepositoryRecord {
+
+ /**
+ * @return FlowFileQueue to which the FlowFile is to be transferred
+ */
+ FlowFileQueue getDestination();
+
+ /**
+ * @return FlowFileQueue from which the record was pulled
+ */
+ FlowFileQueue getOriginalQueue();
+
+ /**
+ * @return type of update that this record encapsulates
+ */
+ RepositoryRecordType getType();
+
+ /**
+ * @return current ContentClaim for the FlowFile
+ */
+ ContentClaim getCurrentClaim();
+
+ /**
+ * @return original ContentClaim for the FlowFile before any changes were made
+ */
+ ContentClaim getOriginalClaim();
+
+ /**
+ * @return byte offset into the Content Claim where this FlowFile's content
+ * begins
+ */
+ long getCurrentClaimOffset();
+
+ /**
+ * @return FlowFile being encapsulated by this record
+ */
+ FlowFileRecord getCurrent();
+
+ /**
+ * @return Whether or not the FlowFile's attributes have changed since the FlowFile
+ * was pulled from its queue (or created)
+ */
+ boolean isAttributesChanged();
+
+ /**
+ * @return <code>true</code> if the FlowFile is not viable and should be
+ * aborted (e.g., the content of the FlowFile cannot be found)
+ */
+ boolean isMarkedForAbort();
+
+ /**
+ * @return If the FlowFile is swapped out of the Java heap space, provides the
+ * location of the swap file, or <code>null</code> if the FlowFile is not
+ * swapped out
+ */
+ String getSwapLocation();
+}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-framework-api/src/main/java/org/apache/nifi/controller/repository/RepositoryRecordType.java
----------------------------------------------------------------------
diff --git a/nifi-framework-api/src/main/java/org/apache/nifi/controller/repository/RepositoryRecordType.java b/nifi-framework-api/src/main/java/org/apache/nifi/controller/repository/RepositoryRecordType.java
new file mode 100644
index 0000000..ff8dc50
--- /dev/null
+++ b/nifi-framework-api/src/main/java/org/apache/nifi/controller/repository/RepositoryRecordType.java
@@ -0,0 +1,25 @@
+/*
+ * 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.controller.repository;
+
+/**
+ *
+ */
+public enum RepositoryRecordType {
+
+ UPDATE, CREATE, DELETE, CONTENTMISSING, SWAP_IN, SWAP_OUT;
+}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-framework-api/src/main/java/org/apache/nifi/controller/repository/SwapContents.java
----------------------------------------------------------------------
diff --git a/nifi-framework-api/src/main/java/org/apache/nifi/controller/repository/SwapContents.java b/nifi-framework-api/src/main/java/org/apache/nifi/controller/repository/SwapContents.java
new file mode 100644
index 0000000..2fb7ba4
--- /dev/null
+++ b/nifi-framework-api/src/main/java/org/apache/nifi/controller/repository/SwapContents.java
@@ -0,0 +1,40 @@
+/*
+ * 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.controller.repository;
+
+import java.util.List;
+
+/**
+ * When FlowFiles are constructed from a Swap File, there is information in addition to
+ * the FlowFiles themselves that get stored and recovered. SwapContents provides a
+ * mechanism to encapsulate all of the information contained within a Swap File in a
+ * single object
+ */
+public interface SwapContents {
+
+ /**
+ * @return a summary of information included in a Swap File
+ */
+ SwapSummary getSummary();
+
+ /**
+ * @return the FlowFiles that are contained within a Swap File
+ */
+ List<FlowFileRecord> getFlowFiles();
+
+}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-framework-api/src/main/java/org/apache/nifi/controller/repository/SwapManagerInitializationContext.java
----------------------------------------------------------------------
diff --git a/nifi-framework-api/src/main/java/org/apache/nifi/controller/repository/SwapManagerInitializationContext.java b/nifi-framework-api/src/main/java/org/apache/nifi/controller/repository/SwapManagerInitializationContext.java
new file mode 100644
index 0000000..0e30784
--- /dev/null
+++ b/nifi-framework-api/src/main/java/org/apache/nifi/controller/repository/SwapManagerInitializationContext.java
@@ -0,0 +1,40 @@
+/*
+ * 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.controller.repository;
+
+import org.apache.nifi.controller.repository.claim.ResourceClaimManager;
+import org.apache.nifi.events.EventReporter;
+
+public interface SwapManagerInitializationContext {
+
+ /**
+ * @return the {@link FlowFileRepository} that should be updated when FlowFiles are swapped in and out
+ */
+ FlowFileRepository getFlowFileRepository();
+
+ /**
+ * @return the {@link ResourceClaimManager} that is necessary to provide to the FlowFileRepository when
+ * performing swapping actions
+ */
+ ResourceClaimManager getResourceClaimManager();
+
+ /**
+ * @return an {@link EventReporter} that can be used to report events to users
+ */
+ EventReporter getEventReporter();
+}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-framework-api/src/main/java/org/apache/nifi/controller/repository/SwapSummary.java
----------------------------------------------------------------------
diff --git a/nifi-framework-api/src/main/java/org/apache/nifi/controller/repository/SwapSummary.java b/nifi-framework-api/src/main/java/org/apache/nifi/controller/repository/SwapSummary.java
new file mode 100644
index 0000000..ad01ccd
--- /dev/null
+++ b/nifi-framework-api/src/main/java/org/apache/nifi/controller/repository/SwapSummary.java
@@ -0,0 +1,50 @@
+/*
+ * 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.controller.repository;
+
+import java.util.List;
+
+import org.apache.nifi.controller.queue.QueueSize;
+import org.apache.nifi.controller.repository.claim.ResourceClaim;
+
+/**
+ * <p>
+ * Provides a summary of the information that is stored in a FlowFile swap file.
+ * </p>
+ */
+public interface SwapSummary {
+ /**
+ * @return a QueueSize that represents the number of FlowFiles are in the swap file and their
+ * aggregate content size
+ */
+ QueueSize getQueueSize();
+
+ /**
+ * @return the largest ID of any of the FlowFiles that are contained in the swap file
+ */
+ Long getMaxFlowFileId();
+
+ /**
+ * Returns a List of all ResoruceClaims that are referenced by the FlowFiles in the swap file.
+ * This List may well contain the same ResourceClaim many times. This indicates that many FlowFiles
+ * reference the same ResourceClaim.
+ *
+ * @return a List of all ResourceClaims that are referenced by the FlowFiles in the swap file
+ */
+ List<ResourceClaim> getResourceClaims();
+}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-framework-api/src/main/java/org/apache/nifi/controller/repository/claim/ContentClaim.java
----------------------------------------------------------------------
diff --git a/nifi-framework-api/src/main/java/org/apache/nifi/controller/repository/claim/ContentClaim.java b/nifi-framework-api/src/main/java/org/apache/nifi/controller/repository/claim/ContentClaim.java
new file mode 100644
index 0000000..5c1d76b
--- /dev/null
+++ b/nifi-framework-api/src/main/java/org/apache/nifi/controller/repository/claim/ContentClaim.java
@@ -0,0 +1,47 @@
+/*
+ * 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.controller.repository.claim;
+
+/**
+ * <p>
+ * A reference to a section of a {@link ResourceClaim}, which may or may not encompass
+ * the entire ResourceClaim. Multiple FlowFiles may reference the same content by both
+ * having the same content claim.
+ * </p>
+ *
+ * <p>
+ * Must be thread safe
+ * </p>
+ */
+public interface ContentClaim extends Comparable<ContentClaim> {
+
+ /**
+ * @return the ResourceClaim that this ContentClaim references
+ */
+ ResourceClaim getResourceClaim();
+
+ /**
+ * @return the offset into the ResourceClaim where the content for this
+ * claim begins
+ */
+ long getOffset();
+
+ /**
+ * @return the length of this ContentClaim
+ */
+ long getLength();
+}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-framework-api/src/main/java/org/apache/nifi/controller/repository/claim/ResourceClaim.java
----------------------------------------------------------------------
diff --git a/nifi-framework-api/src/main/java/org/apache/nifi/controller/repository/claim/ResourceClaim.java b/nifi-framework-api/src/main/java/org/apache/nifi/controller/repository/claim/ResourceClaim.java
new file mode 100644
index 0000000..77e7f84
--- /dev/null
+++ b/nifi-framework-api/src/main/java/org/apache/nifi/controller/repository/claim/ResourceClaim.java
@@ -0,0 +1,54 @@
+/*
+ * 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.controller.repository.claim;
+
+import org.apache.nifi.controller.repository.ContentRepository;
+
+/**
+ * <p>
+ * Represents a resource that can be provided by a {@link ContentRepository}
+ * </p>
+ *
+ * <p>
+ * MUST BE THREAD-SAFE!
+ * </p>
+ */
+public interface ResourceClaim extends Comparable<ResourceClaim> {
+
+ /**
+ * @return the unique identifier for this claim
+ */
+ String getId();
+
+ /**
+ * @return the container identifier in which this claim is held
+ */
+ String getContainer();
+
+ /**
+ * @return the section within a given container the claim is held
+ */
+ String getSection();
+
+ /**
+ * @return Indicates whether or not the Claim is loss-tolerant. If so, we will
+ * attempt to keep the content but will not sacrifice a great deal of
+ * performance to do so
+ */
+ boolean isLossTolerant();
+
+}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-framework-api/src/main/java/org/apache/nifi/controller/repository/claim/ResourceClaimManager.java
----------------------------------------------------------------------
diff --git a/nifi-framework-api/src/main/java/org/apache/nifi/controller/repository/claim/ResourceClaimManager.java b/nifi-framework-api/src/main/java/org/apache/nifi/controller/repository/claim/ResourceClaimManager.java
new file mode 100644
index 0000000..01f4c65
--- /dev/null
+++ b/nifi-framework-api/src/main/java/org/apache/nifi/controller/repository/claim/ResourceClaimManager.java
@@ -0,0 +1,135 @@
+/*
+ * 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.controller.repository.claim;
+
+import java.util.Collection;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * Responsible for managing all ResourceClaims that are used in the application
+ */
+public interface ResourceClaimManager {
+
+ /**
+ * Creates a new Resource Claim with the given id, container, section, and
+ * loss tolerance.
+ *
+ * @param id of claim
+ * @param container of claim
+ * @param section of claim
+ * @param lossTolerant of claim
+ * @return new claim
+ */
+ ResourceClaim newResourceClaim(String container, String section, String id, boolean lossTolerant);
+
+ /**
+ * @param claim to obtain reference count for
+ * @return the number of FlowFiles that hold a claim to a particular piece
+ * of FlowFile content
+ */
+ int getClaimantCount(ResourceClaim claim);
+
+ /**
+ * Decreases by 1 the count of how many FlowFiles hold a claim to a
+ * particular piece of FlowFile content and returns the new count
+ *
+ * @param claim to decrement claimants on
+ * @return new claimaint count
+ */
+ int decrementClaimantCount(ResourceClaim claim);
+
+ /**
+ * Increases by 1 the count of how many FlowFiles hold a claim to a
+ * particular piece of FlowFile content and returns the new count
+ *
+ * @param claim to increment claims on
+ * @return new claimant count
+ */
+ int incrementClaimantCount(ResourceClaim claim);
+
+ /**
+ * Increases by 1 the count of how many FlowFiles hold a claim to a
+ * particular piece of FlowFile content and returns the new count.
+ *
+ * If it is known that the Content Claim whose count is being incremented is
+ * a newly created ResourceClaim, this method should be called with a value
+ * of {@code true} as the second argument, as it may allow the manager to
+ * optimize its tasks, knowing that the Content Claim cannot be referenced
+ * by any other component
+ *
+ * @param claim to increment
+ * @param newClaim provides a hint that no other process can have access to this
+ * claim right now
+ * @return new claim count
+ */
+ int incrementClaimantCount(ResourceClaim claim, boolean newClaim);
+
+ /**
+ * Indicates that the given ResourceClaim can now be destroyed by the
+ * appropriate Content Repository. This should be done only after it is
+ * guaranteed that the FlowFile Repository has been synchronized with its
+ * underlying storage component. This way, we avoid the following sequence
+ * of events:
+ * <ul>
+ * <li>FlowFile Repository is updated to indicate that FlowFile F no longer depends on ResourceClaim C</li>
+ * <li>ResourceClaim C is no longer needed and is destroyed</li>
+ * <li>The Operating System crashes or there is a power failure</li>
+ * <li>Upon restart, the FlowFile Repository was not synchronized with its underlying storage mechanism and as such indicates that FlowFile F needs ResourceClaim C.</li>
+ * <li>Since ResourceClaim C has already been destroyed, it is inaccessible, and FlowFile F's Content is not found, so the FlowFile is removed, resulting in data loss.</li>
+ * </ul>
+ *
+ * <p>
+ * Using this method of marking the ResourceClaim as destructable only when the FlowFile repository has been synced with the underlying storage mechanism, we can ensure that on restart, we will
+ * not point to this unneeded claim. As such, it is now safe to destroy the contents.
+ * </p>
+ *
+ * @param claim to mark as now destructable
+ */
+ void markDestructable(ResourceClaim claim);
+
+ /**
+ * Drains up to {@code maxElements} Content Claims from the internal queue
+ * of destructable content claims to the given {@code destination} so that
+ * they can be destroyed.
+ *
+ * @param destination to drain to
+ * @param maxElements max items to drain
+ */
+ void drainDestructableClaims(Collection<ResourceClaim> destination, int maxElements);
+
+ /**
+ * Drains up to {@code maxElements} Content Claims from the internal queue
+ * of destructable content claims to the given {@code destination} so that
+ * they can be destroyed. If no ResourceClaim is ready to be destroyed at
+ * this time, will wait up to the specified amount of time before returning.
+ * If, after the specified amount of time, there is still no ResourceClaim
+ * ready to be destroyed, the method will return without having added
+ * anything to the given {@code destination}.
+ *
+ * @param destination to drain to
+ * @param maxElements max items to drain
+ * @param timeout maximum time to wait
+ * @param unit unit of time to wait
+ */
+ void drainDestructableClaims(Collection<ResourceClaim> destination, int maxElements, long timeout, TimeUnit unit);
+
+ /**
+ * Clears the manager's memory of any and all ResourceClaims that it knows
+ * about
+ */
+ void purge();
+}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-framework-api/src/main/java/org/apache/nifi/controller/status/history/ComponentStatusRepository.java
----------------------------------------------------------------------
diff --git a/nifi-framework-api/src/main/java/org/apache/nifi/controller/status/history/ComponentStatusRepository.java b/nifi-framework-api/src/main/java/org/apache/nifi/controller/status/history/ComponentStatusRepository.java
new file mode 100644
index 0000000..d273096
--- /dev/null
+++ b/nifi-framework-api/src/main/java/org/apache/nifi/controller/status/history/ComponentStatusRepository.java
@@ -0,0 +1,120 @@
+/*
+ * 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.controller.status.history;
+
+import java.util.Date;
+
+import org.apache.nifi.controller.status.ProcessGroupStatus;
+
+/**
+ * A repository for storing and retrieving components' historical status
+ * information
+ */
+public interface ComponentStatusRepository {
+
+ /**
+ * Captures the status information provided in the given report
+ *
+ * @param rootGroupStatus status of root group
+ */
+ void capture(ProcessGroupStatus rootGroupStatus);
+
+ /**
+ * Captures the status information provided in the given report, providing a
+ * timestamp that indicates the time at which the status report was
+ * generated. This can be used to replay historical values.
+ *
+ * @param rootGroupStatus status
+ * @param timestamp timestamp of capture
+ */
+ void capture(ProcessGroupStatus rootGroupStatus, Date timestamp);
+
+ /**
+ * @return the Date at which the latest capture was performed
+ */
+ Date getLastCaptureDate();
+
+ /**
+ * @param connectionId the ID of the Connection for which the Status is
+ * desired
+ * @param start the earliest date for which status information should be
+ * returned; if <code>null</code>, the start date should be assumed to be
+ * the beginning of time
+ * @param end the latest date for which status information should be
+ * returned; if <code>null</code>, the end date should be assumed to be the
+ * current time
+ * @param preferredDataPoints the preferred number of data points to return.
+ * If the date range is large, the total number of data points could be far
+ * too many to process. Therefore, this parameter allows the requestor to
+ * indicate how many samples to return.
+ * @return a {@link StatusHistory} that provides the status information
+ * about the Connection with the given ID during the given time period
+ */
+ StatusHistory getConnectionStatusHistory(String connectionId, Date start, Date end, int preferredDataPoints);
+
+ /**
+ * @param processGroupId of group to get status of
+ * @param start the earliest date for which status information should be
+ * returned; if <code>null</code>, the start date should be assumed to be
+ * the beginning of time
+ * @param end the latest date for which status information should be
+ * returned; if <code>null</code>, the end date should be assumed to be the
+ * current time
+ * @param preferredDataPoints the preferred number of data points to return.
+ * If the date range is large, the total number of data points could be far
+ * too many to process. Therefore, this parameter allows the requestor to
+ * indicate how many samples to return.
+ * @return a {@link StatusHistory} that provides the status information
+ * about the Process Group with the given ID during the given time period
+ */
+ StatusHistory getProcessGroupStatusHistory(String processGroupId, Date start, Date end, int preferredDataPoints);
+
+ /**
+ * @param processorId to get status of
+ * @param start the earliest date for which status information should be
+ * returned; if <code>null</code>, the start date should be assumed to be
+ * the beginning of time
+ * @param end the latest date for which status information should be
+ * returned; if <code>null</code>, the end date should be assumed to be the
+ * current time
+ * @param preferredDataPoints the preferred number of data points to return.
+ * If the date range is large, the total number of data points could be far
+ * too many to process. Therefore, this parameter allows the requestor to
+ * indicate how many samples to return.
+ * @return a {@link StatusHistory} that provides the status information
+ * about the Processor with the given ID during the given time period
+ */
+ StatusHistory getProcessorStatusHistory(String processorId, Date start, Date end, int preferredDataPoints);
+
+ /**
+ * @param remoteGroupId to get history of
+ * @param start the earliest date for which status information should be
+ * returned; if <code>null</code>, the start date should be assumed to be
+ * the beginning of time
+ * @param end the latest date for which status information should be
+ * returned; if <code>null</code>, the end date should be assumed to be the
+ * current time
+ * @param preferredDataPoints the preferred number of data points to return.
+ * If the date range is large, the total number of data points could be far
+ * too many to process. Therefore, this parameter allows the requestor to
+ * indicate how many samples to return.
+ * @return a {@link StatusHistory} that provides the status information
+ * about the Remote Process Group with the given ID during the given time
+ * period
+ */
+ StatusHistory getRemoteProcessGroupStatusHistory(String remoteGroupId, Date start, Date end, int preferredDataPoints);
+}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-framework-api/src/main/java/org/apache/nifi/controller/status/history/MetricDescriptor.java
----------------------------------------------------------------------
diff --git a/nifi-framework-api/src/main/java/org/apache/nifi/controller/status/history/MetricDescriptor.java b/nifi-framework-api/src/main/java/org/apache/nifi/controller/status/history/MetricDescriptor.java
new file mode 100644
index 0000000..8fdce05
--- /dev/null
+++ b/nifi-framework-api/src/main/java/org/apache/nifi/controller/status/history/MetricDescriptor.java
@@ -0,0 +1,66 @@
+/*
+ * 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.controller.status.history;
+
+/**
+ * Describes a particular metric that is derived from a Status History
+ *
+ * @param <T> type of metric
+ */
+public interface MetricDescriptor<T> {
+
+ public enum Formatter {
+
+ COUNT,
+ DURATION,
+ DATA_SIZE
+ };
+
+ /**
+ * Specifies how the values should be formatted
+ *
+ * @return formatter for values
+ */
+ Formatter getFormatter();
+
+ /**
+ * @return a human-readable description of the field
+ */
+ String getDescription();
+
+ /**
+ * @return a human-readable label for the field
+ */
+ String getLabel();
+
+ /**
+ * @return the name of a field
+ */
+ String getField();
+
+ /**
+ * @return a {@link ValueMapper} that can be used to extract a value for the
+ * status history
+ */
+ ValueMapper<T> getValueFunction();
+
+ /**
+ * @return a {@link ValueReducer} that can reduce multiple StatusSnapshots
+ * into a single Long value
+ */
+ ValueReducer<StatusSnapshot, Long> getValueReducer();
+}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-framework-api/src/main/java/org/apache/nifi/controller/status/history/StatusHistory.java
----------------------------------------------------------------------
diff --git a/nifi-framework-api/src/main/java/org/apache/nifi/controller/status/history/StatusHistory.java b/nifi-framework-api/src/main/java/org/apache/nifi/controller/status/history/StatusHistory.java
new file mode 100644
index 0000000..f1bb946
--- /dev/null
+++ b/nifi-framework-api/src/main/java/org/apache/nifi/controller/status/history/StatusHistory.java
@@ -0,0 +1,44 @@
+/*
+ * 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.controller.status.history;
+
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Represents a collection of historical status values for a component
+ */
+public interface StatusHistory {
+
+ /**
+ * @return a Date indicating when this report was generated
+ */
+ Date getDateGenerated();
+
+ /**
+ * @return a Map of component field names and their values. The order in
+ * which these values are displayed is dependent on the natural ordering of
+ * the Map returned
+ */
+ Map<String, String> getComponentDetails();
+
+ /**
+ * @return List of snapshots for a given component
+ */
+ List<StatusSnapshot> getStatusSnapshots();
+}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-framework-api/src/main/java/org/apache/nifi/controller/status/history/StatusSnapshot.java
----------------------------------------------------------------------
diff --git a/nifi-framework-api/src/main/java/org/apache/nifi/controller/status/history/StatusSnapshot.java b/nifi-framework-api/src/main/java/org/apache/nifi/controller/status/history/StatusSnapshot.java
new file mode 100644
index 0000000..551ceb2
--- /dev/null
+++ b/nifi-framework-api/src/main/java/org/apache/nifi/controller/status/history/StatusSnapshot.java
@@ -0,0 +1,42 @@
+/*
+ * 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.controller.status.history;
+
+import java.util.Date;
+import java.util.Map;
+
+/**
+ * A StatusSnapshot represents a Component's status report at some point in time
+ */
+public interface StatusSnapshot {
+
+ /**
+ * @return the point in time for which the status values were obtained
+ */
+ Date getTimestamp();
+
+ /**
+ * @return a Map of MetricDescriptor to value
+ */
+ Map<MetricDescriptor<?>, Long> getStatusMetrics();
+
+ /**
+ * @return a {@link ValueReducer} that is capable of merging multiple
+ * StatusSnapshot objects into a single one
+ */
+ ValueReducer<StatusSnapshot, StatusSnapshot> getValueReducer();
+}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-framework-api/src/main/java/org/apache/nifi/controller/status/history/ValueMapper.java
----------------------------------------------------------------------
diff --git a/nifi-framework-api/src/main/java/org/apache/nifi/controller/status/history/ValueMapper.java b/nifi-framework-api/src/main/java/org/apache/nifi/controller/status/history/ValueMapper.java
new file mode 100644
index 0000000..8000b3a
--- /dev/null
+++ b/nifi-framework-api/src/main/java/org/apache/nifi/controller/status/history/ValueMapper.java
@@ -0,0 +1,23 @@
+/*
+ * 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.controller.status.history;
+
+public interface ValueMapper<S> {
+
+ Long getValue(S status);
+
+}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-framework-api/src/main/java/org/apache/nifi/controller/status/history/ValueReducer.java
----------------------------------------------------------------------
diff --git a/nifi-framework-api/src/main/java/org/apache/nifi/controller/status/history/ValueReducer.java b/nifi-framework-api/src/main/java/org/apache/nifi/controller/status/history/ValueReducer.java
new file mode 100644
index 0000000..0427da7
--- /dev/null
+++ b/nifi-framework-api/src/main/java/org/apache/nifi/controller/status/history/ValueReducer.java
@@ -0,0 +1,25 @@
+/*
+ * 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.controller.status.history;
+
+import java.util.List;
+
+public interface ValueReducer<T, R> {
+
+ R reduce(List<T> values);
+
+}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-framework-api/src/main/java/org/apache/nifi/events/EventReporter.java
----------------------------------------------------------------------
diff --git a/nifi-framework-api/src/main/java/org/apache/nifi/events/EventReporter.java b/nifi-framework-api/src/main/java/org/apache/nifi/events/EventReporter.java
new file mode 100644
index 0000000..d645d60
--- /dev/null
+++ b/nifi-framework-api/src/main/java/org/apache/nifi/events/EventReporter.java
@@ -0,0 +1,29 @@
+/*
+ * 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.events;
+
+import java.io.Serializable;
+
+import org.apache.nifi.reporting.Severity;
+
+/**
+ * Implementations MUST be thread-safe
+ */
+public interface EventReporter extends Serializable {
+
+ void reportEvent(Severity severity, String category, String message);
+}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-framework-api/src/main/java/org/apache/nifi/flowfile/FlowFilePrioritizer.java
----------------------------------------------------------------------
diff --git a/nifi-framework-api/src/main/java/org/apache/nifi/flowfile/FlowFilePrioritizer.java b/nifi-framework-api/src/main/java/org/apache/nifi/flowfile/FlowFilePrioritizer.java
new file mode 100644
index 0000000..684f454
--- /dev/null
+++ b/nifi-framework-api/src/main/java/org/apache/nifi/flowfile/FlowFilePrioritizer.java
@@ -0,0 +1,29 @@
+/*
+ * 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.flowfile;
+
+import java.util.Comparator;
+
+/**
+ * Provides a mechanism to prioritize flow file objects based on their
+ * attributes. The actual flow file content will not be available for comparison
+ * so if features of that content are necessary for prioritization it should be
+ * extracted to be used as an attribute of the flow file.
+ *
+ */
+public interface FlowFilePrioritizer extends Comparator<FlowFile> {
+}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-framework-api/src/main/java/org/apache/nifi/provenance/ProvenanceAuthorizableFactory.java
----------------------------------------------------------------------
diff --git a/nifi-framework-api/src/main/java/org/apache/nifi/provenance/ProvenanceAuthorizableFactory.java b/nifi-framework-api/src/main/java/org/apache/nifi/provenance/ProvenanceAuthorizableFactory.java
new file mode 100644
index 0000000..23d6b3d
--- /dev/null
+++ b/nifi-framework-api/src/main/java/org/apache/nifi/provenance/ProvenanceAuthorizableFactory.java
@@ -0,0 +1,35 @@
+/*
+ * 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.provenance;
+
+import org.apache.nifi.authorization.resource.Authorizable;
+import org.apache.nifi.web.ResourceNotFoundException;
+
+public interface ProvenanceAuthorizableFactory {
+
+ /**
+ * Generates an Authorizable object for the Provenance events of the component with the given ID
+ *
+ * @param componentId the ID of the component to which the Provenance events belong
+ *
+ * @return the Authorizable that can be use to authorize access to provenance events
+ * @throws ResourceNotFoundException if no component can be found with the given ID
+ */
+ Authorizable createProvenanceAuthorizable(String componentId);
+
+}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-framework-api/src/main/java/org/apache/nifi/provenance/ProvenanceRepository.java
----------------------------------------------------------------------
diff --git a/nifi-framework-api/src/main/java/org/apache/nifi/provenance/ProvenanceRepository.java b/nifi-framework-api/src/main/java/org/apache/nifi/provenance/ProvenanceRepository.java
new file mode 100644
index 0000000..7ac1a65
--- /dev/null
+++ b/nifi-framework-api/src/main/java/org/apache/nifi/provenance/ProvenanceRepository.java
@@ -0,0 +1,160 @@
+/*
+ * 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.provenance;
+
+
+import org.apache.nifi.authorization.Authorizer;
+import org.apache.nifi.authorization.user.NiFiUser;
+import org.apache.nifi.events.EventReporter;
+import org.apache.nifi.provenance.lineage.ComputeLineageSubmission;
+import org.apache.nifi.provenance.search.Query;
+import org.apache.nifi.provenance.search.QuerySubmission;
+import org.apache.nifi.provenance.search.SearchableField;
+
+import java.io.IOException;
+import java.util.List;
+
+public interface ProvenanceRepository extends ProvenanceEventRepository {
+
+ /**
+ * Performs any initialization needed. This should be called only by the
+ * framework.
+ *
+ * @param eventReporter to report to
+ * @param authorizer the authorizer to use for authorizing individual events
+ * @param resourceFactory the resource factory to use for generating Provenance Resource objects for authorization purposes
+ * @throws java.io.IOException if unable to initialize
+ */
+ void initialize(EventReporter eventReporter, Authorizer authorizer, ProvenanceAuthorizableFactory resourceFactory) throws IOException;
+
+
+ ProvenanceEventRecord getEvent(long id, NiFiUser user) throws IOException;
+
+ /**
+ * Returns a List of all <code>ProvenanceEventRecord</code>s in the
+ * repository starting with the given ID. The first ID in the repository
+ * will always be 0 or higher. Each event that is found will be authorized
+ * against the given NiFiUser. If the user does not have authorization for
+ * the event, the event will not be returned.
+ *
+ * @param firstRecordId id of the first record to retrieve
+ * @param maxRecords maximum number of records to retrieve
+ * @param user the NiFi user that the events should be authorized against
+ * @return records
+ * @throws java.io.IOException if error reading from repository
+ */
+ List<ProvenanceEventRecord> getEvents(long firstRecordId, final int maxRecords, NiFiUser user) throws IOException;
+
+ /**
+ * @return the {@link ProvenanceEventRepository} backing this ProvenanceRepository
+ */
+ ProvenanceEventRepository getProvenanceEventRepository();
+
+ /**
+ * Submits an asynchronous request to process the given query, returning an
+ * identifier that can be used to fetch the results at a later time
+ *
+ * @param query to submit
+ * @param user the NiFi User to authorize the events against
+ *
+ * @return an identifier that can be used to fetch the results at a later
+ * time
+ */
+ QuerySubmission submitQuery(Query query, NiFiUser user);
+
+ /**
+ * @param queryIdentifier of the query
+ * @param user the user who is retrieving the query
+ *
+ * @return the QueryResult associated with the given identifier, if the
+ * query has finished processing. If the query has not yet finished running,
+ * returns <code>null</code>
+ */
+ QuerySubmission retrieveQuerySubmission(String queryIdentifier, NiFiUser user);
+
+ /**
+ * Submits a Lineage Computation to be completed and returns the
+ * AsynchronousLineageResult that indicates the status of the request and
+ * the results, if the computation is complete. If the given user does not
+ * have authorization to view one of the events in the lineage, a placeholder
+ * event will be used instead that provides none of the event details except
+ * for the identifier of the component that emitted the Provenance Event. It is
+ * necessary to include this node in the lineage view so that the lineage makes
+ * sense, rather than showing disconnected graphs when the user is not authorized
+ * for all components' provenance events.
+ *
+ * @param flowFileUuid the UUID of the FlowFile for which the Lineage should
+ * be calculated
+ * @param user the NiFi User to authorize events against
+ *
+ * @return a {@link ComputeLineageSubmission} object that can be used to
+ * check if the computing is complete and if so get the results
+ */
+ ComputeLineageSubmission submitLineageComputation(String flowFileUuid, NiFiUser user);
+
+ /**
+ * @param lineageIdentifier identifier of lineage to compute
+ * @param user the user who is retrieving the lineage submission
+ *
+ * @return the {@link ComputeLineageSubmission} associated with the given
+ * identifier
+ */
+ ComputeLineageSubmission retrieveLineageSubmission(String lineageIdentifier, NiFiUser user);
+
+ /**
+ * Submits a request to expand the parents of the event with the given id. If the given user
+ * is not authorized to access any event, a placeholder will be used instead that contains only
+ * the ID of the component that emitted the event.
+ *
+ * @param eventId the one-up id of the Event to expand
+ * @param user the NiFi user to authorize events against
+ * @return a submission which can be checked for status
+ *
+ * @throws IllegalArgumentException if the given identifier identifies a
+ * Provenance Event that has a Type that is not expandable or if the
+ * identifier cannot be found
+ */
+ ComputeLineageSubmission submitExpandParents(long eventId, NiFiUser user);
+
+ /**
+ * Submits a request to expand the children of the event with the given id. If the given user
+ * is not authorized to access any event, a placeholder will be used instead that contains only
+ * the ID of the component that emitted the event.
+ *
+ * @param eventId the one-up id of the Event
+ * @param user the NiFi user to authorize events against
+ *
+ * @return a submission which can be checked for status
+ *
+ * @throws IllegalArgumentException if the given identifier identifies a
+ * Provenance Event that has a Type that is not expandable or if the
+ * identifier cannot be found
+ */
+ ComputeLineageSubmission submitExpandChildren(long eventId, NiFiUser user);
+
+ /**
+ * @return a list of all fields that can be searched via the
+ * {@link ProvenanceRepository#submitQuery(Query, NiFiUser)} method
+ */
+ List<SearchableField> getSearchableFields();
+
+ /**
+ * @return a list of all FlowFile attributes that can be searched via the
+ * {@link ProvenanceRepository#submitQuery(Query, NiFiUser)} method
+ */
+ List<SearchableField> getSearchableAttributes();
+}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-framework-api/src/main/java/org/apache/nifi/provenance/lineage/ComputeLineageResult.java
----------------------------------------------------------------------
diff --git a/nifi-framework-api/src/main/java/org/apache/nifi/provenance/lineage/ComputeLineageResult.java b/nifi-framework-api/src/main/java/org/apache/nifi/provenance/lineage/ComputeLineageResult.java
new file mode 100644
index 0000000..4d0f991
--- /dev/null
+++ b/nifi-framework-api/src/main/java/org/apache/nifi/provenance/lineage/ComputeLineageResult.java
@@ -0,0 +1,58 @@
+/*
+ * 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.provenance.lineage;
+
+import java.util.Date;
+import java.util.List;
+
+/**
+ *
+ */
+public interface ComputeLineageResult {
+
+ /**
+ * @return all nodes for the graph
+ */
+ List<LineageNode> getNodes();
+
+ /**
+ * @return all links for the graph
+ */
+ List<LineageEdge> getEdges();
+
+ /**
+ * @return the date at which this AsynchronousLineageResult will expire
+ */
+ Date getExpiration();
+
+ /**
+ * @return If an error occurred while computing the lineage, this will return the
+ * serialized error; otherwise, returns <code>null</code>
+ */
+ String getError();
+
+ /**
+ * @return an integer between 0 and 100 (inclusive) that indicates what
+ * percentage of completion the computation has reached
+ */
+ int getPercentComplete();
+
+ /**
+ * @return Indicates whether or not the lineage has finished running
+ */
+ boolean isFinished();
+}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-framework-api/src/main/java/org/apache/nifi/provenance/lineage/ComputeLineageSubmission.java
----------------------------------------------------------------------
diff --git a/nifi-framework-api/src/main/java/org/apache/nifi/provenance/lineage/ComputeLineageSubmission.java b/nifi-framework-api/src/main/java/org/apache/nifi/provenance/lineage/ComputeLineageSubmission.java
new file mode 100644
index 0000000..8a11523
--- /dev/null
+++ b/nifi-framework-api/src/main/java/org/apache/nifi/provenance/lineage/ComputeLineageSubmission.java
@@ -0,0 +1,75 @@
+/*
+ * 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.provenance.lineage;
+
+import java.util.Collection;
+import java.util.Date;
+
+public interface ComputeLineageSubmission {
+
+ /**
+ * @return the {@link ComputeLineageResult} that contains the results. The
+ * results may be partial if a call to
+ * {@link ComputeLineageResult#isFinished()} returns <code>false</code>
+ */
+ ComputeLineageResult getResult();
+
+ /**
+ * @return the date at which this lineage was submitted
+ */
+ Date getSubmissionTime();
+
+ /**
+ * @return the identity of the user who submitted the request
+ */
+ String getSubmitterIdentity();
+
+ /**
+ * @return the generated identifier for this lineage result
+ */
+ String getLineageIdentifier();
+
+ /**
+ * Cancels the lineage computation
+ */
+ void cancel();
+
+ /**
+ * @return <code>true</code> if {@link #cancel()} has been called,
+ * <code>false</code> otherwise
+ */
+ boolean isCanceled();
+
+ /**
+ * @return the type of Lineage Computation that was submitted
+ */
+ LineageComputationType getLineageComputationType();
+
+ /**
+ * @return If the Lineage Computation Type of this submission is
+ * {@link LineageComputationType.EXPAND_CHILDREN} or
+ * {@link LineageComputationType.EXPAND_PARENTS}, indicates the ID event
+ * that is to be expanded; otherwise, returns <code>null</code>
+ */
+ Long getExpandedEventId();
+
+ /**
+ * @return all FlowFile UUID's that are encapsulated in this lineage
+ * computation submission
+ */
+ Collection<String> getLineageFlowFileUuids();
+}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-framework-api/src/main/java/org/apache/nifi/provenance/lineage/Lineage.java
----------------------------------------------------------------------
diff --git a/nifi-framework-api/src/main/java/org/apache/nifi/provenance/lineage/Lineage.java b/nifi-framework-api/src/main/java/org/apache/nifi/provenance/lineage/Lineage.java
new file mode 100644
index 0000000..ff5fee7
--- /dev/null
+++ b/nifi-framework-api/src/main/java/org/apache/nifi/provenance/lineage/Lineage.java
@@ -0,0 +1,37 @@
+/*
+ * 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.provenance.lineage;
+
+import java.util.List;
+
+/**
+ * A Data Structure for representing a Directed Graph that depicts the lineage
+ * of a FlowFile and all events that occurred for the FlowFile
+ */
+public interface Lineage {
+
+ /**
+ * @return all nodes for the graph
+ */
+ public List<LineageNode> getNodes();
+
+ /**
+ * @return all links for the graph
+ */
+ public List<LineageEdge> getEdges();
+
+}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-framework-api/src/main/java/org/apache/nifi/provenance/lineage/LineageComputationType.java
----------------------------------------------------------------------
diff --git a/nifi-framework-api/src/main/java/org/apache/nifi/provenance/lineage/LineageComputationType.java b/nifi-framework-api/src/main/java/org/apache/nifi/provenance/lineage/LineageComputationType.java
new file mode 100644
index 0000000..be74324
--- /dev/null
+++ b/nifi-framework-api/src/main/java/org/apache/nifi/provenance/lineage/LineageComputationType.java
@@ -0,0 +1,27 @@
+/*
+ * 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.provenance.lineage;
+
+/**
+ *
+ */
+public enum LineageComputationType {
+
+ FLOWFILE_LINEAGE,
+ EXPAND_PARENTS,
+ EXPAND_CHILDREN;
+}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-framework-api/src/main/java/org/apache/nifi/provenance/lineage/LineageEdge.java
----------------------------------------------------------------------
diff --git a/nifi-framework-api/src/main/java/org/apache/nifi/provenance/lineage/LineageEdge.java b/nifi-framework-api/src/main/java/org/apache/nifi/provenance/lineage/LineageEdge.java
new file mode 100644
index 0000000..dba56f3
--- /dev/null
+++ b/nifi-framework-api/src/main/java/org/apache/nifi/provenance/lineage/LineageEdge.java
@@ -0,0 +1,26 @@
+/*
+ * 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.provenance.lineage;
+
+public interface LineageEdge {
+
+ String getUuid();
+
+ LineageNode getSource();
+
+ LineageNode getDestination();
+}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-framework-api/src/main/java/org/apache/nifi/provenance/lineage/LineageNode.java
----------------------------------------------------------------------
diff --git a/nifi-framework-api/src/main/java/org/apache/nifi/provenance/lineage/LineageNode.java b/nifi-framework-api/src/main/java/org/apache/nifi/provenance/lineage/LineageNode.java
new file mode 100644
index 0000000..5d0956e
--- /dev/null
+++ b/nifi-framework-api/src/main/java/org/apache/nifi/provenance/lineage/LineageNode.java
@@ -0,0 +1,45 @@
+/*
+ * 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.provenance.lineage;
+
+public interface LineageNode {
+
+ /**
+ * @return the type of the LineageNode
+ */
+ LineageNodeType getNodeType();
+
+ /**
+ * @return the UUID of the FlowFile for which this Node was created
+ */
+ String getFlowFileUuid();
+
+ /**
+ * @return the UUID for this LineageNode
+ */
+ String getIdentifier();
+
+ /**
+ * @return the timestamp that corresponds to this Node. The meaning of the
+ * timestamp may differ between implementations. For example, a
+ * {@link ProvenanceEventLineageNode}'s timestamp indicates the time at
+ * which the event occurred. However, for a Node that reperesents a
+ * FlowFile, for example, the timestamp may represent the time at which the
+ * FlowFile was created
+ */
+ long getTimestamp();
+}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-framework-api/src/main/java/org/apache/nifi/provenance/lineage/LineageNodeType.java
----------------------------------------------------------------------
diff --git a/nifi-framework-api/src/main/java/org/apache/nifi/provenance/lineage/LineageNodeType.java b/nifi-framework-api/src/main/java/org/apache/nifi/provenance/lineage/LineageNodeType.java
new file mode 100644
index 0000000..67e0d61
--- /dev/null
+++ b/nifi-framework-api/src/main/java/org/apache/nifi/provenance/lineage/LineageNodeType.java
@@ -0,0 +1,23 @@
+/*
+ * 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.provenance.lineage;
+
+public enum LineageNodeType {
+
+ FLOWFILE_NODE,
+ PROVENANCE_EVENT_NODE;
+}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-framework-api/src/main/java/org/apache/nifi/provenance/lineage/ProvenanceEventLineageNode.java
----------------------------------------------------------------------
diff --git a/nifi-framework-api/src/main/java/org/apache/nifi/provenance/lineage/ProvenanceEventLineageNode.java b/nifi-framework-api/src/main/java/org/apache/nifi/provenance/lineage/ProvenanceEventLineageNode.java
new file mode 100644
index 0000000..f490496
--- /dev/null
+++ b/nifi-framework-api/src/main/java/org/apache/nifi/provenance/lineage/ProvenanceEventLineageNode.java
@@ -0,0 +1,32 @@
+/*
+ * 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.provenance.lineage;
+
+import java.util.List;
+
+import org.apache.nifi.provenance.ProvenanceEventType;
+
+public interface ProvenanceEventLineageNode extends LineageNode {
+
+ ProvenanceEventType getEventType();
+
+ long getEventIdentifier();
+
+ List<String> getParentUuids();
+
+ List<String> getChildUuids();
+}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-framework-api/src/main/java/org/apache/nifi/provenance/search/Query.java
----------------------------------------------------------------------
diff --git a/nifi-framework-api/src/main/java/org/apache/nifi/provenance/search/Query.java b/nifi-framework-api/src/main/java/org/apache/nifi/provenance/search/Query.java
new file mode 100644
index 0000000..3519c14
--- /dev/null
+++ b/nifi-framework-api/src/main/java/org/apache/nifi/provenance/search/Query.java
@@ -0,0 +1,96 @@
+/*
+ * 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.provenance.search;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Date;
+import java.util.List;
+import java.util.Objects;
+
+
+public class Query {
+
+ private final String identifier;
+ private final List<SearchTerm> searchTerms = new ArrayList<>();
+ private Date startDate;
+ private Date endDate;
+ private String minFileSize;
+ private String maxFileSize;
+ private int maxResults = 1000;
+
+ public Query(final String identifier) {
+ this.identifier = Objects.requireNonNull(identifier);
+ }
+
+ public String getIdentifier() {
+ return identifier;
+ }
+
+ public void addSearchTerm(final SearchTerm searchTerm) {
+ searchTerms.add(searchTerm);
+ }
+
+ public List<SearchTerm> getSearchTerms() {
+ return Collections.unmodifiableList(searchTerms);
+ }
+
+ public Date getStartDate() {
+ return startDate;
+ }
+
+ public void setStartDate(Date startDate) {
+ this.startDate = startDate;
+ }
+
+ public Date getEndDate() {
+ return endDate;
+ }
+
+ public void setEndDate(Date endDate) {
+ this.endDate = endDate;
+ }
+
+ public int getMaxResults() {
+ return maxResults;
+ }
+
+ public void setMaxResults(int maxResults) {
+ this.maxResults = maxResults;
+ }
+
+ public void setMinFileSize(final String fileSize) {
+ this.minFileSize = fileSize;
+ }
+
+ public String getMinFileSize() {
+ return minFileSize;
+ }
+
+ public void setMaxFileSize(final String fileSize) {
+ this.maxFileSize = fileSize;
+ }
+
+ public String getMaxFileSize() {
+ return maxFileSize;
+ }
+
+ @Override
+ public String toString() {
+ return "Query[ " + searchTerms + " ]";
+ }
+}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-framework-api/src/main/java/org/apache/nifi/provenance/search/QueryResult.java
----------------------------------------------------------------------
diff --git a/nifi-framework-api/src/main/java/org/apache/nifi/provenance/search/QueryResult.java b/nifi-framework-api/src/main/java/org/apache/nifi/provenance/search/QueryResult.java
new file mode 100644
index 0000000..0079433
--- /dev/null
+++ b/nifi-framework-api/src/main/java/org/apache/nifi/provenance/search/QueryResult.java
@@ -0,0 +1,63 @@
+/*
+ * 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.provenance.search;
+
+import java.util.Date;
+import java.util.List;
+
+import org.apache.nifi.provenance.ProvenanceEventRecord;
+
+public interface QueryResult {
+
+ /**
+ * @return the Provenance events that match the query (up to the limit
+ * specified in the query)
+ */
+ List<ProvenanceEventRecord> getMatchingEvents();
+
+ /**
+ * @return the total number of Provenance Events that hit
+ */
+ long getTotalHitCount();
+
+ /**
+ * @return the number of milliseconds the query took to run
+ */
+ long getQueryTime();
+
+ /**
+ * @return the date at which this QueryResult will expire
+ */
+ Date getExpiration();
+
+ /**
+ * @return If an error occurred while computing the lineage, this will return the
+ * serialized error; otherwise, returns <code>null</code>
+ */
+ String getError();
+
+ /**
+ * @return an integer between 0 and 100 (inclusive) that indicates what
+ * percentage of completion the query has reached
+ */
+ int getPercentComplete();
+
+ /**
+ * @return Indicates whether or not the query has finished running
+ */
+ boolean isFinished();
+}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-framework-api/src/main/java/org/apache/nifi/provenance/search/QuerySubmission.java
----------------------------------------------------------------------
diff --git a/nifi-framework-api/src/main/java/org/apache/nifi/provenance/search/QuerySubmission.java b/nifi-framework-api/src/main/java/org/apache/nifi/provenance/search/QuerySubmission.java
new file mode 100644
index 0000000..45efe4b
--- /dev/null
+++ b/nifi-framework-api/src/main/java/org/apache/nifi/provenance/search/QuerySubmission.java
@@ -0,0 +1,60 @@
+/*
+ * 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.provenance.search;
+
+import java.util.Date;
+
+public interface QuerySubmission {
+
+ /**
+ * @return the query that this submission pertains to
+ */
+ Query getQuery();
+
+ /**
+ * @return the {@link QueryResult} for this query. Note that the result is
+ * only a partial result if the result of calling
+ * {@link QueryResult#isFinished()} is <code>false</code>
+ */
+ QueryResult getResult();
+
+ /**
+ * @return the date at which this query was submitted
+ */
+ Date getSubmissionTime();
+
+ /**
+ * @return the generated identifier for this query result
+ */
+ String getQueryIdentifier();
+
+ /**
+ * Cancels the query
+ */
+ void cancel();
+
+ /**
+ * @return <code>true</code> if {@link #cancel()} has been called,
+ * <code>false</code> otherwise
+ */
+ boolean isCanceled();
+
+ /**
+ * @return the identity of the user who submitted the query
+ */
+ String getSubmitterIdentity();
+}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-framework-api/src/main/java/org/apache/nifi/provenance/search/SearchTerm.java
----------------------------------------------------------------------
diff --git a/nifi-framework-api/src/main/java/org/apache/nifi/provenance/search/SearchTerm.java b/nifi-framework-api/src/main/java/org/apache/nifi/provenance/search/SearchTerm.java
new file mode 100644
index 0000000..573dbd7
--- /dev/null
+++ b/nifi-framework-api/src/main/java/org/apache/nifi/provenance/search/SearchTerm.java
@@ -0,0 +1,24 @@
+/*
+ * 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.provenance.search;
+
+public interface SearchTerm {
+
+ SearchableField getSearchableField();
+
+ String getValue();
+}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-framework-api/src/main/java/org/apache/nifi/provenance/search/SearchTerms.java
----------------------------------------------------------------------
diff --git a/nifi-framework-api/src/main/java/org/apache/nifi/provenance/search/SearchTerms.java b/nifi-framework-api/src/main/java/org/apache/nifi/provenance/search/SearchTerms.java
new file mode 100644
index 0000000..aad4d7b
--- /dev/null
+++ b/nifi-framework-api/src/main/java/org/apache/nifi/provenance/search/SearchTerms.java
@@ -0,0 +1,39 @@
+/*
+ * 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.provenance.search;
+
+public class SearchTerms {
+
+ public static SearchTerm newSearchTerm(final SearchableField field, final String value) {
+ return new SearchTerm() {
+ @Override
+ public SearchableField getSearchableField() {
+ return field;
+ }
+
+ @Override
+ public String getValue() {
+ return value;
+ }
+
+ @Override
+ public String toString() {
+ return getValue();
+ }
+ };
+ }
+}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-framework-api/src/main/java/org/apache/nifi/provenance/search/SearchableField.java
----------------------------------------------------------------------
diff --git a/nifi-framework-api/src/main/java/org/apache/nifi/provenance/search/SearchableField.java b/nifi-framework-api/src/main/java/org/apache/nifi/provenance/search/SearchableField.java
new file mode 100644
index 0000000..85c6154
--- /dev/null
+++ b/nifi-framework-api/src/main/java/org/apache/nifi/provenance/search/SearchableField.java
@@ -0,0 +1,52 @@
+/*
+ * 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.provenance.search;
+
+/**
+ * A SearchableField represents a field in a Provenance Event that can be
+ * searched
+ */
+public interface SearchableField {
+
+ /**
+ * @return the identifier that is used to refer to this field
+ */
+ String getIdentifier();
+
+ /**
+ * @return the name of the field that is used when searching the repository
+ */
+ String getSearchableFieldName();
+
+ /**
+ * @return the "friendly" name or "display name" of the field, which may be
+ * more human-readable than the searchable field name
+ */
+ String getFriendlyName();
+
+ /**
+ * @return the type of the data stored in this field
+ */
+ SearchableFieldType getFieldType();
+
+ /**
+ * @return <code>true</code> if this field represents a FlowFile attribute,
+ * <code>false</code> if the field represents a Provenance Event detail,
+ * such as Source System URI
+ */
+ boolean isAttribute();
+}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-framework-api/src/main/java/org/apache/nifi/provenance/search/SearchableFieldType.java
----------------------------------------------------------------------
diff --git a/nifi-framework-api/src/main/java/org/apache/nifi/provenance/search/SearchableFieldType.java b/nifi-framework-api/src/main/java/org/apache/nifi/provenance/search/SearchableFieldType.java
new file mode 100644
index 0000000..51ece58
--- /dev/null
+++ b/nifi-framework-api/src/main/java/org/apache/nifi/provenance/search/SearchableFieldType.java
@@ -0,0 +1,28 @@
+/*
+ * 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.provenance.search;
+
+/**
+ *
+ */
+public enum SearchableFieldType {
+
+ STRING,
+ DATE,
+ DATA_SIZE,
+ LONG;
+}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-framework-api/src/main/java/org/apache/nifi/remote/RemoteDestination.java
----------------------------------------------------------------------
diff --git a/nifi-framework-api/src/main/java/org/apache/nifi/remote/RemoteDestination.java b/nifi-framework-api/src/main/java/org/apache/nifi/remote/RemoteDestination.java
new file mode 100644
index 0000000..c3a34b2
--- /dev/null
+++ b/nifi-framework-api/src/main/java/org/apache/nifi/remote/RemoteDestination.java
@@ -0,0 +1,50 @@
+/*
+ * 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.remote;
+
+import java.util.concurrent.TimeUnit;
+
+/**
+ * A model object for referring to a remote destination (i.e., a Port) for
+ * site-to-site communications
+ */
+public interface RemoteDestination {
+
+ /**
+ * @return the identifier of the remote destination
+ */
+ String getIdentifier();
+
+ /**
+ * @return the human-readable name of the remote destination
+ */
+ String getName();
+
+ /**
+ * @param timeUnit to yield
+ * @return the amount of time that system should pause sending to a
+ * particular node if unable to send data to or receive data from this
+ * endpoint
+ */
+ long getYieldPeriod(TimeUnit timeUnit);
+
+ /**
+ * @return whether or not compression should be used when transferring data
+ * to or receiving data from the remote endpoint
+ */
+ boolean isUseCompression();
+}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-framework-api/src/main/java/org/apache/nifi/web/ClusterRequestException.java
----------------------------------------------------------------------
diff --git a/nifi-framework-api/src/main/java/org/apache/nifi/web/ClusterRequestException.java b/nifi-framework-api/src/main/java/org/apache/nifi/web/ClusterRequestException.java
new file mode 100644
index 0000000..ee5f417
--- /dev/null
+++ b/nifi-framework-api/src/main/java/org/apache/nifi/web/ClusterRequestException.java
@@ -0,0 +1,39 @@
+/*
+ * 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.web;
+
+/**
+ * An general error occurred when attempting to communicate with the cluster.
+ */
+public class ClusterRequestException extends RuntimeException {
+
+ public ClusterRequestException(Throwable cause) {
+ super(cause);
+ }
+
+ public ClusterRequestException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public ClusterRequestException(String message) {
+ super(message);
+ }
+
+ public ClusterRequestException() {
+ }
+
+}
[07/10] nifi git commit: NIFI-1896 This closes #650. Refactored
nifi-api into nifi-framework-api and other locations. The nifi-api is
specific to that which is needed for intended extension points.
Posted by jo...@apache.org.
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-api/src/main/java/org/apache/nifi/controller/status/history/ComponentStatusRepository.java
----------------------------------------------------------------------
diff --git a/nifi-api/src/main/java/org/apache/nifi/controller/status/history/ComponentStatusRepository.java b/nifi-api/src/main/java/org/apache/nifi/controller/status/history/ComponentStatusRepository.java
deleted file mode 100644
index d273096..0000000
--- a/nifi-api/src/main/java/org/apache/nifi/controller/status/history/ComponentStatusRepository.java
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * 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.controller.status.history;
-
-import java.util.Date;
-
-import org.apache.nifi.controller.status.ProcessGroupStatus;
-
-/**
- * A repository for storing and retrieving components' historical status
- * information
- */
-public interface ComponentStatusRepository {
-
- /**
- * Captures the status information provided in the given report
- *
- * @param rootGroupStatus status of root group
- */
- void capture(ProcessGroupStatus rootGroupStatus);
-
- /**
- * Captures the status information provided in the given report, providing a
- * timestamp that indicates the time at which the status report was
- * generated. This can be used to replay historical values.
- *
- * @param rootGroupStatus status
- * @param timestamp timestamp of capture
- */
- void capture(ProcessGroupStatus rootGroupStatus, Date timestamp);
-
- /**
- * @return the Date at which the latest capture was performed
- */
- Date getLastCaptureDate();
-
- /**
- * @param connectionId the ID of the Connection for which the Status is
- * desired
- * @param start the earliest date for which status information should be
- * returned; if <code>null</code>, the start date should be assumed to be
- * the beginning of time
- * @param end the latest date for which status information should be
- * returned; if <code>null</code>, the end date should be assumed to be the
- * current time
- * @param preferredDataPoints the preferred number of data points to return.
- * If the date range is large, the total number of data points could be far
- * too many to process. Therefore, this parameter allows the requestor to
- * indicate how many samples to return.
- * @return a {@link StatusHistory} that provides the status information
- * about the Connection with the given ID during the given time period
- */
- StatusHistory getConnectionStatusHistory(String connectionId, Date start, Date end, int preferredDataPoints);
-
- /**
- * @param processGroupId of group to get status of
- * @param start the earliest date for which status information should be
- * returned; if <code>null</code>, the start date should be assumed to be
- * the beginning of time
- * @param end the latest date for which status information should be
- * returned; if <code>null</code>, the end date should be assumed to be the
- * current time
- * @param preferredDataPoints the preferred number of data points to return.
- * If the date range is large, the total number of data points could be far
- * too many to process. Therefore, this parameter allows the requestor to
- * indicate how many samples to return.
- * @return a {@link StatusHistory} that provides the status information
- * about the Process Group with the given ID during the given time period
- */
- StatusHistory getProcessGroupStatusHistory(String processGroupId, Date start, Date end, int preferredDataPoints);
-
- /**
- * @param processorId to get status of
- * @param start the earliest date for which status information should be
- * returned; if <code>null</code>, the start date should be assumed to be
- * the beginning of time
- * @param end the latest date for which status information should be
- * returned; if <code>null</code>, the end date should be assumed to be the
- * current time
- * @param preferredDataPoints the preferred number of data points to return.
- * If the date range is large, the total number of data points could be far
- * too many to process. Therefore, this parameter allows the requestor to
- * indicate how many samples to return.
- * @return a {@link StatusHistory} that provides the status information
- * about the Processor with the given ID during the given time period
- */
- StatusHistory getProcessorStatusHistory(String processorId, Date start, Date end, int preferredDataPoints);
-
- /**
- * @param remoteGroupId to get history of
- * @param start the earliest date for which status information should be
- * returned; if <code>null</code>, the start date should be assumed to be
- * the beginning of time
- * @param end the latest date for which status information should be
- * returned; if <code>null</code>, the end date should be assumed to be the
- * current time
- * @param preferredDataPoints the preferred number of data points to return.
- * If the date range is large, the total number of data points could be far
- * too many to process. Therefore, this parameter allows the requestor to
- * indicate how many samples to return.
- * @return a {@link StatusHistory} that provides the status information
- * about the Remote Process Group with the given ID during the given time
- * period
- */
- StatusHistory getRemoteProcessGroupStatusHistory(String remoteGroupId, Date start, Date end, int preferredDataPoints);
-}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-api/src/main/java/org/apache/nifi/controller/status/history/MetricDescriptor.java
----------------------------------------------------------------------
diff --git a/nifi-api/src/main/java/org/apache/nifi/controller/status/history/MetricDescriptor.java b/nifi-api/src/main/java/org/apache/nifi/controller/status/history/MetricDescriptor.java
deleted file mode 100644
index 8fdce05..0000000
--- a/nifi-api/src/main/java/org/apache/nifi/controller/status/history/MetricDescriptor.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * 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.controller.status.history;
-
-/**
- * Describes a particular metric that is derived from a Status History
- *
- * @param <T> type of metric
- */
-public interface MetricDescriptor<T> {
-
- public enum Formatter {
-
- COUNT,
- DURATION,
- DATA_SIZE
- };
-
- /**
- * Specifies how the values should be formatted
- *
- * @return formatter for values
- */
- Formatter getFormatter();
-
- /**
- * @return a human-readable description of the field
- */
- String getDescription();
-
- /**
- * @return a human-readable label for the field
- */
- String getLabel();
-
- /**
- * @return the name of a field
- */
- String getField();
-
- /**
- * @return a {@link ValueMapper} that can be used to extract a value for the
- * status history
- */
- ValueMapper<T> getValueFunction();
-
- /**
- * @return a {@link ValueReducer} that can reduce multiple StatusSnapshots
- * into a single Long value
- */
- ValueReducer<StatusSnapshot, Long> getValueReducer();
-}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-api/src/main/java/org/apache/nifi/controller/status/history/StatusHistory.java
----------------------------------------------------------------------
diff --git a/nifi-api/src/main/java/org/apache/nifi/controller/status/history/StatusHistory.java b/nifi-api/src/main/java/org/apache/nifi/controller/status/history/StatusHistory.java
deleted file mode 100644
index f1bb946..0000000
--- a/nifi-api/src/main/java/org/apache/nifi/controller/status/history/StatusHistory.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * 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.controller.status.history;
-
-import java.util.Date;
-import java.util.List;
-import java.util.Map;
-
-/**
- * Represents a collection of historical status values for a component
- */
-public interface StatusHistory {
-
- /**
- * @return a Date indicating when this report was generated
- */
- Date getDateGenerated();
-
- /**
- * @return a Map of component field names and their values. The order in
- * which these values are displayed is dependent on the natural ordering of
- * the Map returned
- */
- Map<String, String> getComponentDetails();
-
- /**
- * @return List of snapshots for a given component
- */
- List<StatusSnapshot> getStatusSnapshots();
-}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-api/src/main/java/org/apache/nifi/controller/status/history/StatusSnapshot.java
----------------------------------------------------------------------
diff --git a/nifi-api/src/main/java/org/apache/nifi/controller/status/history/StatusSnapshot.java b/nifi-api/src/main/java/org/apache/nifi/controller/status/history/StatusSnapshot.java
deleted file mode 100644
index 551ceb2..0000000
--- a/nifi-api/src/main/java/org/apache/nifi/controller/status/history/StatusSnapshot.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * 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.controller.status.history;
-
-import java.util.Date;
-import java.util.Map;
-
-/**
- * A StatusSnapshot represents a Component's status report at some point in time
- */
-public interface StatusSnapshot {
-
- /**
- * @return the point in time for which the status values were obtained
- */
- Date getTimestamp();
-
- /**
- * @return a Map of MetricDescriptor to value
- */
- Map<MetricDescriptor<?>, Long> getStatusMetrics();
-
- /**
- * @return a {@link ValueReducer} that is capable of merging multiple
- * StatusSnapshot objects into a single one
- */
- ValueReducer<StatusSnapshot, StatusSnapshot> getValueReducer();
-}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-api/src/main/java/org/apache/nifi/controller/status/history/ValueMapper.java
----------------------------------------------------------------------
diff --git a/nifi-api/src/main/java/org/apache/nifi/controller/status/history/ValueMapper.java b/nifi-api/src/main/java/org/apache/nifi/controller/status/history/ValueMapper.java
deleted file mode 100644
index 8000b3a..0000000
--- a/nifi-api/src/main/java/org/apache/nifi/controller/status/history/ValueMapper.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * 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.controller.status.history;
-
-public interface ValueMapper<S> {
-
- Long getValue(S status);
-
-}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-api/src/main/java/org/apache/nifi/controller/status/history/ValueReducer.java
----------------------------------------------------------------------
diff --git a/nifi-api/src/main/java/org/apache/nifi/controller/status/history/ValueReducer.java b/nifi-api/src/main/java/org/apache/nifi/controller/status/history/ValueReducer.java
deleted file mode 100644
index 0427da7..0000000
--- a/nifi-api/src/main/java/org/apache/nifi/controller/status/history/ValueReducer.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * 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.controller.status.history;
-
-import java.util.List;
-
-public interface ValueReducer<T, R> {
-
- R reduce(List<T> values);
-
-}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-api/src/main/java/org/apache/nifi/events/EventReporter.java
----------------------------------------------------------------------
diff --git a/nifi-api/src/main/java/org/apache/nifi/events/EventReporter.java b/nifi-api/src/main/java/org/apache/nifi/events/EventReporter.java
deleted file mode 100644
index d645d60..0000000
--- a/nifi-api/src/main/java/org/apache/nifi/events/EventReporter.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * 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.events;
-
-import java.io.Serializable;
-
-import org.apache.nifi.reporting.Severity;
-
-/**
- * Implementations MUST be thread-safe
- */
-public interface EventReporter extends Serializable {
-
- void reportEvent(Severity severity, String category, String message);
-}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-api/src/main/java/org/apache/nifi/flowfile/FlowFile.java
----------------------------------------------------------------------
diff --git a/nifi-api/src/main/java/org/apache/nifi/flowfile/FlowFile.java b/nifi-api/src/main/java/org/apache/nifi/flowfile/FlowFile.java
index 0f4d2d0..7d0e27e 100644
--- a/nifi-api/src/main/java/org/apache/nifi/flowfile/FlowFile.java
+++ b/nifi-api/src/main/java/org/apache/nifi/flowfile/FlowFile.java
@@ -68,7 +68,7 @@ public interface FlowFile extends Comparable<FlowFile> {
* @return the time at which the FlowFile was most recently added to a
* FlowFile queue, or {@code null} if the FlowFile has never been enqueued.
* This value will always be populated before it is passed to a
- * {@link FlowFilePrioritizer}
+ * FlowFilePrioritizer
*/
Long getLastQueueDate();
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-api/src/main/java/org/apache/nifi/flowfile/FlowFilePrioritizer.java
----------------------------------------------------------------------
diff --git a/nifi-api/src/main/java/org/apache/nifi/flowfile/FlowFilePrioritizer.java b/nifi-api/src/main/java/org/apache/nifi/flowfile/FlowFilePrioritizer.java
deleted file mode 100644
index 684f454..0000000
--- a/nifi-api/src/main/java/org/apache/nifi/flowfile/FlowFilePrioritizer.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * 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.flowfile;
-
-import java.util.Comparator;
-
-/**
- * Provides a mechanism to prioritize flow file objects based on their
- * attributes. The actual flow file content will not be available for comparison
- * so if features of that content are necessary for prioritization it should be
- * extracted to be used as an attribute of the flow file.
- *
- */
-public interface FlowFilePrioritizer extends Comparator<FlowFile> {
-}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-api/src/main/java/org/apache/nifi/provenance/ProvenanceAuthorizableFactory.java
----------------------------------------------------------------------
diff --git a/nifi-api/src/main/java/org/apache/nifi/provenance/ProvenanceAuthorizableFactory.java b/nifi-api/src/main/java/org/apache/nifi/provenance/ProvenanceAuthorizableFactory.java
deleted file mode 100644
index 23d6b3d..0000000
--- a/nifi-api/src/main/java/org/apache/nifi/provenance/ProvenanceAuthorizableFactory.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * 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.provenance;
-
-import org.apache.nifi.authorization.resource.Authorizable;
-import org.apache.nifi.web.ResourceNotFoundException;
-
-public interface ProvenanceAuthorizableFactory {
-
- /**
- * Generates an Authorizable object for the Provenance events of the component with the given ID
- *
- * @param componentId the ID of the component to which the Provenance events belong
- *
- * @return the Authorizable that can be use to authorize access to provenance events
- * @throws ResourceNotFoundException if no component can be found with the given ID
- */
- Authorizable createProvenanceAuthorizable(String componentId);
-
-}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-api/src/main/java/org/apache/nifi/provenance/ProvenanceEventRepository.java
----------------------------------------------------------------------
diff --git a/nifi-api/src/main/java/org/apache/nifi/provenance/ProvenanceEventRepository.java b/nifi-api/src/main/java/org/apache/nifi/provenance/ProvenanceEventRepository.java
index 235a1fa..14991ad 100644
--- a/nifi-api/src/main/java/org/apache/nifi/provenance/ProvenanceEventRepository.java
+++ b/nifi-api/src/main/java/org/apache/nifi/provenance/ProvenanceEventRepository.java
@@ -19,16 +19,6 @@ package org.apache.nifi.provenance;
import java.io.IOException;
import java.util.List;
-import org.apache.nifi.authorization.AccessDeniedException;
-import org.apache.nifi.authorization.Authorizer;
-import org.apache.nifi.authorization.user.NiFiUser;
-import org.apache.nifi.events.EventReporter;
-import org.apache.nifi.provenance.lineage.ComputeLineageSubmission;
-import org.apache.nifi.provenance.search.Query;
-import org.apache.nifi.provenance.search.QuerySubmission;
-import org.apache.nifi.provenance.search.SearchableField;
-import org.apache.nifi.web.ResourceNotFoundException;
-
/**
* This Repository houses Provenance Events. The repository is responsible for
* managing the life-cycle of the events, providing access to the events that it
@@ -38,18 +28,6 @@ import org.apache.nifi.web.ResourceNotFoundException;
public interface ProvenanceEventRepository {
/**
- * Performs any initialization needed. This should be called only by the
- * framework.
- *
- * @param eventReporter to report to
- * @param authorizer the authorizer to use for authorizing individual events
- * @param resourceFactory the resource factory to use for generating Provenance Resource objects for authorization purposes
- *
- * @throws java.io.IOException if unable to initialize
- */
- void initialize(EventReporter eventReporter, Authorizer authorizer, ProvenanceAuthorizableFactory resourceFactory) throws IOException;
-
- /**
* Returns a {@link ProvenanceEventBuilder} that is capable of building
* {@link ProvenanceEventRecord}s
*
@@ -91,21 +69,6 @@ public interface ProvenanceEventRepository {
*/
List<ProvenanceEventRecord> getEvents(long firstRecordId, final int maxRecords) throws IOException;
- /**
- * Returns a List of all <code>ProvenanceEventRecord</code>s in the
- * repository starting with the given ID. The first ID in the repository
- * will always be 0 or higher. Each event that is found will be authorized
- * against the given NiFiUser. If the user does not have authorization for
- * the event, the event will not be returned.
- *
- * @param firstRecordId id of the first record to retrieve
- * @param maxRecords maximum number of records to retrieve
- * @param user the NiFi user that the events should be authorized against
- *
- * @return records
- * @throws java.io.IOException if error reading from repository
- */
- List<ProvenanceEventRecord> getEvents(long firstRecordId, final int maxRecords, NiFiUser user) throws IOException;
/**
* @return the largest ID of any event that is queryable in the repository.
@@ -114,57 +77,6 @@ public interface ProvenanceEventRepository {
Long getMaxEventId();
/**
- * Submits an asynchronous request to process the given query, returning an
- * identifier that can be used to fetch the results at a later time
- *
- * @param query to submit
- * @param user the NiFi User to authorize the events against
- *
- * @return an identifier that can be used to fetch the results at a later
- * time
- */
- QuerySubmission submitQuery(Query query, NiFiUser user);
-
- /**
- * @param queryIdentifier of the query
- * @param user the user who is retrieving the query
- *
- * @return the QueryResult associated with the given identifier, if the
- * query has finished processing. If the query has not yet finished running,
- * returns <code>null</code>
- */
- QuerySubmission retrieveQuerySubmission(String queryIdentifier, NiFiUser user);
-
- /**
- * Submits a Lineage Computation to be completed and returns the
- * AsynchronousLineageResult that indicates the status of the request and
- * the results, if the computation is complete. If the given user does not
- * have authorization to view one of the events in the lineage, a placeholder
- * event will be used instead that provides none of the event details except
- * for the identifier of the component that emitted the Provenance Event. It is
- * necessary to include this node in the lineage view so that the lineage makes
- * sense, rather than showing disconnected graphs when the user is not authorized
- * for all components' provenance events.
- *
- * @param flowFileUuid the UUID of the FlowFile for which the Lineage should
- * be calculated
- * @param user the NiFi User to authorize events against
- *
- * @return a {@link ComputeLineageSubmission} object that can be used to
- * check if the computing is complete and if so get the results
- */
- ComputeLineageSubmission submitLineageComputation(String flowFileUuid, NiFiUser user);
-
- /**
- * @param lineageIdentifier identifier of lineage to compute
- * @param user the user who is retrieving the lineage submission
- *
- * @return the {@link ComputeLineageSubmission} associated with the given
- * identifier
- */
- ComputeLineageSubmission retrieveLineageSubmission(String lineageIdentifier, NiFiUser user);
-
- /**
* Retrieves the Provenance Event with the given ID. The event will be returned only
* if the given user is authorized to access the event. Otherwise, an
* AccessDeniedException or ResourceNotFoundException will be thrown, as appropriate
@@ -173,41 +85,8 @@ public interface ProvenanceEventRepository {
* @return the Provenance Event Record with the given ID, if it exists, or
* {@code null} otherwise
* @throws IOException if failure while retrieving event
- * @throws AccessDeniedException if the user does not have access to the component
- * @throws ResourceNotFoundException if the component that the event belongs to cannot be found
- */
- ProvenanceEventRecord getEvent(long id, NiFiUser user) throws IOException;
-
- /**
- * Submits a request to expand the parents of the event with the given id. If the given user
- * is not authorized to access any event, a placeholder will be used instead that contains only
- * the ID of the component that emitted the event.
- *
- * @param eventId the one-up id of the Event to expand
- * @param user the NiFi user to authorize events against
- * @return a submission which can be checked for status
- *
- * @throws IllegalArgumentException if the given identifier identifies a
- * Provenance Event that has a Type that is not expandable or if the
- * identifier cannot be found
- */
- ComputeLineageSubmission submitExpandParents(long eventId, NiFiUser user);
-
- /**
- * Submits a request to expand the children of the event with the given id. If the given user
- * is not authorized to access any event, a placeholder will be used instead that contains only
- * the ID of the component that emitted the event.
- *
- * @param eventId the one-up id of the Event
- * @param user the NiFi user to authorize events against
- *
- * @return a submission which can be checked for status
- *
- * @throws IllegalArgumentException if the given identifier identifies a
- * Provenance Event that has a Type that is not expandable or if the
- * identifier cannot be found
*/
- ComputeLineageSubmission submitExpandChildren(long eventId, NiFiUser user);
+ ProvenanceEventRecord getEvent(long id) throws IOException;
/**
* Closes the repository, freeing any resources
@@ -216,15 +95,5 @@ public interface ProvenanceEventRepository {
*/
void close() throws IOException;
- /**
- * @return a list of all fields that can be searched via the
- * {@link #submitQuery(nifi.provenance.search.Query)} method
- */
- List<SearchableField> getSearchableFields();
- /**
- * @return a list of all FlowFile attributes that can be searched via the
- * {@link #submitQuery(nifi.provenance.search.Query)} method
- */
- List<SearchableField> getSearchableAttributes();
}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-api/src/main/java/org/apache/nifi/provenance/lineage/ComputeLineageResult.java
----------------------------------------------------------------------
diff --git a/nifi-api/src/main/java/org/apache/nifi/provenance/lineage/ComputeLineageResult.java b/nifi-api/src/main/java/org/apache/nifi/provenance/lineage/ComputeLineageResult.java
deleted file mode 100644
index e754ff7..0000000
--- a/nifi-api/src/main/java/org/apache/nifi/provenance/lineage/ComputeLineageResult.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * 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.provenance.lineage;
-
-import java.util.Date;
-import java.util.List;
-
-/**
- *
- */
-public interface ComputeLineageResult {
-
- /**
- * @return all nodes for the graph
- */
- public List<LineageNode> getNodes();
-
- /**
- * @return all links for the graph
- */
- public List<LineageEdge> getEdges();
-
- /**
- * @return the date at which this AsynchronousLineageResult will expire
- */
- Date getExpiration();
-
- /**
- * @return If an error occurred while computing the lineage, this will return the
- * serialized error; otherwise, returns <code>null</code>
- */
- String getError();
-
- /**
- * @return an integer between 0 and 100 (inclusive) that indicates what
- * percentage of completion the computation has reached
- */
- int getPercentComplete();
-
- /**
- * @return Indicates whether or not the lineage has finished running
- */
- boolean isFinished();
-}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-api/src/main/java/org/apache/nifi/provenance/lineage/ComputeLineageSubmission.java
----------------------------------------------------------------------
diff --git a/nifi-api/src/main/java/org/apache/nifi/provenance/lineage/ComputeLineageSubmission.java b/nifi-api/src/main/java/org/apache/nifi/provenance/lineage/ComputeLineageSubmission.java
deleted file mode 100644
index 8a11523..0000000
--- a/nifi-api/src/main/java/org/apache/nifi/provenance/lineage/ComputeLineageSubmission.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * 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.provenance.lineage;
-
-import java.util.Collection;
-import java.util.Date;
-
-public interface ComputeLineageSubmission {
-
- /**
- * @return the {@link ComputeLineageResult} that contains the results. The
- * results may be partial if a call to
- * {@link ComputeLineageResult#isFinished()} returns <code>false</code>
- */
- ComputeLineageResult getResult();
-
- /**
- * @return the date at which this lineage was submitted
- */
- Date getSubmissionTime();
-
- /**
- * @return the identity of the user who submitted the request
- */
- String getSubmitterIdentity();
-
- /**
- * @return the generated identifier for this lineage result
- */
- String getLineageIdentifier();
-
- /**
- * Cancels the lineage computation
- */
- void cancel();
-
- /**
- * @return <code>true</code> if {@link #cancel()} has been called,
- * <code>false</code> otherwise
- */
- boolean isCanceled();
-
- /**
- * @return the type of Lineage Computation that was submitted
- */
- LineageComputationType getLineageComputationType();
-
- /**
- * @return If the Lineage Computation Type of this submission is
- * {@link LineageComputationType.EXPAND_CHILDREN} or
- * {@link LineageComputationType.EXPAND_PARENTS}, indicates the ID event
- * that is to be expanded; otherwise, returns <code>null</code>
- */
- Long getExpandedEventId();
-
- /**
- * @return all FlowFile UUID's that are encapsulated in this lineage
- * computation submission
- */
- Collection<String> getLineageFlowFileUuids();
-}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-api/src/main/java/org/apache/nifi/provenance/lineage/Lineage.java
----------------------------------------------------------------------
diff --git a/nifi-api/src/main/java/org/apache/nifi/provenance/lineage/Lineage.java b/nifi-api/src/main/java/org/apache/nifi/provenance/lineage/Lineage.java
deleted file mode 100644
index ff5fee7..0000000
--- a/nifi-api/src/main/java/org/apache/nifi/provenance/lineage/Lineage.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * 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.provenance.lineage;
-
-import java.util.List;
-
-/**
- * A Data Structure for representing a Directed Graph that depicts the lineage
- * of a FlowFile and all events that occurred for the FlowFile
- */
-public interface Lineage {
-
- /**
- * @return all nodes for the graph
- */
- public List<LineageNode> getNodes();
-
- /**
- * @return all links for the graph
- */
- public List<LineageEdge> getEdges();
-
-}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-api/src/main/java/org/apache/nifi/provenance/lineage/LineageComputationType.java
----------------------------------------------------------------------
diff --git a/nifi-api/src/main/java/org/apache/nifi/provenance/lineage/LineageComputationType.java b/nifi-api/src/main/java/org/apache/nifi/provenance/lineage/LineageComputationType.java
deleted file mode 100644
index be74324..0000000
--- a/nifi-api/src/main/java/org/apache/nifi/provenance/lineage/LineageComputationType.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * 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.provenance.lineage;
-
-/**
- *
- */
-public enum LineageComputationType {
-
- FLOWFILE_LINEAGE,
- EXPAND_PARENTS,
- EXPAND_CHILDREN;
-}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-api/src/main/java/org/apache/nifi/provenance/lineage/LineageEdge.java
----------------------------------------------------------------------
diff --git a/nifi-api/src/main/java/org/apache/nifi/provenance/lineage/LineageEdge.java b/nifi-api/src/main/java/org/apache/nifi/provenance/lineage/LineageEdge.java
deleted file mode 100644
index dba56f3..0000000
--- a/nifi-api/src/main/java/org/apache/nifi/provenance/lineage/LineageEdge.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * 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.provenance.lineage;
-
-public interface LineageEdge {
-
- String getUuid();
-
- LineageNode getSource();
-
- LineageNode getDestination();
-}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-api/src/main/java/org/apache/nifi/provenance/lineage/LineageNode.java
----------------------------------------------------------------------
diff --git a/nifi-api/src/main/java/org/apache/nifi/provenance/lineage/LineageNode.java b/nifi-api/src/main/java/org/apache/nifi/provenance/lineage/LineageNode.java
deleted file mode 100644
index 5d0956e..0000000
--- a/nifi-api/src/main/java/org/apache/nifi/provenance/lineage/LineageNode.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * 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.provenance.lineage;
-
-public interface LineageNode {
-
- /**
- * @return the type of the LineageNode
- */
- LineageNodeType getNodeType();
-
- /**
- * @return the UUID of the FlowFile for which this Node was created
- */
- String getFlowFileUuid();
-
- /**
- * @return the UUID for this LineageNode
- */
- String getIdentifier();
-
- /**
- * @return the timestamp that corresponds to this Node. The meaning of the
- * timestamp may differ between implementations. For example, a
- * {@link ProvenanceEventLineageNode}'s timestamp indicates the time at
- * which the event occurred. However, for a Node that reperesents a
- * FlowFile, for example, the timestamp may represent the time at which the
- * FlowFile was created
- */
- long getTimestamp();
-}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-api/src/main/java/org/apache/nifi/provenance/lineage/LineageNodeType.java
----------------------------------------------------------------------
diff --git a/nifi-api/src/main/java/org/apache/nifi/provenance/lineage/LineageNodeType.java b/nifi-api/src/main/java/org/apache/nifi/provenance/lineage/LineageNodeType.java
deleted file mode 100644
index 67e0d61..0000000
--- a/nifi-api/src/main/java/org/apache/nifi/provenance/lineage/LineageNodeType.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * 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.provenance.lineage;
-
-public enum LineageNodeType {
-
- FLOWFILE_NODE,
- PROVENANCE_EVENT_NODE;
-}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-api/src/main/java/org/apache/nifi/provenance/lineage/ProvenanceEventLineageNode.java
----------------------------------------------------------------------
diff --git a/nifi-api/src/main/java/org/apache/nifi/provenance/lineage/ProvenanceEventLineageNode.java b/nifi-api/src/main/java/org/apache/nifi/provenance/lineage/ProvenanceEventLineageNode.java
deleted file mode 100644
index f490496..0000000
--- a/nifi-api/src/main/java/org/apache/nifi/provenance/lineage/ProvenanceEventLineageNode.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * 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.provenance.lineage;
-
-import java.util.List;
-
-import org.apache.nifi.provenance.ProvenanceEventType;
-
-public interface ProvenanceEventLineageNode extends LineageNode {
-
- ProvenanceEventType getEventType();
-
- long getEventIdentifier();
-
- List<String> getParentUuids();
-
- List<String> getChildUuids();
-}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-api/src/main/java/org/apache/nifi/provenance/search/Query.java
----------------------------------------------------------------------
diff --git a/nifi-api/src/main/java/org/apache/nifi/provenance/search/Query.java b/nifi-api/src/main/java/org/apache/nifi/provenance/search/Query.java
deleted file mode 100644
index 3519c14..0000000
--- a/nifi-api/src/main/java/org/apache/nifi/provenance/search/Query.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * 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.provenance.search;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Date;
-import java.util.List;
-import java.util.Objects;
-
-
-public class Query {
-
- private final String identifier;
- private final List<SearchTerm> searchTerms = new ArrayList<>();
- private Date startDate;
- private Date endDate;
- private String minFileSize;
- private String maxFileSize;
- private int maxResults = 1000;
-
- public Query(final String identifier) {
- this.identifier = Objects.requireNonNull(identifier);
- }
-
- public String getIdentifier() {
- return identifier;
- }
-
- public void addSearchTerm(final SearchTerm searchTerm) {
- searchTerms.add(searchTerm);
- }
-
- public List<SearchTerm> getSearchTerms() {
- return Collections.unmodifiableList(searchTerms);
- }
-
- public Date getStartDate() {
- return startDate;
- }
-
- public void setStartDate(Date startDate) {
- this.startDate = startDate;
- }
-
- public Date getEndDate() {
- return endDate;
- }
-
- public void setEndDate(Date endDate) {
- this.endDate = endDate;
- }
-
- public int getMaxResults() {
- return maxResults;
- }
-
- public void setMaxResults(int maxResults) {
- this.maxResults = maxResults;
- }
-
- public void setMinFileSize(final String fileSize) {
- this.minFileSize = fileSize;
- }
-
- public String getMinFileSize() {
- return minFileSize;
- }
-
- public void setMaxFileSize(final String fileSize) {
- this.maxFileSize = fileSize;
- }
-
- public String getMaxFileSize() {
- return maxFileSize;
- }
-
- @Override
- public String toString() {
- return "Query[ " + searchTerms + " ]";
- }
-}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-api/src/main/java/org/apache/nifi/provenance/search/QueryResult.java
----------------------------------------------------------------------
diff --git a/nifi-api/src/main/java/org/apache/nifi/provenance/search/QueryResult.java b/nifi-api/src/main/java/org/apache/nifi/provenance/search/QueryResult.java
deleted file mode 100644
index 0079433..0000000
--- a/nifi-api/src/main/java/org/apache/nifi/provenance/search/QueryResult.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * 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.provenance.search;
-
-import java.util.Date;
-import java.util.List;
-
-import org.apache.nifi.provenance.ProvenanceEventRecord;
-
-public interface QueryResult {
-
- /**
- * @return the Provenance events that match the query (up to the limit
- * specified in the query)
- */
- List<ProvenanceEventRecord> getMatchingEvents();
-
- /**
- * @return the total number of Provenance Events that hit
- */
- long getTotalHitCount();
-
- /**
- * @return the number of milliseconds the query took to run
- */
- long getQueryTime();
-
- /**
- * @return the date at which this QueryResult will expire
- */
- Date getExpiration();
-
- /**
- * @return If an error occurred while computing the lineage, this will return the
- * serialized error; otherwise, returns <code>null</code>
- */
- String getError();
-
- /**
- * @return an integer between 0 and 100 (inclusive) that indicates what
- * percentage of completion the query has reached
- */
- int getPercentComplete();
-
- /**
- * @return Indicates whether or not the query has finished running
- */
- boolean isFinished();
-}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-api/src/main/java/org/apache/nifi/provenance/search/QuerySubmission.java
----------------------------------------------------------------------
diff --git a/nifi-api/src/main/java/org/apache/nifi/provenance/search/QuerySubmission.java b/nifi-api/src/main/java/org/apache/nifi/provenance/search/QuerySubmission.java
deleted file mode 100644
index 45efe4b..0000000
--- a/nifi-api/src/main/java/org/apache/nifi/provenance/search/QuerySubmission.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * 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.provenance.search;
-
-import java.util.Date;
-
-public interface QuerySubmission {
-
- /**
- * @return the query that this submission pertains to
- */
- Query getQuery();
-
- /**
- * @return the {@link QueryResult} for this query. Note that the result is
- * only a partial result if the result of calling
- * {@link QueryResult#isFinished()} is <code>false</code>
- */
- QueryResult getResult();
-
- /**
- * @return the date at which this query was submitted
- */
- Date getSubmissionTime();
-
- /**
- * @return the generated identifier for this query result
- */
- String getQueryIdentifier();
-
- /**
- * Cancels the query
- */
- void cancel();
-
- /**
- * @return <code>true</code> if {@link #cancel()} has been called,
- * <code>false</code> otherwise
- */
- boolean isCanceled();
-
- /**
- * @return the identity of the user who submitted the query
- */
- String getSubmitterIdentity();
-}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-api/src/main/java/org/apache/nifi/provenance/search/SearchTerm.java
----------------------------------------------------------------------
diff --git a/nifi-api/src/main/java/org/apache/nifi/provenance/search/SearchTerm.java b/nifi-api/src/main/java/org/apache/nifi/provenance/search/SearchTerm.java
deleted file mode 100644
index 573dbd7..0000000
--- a/nifi-api/src/main/java/org/apache/nifi/provenance/search/SearchTerm.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * 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.provenance.search;
-
-public interface SearchTerm {
-
- SearchableField getSearchableField();
-
- String getValue();
-}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-api/src/main/java/org/apache/nifi/provenance/search/SearchTerms.java
----------------------------------------------------------------------
diff --git a/nifi-api/src/main/java/org/apache/nifi/provenance/search/SearchTerms.java b/nifi-api/src/main/java/org/apache/nifi/provenance/search/SearchTerms.java
deleted file mode 100644
index aad4d7b..0000000
--- a/nifi-api/src/main/java/org/apache/nifi/provenance/search/SearchTerms.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * 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.provenance.search;
-
-public class SearchTerms {
-
- public static SearchTerm newSearchTerm(final SearchableField field, final String value) {
- return new SearchTerm() {
- @Override
- public SearchableField getSearchableField() {
- return field;
- }
-
- @Override
- public String getValue() {
- return value;
- }
-
- @Override
- public String toString() {
- return getValue();
- }
- };
- }
-}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-api/src/main/java/org/apache/nifi/provenance/search/SearchableField.java
----------------------------------------------------------------------
diff --git a/nifi-api/src/main/java/org/apache/nifi/provenance/search/SearchableField.java b/nifi-api/src/main/java/org/apache/nifi/provenance/search/SearchableField.java
deleted file mode 100644
index 85c6154..0000000
--- a/nifi-api/src/main/java/org/apache/nifi/provenance/search/SearchableField.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * 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.provenance.search;
-
-/**
- * A SearchableField represents a field in a Provenance Event that can be
- * searched
- */
-public interface SearchableField {
-
- /**
- * @return the identifier that is used to refer to this field
- */
- String getIdentifier();
-
- /**
- * @return the name of the field that is used when searching the repository
- */
- String getSearchableFieldName();
-
- /**
- * @return the "friendly" name or "display name" of the field, which may be
- * more human-readable than the searchable field name
- */
- String getFriendlyName();
-
- /**
- * @return the type of the data stored in this field
- */
- SearchableFieldType getFieldType();
-
- /**
- * @return <code>true</code> if this field represents a FlowFile attribute,
- * <code>false</code> if the field represents a Provenance Event detail,
- * such as Source System URI
- */
- boolean isAttribute();
-}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-api/src/main/java/org/apache/nifi/provenance/search/SearchableFieldType.java
----------------------------------------------------------------------
diff --git a/nifi-api/src/main/java/org/apache/nifi/provenance/search/SearchableFieldType.java b/nifi-api/src/main/java/org/apache/nifi/provenance/search/SearchableFieldType.java
deleted file mode 100644
index 51ece58..0000000
--- a/nifi-api/src/main/java/org/apache/nifi/provenance/search/SearchableFieldType.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * 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.provenance.search;
-
-/**
- *
- */
-public enum SearchableFieldType {
-
- STRING,
- DATE,
- DATA_SIZE,
- LONG;
-}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-api/src/main/java/org/apache/nifi/remote/RemoteDestination.java
----------------------------------------------------------------------
diff --git a/nifi-api/src/main/java/org/apache/nifi/remote/RemoteDestination.java b/nifi-api/src/main/java/org/apache/nifi/remote/RemoteDestination.java
deleted file mode 100644
index c3a34b2..0000000
--- a/nifi-api/src/main/java/org/apache/nifi/remote/RemoteDestination.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * 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.remote;
-
-import java.util.concurrent.TimeUnit;
-
-/**
- * A model object for referring to a remote destination (i.e., a Port) for
- * site-to-site communications
- */
-public interface RemoteDestination {
-
- /**
- * @return the identifier of the remote destination
- */
- String getIdentifier();
-
- /**
- * @return the human-readable name of the remote destination
- */
- String getName();
-
- /**
- * @param timeUnit to yield
- * @return the amount of time that system should pause sending to a
- * particular node if unable to send data to or receive data from this
- * endpoint
- */
- long getYieldPeriod(TimeUnit timeUnit);
-
- /**
- * @return whether or not compression should be used when transferring data
- * to or receiving data from the remote endpoint
- */
- boolean isUseCompression();
-}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-api/src/main/java/org/apache/nifi/reporting/BulletinRepository.java
----------------------------------------------------------------------
diff --git a/nifi-api/src/main/java/org/apache/nifi/reporting/BulletinRepository.java b/nifi-api/src/main/java/org/apache/nifi/reporting/BulletinRepository.java
index 695ed7f..be0e3f4 100644
--- a/nifi-api/src/main/java/org/apache/nifi/reporting/BulletinRepository.java
+++ b/nifi-api/src/main/java/org/apache/nifi/reporting/BulletinRepository.java
@@ -25,8 +25,8 @@ import java.util.List;
*/
public interface BulletinRepository {
- public static final int MAX_BULLETINS_PER_COMPONENT = 5;
- public static final int MAX_BULLETINS_FOR_CONTROLLER = 10;
+ int MAX_BULLETINS_PER_COMPONENT = 5;
+ int MAX_BULLETINS_FOR_CONTROLLER = 10;
/**
* Adds a Bulletin to the repository.
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-api/src/main/java/org/apache/nifi/web/ClusterRequestException.java
----------------------------------------------------------------------
diff --git a/nifi-api/src/main/java/org/apache/nifi/web/ClusterRequestException.java b/nifi-api/src/main/java/org/apache/nifi/web/ClusterRequestException.java
deleted file mode 100644
index ee5f417..0000000
--- a/nifi-api/src/main/java/org/apache/nifi/web/ClusterRequestException.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * 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.web;
-
-/**
- * An general error occurred when attempting to communicate with the cluster.
- */
-public class ClusterRequestException extends RuntimeException {
-
- public ClusterRequestException(Throwable cause) {
- super(cause);
- }
-
- public ClusterRequestException(String message, Throwable cause) {
- super(message, cause);
- }
-
- public ClusterRequestException(String message) {
- super(message);
- }
-
- public ClusterRequestException() {
- }
-
-}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-api/src/main/java/org/apache/nifi/web/ComponentDescriptor.java
----------------------------------------------------------------------
diff --git a/nifi-api/src/main/java/org/apache/nifi/web/ComponentDescriptor.java b/nifi-api/src/main/java/org/apache/nifi/web/ComponentDescriptor.java
deleted file mode 100644
index 9412ee1..0000000
--- a/nifi-api/src/main/java/org/apache/nifi/web/ComponentDescriptor.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * 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.web;
-
-import java.util.Map;
-
-public class ComponentDescriptor {
-
- private final String name;
- private final String displayName;
- private final String description;
- private final String defaultValue;
- private final Map<String,String> allowableValues;
-
- private ComponentDescriptor(Builder builder){
- this.name = builder.name;
- this.displayName = builder.displayName;
- this.description = builder.description;
- this.defaultValue = builder.defaultValue;
- this.allowableValues = builder.allowableValues;
- }
-
- public String getName() {
- return name;
- }
-
- public String getDisplayName() {
- return displayName;
- }
-
- public String getDescription() {
- return description;
- }
-
- public String getDefaultValue() {
- return defaultValue;
- }
-
- public Map<String,String> getAllowableValues() {
- return allowableValues;
- }
-
- public static final class Builder{
- private String name;
- private String displayName;
- private String description;
- private String defaultValue;
- private Map<String,String> allowableValues;
-
- public Builder name(String name){
- this.name = name;
- return this;
- }
-
- public Builder displayName(String displayName){
- this.displayName = displayName;
- return this;
- }
-
- public Builder description(String description){
- this.description = description;
- return this;
- }
-
- public Builder defaultValue(String defaultValue){
- this.defaultValue = defaultValue;
- return this;
- }
-
- public Builder allowableValues(Map<String,String> allowableValues){
- this.allowableValues = allowableValues;
- return this;
- }
-
- public ComponentDescriptor build(){
- return new ComponentDescriptor(this);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-api/src/main/java/org/apache/nifi/web/ComponentDetails.java
----------------------------------------------------------------------
diff --git a/nifi-api/src/main/java/org/apache/nifi/web/ComponentDetails.java b/nifi-api/src/main/java/org/apache/nifi/web/ComponentDetails.java
deleted file mode 100644
index 9d163e4..0000000
--- a/nifi-api/src/main/java/org/apache/nifi/web/ComponentDetails.java
+++ /dev/null
@@ -1,163 +0,0 @@
-/*
- * 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.web;
-
-import java.util.Collection;
-import java.util.Map;
-
-/**
- * Details about a given component. Contains configuration and current
- * validation errors.
- */
-public class ComponentDetails {
-
- private final String id;
- private final String name;
- private final String type;
- private final String state;
- private final String annotationData;
- private final Map<String, String> properties;
- private final Map<String, ComponentDescriptor> descriptors;
-
- private final Collection<String> validationErrors;
-
- private ComponentDetails(final Builder builder) {
- this.id = builder.id;
- this.name = builder.name;
- this.type = builder.type;
- this.state = builder.state;
- this.annotationData = builder.annotationData;
- this.properties = builder.properties;
- this.descriptors = builder.descriptors;
- this.validationErrors = builder.validationErrors;
-
- }
-
- /**
- * @return component id
- */
- public String getId() {
- return id;
- }
-
- /**
- * @return component name
- */
- public String getName() {
- return name;
- }
-
- /**
- * @return component type
- */
- public String getType() {
- return type;
- }
-
- /**
- * @return component state
- */
- public String getState() {
- return state;
- }
-
- /**
- * @return component's annotation data
- */
- public String getAnnotationData() {
- return annotationData;
- }
-
- /**
- * @return Mapping of component properties
- */
- public Map<String, String> getProperties() {
- return properties;
- }
-
-
- /**
- * @return Mapping of component descriptors
- */
- public Map<String,ComponentDescriptor> getDescriptors(){
- return descriptors;
- }
-
- /**
- * @return Current validation errors for the component
- */
- public Collection<String> getValidationErrors() {
- return validationErrors;
- }
-
- public static final class Builder {
-
- private String id;
- private String name;
- private String type;
- private String state;
- private String annotationData;
- private Map<String, String> properties;
- private Map<String,ComponentDescriptor> descriptors;
-
- private Collection<String> validationErrors;
-
- public Builder id(final String id) {
- this.id = id;
- return this;
- }
-
- public Builder name(final String name) {
- this.name = name;
- return this;
- }
-
- public Builder type(final String type) {
- this.type = type;
- return this;
- }
-
- public Builder state(final String state) {
- this.state = state;
- return this;
- }
-
- public Builder annotationData(final String annotationData) {
- this.annotationData = annotationData;
- return this;
- }
-
- public Builder properties(final Map<String, String> properties) {
- this.properties = properties;
- return this;
- }
-
- public Builder validateErrors(final Collection<String> validationErrors) {
- this.validationErrors = validationErrors;
- return this;
- }
-
- public Builder descriptors(final Map<String,ComponentDescriptor> descriptors){
- this.descriptors = descriptors;
- return this;
- }
-
- public ComponentDetails build() {
- return new ComponentDetails(this);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-api/src/main/java/org/apache/nifi/web/ConfigurationAction.java
----------------------------------------------------------------------
diff --git a/nifi-api/src/main/java/org/apache/nifi/web/ConfigurationAction.java b/nifi-api/src/main/java/org/apache/nifi/web/ConfigurationAction.java
deleted file mode 100644
index 96f2abf..0000000
--- a/nifi-api/src/main/java/org/apache/nifi/web/ConfigurationAction.java
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
- * 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.web;
-
-/**
- * An action that represents the configuration of a component.
- */
-public class ConfigurationAction {
-
- private final String id;
- private final String name;
- private final String type;
- private final String field;
- private final String previousValue;
- private final String value;
-
- private ConfigurationAction(final Builder builder) {
- this.id = builder.id;
- this.name = builder.name;
- this.type = builder.type;
- this.field = builder.field;
- this.previousValue = builder.previousValue;
- this.value = builder.value;
- }
-
- /**
- * @return id of the component being modified
- */
- public String getId() {
- return id;
- }
-
- /**
- * @return name of the component being modified
- */
- public String getName() {
- return name;
- }
-
- /**
- * @return type of the component being modified
- */
- public String getType() {
- return type;
- }
-
- /**
- * @return the name of the field, property, etc that has been modified
- */
- public String getField() {
- return field;
- }
-
- /**
- * @return the previous value
- */
- public String getPreviousValue() {
- return previousValue;
- }
-
- /**
- * @return the new value
- */
- public String getValue() {
- return value;
- }
-
- public static class Builder {
-
- private String id;
- private String name;
- private String type;
- private String field;
- private String previousValue;
- private String value;
-
- public Builder id(final String id) {
- this.id = id;
- return this;
- }
-
- public Builder name(final String name) {
- this.name = name;
- return this;
- }
-
- public Builder type(final String type) {
- this.type = type;
- return this;
- }
-
- public Builder field(final String field) {
- this.field = field;
- return this;
- }
-
- public Builder previousValue(final String previousValue) {
- this.previousValue = previousValue;
- return this;
- }
-
- public Builder value(final String value) {
- this.value = value;
- return this;
- }
-
- public ConfigurationAction build() {
- return new ConfigurationAction(this);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-api/src/main/java/org/apache/nifi/web/InvalidRevisionException.java
----------------------------------------------------------------------
diff --git a/nifi-api/src/main/java/org/apache/nifi/web/InvalidRevisionException.java b/nifi-api/src/main/java/org/apache/nifi/web/InvalidRevisionException.java
deleted file mode 100644
index 8e04f69..0000000
--- a/nifi-api/src/main/java/org/apache/nifi/web/InvalidRevisionException.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * 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.web;
-
-/**
- * Exception indicating that the client has included an old revision in their
- * request.
- */
-@SuppressWarnings("serial")
-public class InvalidRevisionException extends RuntimeException {
-
- public InvalidRevisionException(String message) {
- super(message);
- }
-
- public InvalidRevisionException(String message, Throwable cause) {
- super(message, cause);
- }
-}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-api/src/main/java/org/apache/nifi/web/NiFiWebConfigurationContext.java
----------------------------------------------------------------------
diff --git a/nifi-api/src/main/java/org/apache/nifi/web/NiFiWebConfigurationContext.java b/nifi-api/src/main/java/org/apache/nifi/web/NiFiWebConfigurationContext.java
deleted file mode 100644
index 5082af2..0000000
--- a/nifi-api/src/main/java/org/apache/nifi/web/NiFiWebConfigurationContext.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * 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.web;
-
-import org.apache.nifi.controller.ControllerService;
-
-import java.util.Collection;
-import java.util.Map;
-
-/**
- * NiFi web context providing limited access to dataflow configuration for
- * component custom UIs.
- */
-public interface NiFiWebConfigurationContext {
-
- /**
- * @param serviceIdentifier of the controller service
- * @param componentId the id of the component that is referencing the controller service
- * @return the ControllerService for the specified identifier. If a
- * corresponding service cannot be found, null is returned. If this NiFi is
- * clustered, the only services available will be those those availability
- * is NCM only
- */
- ControllerService getControllerService(String serviceIdentifier, String componentId);
-
- /**
- * Provides a mechanism for custom UIs to save actions to appear in NiFi
- * configuration history. Note all fields within each Action must be
- * populated. Null values will result in a failure to insert the audit
- * record. Since the saving to these actions is separate from the actual
- * configuration change, a failure to insert here will just generate a
- * warning log message. The recording of these actions typically happens
- * after a configuration change is applied. Since those changes have already
- * been applied to the flow, we cannot revert them because of a failure to
- * insert an audit record.
- *
- * @param requestContext context of the request
- * @param actions to save
- * @throws IllegalArgumentException When the requestContext isn't fully
- * populated or isn't appropriate for the given request
- */
- void saveActions(NiFiWebRequestContext requestContext, Collection<ConfigurationAction> actions);
-
- /**
- * @return the current user identity. The value may be a DN, an email, a username, or any string that identities the user. Returns null if no user is found
- */
- String getCurrentUserIdentity();
-
- /**
- * Sets the annotation data for the underlying component.
- *
- * @param configurationContext config context
- * @param annotationData the data
- * @param properties component properties
- * @return the configuration for the underlying component
- * @throws ResourceNotFoundException if the underlying component does not
- * exit
- * @throws InvalidRevisionException if a revision other than the current
- * revision is given
- * @throws ClusterRequestException if the annotation data was unable to be
- * set for the underlying component. This exception will only be thrown when
- * operating in a cluster.
- * @throws IllegalArgumentException When the requestContext isn't fully
- * populated or isn't appropriate for the given request
- */
- ComponentDetails updateComponent(NiFiWebConfigurationRequestContext configurationContext, String annotationData, Map<String, String> properties)
- throws ResourceNotFoundException, InvalidRevisionException, ClusterRequestException;
-
-
- /**
- * Gets the details for the underlying component (including configuration,
- * validation errors, and annotation data).
- *
- * @param requestContext context of request
- * @return the configuration for the underlying component
- * @throws ResourceNotFoundException if the underlying component does not
- * exit
- * @throws ClusterRequestException if the underlying component was unable to
- * be retrieved from the cluster. This exception will only be thrown when
- * operating in a cluster.
- * @throws IllegalArgumentException When the requestContext isn't fully
- * populated or isn't appropriate for the given request
- */
- ComponentDetails getComponentDetails(NiFiWebRequestContext requestContext) throws ResourceNotFoundException, ClusterRequestException;
-}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-api/src/main/java/org/apache/nifi/web/NiFiWebConfigurationRequestContext.java
----------------------------------------------------------------------
diff --git a/nifi-api/src/main/java/org/apache/nifi/web/NiFiWebConfigurationRequestContext.java b/nifi-api/src/main/java/org/apache/nifi/web/NiFiWebConfigurationRequestContext.java
deleted file mode 100644
index c75d9dc..0000000
--- a/nifi-api/src/main/java/org/apache/nifi/web/NiFiWebConfigurationRequestContext.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * 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.web;
-
-/**
- * Contextual details required to make a configuration request from a UI
- * extension.
- */
-public interface NiFiWebConfigurationRequestContext extends NiFiWebRequestContext {
-
- /**
- * The revision to include in the request.
- *
- * @return the revision
- */
- Revision getRevision();
-
-}
[10/10] nifi git commit: NIFI-1896 This closes #650. Refactored
nifi-api into nifi-framework-api and other locations. The nifi-api is
specific to that which is needed for intended extension points.
Posted by jo...@apache.org.
NIFI-1896 This closes #650. Refactored nifi-api into nifi-framework-api and other locations. The nifi-api is specific to that which is needed for intended extension points.
Project: http://git-wip-us.apache.org/repos/asf/nifi/repo
Commit: http://git-wip-us.apache.org/repos/asf/nifi/commit/d1129706
Tree: http://git-wip-us.apache.org/repos/asf/nifi/tree/d1129706
Diff: http://git-wip-us.apache.org/repos/asf/nifi/diff/d1129706
Branch: refs/heads/master
Commit: d1129706e235548daaf4eecf7001b244300761e9
Parents: 048ba53
Author: Aldrin Piri <al...@apache.org>
Authored: Wed Jul 13 09:28:19 2016 -0400
Committer: joewitt <jo...@apache.org>
Committed: Thu Jul 14 18:24:48 2016 -0400
----------------------------------------------------------------------
.../component/details/ExtensionDetails.java | 26 -
.../details/RemoteProcessGroupDetails.java | 26 -
.../nifi/action/details/ConfigureDetails.java | 30 -
.../nifi/action/details/ConnectDetails.java | 40 --
.../apache/nifi/action/details/MoveDetails.java | 30 -
.../nifi/action/details/PurgeDetails.java | 28 -
.../annotation/behavior/DynamicProperties.java | 2 +-
.../annotation/behavior/DynamicProperty.java | 8 +-
.../behavior/DynamicRelationship.java | 4 +-
.../annotation/behavior/InputRequirement.java | 2 +-
.../annotation/behavior/ReadsAttributes.java | 2 +-
.../annotation/behavior/WritesAttribute.java | 4 +-
.../annotation/behavior/WritesAttributes.java | 2 +-
.../nifi/annotation/documentation/SeeAlso.java | 4 +-
.../nifi/annotation/documentation/Tags.java | 2 +-
.../authentication/AuthenticationResponse.java | 65 ---
.../nifi/authentication/LoginCredentials.java | 39 --
.../authentication/LoginIdentityProvider.java | 61 --
...ginIdentityProviderConfigurationContext.java | 48 --
...inIdentityProviderInitializationContext.java | 27 -
.../LoginIdentityProviderLookup.java | 25 -
.../LoginIdentityProviderContext.java | 35 --
.../exception/IdentityAccessException.java | 33 --
.../InvalidLoginCredentialsException.java | 33 --
.../exception/ProviderCreationException.java | 39 --
.../exception/ProviderDestructionException.java | 39 --
.../AbstractPolicyBasedAuthorizer.java | 552 -------------------
.../authorization/AccessDeniedException.java | 39 --
.../apache/nifi/authorization/AccessPolicy.java | 330 -----------
.../authorization/AuthorizationRequest.java | 171 ------
.../nifi/authorization/AuthorizationResult.java | 99 ----
.../apache/nifi/authorization/Authorizer.java | 59 --
.../AuthorizerConfigurationContext.java | 50 --
.../AuthorizerInitializationContext.java | 37 --
.../nifi/authorization/AuthorizerLookup.java | 31 --
.../org/apache/nifi/authorization/Group.java | 226 --------
.../nifi/authorization/RequestAction.java | 46 --
.../org/apache/nifi/authorization/Resource.java | 37 --
.../org/apache/nifi/authorization/User.java | 151 -----
.../nifi/authorization/UserContextKeys.java | 26 -
.../authorization/UsersAndAccessPolicies.java | 52 --
.../annotation/AuthorizerContext.java | 35 --
.../exception/AuthorizationAccessException.java | 32 --
.../exception/AuthorizerCreationException.java | 39 --
.../AuthorizerDestructionException.java | 39 --
.../authorization/resource/Authorizable.java | 173 ------
.../nifi/authorization/user/NiFiUser.java | 45 --
.../apache/nifi/components/PropertyValue.java | 38 +-
.../nifi/components/state/StateProvider.java | 133 -----
.../StateProviderInitializationContext.java | 56 --
.../state/exception/StateTooLargeException.java | 2 +
.../org/apache/nifi/controller/Snippet.java | 83 ---
.../org/apache/nifi/controller/Triggerable.java | 117 ----
.../controller/queue/DropFlowFileState.java | 57 --
.../controller/queue/DropFlowFileStatus.java | 78 ---
.../nifi/controller/queue/FlowFileQueue.java | 275 ---------
.../nifi/controller/queue/FlowFileSummary.java | 59 --
.../controller/queue/ListFlowFileState.java | 57 --
.../controller/queue/ListFlowFileStatus.java | 70 ---
.../nifi/controller/queue/SortColumn.java | 108 ----
.../nifi/controller/queue/SortDirection.java | 37 --
.../repository/ContentRepository.java | 277 ----------
.../controller/repository/FlowFileRecord.java | 48 --
.../repository/FlowFileRepository.java | 123 -----
.../repository/FlowFileSwapManager.java | 105 ----
.../repository/IncompleteSwapFileException.java | 45 --
.../controller/repository/QueueProvider.java | 33 --
.../controller/repository/RepositoryRecord.java | 82 ---
.../repository/RepositoryRecordType.java | 25 -
.../controller/repository/SwapContents.java | 40 --
.../SwapManagerInitializationContext.java | 40 --
.../nifi/controller/repository/SwapSummary.java | 50 --
.../repository/claim/ContentClaim.java | 47 --
.../repository/claim/ResourceClaim.java | 54 --
.../repository/claim/ResourceClaimManager.java | 135 -----
.../history/ComponentStatusRepository.java | 120 ----
.../status/history/MetricDescriptor.java | 66 ---
.../status/history/StatusHistory.java | 44 --
.../status/history/StatusSnapshot.java | 42 --
.../controller/status/history/ValueMapper.java | 23 -
.../controller/status/history/ValueReducer.java | 25 -
.../org/apache/nifi/events/EventReporter.java | 29 -
.../java/org/apache/nifi/flowfile/FlowFile.java | 2 +-
.../nifi/flowfile/FlowFilePrioritizer.java | 29 -
.../ProvenanceAuthorizableFactory.java | 35 --
.../provenance/ProvenanceEventRepository.java | 133 +----
.../lineage/ComputeLineageResult.java | 58 --
.../lineage/ComputeLineageSubmission.java | 75 ---
.../apache/nifi/provenance/lineage/Lineage.java | 37 --
.../lineage/LineageComputationType.java | 27 -
.../nifi/provenance/lineage/LineageEdge.java | 26 -
.../nifi/provenance/lineage/LineageNode.java | 45 --
.../provenance/lineage/LineageNodeType.java | 23 -
.../lineage/ProvenanceEventLineageNode.java | 32 --
.../apache/nifi/provenance/search/Query.java | 96 ----
.../nifi/provenance/search/QueryResult.java | 63 ---
.../nifi/provenance/search/QuerySubmission.java | 60 --
.../nifi/provenance/search/SearchTerm.java | 24 -
.../nifi/provenance/search/SearchTerms.java | 39 --
.../nifi/provenance/search/SearchableField.java | 52 --
.../provenance/search/SearchableFieldType.java | 28 -
.../apache/nifi/remote/RemoteDestination.java | 50 --
.../nifi/reporting/BulletinRepository.java | 4 +-
.../nifi/web/ClusterRequestException.java | 39 --
.../apache/nifi/web/ComponentDescriptor.java | 93 ----
.../org/apache/nifi/web/ComponentDetails.java | 163 ------
.../apache/nifi/web/ConfigurationAction.java | 125 -----
.../nifi/web/InvalidRevisionException.java | 33 --
.../nifi/web/NiFiWebConfigurationContext.java | 99 ----
.../web/NiFiWebConfigurationRequestContext.java | 32 --
.../apache/nifi/web/NiFiWebRequestContext.java | 56 --
.../nifi/web/ResourceNotFoundException.java | 32 --
.../main/java/org/apache/nifi/web/Revision.java | 129 -----
.../org/apache/nifi/web/UiExtensionType.java | 32 --
.../org/apache/nifi/web/ViewableContent.java | 71 ---
.../TestAbstractPolicyBasedAuthorizer.java | 447 ---------------
.../nifi/authorization/TestAccessPolicy.java | 240 --------
.../apache/nifi/authorization/TestGroup.java | 169 ------
.../org/apache/nifi/authorization/TestUser.java | 85 ---
.../java/org/apache/nifi/web/TestRevision.java | 61 --
nifi-assembly/pom.xml | 4 +
nifi-commons/nifi-data-provenance-utils/pom.xml | 4 +
nifi-commons/nifi-site-to-site-client/pom.xml | 4 +
nifi-framework-api/pom.xml | 32 ++
.../component/details/ExtensionDetails.java | 26 +
.../details/RemoteProcessGroupDetails.java | 26 +
.../nifi/action/details/ConfigureDetails.java | 30 +
.../nifi/action/details/ConnectDetails.java | 40 ++
.../apache/nifi/action/details/MoveDetails.java | 30 +
.../nifi/action/details/PurgeDetails.java | 28 +
.../authentication/AuthenticationResponse.java | 65 +++
.../nifi/authentication/LoginCredentials.java | 39 ++
.../authentication/LoginIdentityProvider.java | 61 ++
...ginIdentityProviderConfigurationContext.java | 48 ++
...inIdentityProviderInitializationContext.java | 27 +
.../LoginIdentityProviderLookup.java | 25 +
.../LoginIdentityProviderContext.java | 35 ++
.../exception/IdentityAccessException.java | 33 ++
.../InvalidLoginCredentialsException.java | 33 ++
.../exception/ProviderCreationException.java | 39 ++
.../exception/ProviderDestructionException.java | 39 ++
.../AbstractPolicyBasedAuthorizer.java | 552 +++++++++++++++++++
.../authorization/AccessDeniedException.java | 39 ++
.../apache/nifi/authorization/AccessPolicy.java | 330 +++++++++++
.../authorization/AuthorizationRequest.java | 171 ++++++
.../nifi/authorization/AuthorizationResult.java | 99 ++++
.../apache/nifi/authorization/Authorizer.java | 59 ++
.../AuthorizerConfigurationContext.java | 50 ++
.../AuthorizerInitializationContext.java | 37 ++
.../nifi/authorization/AuthorizerLookup.java | 31 ++
.../org/apache/nifi/authorization/Group.java | 226 ++++++++
.../nifi/authorization/RequestAction.java | 46 ++
.../org/apache/nifi/authorization/Resource.java | 37 ++
.../org/apache/nifi/authorization/User.java | 151 +++++
.../nifi/authorization/UserContextKeys.java | 26 +
.../authorization/UsersAndAccessPolicies.java | 52 ++
.../annotation/AuthorizerContext.java | 35 ++
.../exception/AuthorizationAccessException.java | 32 ++
.../exception/AuthorizerCreationException.java | 39 ++
.../AuthorizerDestructionException.java | 39 ++
.../authorization/resource/Authorizable.java | 173 ++++++
.../nifi/authorization/user/NiFiUser.java | 45 ++
.../nifi/components/state/StateProvider.java | 133 +++++
.../StateProviderInitializationContext.java | 56 ++
.../org/apache/nifi/controller/Snippet.java | 83 +++
.../org/apache/nifi/controller/Triggerable.java | 117 ++++
.../controller/queue/DropFlowFileState.java | 57 ++
.../controller/queue/DropFlowFileStatus.java | 78 +++
.../nifi/controller/queue/FlowFileQueue.java | 275 +++++++++
.../nifi/controller/queue/FlowFileSummary.java | 59 ++
.../controller/queue/ListFlowFileState.java | 57 ++
.../controller/queue/ListFlowFileStatus.java | 70 +++
.../nifi/controller/queue/SortColumn.java | 108 ++++
.../nifi/controller/queue/SortDirection.java | 37 ++
.../repository/ContentRepository.java | 277 ++++++++++
.../controller/repository/FlowFileRecord.java | 48 ++
.../repository/FlowFileRepository.java | 123 +++++
.../repository/FlowFileSwapManager.java | 105 ++++
.../repository/IncompleteSwapFileException.java | 45 ++
.../controller/repository/QueueProvider.java | 33 ++
.../controller/repository/RepositoryRecord.java | 82 +++
.../repository/RepositoryRecordType.java | 25 +
.../controller/repository/SwapContents.java | 40 ++
.../SwapManagerInitializationContext.java | 40 ++
.../nifi/controller/repository/SwapSummary.java | 50 ++
.../repository/claim/ContentClaim.java | 47 ++
.../repository/claim/ResourceClaim.java | 54 ++
.../repository/claim/ResourceClaimManager.java | 135 +++++
.../history/ComponentStatusRepository.java | 120 ++++
.../status/history/MetricDescriptor.java | 66 +++
.../status/history/StatusHistory.java | 44 ++
.../status/history/StatusSnapshot.java | 42 ++
.../controller/status/history/ValueMapper.java | 23 +
.../controller/status/history/ValueReducer.java | 25 +
.../org/apache/nifi/events/EventReporter.java | 29 +
.../nifi/flowfile/FlowFilePrioritizer.java | 29 +
.../ProvenanceAuthorizableFactory.java | 35 ++
.../nifi/provenance/ProvenanceRepository.java | 160 ++++++
.../lineage/ComputeLineageResult.java | 58 ++
.../lineage/ComputeLineageSubmission.java | 75 +++
.../apache/nifi/provenance/lineage/Lineage.java | 37 ++
.../lineage/LineageComputationType.java | 27 +
.../nifi/provenance/lineage/LineageEdge.java | 26 +
.../nifi/provenance/lineage/LineageNode.java | 45 ++
.../provenance/lineage/LineageNodeType.java | 23 +
.../lineage/ProvenanceEventLineageNode.java | 32 ++
.../apache/nifi/provenance/search/Query.java | 96 ++++
.../nifi/provenance/search/QueryResult.java | 63 +++
.../nifi/provenance/search/QuerySubmission.java | 60 ++
.../nifi/provenance/search/SearchTerm.java | 24 +
.../nifi/provenance/search/SearchTerms.java | 39 ++
.../nifi/provenance/search/SearchableField.java | 52 ++
.../provenance/search/SearchableFieldType.java | 28 +
.../apache/nifi/remote/RemoteDestination.java | 50 ++
.../nifi/web/ClusterRequestException.java | 39 ++
.../apache/nifi/web/ComponentDescriptor.java | 93 ++++
.../org/apache/nifi/web/ComponentDetails.java | 163 ++++++
.../apache/nifi/web/ConfigurationAction.java | 125 +++++
.../nifi/web/InvalidRevisionException.java | 33 ++
.../nifi/web/NiFiWebConfigurationContext.java | 99 ++++
.../web/NiFiWebConfigurationRequestContext.java | 32 ++
.../apache/nifi/web/NiFiWebRequestContext.java | 56 ++
.../nifi/web/ResourceNotFoundException.java | 32 ++
.../main/java/org/apache/nifi/web/Revision.java | 129 +++++
.../org/apache/nifi/web/UiExtensionType.java | 32 ++
.../org/apache/nifi/web/ViewableContent.java | 71 +++
.../TestAbstractPolicyBasedAuthorizer.java | 447 +++++++++++++++
.../nifi/authorization/TestAccessPolicy.java | 240 ++++++++
.../apache/nifi/authorization/TestGroup.java | 169 ++++++
.../org/apache/nifi/authorization/TestUser.java | 85 +++
.../java/org/apache/nifi/web/TestRevision.java | 61 ++
nifi-mock/pom.xml | 4 +
.../MockProvenanceEventRepository.java | 139 -----
.../provenance/MockProvenanceRepository.java | 149 +++++
.../org/apache/nifi/util/MockEventAccess.java | 1 -
.../nifi-framework/nifi-administration/pom.xml | 4 +
.../nifi-framework/nifi-authorizer/pom.xml | 4 +
.../nifi-framework/nifi-documentation/pom.xml | 4 +
.../nifi-framework/nifi-file-authorizer/pom.xml | 4 +
.../nifi-framework-authorization/pom.xml | 4 +
.../nifi-framework-cluster/pom.xml | 4 +
.../nifi-framework-core-api/pom.xml | 4 +
.../nifi-framework/nifi-framework-core/pom.xml | 4 +
.../apache/nifi/controller/FlowController.java | 93 ++--
.../nifi/controller/TestFlowController.java | 4 +-
.../repository/TestStandardProcessSession.java | 4 +-
.../scheduling/TestProcessorLifecycle.java | 4 +-
.../nifi-framework/nifi-nar-utils/pom.xml | 4 +
.../org/apache/nifi/nar/ExtensionManager.java | 24 +-
.../nifi/nar/NarThreadContextClassLoader.java | 4 +-
.../nifi-framework/nifi-site-to-site/pom.xml | 4 +
.../nifi-framework/nifi-user-actions/pom.xml | 4 +
.../nifi-web/nifi-custom-ui-utilities/pom.xml | 4 +
.../nifi-web/nifi-ui-extension/pom.xml | 4 +
.../nifi-web/nifi-web-api/pom.xml | 5 +
.../nifi/web/controller/ControllerFacade.java | 16 +-
.../nifi-web/nifi-web-content-viewer/pom.xml | 4 +
.../nifi-web-optimistic-locking/pom.xml | 4 +
.../nifi-web/nifi-web-security/pom.xml | 4 +
.../nifi-kerberos-iaa-providers/pom.xml | 4 +
.../nifi-ldap-iaa-providers/pom.xml | 4 +
.../nifi-media-bundle/nifi-image-viewer/pom.xml | 4 +
.../pom.xml | 4 +
.../PersistentProvenanceRepository.java | 9 +-
...he.nifi.provenance.ProvenanceEventRepository | 15 -
....apache.nifi.provenance.ProvenanceRepository | 15 +
.../nifi-volatile-provenance-repository/pom.xml | 4 +
.../VolatileProvenanceRepository.java | 10 +-
...he.nifi.provenance.ProvenanceEventRepository | 15 -
....apache.nifi.provenance.ProvenanceRepository | 15 +
.../nifi/snmp/processors/GetSNMPTest.java | 4 +-
.../nifi-jolt-transform-json-ui/pom.xml | 5 +
.../nifi-standard-content-viewer/pom.xml | 4 +
.../nifi/controller/MonitorMemoryTest.java | 4 +-
.../nifi-update-attribute-ui/pom.xml | 5 +
nifi-nar-bundles/pom.xml | 6 +
pom.xml | 6 +
277 files changed, 8815 insertions(+), 8604 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-api/src/main/java/org/apache/nifi/action/component/details/ExtensionDetails.java
----------------------------------------------------------------------
diff --git a/nifi-api/src/main/java/org/apache/nifi/action/component/details/ExtensionDetails.java b/nifi-api/src/main/java/org/apache/nifi/action/component/details/ExtensionDetails.java
deleted file mode 100644
index 5726c1b..0000000
--- a/nifi-api/src/main/java/org/apache/nifi/action/component/details/ExtensionDetails.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * 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.action.component.details;
-
-/**
- * Provides details of an extension on an Action.
- */
-public interface ExtensionDetails extends ComponentDetails {
-
- String getType();
-
-}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-api/src/main/java/org/apache/nifi/action/component/details/RemoteProcessGroupDetails.java
----------------------------------------------------------------------
diff --git a/nifi-api/src/main/java/org/apache/nifi/action/component/details/RemoteProcessGroupDetails.java b/nifi-api/src/main/java/org/apache/nifi/action/component/details/RemoteProcessGroupDetails.java
deleted file mode 100644
index 62f8628..0000000
--- a/nifi-api/src/main/java/org/apache/nifi/action/component/details/RemoteProcessGroupDetails.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * 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.action.component.details;
-
-/**
- * Provides details of a remote process group to an Action.
- */
-public interface RemoteProcessGroupDetails extends ComponentDetails {
-
- String getUri();
-
-}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-api/src/main/java/org/apache/nifi/action/details/ConfigureDetails.java
----------------------------------------------------------------------
diff --git a/nifi-api/src/main/java/org/apache/nifi/action/details/ConfigureDetails.java b/nifi-api/src/main/java/org/apache/nifi/action/details/ConfigureDetails.java
deleted file mode 100644
index ff8db40..0000000
--- a/nifi-api/src/main/java/org/apache/nifi/action/details/ConfigureDetails.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * 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.action.details;
-
-/**
- * Provides details about a configure action.
- */
-public interface ConfigureDetails extends ActionDetails {
-
- String getName();
-
- String getPreviousValue();
-
- String getValue();
-
-}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-api/src/main/java/org/apache/nifi/action/details/ConnectDetails.java
----------------------------------------------------------------------
diff --git a/nifi-api/src/main/java/org/apache/nifi/action/details/ConnectDetails.java b/nifi-api/src/main/java/org/apache/nifi/action/details/ConnectDetails.java
deleted file mode 100644
index 3c8c91b..0000000
--- a/nifi-api/src/main/java/org/apache/nifi/action/details/ConnectDetails.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * 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.action.details;
-
-import org.apache.nifi.action.Component;
-
-/**
- * Provides details about a connect action.
- */
-public interface ConnectDetails extends ActionDetails {
-
- String getSourceId();
-
- String getSourceName();
-
- Component getSourceType();
-
- String getDestinationId();
-
- String getDestinationName();
-
- Component getDestinationType();
-
- String getRelationship();
-
-}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-api/src/main/java/org/apache/nifi/action/details/MoveDetails.java
----------------------------------------------------------------------
diff --git a/nifi-api/src/main/java/org/apache/nifi/action/details/MoveDetails.java b/nifi-api/src/main/java/org/apache/nifi/action/details/MoveDetails.java
deleted file mode 100644
index 0533b3b..0000000
--- a/nifi-api/src/main/java/org/apache/nifi/action/details/MoveDetails.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * 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.action.details;
-
-/**
- * Provides details about a move action.
- */
-public interface MoveDetails extends ActionDetails {
- String getGroup();
-
- String getGroupId();
-
- String getPreviousGroup();
-
- String getPreviousGroupId();
-}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-api/src/main/java/org/apache/nifi/action/details/PurgeDetails.java
----------------------------------------------------------------------
diff --git a/nifi-api/src/main/java/org/apache/nifi/action/details/PurgeDetails.java b/nifi-api/src/main/java/org/apache/nifi/action/details/PurgeDetails.java
deleted file mode 100644
index 57bc57e..0000000
--- a/nifi-api/src/main/java/org/apache/nifi/action/details/PurgeDetails.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * 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.action.details;
-
-import java.util.Date;
-
-/**
- * Provides details about a purge action.
- */
-public interface PurgeDetails extends ActionDetails {
-
- Date getEndDate();
-
-}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-api/src/main/java/org/apache/nifi/annotation/behavior/DynamicProperties.java
----------------------------------------------------------------------
diff --git a/nifi-api/src/main/java/org/apache/nifi/annotation/behavior/DynamicProperties.java b/nifi-api/src/main/java/org/apache/nifi/annotation/behavior/DynamicProperties.java
index b936ff0..9670535 100644
--- a/nifi-api/src/main/java/org/apache/nifi/annotation/behavior/DynamicProperties.java
+++ b/nifi-api/src/main/java/org/apache/nifi/annotation/behavior/DynamicProperties.java
@@ -33,5 +33,5 @@ import java.lang.annotation.Target;
@Inherited
public @interface DynamicProperties {
- public DynamicProperty[] value();
+ DynamicProperty[] value();
}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-api/src/main/java/org/apache/nifi/annotation/behavior/DynamicProperty.java
----------------------------------------------------------------------
diff --git a/nifi-api/src/main/java/org/apache/nifi/annotation/behavior/DynamicProperty.java b/nifi-api/src/main/java/org/apache/nifi/annotation/behavior/DynamicProperty.java
index d5f0511..e7712df 100644
--- a/nifi-api/src/main/java/org/apache/nifi/annotation/behavior/DynamicProperty.java
+++ b/nifi-api/src/main/java/org/apache/nifi/annotation/behavior/DynamicProperty.java
@@ -36,11 +36,11 @@ import org.apache.nifi.components.ConfigurableComponent;
@Inherited
public @interface DynamicProperty {
- public String name();
+ String name();
- public boolean supportsExpressionLanguage() default false;
+ boolean supportsExpressionLanguage() default false;
- public String value();
+ String value();
- public String description();
+ String description();
}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-api/src/main/java/org/apache/nifi/annotation/behavior/DynamicRelationship.java
----------------------------------------------------------------------
diff --git a/nifi-api/src/main/java/org/apache/nifi/annotation/behavior/DynamicRelationship.java b/nifi-api/src/main/java/org/apache/nifi/annotation/behavior/DynamicRelationship.java
index 88d3b1d..68d40c7 100644
--- a/nifi-api/src/main/java/org/apache/nifi/annotation/behavior/DynamicRelationship.java
+++ b/nifi-api/src/main/java/org/apache/nifi/annotation/behavior/DynamicRelationship.java
@@ -39,7 +39,7 @@ import org.apache.nifi.processor.Relationship;
@Inherited
public @interface DynamicRelationship {
- public String name();
+ String name();
- public String description();
+ String description();
}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-api/src/main/java/org/apache/nifi/annotation/behavior/InputRequirement.java
----------------------------------------------------------------------
diff --git a/nifi-api/src/main/java/org/apache/nifi/annotation/behavior/InputRequirement.java b/nifi-api/src/main/java/org/apache/nifi/annotation/behavior/InputRequirement.java
index 13f442c..372d80c 100644
--- a/nifi-api/src/main/java/org/apache/nifi/annotation/behavior/InputRequirement.java
+++ b/nifi-api/src/main/java/org/apache/nifi/annotation/behavior/InputRequirement.java
@@ -39,7 +39,7 @@ import java.lang.annotation.Target;
public @interface InputRequirement {
Requirement value();
- public static enum Requirement {
+ enum Requirement {
/**
* This value is used to indicate that the Processor requires input from other Processors
* in order to run. As a result, the Processor will not be valid if it does not have any
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-api/src/main/java/org/apache/nifi/annotation/behavior/ReadsAttributes.java
----------------------------------------------------------------------
diff --git a/nifi-api/src/main/java/org/apache/nifi/annotation/behavior/ReadsAttributes.java b/nifi-api/src/main/java/org/apache/nifi/annotation/behavior/ReadsAttributes.java
index e65746c..fe1f8bd 100644
--- a/nifi-api/src/main/java/org/apache/nifi/annotation/behavior/ReadsAttributes.java
+++ b/nifi-api/src/main/java/org/apache/nifi/annotation/behavior/ReadsAttributes.java
@@ -35,5 +35,5 @@ import java.lang.annotation.Target;
@Inherited
public @interface ReadsAttributes {
- public ReadsAttribute[] value();
+ ReadsAttribute[] value();
}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-api/src/main/java/org/apache/nifi/annotation/behavior/WritesAttribute.java
----------------------------------------------------------------------
diff --git a/nifi-api/src/main/java/org/apache/nifi/annotation/behavior/WritesAttribute.java b/nifi-api/src/main/java/org/apache/nifi/annotation/behavior/WritesAttribute.java
index b2e1c48..d06af8f 100644
--- a/nifi-api/src/main/java/org/apache/nifi/annotation/behavior/WritesAttribute.java
+++ b/nifi-api/src/main/java/org/apache/nifi/annotation/behavior/WritesAttribute.java
@@ -35,7 +35,7 @@ import java.lang.annotation.Target;
@Inherited
public @interface WritesAttribute {
- public String attribute();
+ String attribute();
- public String description() default "";
+ String description() default "";
}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-api/src/main/java/org/apache/nifi/annotation/behavior/WritesAttributes.java
----------------------------------------------------------------------
diff --git a/nifi-api/src/main/java/org/apache/nifi/annotation/behavior/WritesAttributes.java b/nifi-api/src/main/java/org/apache/nifi/annotation/behavior/WritesAttributes.java
index ad3e401..603eb86 100644
--- a/nifi-api/src/main/java/org/apache/nifi/annotation/behavior/WritesAttributes.java
+++ b/nifi-api/src/main/java/org/apache/nifi/annotation/behavior/WritesAttributes.java
@@ -35,5 +35,5 @@ import java.lang.annotation.Target;
@Inherited
public @interface WritesAttributes {
- public WritesAttribute[] value();
+ WritesAttribute[] value();
}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-api/src/main/java/org/apache/nifi/annotation/documentation/SeeAlso.java
----------------------------------------------------------------------
diff --git a/nifi-api/src/main/java/org/apache/nifi/annotation/documentation/SeeAlso.java b/nifi-api/src/main/java/org/apache/nifi/annotation/documentation/SeeAlso.java
index 4b77c43..f89e25b 100644
--- a/nifi-api/src/main/java/org/apache/nifi/annotation/documentation/SeeAlso.java
+++ b/nifi-api/src/main/java/org/apache/nifi/annotation/documentation/SeeAlso.java
@@ -38,7 +38,7 @@ import org.apache.nifi.components.ConfigurableComponent;
@Inherited
public @interface SeeAlso {
- public Class<? extends ConfigurableComponent>[] value() default {};
+ Class<? extends ConfigurableComponent>[] value() default {};
- public String[] classNames() default {};
+ String[] classNames() default {};
}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-api/src/main/java/org/apache/nifi/annotation/documentation/Tags.java
----------------------------------------------------------------------
diff --git a/nifi-api/src/main/java/org/apache/nifi/annotation/documentation/Tags.java b/nifi-api/src/main/java/org/apache/nifi/annotation/documentation/Tags.java
index 366dd4c..d9721ab 100644
--- a/nifi-api/src/main/java/org/apache/nifi/annotation/documentation/Tags.java
+++ b/nifi-api/src/main/java/org/apache/nifi/annotation/documentation/Tags.java
@@ -38,5 +38,5 @@ import java.lang.annotation.Target;
@Inherited
public @interface Tags {
- public String[] value();
+ String[] value();
}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-api/src/main/java/org/apache/nifi/authentication/AuthenticationResponse.java
----------------------------------------------------------------------
diff --git a/nifi-api/src/main/java/org/apache/nifi/authentication/AuthenticationResponse.java b/nifi-api/src/main/java/org/apache/nifi/authentication/AuthenticationResponse.java
deleted file mode 100644
index e9999fc..0000000
--- a/nifi-api/src/main/java/org/apache/nifi/authentication/AuthenticationResponse.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * 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.authentication;
-
-/**
- * Authentication response for a user login attempt.
- */
-public class AuthenticationResponse {
-
- private final String identity;
- private final String username;
- private final long expiration;
- private final String issuer;
-
- /**
- * Creates an authentication response. The username and how long the authentication is valid in milliseconds
- *
- * @param identity The user identity
- * @param username The username
- * @param expiration The expiration in milliseconds
- * @param issuer The issuer of the token
- */
- public AuthenticationResponse(final String identity, final String username, final long expiration, final String issuer) {
- this.identity = identity;
- this.username = username;
- this.expiration = expiration;
- this.issuer = issuer;
- }
-
- public String getIdentity() {
- return identity;
- }
-
- public String getUsername() {
- return username;
- }
-
- public String getIssuer() {
- return issuer;
- }
-
- /**
- * Returns the expiration of a given authentication in milliseconds.
- *
- * @return The expiration in milliseconds
- */
- public long getExpiration() {
- return expiration;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-api/src/main/java/org/apache/nifi/authentication/LoginCredentials.java
----------------------------------------------------------------------
diff --git a/nifi-api/src/main/java/org/apache/nifi/authentication/LoginCredentials.java b/nifi-api/src/main/java/org/apache/nifi/authentication/LoginCredentials.java
deleted file mode 100644
index afb7827..0000000
--- a/nifi-api/src/main/java/org/apache/nifi/authentication/LoginCredentials.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * 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.authentication;
-
-/**
- * Login credentials for a user.
- */
-public class LoginCredentials {
-
- private final String username;
- private final String password;
-
- public LoginCredentials(String username, String password) {
- this.username = username;
- this.password = password;
- }
-
- public String getUsername() {
- return username;
- }
-
- public String getPassword() {
- return password;
- }
-}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-api/src/main/java/org/apache/nifi/authentication/LoginIdentityProvider.java
----------------------------------------------------------------------
diff --git a/nifi-api/src/main/java/org/apache/nifi/authentication/LoginIdentityProvider.java b/nifi-api/src/main/java/org/apache/nifi/authentication/LoginIdentityProvider.java
deleted file mode 100644
index 145bdb4..0000000
--- a/nifi-api/src/main/java/org/apache/nifi/authentication/LoginIdentityProvider.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * 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.authentication;
-
-import org.apache.nifi.authentication.exception.IdentityAccessException;
-import org.apache.nifi.authentication.exception.InvalidLoginCredentialsException;
-import org.apache.nifi.authentication.exception.ProviderCreationException;
-import org.apache.nifi.authentication.exception.ProviderDestructionException;
-
-/**
- * Identity provider that is able to authentication a user with username/password credentials.
- */
-public interface LoginIdentityProvider {
-
- /**
- * Authenticates the specified login credentials.
- *
- * @param credentials the credentials
- * @return The authentication response
- * @throws InvalidLoginCredentialsException The login credentials were invalid
- * @throws IdentityAccessException Unable to register the user due to an issue accessing the underlying storage
- */
- AuthenticationResponse authenticate(LoginCredentials credentials) throws InvalidLoginCredentialsException, IdentityAccessException;
-
- /**
- * Called immediately after instance creation for implementers to perform additional setup
- *
- * @param initializationContext in which to initialize
- * @throws ProviderCreationException Unable to initialize
- */
- void initialize(LoginIdentityProviderInitializationContext initializationContext) throws ProviderCreationException;
-
- /**
- * Called to configure the AuthorityProvider.
- *
- * @param configurationContext at the time of configuration
- * @throws ProviderCreationException for any issues configuring the provider
- */
- void onConfigured(LoginIdentityProviderConfigurationContext configurationContext) throws ProviderCreationException;
-
- /**
- * Called immediately before instance destruction for implementers to release resources.
- *
- * @throws ProviderDestructionException If pre-destruction fails.
- */
- void preDestruction() throws ProviderDestructionException;
-}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-api/src/main/java/org/apache/nifi/authentication/LoginIdentityProviderConfigurationContext.java
----------------------------------------------------------------------
diff --git a/nifi-api/src/main/java/org/apache/nifi/authentication/LoginIdentityProviderConfigurationContext.java b/nifi-api/src/main/java/org/apache/nifi/authentication/LoginIdentityProviderConfigurationContext.java
deleted file mode 100644
index 6fe61fc..0000000
--- a/nifi-api/src/main/java/org/apache/nifi/authentication/LoginIdentityProviderConfigurationContext.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * 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.authentication;
-
-import java.util.Map;
-
-/**
- *
- */
-public interface LoginIdentityProviderConfigurationContext {
-
- /**
- * @return identifier for the authority provider
- */
- String getIdentifier();
-
- /**
- * Retrieves all properties the component currently understands regardless
- * of whether a value has been set for them or not. If no value is present
- * then its value is null and thus any registered default for the property
- * descriptor applies.
- *
- * @return Map of all properties
- */
- Map<String, String> getProperties();
-
- /**
- * @param property to lookup the descriptor and value of
- * @return the value the component currently understands for the given
- * PropertyDescriptor. This method does not substitute default
- * PropertyDescriptor values, so the value returned will be null if not set
- */
- String getProperty(String property);
-}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-api/src/main/java/org/apache/nifi/authentication/LoginIdentityProviderInitializationContext.java
----------------------------------------------------------------------
diff --git a/nifi-api/src/main/java/org/apache/nifi/authentication/LoginIdentityProviderInitializationContext.java b/nifi-api/src/main/java/org/apache/nifi/authentication/LoginIdentityProviderInitializationContext.java
deleted file mode 100644
index 7aa72a7..0000000
--- a/nifi-api/src/main/java/org/apache/nifi/authentication/LoginIdentityProviderInitializationContext.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * 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.authentication;
-
-/**
- *
- */
-public interface LoginIdentityProviderInitializationContext {
-
- public String getIdentifier();
-
- public LoginIdentityProviderLookup getAuthorityProviderLookup();
-}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-api/src/main/java/org/apache/nifi/authentication/LoginIdentityProviderLookup.java
----------------------------------------------------------------------
diff --git a/nifi-api/src/main/java/org/apache/nifi/authentication/LoginIdentityProviderLookup.java b/nifi-api/src/main/java/org/apache/nifi/authentication/LoginIdentityProviderLookup.java
deleted file mode 100644
index 3cd0ba7..0000000
--- a/nifi-api/src/main/java/org/apache/nifi/authentication/LoginIdentityProviderLookup.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * 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.authentication;
-
-/**
- *
- */
-public interface LoginIdentityProviderLookup {
-
- LoginIdentityProvider getLoginIdentityProvider(String identifier);
-}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-api/src/main/java/org/apache/nifi/authentication/annotation/LoginIdentityProviderContext.java
----------------------------------------------------------------------
diff --git a/nifi-api/src/main/java/org/apache/nifi/authentication/annotation/LoginIdentityProviderContext.java b/nifi-api/src/main/java/org/apache/nifi/authentication/annotation/LoginIdentityProviderContext.java
deleted file mode 100644
index 88df259..0000000
--- a/nifi-api/src/main/java/org/apache/nifi/authentication/annotation/LoginIdentityProviderContext.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * 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.authentication.annotation;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Inherited;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- *
- *
- */
-@Documented
-@Target({ElementType.FIELD, ElementType.METHOD})
-@Retention(RetentionPolicy.RUNTIME)
-@Inherited
-public @interface LoginIdentityProviderContext {
-}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-api/src/main/java/org/apache/nifi/authentication/exception/IdentityAccessException.java
----------------------------------------------------------------------
diff --git a/nifi-api/src/main/java/org/apache/nifi/authentication/exception/IdentityAccessException.java b/nifi-api/src/main/java/org/apache/nifi/authentication/exception/IdentityAccessException.java
deleted file mode 100644
index b68c675..0000000
--- a/nifi-api/src/main/java/org/apache/nifi/authentication/exception/IdentityAccessException.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * 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.authentication.exception;
-
-/**
- * Represents the case when the identity could not be confirmed because it was unable
- * to access the backing store.
- */
-public class IdentityAccessException extends RuntimeException {
-
- public IdentityAccessException(String message, Throwable cause) {
- super(message, cause);
- }
-
- public IdentityAccessException(String message) {
- super(message);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-api/src/main/java/org/apache/nifi/authentication/exception/InvalidLoginCredentialsException.java
----------------------------------------------------------------------
diff --git a/nifi-api/src/main/java/org/apache/nifi/authentication/exception/InvalidLoginCredentialsException.java b/nifi-api/src/main/java/org/apache/nifi/authentication/exception/InvalidLoginCredentialsException.java
deleted file mode 100644
index fbfa324..0000000
--- a/nifi-api/src/main/java/org/apache/nifi/authentication/exception/InvalidLoginCredentialsException.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * 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.authentication.exception;
-
-/**
- * Represents the case when the identity could not be confirmed because the
- * login credentials were invalid.
- */
-public class InvalidLoginCredentialsException extends RuntimeException {
-
- public InvalidLoginCredentialsException(String message, Throwable cause) {
- super(message, cause);
- }
-
- public InvalidLoginCredentialsException(String message) {
- super(message);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-api/src/main/java/org/apache/nifi/authentication/exception/ProviderCreationException.java
----------------------------------------------------------------------
diff --git a/nifi-api/src/main/java/org/apache/nifi/authentication/exception/ProviderCreationException.java b/nifi-api/src/main/java/org/apache/nifi/authentication/exception/ProviderCreationException.java
deleted file mode 100644
index b352787..0000000
--- a/nifi-api/src/main/java/org/apache/nifi/authentication/exception/ProviderCreationException.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * 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.authentication.exception;
-
-/**
- * Represents the exceptional case when an AuthorityProvider fails instantiated.
- *
- */
-public class ProviderCreationException extends RuntimeException {
-
- public ProviderCreationException() {
- }
-
- public ProviderCreationException(String msg) {
- super(msg);
- }
-
- public ProviderCreationException(Throwable cause) {
- super(cause);
- }
-
- public ProviderCreationException(String msg, Throwable cause) {
- super(msg, cause);
- }
-}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-api/src/main/java/org/apache/nifi/authentication/exception/ProviderDestructionException.java
----------------------------------------------------------------------
diff --git a/nifi-api/src/main/java/org/apache/nifi/authentication/exception/ProviderDestructionException.java b/nifi-api/src/main/java/org/apache/nifi/authentication/exception/ProviderDestructionException.java
deleted file mode 100644
index 1e12146..0000000
--- a/nifi-api/src/main/java/org/apache/nifi/authentication/exception/ProviderDestructionException.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * 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.authentication.exception;
-
-/**
- * Represents the exceptional case when an AuthorityProvider fails destruction.
- *
- */
-public class ProviderDestructionException extends RuntimeException {
-
- public ProviderDestructionException() {
- }
-
- public ProviderDestructionException(String msg) {
- super(msg);
- }
-
- public ProviderDestructionException(Throwable cause) {
- super(cause);
- }
-
- public ProviderDestructionException(String msg, Throwable cause) {
- super(msg, cause);
- }
-}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-api/src/main/java/org/apache/nifi/authorization/AbstractPolicyBasedAuthorizer.java
----------------------------------------------------------------------
diff --git a/nifi-api/src/main/java/org/apache/nifi/authorization/AbstractPolicyBasedAuthorizer.java b/nifi-api/src/main/java/org/apache/nifi/authorization/AbstractPolicyBasedAuthorizer.java
deleted file mode 100644
index 8fbe0fb..0000000
--- a/nifi-api/src/main/java/org/apache/nifi/authorization/AbstractPolicyBasedAuthorizer.java
+++ /dev/null
@@ -1,552 +0,0 @@
-/*
- * 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.authorization;
-
-import org.apache.nifi.authorization.exception.AuthorizationAccessException;
-import org.apache.nifi.authorization.exception.AuthorizerCreationException;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import org.xml.sax.SAXException;
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.stream.XMLOutputFactory;
-import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.XMLStreamWriter;
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.StringWriter;
-import java.nio.charset.StandardCharsets;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.List;
-import java.util.Set;
-
-/**
- * An Authorizer that provides management of users, groups, and policies.
- */
-public abstract class AbstractPolicyBasedAuthorizer implements Authorizer {
-
- static final DocumentBuilderFactory DOCUMENT_BUILDER_FACTORY = DocumentBuilderFactory.newInstance();
- static final XMLOutputFactory XML_OUTPUT_FACTORY = XMLOutputFactory.newInstance();
-
- static final String USER_ELEMENT = "user";
- static final String GROUP_USER_ELEMENT = "groupUser";
- static final String GROUP_ELEMENT = "group";
- static final String POLICY_ELEMENT = "policy";
- static final String POLICY_USER_ELEMENT = "policyUser";
- static final String POLICY_GROUP_ELEMENT = "policyGroup";
- static final String IDENTIFIER_ATTR = "identifier";
- static final String IDENTITY_ATTR = "identity";
- static final String NAME_ATTR = "name";
- static final String RESOURCE_ATTR = "resource";
- static final String ACTIONS_ATTR = "actions";
-
- public static final String EMPTY_FINGERPRINT = "EMPTY";
-
- @Override
- public final void onConfigured(final AuthorizerConfigurationContext configurationContext) throws AuthorizerCreationException {
- doOnConfigured(configurationContext);
-
- // ensure that only one policy per resource-action exists
- for (AccessPolicy accessPolicy : getAccessPolicies()) {
- if (policyExists(accessPolicy)) {
- throw new AuthorizerCreationException("Found multiple policies for " + accessPolicy.getResource()
- + " with " + accessPolicy.getAction());
- }
- }
- }
-
- /**
- * Allows sub-classes to take action when onConfigured is called.
- *
- * @param configurationContext the configuration context
- * @throws AuthorizerCreationException if an error occurs during onConfigured process
- */
- protected abstract void doOnConfigured(final AuthorizerConfigurationContext configurationContext) throws AuthorizerCreationException;
-
- /**
- * Checks if another policy exists with the same resource and action as the given policy.
- *
- * @param checkAccessPolicy an access policy being checked
- * @return true if another access policy exists with the same resource and action, false otherwise
- */
- private boolean policyExists(final AccessPolicy checkAccessPolicy) {
- for (AccessPolicy accessPolicy : getAccessPolicies()) {
- if (!accessPolicy.getIdentifier().equals(checkAccessPolicy.getIdentifier())
- && accessPolicy.getResource().equals(checkAccessPolicy.getResource())
- && accessPolicy.getAction().equals(checkAccessPolicy.getAction())) {
- return true;
- }
- }
- return false;
- }
-
- @Override
- public final AuthorizationResult authorize(AuthorizationRequest request) throws AuthorizationAccessException {
- final UsersAndAccessPolicies usersAndAccessPolicies = getUsersAndAccessPolicies();
- final String resourceIdentifier = request.getResource().getIdentifier();
-
- final AccessPolicy policy = usersAndAccessPolicies.getAccessPolicy(resourceIdentifier, request.getAction());
- if (policy == null) {
- return AuthorizationResult.resourceNotFound();
- }
-
- final User user = usersAndAccessPolicies.getUser(request.getIdentity());
- if (user == null) {
- return AuthorizationResult.denied("Unknown user with identity " + request.getIdentity());
- }
-
- final Set<Group> userGroups = usersAndAccessPolicies.getGroups(user.getIdentity());
- if (policy.getUsers().contains(user.getIdentifier()) || containsGroup(userGroups, policy)) {
- return AuthorizationResult.approved();
- }
-
-
- return AuthorizationResult.denied();
- }
-
- /**
- * Determines if the policy contains one of the user's groups.
- *
- * @param userGroups the set of the user's groups
- * @param policy the policy
- * @return true if one of the Groups in userGroups is contained in the policy
- */
- private boolean containsGroup(final Set<Group> userGroups, final AccessPolicy policy) {
- if (userGroups.isEmpty() || policy.getGroups().isEmpty()) {
- return false;
- }
-
- for (Group userGroup : userGroups) {
- if (policy.getGroups().contains(userGroup.getIdentifier())) {
- return true;
- }
- }
-
- return false;
- }
-
- /**
- * Adds a new group.
- *
- * @param group the Group to add
- * @return the added Group
- * @throws AuthorizationAccessException if there was an unexpected error performing the operation
- */
- public abstract Group addGroup(Group group) throws AuthorizationAccessException;
-
- /**
- * Retrieves a Group by id.
- *
- * @param identifier the identifier of the Group to retrieve
- * @return the Group with the given identifier, or null if no matching group was found
- * @throws AuthorizationAccessException if there was an unexpected error performing the operation
- */
- public abstract Group getGroup(String identifier) throws AuthorizationAccessException;
-
- /**
- * The group represented by the provided instance will be updated based on the provided instance.
- *
- * @param group an updated group instance
- * @return the updated group instance, or null if no matching group was found
- * @throws AuthorizationAccessException if there was an unexpected error performing the operation
- */
- public abstract Group updateGroup(Group group) throws AuthorizationAccessException;
-
- /**
- * Deletes the given group.
- *
- * @param group the group to delete
- * @return the deleted group, or null if no matching group was found
- * @throws AuthorizationAccessException if there was an unexpected error performing the operation
- */
- public abstract Group deleteGroup(Group group) throws AuthorizationAccessException;
-
- /**
- * Retrieves all groups.
- *
- * @return a list of groups
- * @throws AuthorizationAccessException if there was an unexpected error performing the operation
- */
- public abstract Set<Group> getGroups() throws AuthorizationAccessException;
-
-
- /**
- * Adds the given user.
- *
- * @param user the user to add
- * @return the user that was added
- * @throws AuthorizationAccessException if there was an unexpected error performing the operation
- */
- public abstract User addUser(User user) throws AuthorizationAccessException;
-
- /**
- * Retrieves the user with the given identifier.
- *
- * @param identifier the id of the user to retrieve
- * @return the user with the given id, or null if no matching user was found
- * @throws AuthorizationAccessException if there was an unexpected error performing the operation
- */
- public abstract User getUser(String identifier) throws AuthorizationAccessException;
-
- /**
- * Retrieves the user with the given identity.
- *
- * @param identity the identity of the user to retrieve
- * @return the user with the given identity, or null if no matching user was found
- * @throws AuthorizationAccessException if there was an unexpected error performing the operation
- */
- public abstract User getUserByIdentity(String identity) throws AuthorizationAccessException;
-
- /**
- * The user represented by the provided instance will be updated based on the provided instance.
- *
- * @param user an updated user instance
- * @return the updated user instance, or null if no matching user was found
- * @throws AuthorizationAccessException if there was an unexpected error performing the operation
- */
- public abstract User updateUser(User user) throws AuthorizationAccessException;
-
- /**
- * Deletes the given user.
- *
- * @param user the user to delete
- * @return the user that was deleted, or null if no matching user was found
- * @throws AuthorizationAccessException if there was an unexpected error performing the operation
- */
- public abstract User deleteUser(User user) throws AuthorizationAccessException;
-
- /**
- * Retrieves all users.
- *
- * @return a list of users
- * @throws AuthorizationAccessException if there was an unexpected error performing the operation
- */
- public abstract Set<User> getUsers() throws AuthorizationAccessException;
-
- /**
- * Adds the given policy ensuring that multiple policies can not be added for the same resource and action.
- *
- * @param accessPolicy the policy to add
- * @return the policy that was added
- * @throws AuthorizationAccessException if there was an unexpected error performing the operation
- */
- public final synchronized AccessPolicy addAccessPolicy(AccessPolicy accessPolicy) throws AuthorizationAccessException {
- if (policyExists(accessPolicy)) {
- throw new IllegalStateException("Found multiple policies for " + accessPolicy.getResource()
- + " with " + accessPolicy.getAction());
- }
- return doAddAccessPolicy(accessPolicy);
- }
-
- /**
- * Adds the given policy.
- *
- * @param accessPolicy the policy to add
- * @return the policy that was added
- * @throws AuthorizationAccessException if there was an unexpected error performing the operation
- */
- protected abstract AccessPolicy doAddAccessPolicy(AccessPolicy accessPolicy) throws AuthorizationAccessException;
-
- /**
- * Retrieves the policy with the given identifier.
- *
- * @param identifier the id of the policy to retrieve
- * @return the policy with the given id, or null if no matching policy exists
- * @throws AuthorizationAccessException if there was an unexpected error performing the operation
- */
- public abstract AccessPolicy getAccessPolicy(String identifier) throws AuthorizationAccessException;
-
- /**
- * The policy represented by the provided instance will be updated based on the provided instance.
- *
- * @param accessPolicy an updated policy
- * @return the updated policy, or null if no matching policy was found
- * @throws AuthorizationAccessException if there was an unexpected error performing the operation
- */
- public abstract AccessPolicy updateAccessPolicy(AccessPolicy accessPolicy) throws AuthorizationAccessException;
-
- /**
- * Deletes the given policy.
- *
- * @param policy the policy to delete
- * @return the deleted policy, or null if no matching policy was found
- * @throws AuthorizationAccessException if there was an unexpected error performing the operation
- */
- public abstract AccessPolicy deleteAccessPolicy(AccessPolicy policy) throws AuthorizationAccessException;
-
- /**
- * Retrieves all access policies.
- *
- * @return a list of policies
- * @throws AuthorizationAccessException if there was an unexpected error performing the operation
- */
- public abstract Set<AccessPolicy> getAccessPolicies() throws AuthorizationAccessException;
-
- /**
- * Returns the UserAccessPolicies instance.
- *
- * @return the UserAccessPolicies instance
- * @throws AuthorizationAccessException if there was an unexpected error performing the operation
- */
- public abstract UsersAndAccessPolicies getUsersAndAccessPolicies() throws AuthorizationAccessException;
-
- /**
- * Parses the fingerprint and adds any users, groups, and policies to the current Authorizer.
- *
- * @param fingerprint the fingerprint that was obtained from calling getFingerprint() on another Authorizer.
- */
- public final void inheritFingerprint(final String fingerprint) throws AuthorizationAccessException {
- if (fingerprint == null || fingerprint.trim().isEmpty()) {
- return;
- }
-
- final byte[] fingerprintBytes = fingerprint.getBytes(StandardCharsets.UTF_8);
-
- try (final ByteArrayInputStream in = new ByteArrayInputStream(fingerprintBytes)) {
- final DocumentBuilder docBuilder = DOCUMENT_BUILDER_FACTORY.newDocumentBuilder();
- final Document document = docBuilder.parse(in);
- final Element rootElement = document.getDocumentElement();
-
- // parse all the users and add them to the current authorizer
- NodeList userNodes = rootElement.getElementsByTagName(USER_ELEMENT);
- for (int i=0; i < userNodes.getLength(); i++) {
- Node userNode = userNodes.item(i);
- User user = parseUser((Element) userNode);
- addUser(user);
- }
-
- // parse all the groups and add them to the current authorizer
- NodeList groupNodes = rootElement.getElementsByTagName(GROUP_ELEMENT);
- for (int i=0; i < groupNodes.getLength(); i++) {
- Node groupNode = groupNodes.item(i);
- Group group = parseGroup((Element) groupNode);
- addGroup(group);
- }
-
- // parse all the policies and add them to the current authorizer
- NodeList policyNodes = rootElement.getElementsByTagName(POLICY_ELEMENT);
- for (int i=0; i < policyNodes.getLength(); i++) {
- Node policyNode = policyNodes.item(i);
- AccessPolicy policy = parsePolicy((Element) policyNode);
- addAccessPolicy(policy);
- }
-
- } catch (SAXException | ParserConfigurationException | IOException e) {
- throw new AuthorizationAccessException("Unable to parse fingerprint", e);
- }
- }
-
- private User parseUser(final Element element) {
- final User.Builder builder = new User.Builder()
- .identifier(element.getAttribute(IDENTIFIER_ATTR))
- .identity(element.getAttribute(IDENTITY_ATTR));
-
- return builder.build();
- }
-
- private Group parseGroup(final Element element) {
- final Group.Builder builder = new Group.Builder()
- .identifier(element.getAttribute(IDENTIFIER_ATTR))
- .name(element.getAttribute(NAME_ATTR));
-
- NodeList groupUsers = element.getElementsByTagName(GROUP_USER_ELEMENT);
- for (int i=0; i < groupUsers.getLength(); i++) {
- Element groupUserNode = (Element) groupUsers.item(i);
- builder.addUser(groupUserNode.getAttribute(IDENTIFIER_ATTR));
- }
-
- return builder.build();
- }
-
- private AccessPolicy parsePolicy(final Element element) {
- final AccessPolicy.Builder builder = new AccessPolicy.Builder()
- .identifier(element.getAttribute(IDENTIFIER_ATTR))
- .resource(element.getAttribute(RESOURCE_ATTR));
-
- final String actions = element.getAttribute(ACTIONS_ATTR);
- if (actions.equals(RequestAction.READ.name())) {
- builder.action(RequestAction.READ);
- } else if (actions.equals(RequestAction.WRITE.name())) {
- builder.action(RequestAction.WRITE);
- } else {
- throw new IllegalStateException("Unknown Policy Action: " + actions);
- }
-
- NodeList policyUsers = element.getElementsByTagName(POLICY_USER_ELEMENT);
- for (int i=0; i < policyUsers.getLength(); i++) {
- Element policyUserNode = (Element) policyUsers.item(i);
- builder.addUser(policyUserNode.getAttribute(IDENTIFIER_ATTR));
- }
-
- NodeList policyGroups = element.getElementsByTagName(POLICY_GROUP_ELEMENT);
- for (int i=0; i < policyGroups.getLength(); i++) {
- Element policyGroupNode = (Element) policyGroups.item(i);
- builder.addGroup(policyGroupNode.getAttribute(IDENTIFIER_ATTR));
- }
-
- return builder.build();
- }
-
- /**
- * Returns a fingerprint representing the authorizations managed by this authorizer. The fingerprint will be
- * used for comparison to determine if two policy-based authorizers represent a compatible set of users,
- * groups, and policies.
- *
- * @return the fingerprint for this Authorizer
- */
- public final String getFingerprint() throws AuthorizationAccessException {
- final List<User> users = getSortedUsers();
- final List<Group> groups = getSortedGroups();
- final List<AccessPolicy> policies = getSortedAccessPolicies();
-
- // when there are no users, groups, policies we want to always return a simple indicator so
- // it can easily be determined when comparing fingerprints
- if (users.isEmpty() && groups.isEmpty() && policies.isEmpty()) {
- return EMPTY_FINGERPRINT;
- }
-
- XMLStreamWriter writer = null;
- final StringWriter out = new StringWriter();
- try {
- writer = XML_OUTPUT_FACTORY.createXMLStreamWriter(out);
- writer.writeStartDocument();
- writer.writeStartElement("authorizations");
-
- for (User user : users) {
- writeUser(writer, user);
- }
- for (Group group : groups) {
- writeGroup(writer, group);
- }
- for (AccessPolicy policy : policies) {
- writePolicy(writer, policy);
- }
-
- writer.writeEndElement();
- writer.writeEndDocument();
- writer.flush();
- } catch (XMLStreamException e) {
- throw new AuthorizationAccessException("Unable to generate fingerprint", e);
- } finally {
- if (writer != null) {
- try {
- writer.close();
- } catch (XMLStreamException e) {
- // nothing to do here
- }
- }
- }
-
- return out.toString();
- }
-
- private void writeUser(final XMLStreamWriter writer, final User user) throws XMLStreamException {
- writer.writeStartElement(USER_ELEMENT);
- writer.writeAttribute(IDENTIFIER_ATTR, user.getIdentifier());
- writer.writeAttribute(IDENTITY_ATTR, user.getIdentity());
- writer.writeEndElement();
- }
-
- private void writeGroup(final XMLStreamWriter writer, final Group group) throws XMLStreamException {
- List<String> users = new ArrayList<>(group.getUsers());
- Collections.sort(users);
-
- writer.writeStartElement(GROUP_ELEMENT);
- writer.writeAttribute(IDENTIFIER_ATTR, group.getIdentifier());
- writer.writeAttribute(NAME_ATTR, group.getName());
-
- for (String user : users) {
- writer.writeStartElement(GROUP_USER_ELEMENT);
- writer.writeAttribute(IDENTIFIER_ATTR, user);
- writer.writeEndElement();
- }
-
- writer.writeEndElement();
- }
-
- private void writePolicy(final XMLStreamWriter writer, final AccessPolicy policy) throws XMLStreamException {
- // sort the users for the policy
- List<String> policyUsers = new ArrayList<>(policy.getUsers());
- Collections.sort(policyUsers);
-
- // sort the groups for this policy
- List<String> policyGroups = new ArrayList<>(policy.getGroups());
- Collections.sort(policyGroups);
-
- writer.writeStartElement(POLICY_ELEMENT);
- writer.writeAttribute(IDENTIFIER_ATTR, policy.getIdentifier());
- writer.writeAttribute(RESOURCE_ATTR, policy.getResource());
- writer.writeAttribute(ACTIONS_ATTR, policy.getAction().name());
-
- for (String policyUser : policyUsers) {
- writer.writeStartElement(POLICY_USER_ELEMENT);
- writer.writeAttribute(IDENTIFIER_ATTR, policyUser);
- writer.writeEndElement();
- }
-
- for (String policyGroup : policyGroups) {
- writer.writeStartElement(POLICY_GROUP_ELEMENT);
- writer.writeAttribute(IDENTIFIER_ATTR, policyGroup);
- writer.writeEndElement();
- }
-
- writer.writeEndElement();
- }
-
- private List<AccessPolicy> getSortedAccessPolicies() {
- final List<AccessPolicy> policies = new ArrayList<>(getAccessPolicies());
-
- Collections.sort(policies, new Comparator<AccessPolicy>() {
- @Override
- public int compare(AccessPolicy p1, AccessPolicy p2) {
- return p1.getIdentifier().compareTo(p2.getIdentifier());
- }
- });
- return policies;
- }
-
- private List<Group> getSortedGroups() {
- final List<Group> groups = new ArrayList<>(getGroups());
-
- Collections.sort(groups, new Comparator<Group>() {
- @Override
- public int compare(Group g1, Group g2) {
- return g1.getIdentifier().compareTo(g2.getIdentifier());
- }
- });
- return groups;
- }
-
- private List<User> getSortedUsers() {
- final List<User> users = new ArrayList<>(getUsers());
-
- Collections.sort(users, new Comparator<User>() {
- @Override
- public int compare(User u1, User u2) {
- return u1.getIdentifier().compareTo(u2.getIdentifier());
- }
- });
- return users;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-api/src/main/java/org/apache/nifi/authorization/AccessDeniedException.java
----------------------------------------------------------------------
diff --git a/nifi-api/src/main/java/org/apache/nifi/authorization/AccessDeniedException.java b/nifi-api/src/main/java/org/apache/nifi/authorization/AccessDeniedException.java
deleted file mode 100644
index 8712d28..0000000
--- a/nifi-api/src/main/java/org/apache/nifi/authorization/AccessDeniedException.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * 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.authorization;
-
-/**
- * Represents any error that might occur while authorizing user requests.
- */
-public class AccessDeniedException extends RuntimeException {
- private static final long serialVersionUID = -5683444815269084134L;
-
- public AccessDeniedException(Throwable cause) {
- super(cause);
- }
-
- public AccessDeniedException(String message, Throwable cause) {
- super(message, cause);
- }
-
- public AccessDeniedException(String message) {
- super(message);
- }
-
- public AccessDeniedException() {
- }
-}
[08/10] nifi git commit: NIFI-1896 This closes #650. Refactored
nifi-api into nifi-framework-api and other locations. The nifi-api is
specific to that which is needed for intended extension points.
Posted by jo...@apache.org.
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-api/src/main/java/org/apache/nifi/controller/Triggerable.java
----------------------------------------------------------------------
diff --git a/nifi-api/src/main/java/org/apache/nifi/controller/Triggerable.java b/nifi-api/src/main/java/org/apache/nifi/controller/Triggerable.java
deleted file mode 100644
index 4b3149b..0000000
--- a/nifi-api/src/main/java/org/apache/nifi/controller/Triggerable.java
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- * 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.controller;
-
-import java.util.concurrent.TimeUnit;
-
-import org.apache.nifi.processor.ProcessContext;
-import org.apache.nifi.processor.ProcessSession;
-import org.apache.nifi.processor.ProcessSessionFactory;
-import org.apache.nifi.processor.exception.ProcessException;
-
-public interface Triggerable {
-
- public static final long MINIMUM_SCHEDULING_NANOS = 30000L;
-
- /**
- * <p>
- * The method called when this processor is triggered to operate by the
- * controller. This method may be called concurrently from different
- * threads. When this method is called depends on how this processor is
- * configured within a controller to be triggered (timing or event
- * based).</p>
- *
- * <p>
- * The processor may commit, roll back, or allow the framework to
- * automatically manage the session. If the sessions are to be managed by
- * the framework (recommended) then what it will do depends on several
- * factors. If the method call returns due to an exception then the session
- * will be rolled back. If the method returns normally then the session will
- * be committed or the framework may use the session again for another
- * processor down stream</p>
- *
- * @param context in which the component is triggered
- * @param sessionFactory used to generate {@link ProcessSession}s to use for
- * operating on flow files within the repository
- *
- * @throws ProcessException if processing did not complete normally though
- * indicates the problem is an understood potential outcome of processing.
- * The controller/caller will handle these exceptions gracefully such as
- * logging, etc.. If another type of exception is allowed to propagate the
- * controller may no longer trigger this processor to operate as this would
- * indicate a probable coding defect.
- */
- void onTrigger(ProcessContext context, ProcessSessionFactory sessionFactory) throws ProcessException;
-
- /**
- * Determines the number of concurrent tasks that may be running for this
- * <code>Triggerable</code>.
- *
- * @param taskCount a number of concurrent tasks this processor may have
- * running
- * @throws IllegalArgumentException if the given value is less than 1
- */
- void setMaxConcurrentTasks(int taskCount);
-
- /**
- * @return the number of tasks that may execute concurrently for this
- * <code>Triggerable</code>.
- */
- int getMaxConcurrentTasks();
-
- /**
- * Indicates the {@link ScheduledState} of this <code>Triggerable</code>. A
- * value of stopped does NOT indicate that the <code>Triggerable</code> has
- * no active threads, only that it is not currently scheduled to be given
- * any more threads. To determine whether or not the
- * <code>Triggerable</code> has any active threads, see
- * {@link ProcessScheduler#getActiveThreadCount(nifi.connectable.Connectable)}.
- *
- * @return the schedule state
- */
- ScheduledState getScheduledState();
-
- /**
- * Indicates whether or not this <code>Triggerable</code> is "running". It
- * is considered "running" if it is scheduled to run OR if it is no longer
- * scheduled to be given threads but the remaining threads from the last
- * invocation of {@link #onTrigger(ProcessContext, ProcessSessionFactory)}
- * have not yet returned
- *
- * @return true if running;false otherwise
- */
- boolean isRunning();
-
- /**
- * @param timeUnit for the scheduling period of the component
- * @return the amount of time between each scheduling period
- */
- long getSchedulingPeriod(TimeUnit timeUnit);
-
- /**
- * @return a string representation of the time between each scheduling
- * period
- */
- String getSchedulingPeriod();
-
- /**
- * Updates how often this Triggerable should be triggered to run
- *
- * @param schedulingPeriod to set
- */
- void setScheduldingPeriod(String schedulingPeriod);
-}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-api/src/main/java/org/apache/nifi/controller/queue/DropFlowFileState.java
----------------------------------------------------------------------
diff --git a/nifi-api/src/main/java/org/apache/nifi/controller/queue/DropFlowFileState.java b/nifi-api/src/main/java/org/apache/nifi/controller/queue/DropFlowFileState.java
deleted file mode 100644
index 0f258b0..0000000
--- a/nifi-api/src/main/java/org/apache/nifi/controller/queue/DropFlowFileState.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * 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.controller.queue;
-
-/**
- * Represents the state that a Drop FlowFile request is in
- */
-public enum DropFlowFileState {
-
- WAITING_FOR_LOCK("Waiting for destination component to complete its action"),
- DROPPING_FLOWFILES("Dropping FlowFiles from queue"),
- FAILURE("Failed"),
- CANCELED("Canceled by user"),
- COMPLETE("Completed successfully");
-
- private final String description;
-
- private DropFlowFileState(final String description) {
- this.description = description;
- }
-
- @Override
- public String toString() {
- return description;
- }
-
- /**
- * @param description string form of drop flow file state
- * @return the matching DropFlowFileState or null if the description doesn't match
- */
- public static DropFlowFileState valueOfDescription(String description) {
- DropFlowFileState desiredState = null;
-
- for (DropFlowFileState state : values()) {
- if (state.toString().equals(description)) {
- desiredState = state;
- break;
- }
- }
-
- return desiredState;
- }
-}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-api/src/main/java/org/apache/nifi/controller/queue/DropFlowFileStatus.java
----------------------------------------------------------------------
diff --git a/nifi-api/src/main/java/org/apache/nifi/controller/queue/DropFlowFileStatus.java b/nifi-api/src/main/java/org/apache/nifi/controller/queue/DropFlowFileStatus.java
deleted file mode 100644
index 737fbe3..0000000
--- a/nifi-api/src/main/java/org/apache/nifi/controller/queue/DropFlowFileStatus.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * 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.controller.queue;
-
-/**
- * Represents the status of a Drop FlowFile Request that has been issued to
- * a {@link FlowFileQueue}. When a queue is requested to drop its FlowFiles,
- * that process may be rather lengthy in the case of a poorly behaving
- * FlowFileRepository or if the destination Processor is polling from the
- * queue using a filter that is misbehaving. As a result, the dropping of
- * FlowFiles is performed asynchronously.
- *
- * This status object provides information about how far along in the process
- * we currently are and information about the success or failure of the
- * operation.
- */
-public interface DropFlowFileStatus {
-
- /**
- * @return the identifier of the request to drop FlowFiles from the queue
- */
- String getRequestIdentifier();
-
- /**
- * @return the date/time (in milliseconds since epoch) at which the request to
- * drop the FlowFiles from a queue was submitted
- */
- long getRequestSubmissionTime();
-
- /**
- * @return the date/time (in milliseconds since epoch) at which the status of the
- * request was last updated
- */
- long getLastUpdated();
-
- /**
- * @return the size of the queue when the drop request was issued or <code>null</code> if
- * it is not yet known, which can happen if the {@link DropFlowFileState} is
- * {@link DropFlowFileState#WAITING_FOR_LOCK}.
- */
- QueueSize getOriginalSize();
-
- /**
- * @return the current size of the queue or <code>null</code> if it is not yet known
- */
- QueueSize getCurrentSize();
-
- /**
- * @return a QueueSize representing the number of FlowFiles that have been dropped for this request
- * and the aggregate size of those FlowFiles
- */
- QueueSize getDroppedSize();
-
- /**
- * @return the current state of the operation
- */
- DropFlowFileState getState();
-
- /**
- * @return the reason that the state is set to a Failure state, or <code>null</code> if the state is not {@link DropFlowFileState#FAILURE}.
- */
- String getFailureReason();
-}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-api/src/main/java/org/apache/nifi/controller/queue/FlowFileQueue.java
----------------------------------------------------------------------
diff --git a/nifi-api/src/main/java/org/apache/nifi/controller/queue/FlowFileQueue.java b/nifi-api/src/main/java/org/apache/nifi/controller/queue/FlowFileQueue.java
deleted file mode 100644
index 7948ecb..0000000
--- a/nifi-api/src/main/java/org/apache/nifi/controller/queue/FlowFileQueue.java
+++ /dev/null
@@ -1,275 +0,0 @@
-/*
- * 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.controller.queue;
-
-import java.io.IOException;
-import java.util.Collection;
-import java.util.List;
-import java.util.Queue;
-import java.util.Set;
-import java.util.concurrent.TimeUnit;
-
-import org.apache.nifi.controller.repository.FlowFileRecord;
-import org.apache.nifi.controller.repository.SwapSummary;
-import org.apache.nifi.flowfile.FlowFilePrioritizer;
-import org.apache.nifi.processor.FlowFileFilter;
-
-public interface FlowFileQueue {
-
- /**
- * @return the unique identifier for this FlowFileQueue
- */
- String getIdentifier();
-
- /**
- * @return list of processing priorities for this queue
- */
- List<FlowFilePrioritizer> getPriorities();
-
- /**
- * Reads any Swap Files that belong to this queue and returns a summary of what is swapped out.
- * This will be called only during NiFi startup as an initialization step. This
- * method is then responsible for returning a FlowFileSummary of the FlowFiles that are swapped
- * out, or <code>null</code> if no FlowFiles are swapped out for this queue.
- *
- * @return a SwapSummary that describes the FlowFiles that exist in the queue but are swapped out.
- */
- SwapSummary recoverSwappedFlowFiles();
-
- /**
- * Destroys any Swap Files that exist for this queue without updating the FlowFile Repository
- * or Provenance Repository. This is done only on startup in the case of non-persistent
- * repositories. In the case of non-persistent repositories, we may still have Swap Files because
- * we may still need to overflow the FlowFiles from heap onto disk, even though we don't want to keep
- * the FlowFiles on restart.
- */
- void purgeSwapFiles();
-
- /**
- * Resets the comparator used by this queue to maintain order.
- *
- * @param newPriorities the ordered list of prioritizers to use to determine
- * order within this queue.
- * @throws NullPointerException if arg is null
- */
- void setPriorities(List<FlowFilePrioritizer> newPriorities);
-
- /**
- * Establishes this queue's preferred maximum work load.
- *
- * @param maxQueueSize the maximum number of flow files this processor
- * recommends having in its work queue at any one time
- */
- void setBackPressureObjectThreshold(long maxQueueSize);
-
- /**
- * @return maximum number of flow files that should be queued up at any one
- * time
- */
- long getBackPressureObjectThreshold();
-
- /**
- * @param maxDataSize Establishes this queue's preferred maximum data size.
- */
- void setBackPressureDataSizeThreshold(String maxDataSize);
-
- /**
- * @return maximum data size that should be queued up at any one time
- */
- String getBackPressureDataSizeThreshold();
-
- QueueSize size();
-
- /**
- * @return true if no items queue; false otherwise
- */
- boolean isEmpty();
-
- /**
- * @return <code>true</code> if the queue is empty or contains only FlowFiles that already are being processed
- * by others, <code>false</code> if the queue contains at least one FlowFile that is available for processing,
- * regardless of whether that FlowFile(s) is in-memory or swapped out.
- */
- boolean isActiveQueueEmpty();
-
- /**
- * Returns a QueueSize that represents all FlowFiles that are 'unacknowledged'. A FlowFile
- * is considered to be unacknowledged if it has been pulled from the queue by some component
- * but the session that pulled the FlowFile has not yet been committed or rolled back.
- *
- * @return a QueueSize that represents all FlowFiles that are 'unacknowledged'.
- */
- QueueSize getUnacknowledgedQueueSize();
-
- void acknowledge(FlowFileRecord flowFile);
-
- void acknowledge(Collection<FlowFileRecord> flowFiles);
-
- /**
- * @return true if maximum queue size has been reached or exceeded; false
- * otherwise
- */
- boolean isFull();
-
- /**
- * places the given file into the queue
- *
- * @param file to place into queue
- */
- void put(FlowFileRecord file);
-
- /**
- * places the given files into the queue
- *
- * @param files to place into queue
- */
- void putAll(Collection<FlowFileRecord> files);
-
- /**
- * @param expiredRecords expired records
- * @return the next flow file on the queue; null if empty
- */
- FlowFileRecord poll(Set<FlowFileRecord> expiredRecords);
-
- /**
- * @param maxResults limits how many results can be polled
- * @param expiredRecords for expired records
- * @return the next flow files on the queue up to the max results; null if
- * empty
- */
- List<FlowFileRecord> poll(int maxResults, Set<FlowFileRecord> expiredRecords);
-
- /**
- * Drains flow files from the given source queue into the given destination
- * list.
- *
- * @param sourceQueue queue to drain from
- * @param destination Collection to drain to
- * @param maxResults max number to drain
- * @param expiredRecords for expired records
- * @return size (bytes) of flow files drained from queue
- */
- long drainQueue(Queue<FlowFileRecord> sourceQueue, List<FlowFileRecord> destination, int maxResults, Set<FlowFileRecord> expiredRecords);
-
- List<FlowFileRecord> poll(FlowFileFilter filter, Set<FlowFileRecord> expiredRecords);
-
- String getFlowFileExpiration();
-
- int getFlowFileExpiration(TimeUnit timeUnit);
-
- void setFlowFileExpiration(String flowExpirationPeriod);
-
- /**
- * Initiates a request to drop all FlowFiles in this queue. This method returns
- * a DropFlowFileStatus that can be used to determine the current state of the request.
- * Additionally, the DropFlowFileStatus provides a request identifier that can then be
- * passed to the {@link #getDropFlowFileStatus(String)} and {@link #cancelDropFlowFileStatus(String)}
- * methods in order to obtain the status later or cancel a request
- *
- * @param requestIdentifier the identifier of the Drop FlowFile Request
- * @param requestor the entity that is requesting that the FlowFiles be dropped; this will be
- * included in the Provenance Events that are generated.
- *
- * @return the status of the drop request.
- */
- DropFlowFileStatus dropFlowFiles(String requestIdentifier, String requestor);
-
- /**
- * Returns the current status of a Drop FlowFile Request that was initiated via the
- * {@link #dropFlowFiles()} method that has the given identifier
- *
- * @param requestIdentifier the identifier of the Drop FlowFile Request
- * @return the status for the request with the given identifier, or <code>null</code> if no
- * request status exists with that identifier
- */
- DropFlowFileStatus getDropFlowFileStatus(String requestIdentifier);
-
- /**
- * Cancels the request to drop FlowFiles that has the given identifier. After this method is called, the request
- * will no longer be known by this queue, so subsequent calls to {@link #getDropFlowFileStatus(String)} or
- * {@link #cancelDropFlowFileRequest(String)} will return <code>null</code>
- *
- * @param requestIdentifier the identifier of the Drop FlowFile Request
- * @return the status for the request with the given identifier after it has been canceled, or <code>null</code> if no
- * request status exists with that identifier
- */
- DropFlowFileStatus cancelDropFlowFileRequest(String requestIdentifier);
-
- /**
- * <p>
- * Initiates a request to obtain a listing of FlowFiles in this queue. This method returns a
- * ListFlowFileStatus that can be used to obtain information about the FlowFiles that exist
- * within the queue. Additionally, the ListFlowFileStatus provides a request identifier that
- * can then be passed to the {@link #getListFlowFileStatus(String)}. The listing of FlowFiles
- * will be returned ordered by the position of the FlowFile in the queue.
- * </p>
- *
- * <p>
- * Note that if maxResults is larger than the size of the "active queue" (i.e., the un-swapped queued,
- * FlowFiles that are swapped out will not be returned.)
- * </p>
- *
- * @param requestIdentifier the identifier of the List FlowFile Request
- * @param maxResults the maximum number of FlowFileSummary objects to add to the ListFlowFileStatus
- *
- * @return the status for the request
- *
- * @throws IllegalStateException if either the source or the destination of the connection to which this queue belongs
- * is currently running.
- */
- ListFlowFileStatus listFlowFiles(String requestIdentifier, int maxResults);
-
- /**
- * Returns the current status of a List FlowFile Request that was initiated via the {@link #listFlowFiles(String)}
- * method that has the given identifier
- *
- * @param requestIdentifier the identifier of the Drop FlowFile Request
- * @return the current status of the List FlowFile Request with the given identifier or <code>null</code> if no
- * request status exists with that identifier
- */
- ListFlowFileStatus getListFlowFileStatus(String requestIdentifier);
-
- /**
- * Cancels the request to list FlowFiles that has the given identifier. After this method is called, the request
- * will no longer be known by this queue, so subsequent calls to {@link #getListFlowFileStatus(String)} or
- * {@link #cancelListFlowFileRequest(String)} will return <code>null</code>
- *
- * @param requestIdentifier the identifier of the Drop FlowFile Request
- * @return the current status of the List FlowFile Request with the given identifier or <code>null</code> if no
- * request status exists with that identifier
- */
- ListFlowFileStatus cancelListFlowFileRequest(String requestIdentifier);
-
- /**
- * Returns the FlowFile with the given UUID or <code>null</code> if no FlowFile can be found in this queue
- * with the given UUID
- *
- * @param flowFileUuid the UUID of the FlowFile to retrieve
- * @return the FlowFile with the given UUID or <code>null</code> if no FlowFile can be found in this queue
- * with the given UUID
- *
- * @throws IOException if unable to read FlowFiles that are stored on some external device
- */
- FlowFileRecord getFlowFile(String flowFileUuid) throws IOException;
-
- /**
- * Ensures that a listing can be performed on the queue
- *
- * @throws IllegalStateException if the queue is not in a state in which a listing can be performed
- */
- void verifyCanList() throws IllegalStateException;
-}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-api/src/main/java/org/apache/nifi/controller/queue/FlowFileSummary.java
----------------------------------------------------------------------
diff --git a/nifi-api/src/main/java/org/apache/nifi/controller/queue/FlowFileSummary.java b/nifi-api/src/main/java/org/apache/nifi/controller/queue/FlowFileSummary.java
deleted file mode 100644
index b7207f2..0000000
--- a/nifi-api/src/main/java/org/apache/nifi/controller/queue/FlowFileSummary.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * 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.controller.queue;
-
-/**
- * A summary of a FlowFile that can be used to represent a "high level" view of FlowFile
- * without providing all of the information available.
- */
-public interface FlowFileSummary {
- /**
- * @return the UUID of the FlowFile
- */
- String getUuid();
-
- /**
- * @return the value of the 'filename' attribute
- */
- String getFilename();
-
- /**
- * @return the current position of the FlowFile in the queue based on the prioritizers selected
- */
- int getPosition();
-
- /**
- * @return the size of the FlowFile in bytes
- */
- long getSize();
-
- /**
- * @return the timestamp (in milliseconds since epoch) at which the FlowFile was added to the queue
- */
- long getLastQueuedTime();
-
- /**
- * @return the timestamp (in milliseconds since epoch) at which the FlowFile's greatest ancestor entered the flow
- */
- long getLineageStartDate();
-
- /**
- * @return <code>true</code> if the FlowFile is penalized, <code>false</code> otherwise
- */
- boolean isPenalized();
-}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-api/src/main/java/org/apache/nifi/controller/queue/ListFlowFileState.java
----------------------------------------------------------------------
diff --git a/nifi-api/src/main/java/org/apache/nifi/controller/queue/ListFlowFileState.java b/nifi-api/src/main/java/org/apache/nifi/controller/queue/ListFlowFileState.java
deleted file mode 100644
index eb417aa..0000000
--- a/nifi-api/src/main/java/org/apache/nifi/controller/queue/ListFlowFileState.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * 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.controller.queue;
-
-/**
- * Represents the state that a List FlowFile Request is in
- */
-public enum ListFlowFileState {
- WAITING_FOR_LOCK("Waiting for other queue requests to complete"),
- CALCULATING_LIST("Calculating list of FlowFiles"),
- FAILURE("Failed"),
- CANCELED("Canceled by user"),
- COMPLETE("Completed successfully");
-
- private final String description;
-
- private ListFlowFileState(final String description) {
- this.description = description;
- }
-
- @Override
- public String toString() {
- return description;
- }
-
- /**
- * @param description string form of list flow file state
- * @return the matching ListFlowFileState or <code>null</code> if the description doesn't match
- */
- public static ListFlowFileState valueOfDescription(String description) {
- ListFlowFileState desiredState = null;
-
- for (ListFlowFileState state : values()) {
- if (state.toString().equals(description)) {
- desiredState = state;
- break;
- }
- }
-
- return desiredState;
- }
-}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-api/src/main/java/org/apache/nifi/controller/queue/ListFlowFileStatus.java
----------------------------------------------------------------------
diff --git a/nifi-api/src/main/java/org/apache/nifi/controller/queue/ListFlowFileStatus.java b/nifi-api/src/main/java/org/apache/nifi/controller/queue/ListFlowFileStatus.java
deleted file mode 100644
index e3cc337..0000000
--- a/nifi-api/src/main/java/org/apache/nifi/controller/queue/ListFlowFileStatus.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * 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.controller.queue;
-
-import java.util.List;
-
-public interface ListFlowFileStatus {
-
- /**
- * @return the maximum number of FlowFile Summary objects that should be returned
- */
- int getMaxResults();
-
- /**
- * @return the identifier of the request to drop FlowFiles from the queue
- */
- String getRequestIdentifier();
-
- /**
- * @return the date/time (in milliseconds since epoch) at which the request to
- * drop the FlowFiles from a queue was submitted
- */
- long getRequestSubmissionTime();
-
- /**
- * @return the date/time (in milliseconds since epoch) at which the status of the
- * request was last updated
- */
- long getLastUpdated();
-
- /**
- * @return the current state of the operation
- */
- ListFlowFileState getState();
-
- /**
- * @return the reason that the state is set to a Failure state, or <code>null</code> if the state is not {@link ListFlowFileStatus#FAILURE}.
- */
- String getFailureReason();
-
- /**
- * @return the current size of the queue
- */
- QueueSize getQueueSize();
-
- /**
- * @return a List of FlowFileSummary objects
- */
- List<FlowFileSummary> getFlowFileSummaries();
-
- /**
- * @return the percentage (an integer between 0 and 100, inclusive) of how close the request is to being completed
- */
- int getCompletionPercentage();
-}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-api/src/main/java/org/apache/nifi/controller/queue/SortColumn.java
----------------------------------------------------------------------
diff --git a/nifi-api/src/main/java/org/apache/nifi/controller/queue/SortColumn.java b/nifi-api/src/main/java/org/apache/nifi/controller/queue/SortColumn.java
deleted file mode 100644
index 30d285c..0000000
--- a/nifi-api/src/main/java/org/apache/nifi/controller/queue/SortColumn.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * 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.controller.queue;
-
-import java.util.Comparator;
-
-/**
- * Specifies which column to sort on when performing a Listing of FlowFiles via
- * {@link FlowFileQueue#listFlowFiles(String, SortColumn, SortDirection)}
- */
-public enum SortColumn implements Comparator<FlowFileSummary> {
- /**
- * Sort based on the current position in the queue
- */
- QUEUE_POSITION (new Comparator<FlowFileSummary>() {
- @Override
- public int compare(final FlowFileSummary o1, final FlowFileSummary o2) {
- return Integer.compare(o1.getPosition(), o2.getPosition());
- }
- }),
-
- /**
- * Sort based on the UUID of the FlowFile
- */
- FLOWFILE_UUID (new Comparator<FlowFileSummary>() {
- @Override
- public int compare(final FlowFileSummary o1, final FlowFileSummary o2) {
- return o1.getUuid().compareTo(o2.getUuid());
- }
- }),
-
- /**
- * Sort based on the 'filename' attribute of the FlowFile
- */
- FILENAME (new Comparator<FlowFileSummary>() {
- @Override
- public int compare(final FlowFileSummary o1, final FlowFileSummary o2) {
- return o1.getFilename().compareTo(o2.getFilename());
- }
- }),
-
- /**
- * Sort based on the size of the FlowFile
- */
- FLOWFILE_SIZE(new Comparator<FlowFileSummary>() {
- @Override
- public int compare(final FlowFileSummary o1, final FlowFileSummary o2) {
- return Long.compare(o1.getSize(), o2.getSize());
- }
- }),
-
- /**
- * Sort based on how long the FlowFile has been sitting in the queue
- */
- QUEUED_DURATION (new Comparator<FlowFileSummary>() {
- @Override
- public int compare(final FlowFileSummary o1, final FlowFileSummary o2) {
- return -Long.compare(o1.getLastQueuedTime(), o2.getLastQueuedTime());
- }
- }),
-
- /**
- * Sort based on the age of the FlowFile. I.e., the time at which the FlowFile's
- * "greatest ancestor" entered the flow
- */
- FLOWFILE_AGE (new Comparator<FlowFileSummary>() {
- @Override
- public int compare(final FlowFileSummary o1, final FlowFileSummary o2) {
- return Long.compare(o1.getLineageStartDate(), o2.getLineageStartDate());
- }
- }),
-
- /**
- * Sort based on when the FlowFile's penalization ends
- */
- PENALIZATION (new Comparator<FlowFileSummary>() {
- @Override
- public int compare(final FlowFileSummary o1, final FlowFileSummary o2) {
- return Boolean.compare(o1.isPenalized(), o2.isPenalized());
- }
- });
-
- private final Comparator<FlowFileSummary> comparator;
-
- private SortColumn(final Comparator<FlowFileSummary> comparator) {
- this.comparator = comparator;
- }
-
- @Override
- public int compare(final FlowFileSummary o1, final FlowFileSummary o2) {
- return comparator.compare(o1, o2);
- }
-}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-api/src/main/java/org/apache/nifi/controller/queue/SortDirection.java
----------------------------------------------------------------------
diff --git a/nifi-api/src/main/java/org/apache/nifi/controller/queue/SortDirection.java b/nifi-api/src/main/java/org/apache/nifi/controller/queue/SortDirection.java
deleted file mode 100644
index 129e748..0000000
--- a/nifi-api/src/main/java/org/apache/nifi/controller/queue/SortDirection.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * 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.controller.queue;
-
-/**
- * Specifies the order in which FlowFiles should be sorted when performing a listing of
- * FlowFiles via the {@link FlowFileQueue#listFlowFiles(String, SortColumn, SortDirection)}
- * method
- */
-public enum SortDirection {
- /**
- * FlowFiles should be sorted such that the FlowFile with the lowest value for the Sort Column
- * should occur first in the listing.
- */
- ASCENDING,
-
- /**
- * FlowFiles should be sorted such that the FlowFile with the largest value for the Sort Column
- * should occur first in the listing.
- */
- DESCENDING;
-}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-api/src/main/java/org/apache/nifi/controller/repository/ContentRepository.java
----------------------------------------------------------------------
diff --git a/nifi-api/src/main/java/org/apache/nifi/controller/repository/ContentRepository.java b/nifi-api/src/main/java/org/apache/nifi/controller/repository/ContentRepository.java
deleted file mode 100644
index b1ea87c..0000000
--- a/nifi-api/src/main/java/org/apache/nifi/controller/repository/ContentRepository.java
+++ /dev/null
@@ -1,277 +0,0 @@
-/*
- * 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.controller.repository;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.nio.file.Path;
-import java.util.Collection;
-import java.util.Set;
-
-import org.apache.nifi.controller.repository.claim.ContentClaim;
-import org.apache.nifi.controller.repository.claim.ResourceClaimManager;
-
-/**
- * Defines the capabilities of a content repository. Append options are not
- * available on the methods but a merge capability is provided which between
- * that and creating new claims a merge is available.
- *
- */
-public interface ContentRepository {
-
- /**
- * Initializes the Content Repository, providing to it the
- * ContentClaimManager that is to be used for interacting with Content
- * Claims
- *
- * @param claimManager to handle claims
- * @throws java.io.IOException if unable to init
- */
- void initialize(ResourceClaimManager claimManager) throws IOException;
-
- /**
- * Shuts down the Content Repository, freeing any resources that may be
- * held. This is called when an administrator shuts down NiFi.
- */
- void shutdown();
-
- /**
- * @return the names of all Containers that exist for this Content
- * Repository
- */
- Set<String> getContainerNames();
-
- /**
- * @param containerName name of container to check capacity on
- * @return the maximum number of bytes that can be stored in the storage
- * mechanism that backs the container with the given name
- * @throws java.io.IOException if unable to check capacity
- * @throws IllegalArgumentException if no container exists with the given
- * name
- */
- long getContainerCapacity(String containerName) throws IOException;
-
- /**
- * @param containerName to check space on
- * @return the number of bytes available to be used used by the storage
- * mechanism that backs the container with the given name
- * @throws java.io.IOException if unable to check space
- * @throws IllegalArgumentException if no container exists with the given
- * name
- */
- long getContainerUsableSpace(String containerName) throws IOException;
-
- /**
- * Creates a new content claim
- *
- * @param lossTolerant indicates whether the content for the new claim is
- * loss tolerant. If true the repository might choose more volatile storage
- * options which could increase performance for a tradeoff with reliability
- * @return newly created claim
- * @throws java.io.IOException if unable to create claim
- */
- ContentClaim create(boolean lossTolerant) throws IOException;
-
- /**
- * Increments the number of claimants for the given claim
- *
- * @param claim to increment
- * @return the number of claimants after incrementing
- */
- int incrementClaimaintCount(ContentClaim claim);
-
- /**
- * Obtains the current number of claimants for the given claim
- *
- * @param claim to get count of
- * @return the number of claimants
- */
- int getClaimantCount(ContentClaim claim);
-
- /**
- * Reduces the number of claimants for the given claim. Even if the given
- * claim is null or content cannot be found or removed no exception will be
- * thrown.
- *
- * @param claim to decrement
- * @return new claimant count for the given claim
- */
- int decrementClaimantCount(ContentClaim claim);
-
- /**
- * Removes the content indicated by the given claim
- *
- * @param claim to remove
- *
- * @return a boolean indicating whether or not the destruction of the claim
- * was successful
- */
- boolean remove(ContentClaim claim);
-
- /**
- * Clones the content for the given content claim and returns content claim
- * of the new object
- *
- * @param original to clone
- * @param lossTolerant if can be place in a loss tolerant repository
- * @return new claim
- * @throws IOException if an IO error occurs. Any content written to the new
- * destination prior to the error will be destroyed
- */
- ContentClaim clone(ContentClaim original, boolean lossTolerant) throws IOException;
-
- /**
- * Creates a new content item that is the merger in iteration order of all
- * content for the given claims
- *
- * @return the size of the destination
- * @param claims the claims to merge which will be combined in order of
- * collection iteration
- * @param destination the claim to write the merged content to
- * @param header if supplied will be prepended to the output
- * @param footer if supplied will be appended to the output
- * @param demarcator if supplied will be placed in between each merged
- * object
- * @throws IOException if unable to merge
- * @throws IllegalArgumentException if the given destination is included in
- * the given claims
- */
- long merge(Collection<ContentClaim> claims, ContentClaim destination, byte[] header, byte[] footer, byte[] demarcator) throws IOException;
-
- /**
- * Imports content from the given path creating a new content object and
- * claim within the repository.
- *
- * @return the size of the claim
- * @param content to import from
- * @param claim the claim to write imported content to
- * @throws IOException if failure to read given content
- */
- long importFrom(Path content, ContentClaim claim) throws IOException;
-
- /**
- * Imports content from the given stream creating a new content object and
- * claim within the repository.
- *
- * @return the size of the claim
- * @param content to import from
- * @param claim the claim to write imported content to
- * @throws IOException if unable to read content
- */
- long importFrom(InputStream content, ContentClaim claim) throws IOException;
-
- /**
- * Exports the content of the given claim to the given destination.
- *
- * @return the size of the destination or the claim
- * @param claim to export from
- * @param destination where to export data
- * @param append if true appends to the destination; false overwrites
- * @throws IOException if an IO error occurs. The state of the content for
- * the given destination is unknown and callers should consider whether they
- * should clean up any partially created paths
- */
- long exportTo(ContentClaim claim, Path destination, boolean append) throws IOException;
-
- /**
- * Exports the content of the given claim to the given destination.
- *
- * @return the size of the destination or the claim
- * @param claim to export from
- * @param destination where to export data
- * @param append if true appends to the destination; false overwrites
- * @param offset the offset at which the claim should start being copied
- * @param length the number of bytes to copy
- * @throws IOException if an IO error occurs. The state of the content for
- * the given destination is unknown and callers should consider whether they
- * should clean up any partially created paths
- */
- long exportTo(ContentClaim claim, Path destination, boolean append, long offset, long length) throws IOException;
-
- /**
- * Exports the content of the given claim to the given destination.
- *
- * @return the size of the claim
- * @param claim to export from
- * @param destination where to export data
- * @throws IOException if an IO error occurs.
- */
- long exportTo(ContentClaim claim, OutputStream destination) throws IOException;
-
- /**
- * Exports a subset of the content of the given claim, starting at offset
- * and copying length bytes, to the given destination.
- *
- * @return the number of bytes copied
- * @param claim to export from
- * @param destination where to export data
- * @param offset the offset into the claim at which the copy should begin
- * @param length the number of bytes to copy
- * @throws IOException if an IO error occurs.
- */
- long exportTo(ContentClaim claim, OutputStream destination, long offset, long length) throws IOException;
-
- /**
- * @param claim to get size of
- * @return size in bytes of content for given claim
- * @throws IOException if size check failed
- */
- long size(ContentClaim claim) throws IOException;
-
- /**
- * Provides access to the input stream for the given claim
- *
- * @param claim to read from
- * @return InputStream over the content of the given claim
- * @throws IOException if unable to read
- */
- InputStream read(ContentClaim claim) throws IOException;
-
- /**
- * Obtains an OutputStream to the content for the given claim.
- *
- * @param claim to write to
- * @return the stream to write to
- * @throws IOException if unable to obtain stream
- */
- OutputStream write(ContentClaim claim) throws IOException;
-
- /**
- * Purges the contents of the repository, as if the repository were newly
- * created.
- */
- void purge();
-
- /**
- * Performs any cleanup actions that may need to be taken upon system
- * restart. For example, if content was partially written to the repository
- * before the restart, the repository is given a chance to handle this data
- */
- void cleanup();
-
- /**
- * @param contentClaim the Content Claim to check
- * @return Returns a boolean indicating whether or not the content specified
- * by the given claim can be read, regardless of whether the content has
- * been archived or not. If the ContentRepository does not implement
- * archiving capabilities, this method will return <code>false</code>
- *
- * @throws IOException if unable to determine accessibility
- */
- boolean isAccessible(ContentClaim contentClaim) throws IOException;
-}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-api/src/main/java/org/apache/nifi/controller/repository/FlowFileRecord.java
----------------------------------------------------------------------
diff --git a/nifi-api/src/main/java/org/apache/nifi/controller/repository/FlowFileRecord.java b/nifi-api/src/main/java/org/apache/nifi/controller/repository/FlowFileRecord.java
deleted file mode 100644
index b358cd9..0000000
--- a/nifi-api/src/main/java/org/apache/nifi/controller/repository/FlowFileRecord.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * 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.controller.repository;
-
-import org.apache.nifi.controller.repository.claim.ContentClaim;
-import org.apache.nifi.flowfile.FlowFile;
-
-/**
- * <code>FlowFileRecord</code> is a sub-interface of <code>FlowFile</code> and
- * is used to provide additional information about FlowFiles that provide
- * valuable information to the framework but should be hidden from components
- */
-public interface FlowFileRecord extends FlowFile {
-
- /**
- * @return the time (in millis since epoch) at which this FlowFile should no
- * longer be penalized
- */
- long getPenaltyExpirationMillis();
-
- /**
- * @return the {@link ContentClaim} that holds the FlowFile's content
- */
- ContentClaim getContentClaim();
-
- /**
- * @return the byte offset into the {@link ContentClaim} at which the
- * FlowFile's content occurs. This mechanism allows multiple FlowFiles to
- * have the same ContentClaim, which can be significantly more efficient for
- * some implementations of
- * {@link org.apache.nifi.controller.repository.ContentRepository ContentRepository}
- */
- long getContentClaimOffset();
-}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-api/src/main/java/org/apache/nifi/controller/repository/FlowFileRepository.java
----------------------------------------------------------------------
diff --git a/nifi-api/src/main/java/org/apache/nifi/controller/repository/FlowFileRepository.java b/nifi-api/src/main/java/org/apache/nifi/controller/repository/FlowFileRepository.java
deleted file mode 100644
index 906cbe2..0000000
--- a/nifi-api/src/main/java/org/apache/nifi/controller/repository/FlowFileRepository.java
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- * 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.controller.repository;
-
-import java.io.Closeable;
-import java.io.IOException;
-import java.util.Collection;
-import java.util.List;
-
-import org.apache.nifi.controller.queue.FlowFileQueue;
-import org.apache.nifi.controller.repository.claim.ResourceClaimManager;
-
-/**
- * Implementations must be thread safe
- *
- */
-public interface FlowFileRepository extends Closeable {
-
- /**
- * Initializes the Content Repository, providing to it the
- * ContentClaimManager that is to be used for interacting with Content
- * Claims
- *
- * @param claimManager for handling claims
- * @throws java.io.IOException if unable to initialize repository
- */
- void initialize(ResourceClaimManager claimManager) throws IOException;
-
- /**
- * @return the maximum number of bytes that can be stored in the underlying
- * storage mechanism
- *
- * @throws IOException if computing capacity fails
- */
- long getStorageCapacity() throws IOException;
-
- /**
- * @return the number of bytes currently available for use by the underlying
- * storage mechanism
- *
- * @throws IOException if computing usable space fails
- */
- long getUsableStorageSpace() throws IOException;
-
- /**
- * Updates the repository with the given RepositoryRecords.
- *
- * @param records the records to update the repository with
- * @throws java.io.IOException if update fails
- */
- void updateRepository(Collection<RepositoryRecord> records) throws IOException;
-
- /**
- * Loads all flow files found within the repository, establishes the content
- * claims and their reference count
- *
- * @param queueProvider the provider of FlowFile Queues into which the
- * FlowFiles should be enqueued
- * @param minimumSequenceNumber specifies the minimum value that should be
- * returned by a call to {@link #getNextFlowFileSequence()}
- *
- * @return index of highest flow file identifier
- * @throws IOException if load fails
- */
- long loadFlowFiles(QueueProvider queueProvider, long minimumSequenceNumber) throws IOException;
-
- /**
- * @return <code>true</code> if the Repository is volatile (i.e., its data
- * is lost upon application restart), <code>false</code> otherwise
- */
- boolean isVolatile();
-
- /**
- * @return the next ID in sequence for creating <code>FlowFile</code>s.
- */
- long getNextFlowFileSequence();
-
- /**
- * @return the max ID of all <code>FlowFile</code>s that currently exist in
- * the repository.
- * @throws IOException if computing max identifier fails
- */
- long getMaxFlowFileIdentifier() throws IOException;
-
- /**
- * Updates the Repository to indicate that the given FlowFileRecords were
- * Swapped Out of memory
- *
- * @param swappedOut the FlowFiles that were swapped out of memory
- * @param flowFileQueue the queue that the FlowFiles belong to
- * @param swapLocation the location to which the FlowFiles were swapped
- *
- * @throws IOException if swap fails
- */
- void swapFlowFilesOut(List<FlowFileRecord> swappedOut, FlowFileQueue flowFileQueue, String swapLocation) throws IOException;
-
- /**
- * Updates the Repository to indicate that the given FlowFileRecpords were
- * Swapped In to memory
- *
- * @param swapLocation the location (e.g., a filename) from which FlowFiles
- * were recovered
- * @param flowFileRecords the records that were swapped in
- * @param flowFileQueue the queue that the FlowFiles belong to
- *
- * @throws IOException if swap fails
- */
- void swapFlowFilesIn(String swapLocation, List<FlowFileRecord> flowFileRecords, FlowFileQueue flowFileQueue) throws IOException;
-}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-api/src/main/java/org/apache/nifi/controller/repository/FlowFileSwapManager.java
----------------------------------------------------------------------
diff --git a/nifi-api/src/main/java/org/apache/nifi/controller/repository/FlowFileSwapManager.java b/nifi-api/src/main/java/org/apache/nifi/controller/repository/FlowFileSwapManager.java
deleted file mode 100644
index 7092a6f..0000000
--- a/nifi-api/src/main/java/org/apache/nifi/controller/repository/FlowFileSwapManager.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * 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.controller.repository;
-
-import java.io.IOException;
-import java.util.List;
-
-import org.apache.nifi.controller.queue.FlowFileQueue;
-
-/**
- * Defines a mechanism by which FlowFiles can be move into external storage or
- * memory so that they can be removed from the Java heap and vice-versa
- */
-// TODO: This needs to be refactored into two different mechanisms, one that is responsible for doing
-// framework-y types of things, such as updating the repositories, and another that is responsible
-// for serializing and deserializing FlowFiles to external storage.
-public interface FlowFileSwapManager {
-
- /**
- * Initializes the Swap Manager, providing a {@link SwapManagerInitializationContext} so that the
- * Swap Manager has access to all of the components necessary to perform its functions
- *
- * @param initializationContext the context the provides the swap manager with access to the
- * resources that it needs to perform its functions
- */
- void initialize(SwapManagerInitializationContext initializationContext);
-
- /**
- * Swaps out the given FlowFiles that belong to the queue with the given identifier.
- *
- * @param flowFiles the FlowFiles to swap out to external storage
- * @param flowFileQueue the queue that the FlowFiles belong to
- * @return the location of the externally stored swap file
- *
- * @throws IOException if unable to swap the FlowFiles out
- */
- String swapOut(List<FlowFileRecord> flowFiles, FlowFileQueue flowFileQueue) throws IOException;
-
- /**
- * Recovers the FlowFiles from the swap file that lives at the given location. This action
- * provides a view of the FlowFiles but does not actively swap them in, meaning that the swap file
- * at the given location remains in that location and the FlowFile Repository is not updated.
- *
- * @param swapLocation the location of the swap file
- * @param flowFileQueue the queue that the FlowFiles belong to
- * @return a SwapContents that includes the FlowFiles that live at the given swap location
- *
- * @throws IOException if unable to recover the FlowFiles from the given location
- */
- SwapContents peek(String swapLocation, FlowFileQueue flowFileQueue) throws IncompleteSwapFileException, IOException;
-
- /**
- * Recovers the FlowFiles from the swap file that lives at the given location and belongs
- * to the FlowFile Queue with the given identifier. The FlowFile Repository is then updated
- * and the swap file is permanently removed from the external storage
- *
- * @param swapLocation the location of the swap file
- * @param flowFileQueue the queue to which the FlowFiles belong
- *
- * @return a SwapContents that includes FlowFiles that are stored in the given location
- *
- * @throws IOException if unable to recover the FlowFiles from the given location or update the
- * FlowFileRepository
- */
- SwapContents swapIn(String swapLocation, FlowFileQueue flowFileQueue) throws IncompleteSwapFileException, IOException;
-
- /**
- * Determines swap files that exist for the given FlowFileQueue
- *
- * @param flowFileQueue the queue for which the FlowFiles should be recovered
- *
- * @return all swap locations that have been identified for the given queue, in the order that they should
- * be swapped back in
- */
- List<String> recoverSwapLocations(FlowFileQueue flowFileQueue) throws IOException;
-
- /**
- * Parses the contents of the swap file at the given location and provides a SwapSummary that provides
- * pertinent information about the information stored within the swap file
- *
- * @param swapLocation the location of the swap file
- * @return a SwapSummary that provides information about what is contained within the swap file
- * @throws IOException if unable to read or parse the swap file
- */
- SwapSummary getSwapSummary(String swapLocation) throws IOException;
-
- /**
- * Purge all known Swap Files without updating FlowFileRepository or Provenance Repository
- */
- void purge();
-}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-api/src/main/java/org/apache/nifi/controller/repository/IncompleteSwapFileException.java
----------------------------------------------------------------------
diff --git a/nifi-api/src/main/java/org/apache/nifi/controller/repository/IncompleteSwapFileException.java b/nifi-api/src/main/java/org/apache/nifi/controller/repository/IncompleteSwapFileException.java
deleted file mode 100644
index 4408f02..0000000
--- a/nifi-api/src/main/java/org/apache/nifi/controller/repository/IncompleteSwapFileException.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * 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.controller.repository;
-
-import java.io.EOFException;
-
-/**
- * Signals that a Swap File could not be complete read in/parsed because the data was
- * not all present
- */
-public class IncompleteSwapFileException extends EOFException {
- private static final long serialVersionUID = -6818558584430076898L;
-
- private final String swapLocation;
- private final SwapContents partialContents;
-
- public IncompleteSwapFileException(final String swapLocation, final SwapContents partialContents) {
- super();
- this.swapLocation = swapLocation;
- this.partialContents = partialContents;
- }
-
- public String getSwapLocation() {
- return swapLocation;
- }
-
- public SwapContents getPartialContents() {
- return partialContents;
- }
-}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-api/src/main/java/org/apache/nifi/controller/repository/QueueProvider.java
----------------------------------------------------------------------
diff --git a/nifi-api/src/main/java/org/apache/nifi/controller/repository/QueueProvider.java b/nifi-api/src/main/java/org/apache/nifi/controller/repository/QueueProvider.java
deleted file mode 100644
index 95d9f2e..0000000
--- a/nifi-api/src/main/java/org/apache/nifi/controller/repository/QueueProvider.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * 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.controller.repository;
-
-import java.util.Collection;
-
-import org.apache.nifi.controller.queue.FlowFileQueue;
-
-/**
- * Provides a collection of <code>FlowFileQueue</code>s that represents all
- * queues in the current flow
- */
-public interface QueueProvider {
-
- /**
- * @return all <code>FlowFileQueue</code>s that currently exist in the flow
- */
- Collection<FlowFileQueue> getAllQueues();
-}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-api/src/main/java/org/apache/nifi/controller/repository/RepositoryRecord.java
----------------------------------------------------------------------
diff --git a/nifi-api/src/main/java/org/apache/nifi/controller/repository/RepositoryRecord.java b/nifi-api/src/main/java/org/apache/nifi/controller/repository/RepositoryRecord.java
deleted file mode 100644
index 09202c0..0000000
--- a/nifi-api/src/main/java/org/apache/nifi/controller/repository/RepositoryRecord.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * 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.controller.repository;
-
-import org.apache.nifi.controller.queue.FlowFileQueue;
-import org.apache.nifi.controller.repository.claim.ContentClaim;
-
-/**
- * Represents an abstraction of a FlowFile that can be used to track changing
- * state of a FlowFile so that transactionality with repositories can exist
- */
-public interface RepositoryRecord {
-
- /**
- * @return FlowFileQueue to which the FlowFile is to be transferred
- */
- FlowFileQueue getDestination();
-
- /**
- * @return FlowFileQueue from which the record was pulled
- */
- FlowFileQueue getOriginalQueue();
-
- /**
- * @return type of update that this record encapsulates
- */
- RepositoryRecordType getType();
-
- /**
- * @return current ContentClaim for the FlowFile
- */
- ContentClaim getCurrentClaim();
-
- /**
- * @return original ContentClaim for the FlowFile before any changes were made
- */
- ContentClaim getOriginalClaim();
-
- /**
- * @return byte offset into the Content Claim where this FlowFile's content
- * begins
- */
- long getCurrentClaimOffset();
-
- /**
- * @return FlowFile being encapsulated by this record
- */
- FlowFileRecord getCurrent();
-
- /**
- * @return Whether or not the FlowFile's attributes have changed since the FlowFile
- * was pulled from its queue (or created)
- */
- boolean isAttributesChanged();
-
- /**
- * @return <code>true</code> if the FlowFile is not viable and should be
- * aborted (e.g., the content of the FlowFile cannot be found)
- */
- boolean isMarkedForAbort();
-
- /**
- * @return If the FlowFile is swapped out of the Java heap space, provides the
- * location of the swap file, or <code>null</code> if the FlowFile is not
- * swapped out
- */
- String getSwapLocation();
-}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-api/src/main/java/org/apache/nifi/controller/repository/RepositoryRecordType.java
----------------------------------------------------------------------
diff --git a/nifi-api/src/main/java/org/apache/nifi/controller/repository/RepositoryRecordType.java b/nifi-api/src/main/java/org/apache/nifi/controller/repository/RepositoryRecordType.java
deleted file mode 100644
index ff8dc50..0000000
--- a/nifi-api/src/main/java/org/apache/nifi/controller/repository/RepositoryRecordType.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * 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.controller.repository;
-
-/**
- *
- */
-public enum RepositoryRecordType {
-
- UPDATE, CREATE, DELETE, CONTENTMISSING, SWAP_IN, SWAP_OUT;
-}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-api/src/main/java/org/apache/nifi/controller/repository/SwapContents.java
----------------------------------------------------------------------
diff --git a/nifi-api/src/main/java/org/apache/nifi/controller/repository/SwapContents.java b/nifi-api/src/main/java/org/apache/nifi/controller/repository/SwapContents.java
deleted file mode 100644
index 2fb7ba4..0000000
--- a/nifi-api/src/main/java/org/apache/nifi/controller/repository/SwapContents.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * 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.controller.repository;
-
-import java.util.List;
-
-/**
- * When FlowFiles are constructed from a Swap File, there is information in addition to
- * the FlowFiles themselves that get stored and recovered. SwapContents provides a
- * mechanism to encapsulate all of the information contained within a Swap File in a
- * single object
- */
-public interface SwapContents {
-
- /**
- * @return a summary of information included in a Swap File
- */
- SwapSummary getSummary();
-
- /**
- * @return the FlowFiles that are contained within a Swap File
- */
- List<FlowFileRecord> getFlowFiles();
-
-}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-api/src/main/java/org/apache/nifi/controller/repository/SwapManagerInitializationContext.java
----------------------------------------------------------------------
diff --git a/nifi-api/src/main/java/org/apache/nifi/controller/repository/SwapManagerInitializationContext.java b/nifi-api/src/main/java/org/apache/nifi/controller/repository/SwapManagerInitializationContext.java
deleted file mode 100644
index 0e30784..0000000
--- a/nifi-api/src/main/java/org/apache/nifi/controller/repository/SwapManagerInitializationContext.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * 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.controller.repository;
-
-import org.apache.nifi.controller.repository.claim.ResourceClaimManager;
-import org.apache.nifi.events.EventReporter;
-
-public interface SwapManagerInitializationContext {
-
- /**
- * @return the {@link FlowFileRepository} that should be updated when FlowFiles are swapped in and out
- */
- FlowFileRepository getFlowFileRepository();
-
- /**
- * @return the {@link ResourceClaimManager} that is necessary to provide to the FlowFileRepository when
- * performing swapping actions
- */
- ResourceClaimManager getResourceClaimManager();
-
- /**
- * @return an {@link EventReporter} that can be used to report events to users
- */
- EventReporter getEventReporter();
-}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-api/src/main/java/org/apache/nifi/controller/repository/SwapSummary.java
----------------------------------------------------------------------
diff --git a/nifi-api/src/main/java/org/apache/nifi/controller/repository/SwapSummary.java b/nifi-api/src/main/java/org/apache/nifi/controller/repository/SwapSummary.java
deleted file mode 100644
index ad01ccd..0000000
--- a/nifi-api/src/main/java/org/apache/nifi/controller/repository/SwapSummary.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * 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.controller.repository;
-
-import java.util.List;
-
-import org.apache.nifi.controller.queue.QueueSize;
-import org.apache.nifi.controller.repository.claim.ResourceClaim;
-
-/**
- * <p>
- * Provides a summary of the information that is stored in a FlowFile swap file.
- * </p>
- */
-public interface SwapSummary {
- /**
- * @return a QueueSize that represents the number of FlowFiles are in the swap file and their
- * aggregate content size
- */
- QueueSize getQueueSize();
-
- /**
- * @return the largest ID of any of the FlowFiles that are contained in the swap file
- */
- Long getMaxFlowFileId();
-
- /**
- * Returns a List of all ResoruceClaims that are referenced by the FlowFiles in the swap file.
- * This List may well contain the same ResourceClaim many times. This indicates that many FlowFiles
- * reference the same ResourceClaim.
- *
- * @return a List of all ResourceClaims that are referenced by the FlowFiles in the swap file
- */
- List<ResourceClaim> getResourceClaims();
-}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-api/src/main/java/org/apache/nifi/controller/repository/claim/ContentClaim.java
----------------------------------------------------------------------
diff --git a/nifi-api/src/main/java/org/apache/nifi/controller/repository/claim/ContentClaim.java b/nifi-api/src/main/java/org/apache/nifi/controller/repository/claim/ContentClaim.java
deleted file mode 100644
index 5c1d76b..0000000
--- a/nifi-api/src/main/java/org/apache/nifi/controller/repository/claim/ContentClaim.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * 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.controller.repository.claim;
-
-/**
- * <p>
- * A reference to a section of a {@link ResourceClaim}, which may or may not encompass
- * the entire ResourceClaim. Multiple FlowFiles may reference the same content by both
- * having the same content claim.
- * </p>
- *
- * <p>
- * Must be thread safe
- * </p>
- */
-public interface ContentClaim extends Comparable<ContentClaim> {
-
- /**
- * @return the ResourceClaim that this ContentClaim references
- */
- ResourceClaim getResourceClaim();
-
- /**
- * @return the offset into the ResourceClaim where the content for this
- * claim begins
- */
- long getOffset();
-
- /**
- * @return the length of this ContentClaim
- */
- long getLength();
-}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-api/src/main/java/org/apache/nifi/controller/repository/claim/ResourceClaim.java
----------------------------------------------------------------------
diff --git a/nifi-api/src/main/java/org/apache/nifi/controller/repository/claim/ResourceClaim.java b/nifi-api/src/main/java/org/apache/nifi/controller/repository/claim/ResourceClaim.java
deleted file mode 100644
index 77e7f84..0000000
--- a/nifi-api/src/main/java/org/apache/nifi/controller/repository/claim/ResourceClaim.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * 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.controller.repository.claim;
-
-import org.apache.nifi.controller.repository.ContentRepository;
-
-/**
- * <p>
- * Represents a resource that can be provided by a {@link ContentRepository}
- * </p>
- *
- * <p>
- * MUST BE THREAD-SAFE!
- * </p>
- */
-public interface ResourceClaim extends Comparable<ResourceClaim> {
-
- /**
- * @return the unique identifier for this claim
- */
- String getId();
-
- /**
- * @return the container identifier in which this claim is held
- */
- String getContainer();
-
- /**
- * @return the section within a given container the claim is held
- */
- String getSection();
-
- /**
- * @return Indicates whether or not the Claim is loss-tolerant. If so, we will
- * attempt to keep the content but will not sacrifice a great deal of
- * performance to do so
- */
- boolean isLossTolerant();
-
-}
http://git-wip-us.apache.org/repos/asf/nifi/blob/d1129706/nifi-api/src/main/java/org/apache/nifi/controller/repository/claim/ResourceClaimManager.java
----------------------------------------------------------------------
diff --git a/nifi-api/src/main/java/org/apache/nifi/controller/repository/claim/ResourceClaimManager.java b/nifi-api/src/main/java/org/apache/nifi/controller/repository/claim/ResourceClaimManager.java
deleted file mode 100644
index 01f4c65..0000000
--- a/nifi-api/src/main/java/org/apache/nifi/controller/repository/claim/ResourceClaimManager.java
+++ /dev/null
@@ -1,135 +0,0 @@
-/*
- * 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.controller.repository.claim;
-
-import java.util.Collection;
-import java.util.concurrent.TimeUnit;
-
-/**
- * Responsible for managing all ResourceClaims that are used in the application
- */
-public interface ResourceClaimManager {
-
- /**
- * Creates a new Resource Claim with the given id, container, section, and
- * loss tolerance.
- *
- * @param id of claim
- * @param container of claim
- * @param section of claim
- * @param lossTolerant of claim
- * @return new claim
- */
- ResourceClaim newResourceClaim(String container, String section, String id, boolean lossTolerant);
-
- /**
- * @param claim to obtain reference count for
- * @return the number of FlowFiles that hold a claim to a particular piece
- * of FlowFile content
- */
- int getClaimantCount(ResourceClaim claim);
-
- /**
- * Decreases by 1 the count of how many FlowFiles hold a claim to a
- * particular piece of FlowFile content and returns the new count
- *
- * @param claim to decrement claimants on
- * @return new claimaint count
- */
- int decrementClaimantCount(ResourceClaim claim);
-
- /**
- * Increases by 1 the count of how many FlowFiles hold a claim to a
- * particular piece of FlowFile content and returns the new count
- *
- * @param claim to increment claims on
- * @return new claimant count
- */
- int incrementClaimantCount(ResourceClaim claim);
-
- /**
- * Increases by 1 the count of how many FlowFiles hold a claim to a
- * particular piece of FlowFile content and returns the new count.
- *
- * If it is known that the Content Claim whose count is being incremented is
- * a newly created ResourceClaim, this method should be called with a value
- * of {@code true} as the second argument, as it may allow the manager to
- * optimize its tasks, knowing that the Content Claim cannot be referenced
- * by any other component
- *
- * @param claim to increment
- * @param newClaim provides a hint that no other process can have access to this
- * claim right now
- * @return new claim count
- */
- int incrementClaimantCount(ResourceClaim claim, boolean newClaim);
-
- /**
- * Indicates that the given ResourceClaim can now be destroyed by the
- * appropriate Content Repository. This should be done only after it is
- * guaranteed that the FlowFile Repository has been synchronized with its
- * underlying storage component. This way, we avoid the following sequence
- * of events:
- * <ul>
- * <li>FlowFile Repository is updated to indicate that FlowFile F no longer depends on ResourceClaim C</li>
- * <li>ResourceClaim C is no longer needed and is destroyed</li>
- * <li>The Operating System crashes or there is a power failure</li>
- * <li>Upon restart, the FlowFile Repository was not synchronized with its underlying storage mechanism and as such indicates that FlowFile F needs ResourceClaim C.</li>
- * <li>Since ResourceClaim C has already been destroyed, it is inaccessible, and FlowFile F's Content is not found, so the FlowFile is removed, resulting in data loss.</li>
- * </ul>
- *
- * <p>
- * Using this method of marking the ResourceClaim as destructable only when the FlowFile repository has been synced with the underlying storage mechanism, we can ensure that on restart, we will
- * not point to this unneeded claim. As such, it is now safe to destroy the contents.
- * </p>
- *
- * @param claim to mark as now destructable
- */
- void markDestructable(ResourceClaim claim);
-
- /**
- * Drains up to {@code maxElements} Content Claims from the internal queue
- * of destructable content claims to the given {@code destination} so that
- * they can be destroyed.
- *
- * @param destination to drain to
- * @param maxElements max items to drain
- */
- void drainDestructableClaims(Collection<ResourceClaim> destination, int maxElements);
-
- /**
- * Drains up to {@code maxElements} Content Claims from the internal queue
- * of destructable content claims to the given {@code destination} so that
- * they can be destroyed. If no ResourceClaim is ready to be destroyed at
- * this time, will wait up to the specified amount of time before returning.
- * If, after the specified amount of time, there is still no ResourceClaim
- * ready to be destroyed, the method will return without having added
- * anything to the given {@code destination}.
- *
- * @param destination to drain to
- * @param maxElements max items to drain
- * @param timeout maximum time to wait
- * @param unit unit of time to wait
- */
- void drainDestructableClaims(Collection<ResourceClaim> destination, int maxElements, long timeout, TimeUnit unit);
-
- /**
- * Clears the manager's memory of any and all ResourceClaims that it knows
- * about
- */
- void purge();
-}