You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nifi.apache.org by bb...@apache.org on 2019/03/12 14:37:22 UTC
[nifi-registry] branch master updated: NIFIREG-232 Introducing flow
persistence provider migrator and toolkit (#159)
This is an automated email from the ASF dual-hosted git repository.
bbende pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nifi-registry.git
The following commit(s) were added to refs/heads/master by this push:
new cf0e35b NIFIREG-232 Introducing flow persistence provider migrator and toolkit (#159)
cf0e35b is described below
commit cf0e35b80f3b29e80e9f9d66b962cd6257d3ac68
Author: Bryan Rosander <br...@gmail.com>
AuthorDate: Tue Mar 12 10:36:47 2019 -0400
NIFIREG-232 Introducing flow persistence provider migrator and toolkit (#159)
* NIFIREG-232 Introducing flow persistence provider migrator and toolkit
* PR feedback
---
.../provider/flow/StandardFlowSnapshotContext.java | 25 +++
.../org/apache/nifi/registry/NiFiRegistry.java | 12 +-
nifi-registry-toolkit/README.md | 35 +++
.../nifi-registry-toolkit-assembly/LICENSE | 224 +++++++++++++++++++
.../nifi-registry-toolkit-assembly/NOTICE | 244 +++++++++++++++++++++
.../nifi-registry-toolkit-assembly/pom.xml | 68 ++++++
.../src/main/assembly/dependencies.xml | 65 ++++++
.../src/main/resources/bin/persistence-toolkit.bat | 41 ++++
.../src/main/resources/bin/persistence-toolkit.sh | 120 ++++++++++
.../src/main/resources/classpath/log4j.properties | 22 ++
.../nifi-registry-toolkit-persistence/pom.xml | 55 +++++
.../FlowPersistenceProviderMigrator.java | 106 +++++++++
.../FlowPersistenceProviderMigratorTest.java | 155 +++++++++++++
nifi-registry-toolkit/pom.xml | 31 +++
pom.xml | 1 +
15 files changed, 1200 insertions(+), 4 deletions(-)
diff --git a/nifi-registry-core/nifi-registry-framework/src/main/java/org/apache/nifi/registry/provider/flow/StandardFlowSnapshotContext.java b/nifi-registry-core/nifi-registry-framework/src/main/java/org/apache/nifi/registry/provider/flow/StandardFlowSnapshotContext.java
index fcd35ee..dc06769 100644
--- a/nifi-registry-core/nifi-registry-framework/src/main/java/org/apache/nifi/registry/provider/flow/StandardFlowSnapshotContext.java
+++ b/nifi-registry-core/nifi-registry-framework/src/main/java/org/apache/nifi/registry/provider/flow/StandardFlowSnapshotContext.java
@@ -22,6 +22,8 @@ import org.apache.nifi.registry.flow.FlowSnapshotContext;
import org.apache.nifi.registry.flow.VersionedFlow;
import org.apache.nifi.registry.flow.VersionedFlowSnapshotMetadata;
+import java.util.Objects;
+
/**
* Standard implementation of FlowSnapshotContext.
*/
@@ -101,6 +103,29 @@ public class StandardFlowSnapshotContext implements FlowSnapshotContext {
return author;
}
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+ StandardFlowSnapshotContext that = (StandardFlowSnapshotContext) o;
+ return version == that.version && snapshotTimestamp == that.snapshotTimestamp
+ && Objects.equals(bucketId, that.bucketId)
+ && Objects.equals(bucketName, that.bucketName)
+ && Objects.equals(flowId, that.flowId)
+ && Objects.equals(flowName, that.flowName)
+ && Objects.equals(comments, that.comments)
+ && Objects.equals(author, that.author);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(bucketId, bucketName, flowId, flowName, version, comments, author, snapshotTimestamp);
+ }
+
/**
* Builder for creating instances of StandardFlowSnapshotContext.
*/
diff --git a/nifi-registry-core/nifi-registry-runtime/src/main/java/org/apache/nifi/registry/NiFiRegistry.java b/nifi-registry-core/nifi-registry-runtime/src/main/java/org/apache/nifi/registry/NiFiRegistry.java
index 65fdcf4..982b9ea 100644
--- a/nifi-registry-core/nifi-registry-runtime/src/main/java/org/apache/nifi/registry/NiFiRegistry.java
+++ b/nifi-registry-core/nifi-registry-runtime/src/main/java/org/apache/nifi/registry/NiFiRegistry.java
@@ -150,9 +150,7 @@ public class NiFiRegistry {
final CryptoKeyProvider masterKeyProvider;
final NiFiRegistryProperties properties;
try {
- final String bootstrapConfigFilePath = System.getProperty(NIFI_REGISTRY_BOOTSTRAP_FILE_PATH_PROPERTY, RELATIVE_BOOTSTRAP_FILE_LOCATION);
- masterKeyProvider = new BootstrapFileCryptoKeyProvider(bootstrapConfigFilePath);
- LOGGER.info("Read property protection key from {}", bootstrapConfigFilePath);
+ masterKeyProvider = getMasterKeyProvider();
properties = initializeProperties(masterKeyProvider);
} catch (final IllegalArgumentException iae) {
throw new RuntimeException("Unable to load properties: " + iae, iae);
@@ -165,8 +163,14 @@ public class NiFiRegistry {
}
}
- private static NiFiRegistryProperties initializeProperties(CryptoKeyProvider masterKeyProvider) {
+ public static CryptoKeyProvider getMasterKeyProvider() {
+ final String bootstrapConfigFilePath = System.getProperty(NIFI_REGISTRY_BOOTSTRAP_FILE_PATH_PROPERTY, RELATIVE_BOOTSTRAP_FILE_LOCATION);
+ CryptoKeyProvider masterKeyProvider = new BootstrapFileCryptoKeyProvider(bootstrapConfigFilePath);
+ LOGGER.info("Read property protection key from {}", bootstrapConfigFilePath);
+ return masterKeyProvider;
+ }
+ public static NiFiRegistryProperties initializeProperties(CryptoKeyProvider masterKeyProvider) {
String key = CryptoKeyProvider.EMPTY_KEY;
try {
key = masterKeyProvider.getKey();
diff --git a/nifi-registry-toolkit/README.md b/nifi-registry-toolkit/README.md
new file mode 100644
index 0000000..3d03a3d
--- /dev/null
+++ b/nifi-registry-toolkit/README.md
@@ -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.
+-->
+# Apache NiFi Registry Toolkit
+
+This submodule is a landing zone for command line utilities that can be used for maintenance/automation of registry actions.
+
+It currently only contains a migration tool for changing flow persistence providers.
+
+## Build
+
+```
+mvn clean install
+```
+
+## Flow Persistence Provider migrator usage
+
+1. Shutdown registry
+1. (Optional but recommended) Backup your registry by zipping/tarring the directory up
+1. Copy providers.xml -> providers-to.xml
+1. Edit providers-to.xml to reflect what you'd like to migrate to (e.g. git)
+1. In registry home as working directory, run persistence-toolkit.sh -t providers-to.xml
+1. Rename providers-to.xml -> providers.xml
+1. Start registry back up
\ No newline at end of file
diff --git a/nifi-registry-toolkit/nifi-registry-toolkit-assembly/LICENSE b/nifi-registry-toolkit/nifi-registry-toolkit-assembly/LICENSE
new file mode 100644
index 0000000..01efe99
--- /dev/null
+++ b/nifi-registry-toolkit/nifi-registry-toolkit-assembly/LICENSE
@@ -0,0 +1,224 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed 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.
+
+This product bundles karma-test-shim.js and systemjs-angular-loader.js from 'Angular Quickstart' which is available under an MIT license.
+
+ Copyright (c) 2010-2016 Google, Inc. http://angularjs.org
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to deal
+ in the Software without restriction, including without limitation the rights
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ THE SOFTWARE.
\ No newline at end of file
diff --git a/nifi-registry-toolkit/nifi-registry-toolkit-assembly/NOTICE b/nifi-registry-toolkit/nifi-registry-toolkit-assembly/NOTICE
new file mode 100644
index 0000000..5fe58e6
--- /dev/null
+++ b/nifi-registry-toolkit/nifi-registry-toolkit-assembly/NOTICE
@@ -0,0 +1,244 @@
+Apache NiFi Registry Toolkit
+Copyright 2014-2018 The Apache Software Foundation
+
+This product includes software developed at
+The Apache Software Foundation (http://www.apache.org/).
+
+This includes derived works from the Apache NiFi (ASLv2 licensed) project (https://git-wip-us.apache.org/repos/asf?p=nifi.git):
+ Copyright 2015-2018 The Apache Software Foundation
+ This includes sources for bootstrapping, runtime, component API, security/authorization API
+===========================================
+Apache Software License v2
+===========================================
+
+The following binary components are provided under the Apache Software License v2
+
+ (ASLv2) Jetty
+ The following NOTICE information applies:
+ Jetty Web Container
+ Copyright 1995-2017 Mort Bay Consulting Pty Ltd.
+
+ (ASLv2) Apache Commons CLI
+ The following NOTICE information applies:
+ Apache Commons CLI
+ Copyright 2001-2015 The Apache Software Foundation
+
+ (ASLv2) Apache Commons Codec
+ The following NOTICE information applies:
+ Apache Commons Codec
+ Copyright 2002-2014 The Apache Software Foundation
+
+ src/test/org/apache/commons/codec/language/DoubleMetaphoneTest.java
+ contains test data from http://aspell.net/test/orig/batch0.tab.
+ Copyright (C) 2002 Kevin Atkinson (kevina@gnu.org)
+
+ ===============================================================================
+
+ The content of package org.apache.commons.codec.language.bm has been translated
+ from the original php source code available at http://stevemorse.org/phoneticinfo.htm
+ with permission from the original authors.
+ Original source copyright:
+ Copyright (c) 2008 Alexander Beider & Stephen P. Morse.
+
+ (ASLv2) Apache Commons Lang
+ The following NOTICE information applies:
+ Apache Commons Lang
+ Copyright 2001-2017 The Apache Software Foundation
+
+ This product includes software from the Spring Framework,
+ under the Apache License 2.0 (see: StringUtils.containsWhitespace())
+
+ (ASLv2) Jackson JSON processor
+ The following NOTICE information applies:
+ # Jackson JSON processor
+
+ Jackson is a high-performance, Free/Open Source JSON processing library.
+ It was originally written by Tatu Saloranta (tatu.saloranta@iki.fi), and has
+ been in development since 2007.
+ It is currently developed by a community of developers, as well as supported
+ commercially by FasterXML.com.
+
+ ## Licensing
+
+ Jackson core and extension components may licensed under different licenses.
+ To find the details that apply to this artifact see the accompanying LICENSE file.
+ For more information, including possible other licensing options, contact
+ FasterXML.com (http://fasterxml.com).
+
+ ## Credits
+
+ A list of contributors may be found from CREDITS file, which is included
+ in some artifacts (usually source distributions); but is always available
+ from the source code management (SCM) system project uses.
+
+ (ASLv2) JSON-SMART
+ The following NOTICE information applies:
+ Copyright 2011 JSON-SMART authors
+
+ (ASLv2) JsonPath
+ The following NOTICE information applies:
+ Copyright 2011 JsonPath authors
+
+ (ASLv2) Classmate
+ The following NOTICE information applies
+ Java ClassMate library was originally written by Tatu Saloranta (tatu.saloranta@iki.fi)
+
+ Other developers who have contributed code are:
+
+ * Brian Langel
+
+ (ASLv2) Apache Commons IO
+ The following NOTICE information applies:
+ Apache Commons IO
+ Copyright 2002-2016 The Apache Software Foundation
+
+ (ASLv2) Apache log4j
+ The following NOTICE information applies:
+ Apache log4j
+ Copyright 2010 The Apache Software Foundation
+
+ (ASLv2) Spring Framework
+ The following NOTICE information applies:
+ Spring Framework 5.0.2.RELEASE
+ Copyright (c) 2002-2017 Pivotal, Inc.
+
+ (ASLv2) Spring Security
+ The following NOTICE information applies:
+ Spring Framework 5.0.5.RELEASE
+ Copyright (c) 2002-2017 Pivotal, Inc.
+
+ This product includes software developed by Spring Security
+ Project (http://www.springframework.org/security).
+
+ (ASLv2) Spring LDAP
+ The following NOTICE information applies:
+ Spring LDAP 2.3.2.RELEASE
+ Copyright (c) 2002-2017 Pivotal, Inc.
+
+ This product includes software developed by the Spring LDAP
+ Project (http://www.springframework.org/ldap).
+
+ (ASLv2) Apache Tomcat Embed EL
+ The following NOTICE information applies:
+ Apache Tomcat
+ Copyright 1999-2017 The Apache Software Foundation
+
+ This product includes software developed at
+ The Apache Software Foundation (http://www.apache.org/).
+
+ This software contains code derived from netty-native
+ developed by the Netty project
+ (http://netty.io, https://github.com/netty/netty-tcnative/)
+ and from finagle-native developed at Twitter
+ (https://github.com/twitter/finagle).
+
+ The Windows Installer is built with the Nullsoft
+ Scriptable Install System (NSIS), which is
+ open source software. The original software and
+ related information is available at
+ http://nsis.sourceforge.net.
+
+ Java compilation software for JSP pages is provided by the Eclipse
+ JDT Core Batch Compiler component, which is open source software.
+ The original software and related information is available at
+ http://www.eclipse.org/jdt/core/.
+
+ For portions of the Tomcat JNI OpenSSL API and the OpenSSL JSSE integration
+ The org.apache.tomcat.jni and the org.apache.tomcat.net.openssl packages
+ are derivative work originating from the Netty project and the finagle-native
+ project developed at Twitter
+ * Copyright 2014 The Netty Project
+ * Copyright 2014 Twitter
+
+ The original XML Schemas for Java EE Deployment Descriptors:
+ - javaee_5.xsd
+ - javaee_web_services_1_2.xsd
+ - javaee_web_services_client_1_2.xsd
+ - javaee_6.xsd
+ - javaee_web_services_1_3.xsd
+ - javaee_web_services_client_1_3.xsd
+ - jsp_2_2.xsd
+ - web-app_3_0.xsd
+ - web-common_3_0.xsd
+ - web-fragment_3_0.xsd
+ - javaee_7.xsd
+ - javaee_web_services_1_4.xsd
+ - javaee_web_services_client_1_4.xsd
+ - jsp_2_3.xsd
+ - web-app_3_1.xsd
+ - web-common_3_1.xsd
+ - web-fragment_3_1.xsd
+ - javaee_8.xsd
+ - web-app_4_0.xsd
+ - web-common_4_0.xsd
+ - web-fragment_4_0.xsd
+
+ may be obtained from:
+ http://www.oracle.com/webfolder/technetwork/jsc/xml/ns/javaee/index.html
+
+ (ASLv2) SnakeYAML
+ The following NOTICE information applies:
+ Copyright (c) 2008, http://www.snakeyaml.org
+
+ (ASLv2) Swagger UI
+ The following NOTICE information applies:
+ Copyright 2017 SmartBear Software
+
+
+************************
+Common Development and Distribution License 1.1
+************************
+
+The following binary components are provided under the Common Development and Distribution License 1.1. See project link for details.
+
+ (CDDL 1.1) (GPL2 w/ CPE) JavaMail API (compat) (javax.mail:mail:jar:1.4.7 - http://kenai.com/projects/javamail/mail)
+ (CDDL 1.1) (GPL2 w/ CPE) Java Servlet API (javax.servlet:javax.servlet-api:jar:3.1.0 - http://servlet-spec.java.net)
+ (CDDL 1.1) (GPL2 w/ CPE) JavaServer Pages Standard Tag Library (javax.servlet.jsp.jstl:jstl:jar:1.2 - https://javaee.github.io/jstl-api/)
+ (CDDL 1.1) (GPL2 w/ CPE) javax.annotation API (javax.annotation:javax.annotation-api:jar:1.2 - http://jcp.org/en/jsr/detail?id=250)
+ (CDDL 1.1) (GPL2 w/ CPE) aopalliance-repackaged (org.glassfish.hk2.external:aopalliance-repackaged:jar:2.5.0-b42 - https://javaee.github.io/glassfish/)
+ (CDDL 1.1) (GPL2 w/ CPE) asm-all-repackaged (org.glassfish.hk2.external:asm-all-repackaged:jar:2.5.0-b42 - https://javaee.github.io/glassfish/)
+ (CDDL 1.1) (GPL2 w/ CPE) class-model (org.glassfish.hk2:class-model:jar:2.5.0-b42 - https://javaee.github.io/glassfish/)
+ (CDDL 1.1) (GPL2 w/ CPE) config-types (org.glassfish.hk2:config-types:jar:2.5.0-b42 - https://javaee.github.io/glassfish/)
+ (CDDL 1.1) (GPL2 w/ CPE) hk2 (org.glassfish.hk2:hk2:jar:2.5.0-b42 - https://javaee.github.io/glassfish/)
+ (CDDL 1.1) (GPL2 w/ CPE) hk2-api (org.glassfish.hk2:hk2-api:jar:2.5.0-b42 - https://javaee.github.io/glassfish/)
+ (CDDL 1.1) (GPL2 w/ CPE) hk2-utils (org.glassfish.hk2:hk2-utils:jar:2.5.0-b42 - https://javaee.github.io/glassfish/)
+ (CDDL 1.1) (GPL2 w/ CPE) hk2-locator (org.glassfish.hk2:hk2-locator:jar:2.5.0-b42 - https://javaee.github.io/glassfish/)
+ (CDDL 1.1) (GPL2 w/ CPE) hk2-config (org.glassfish.hk2:hk2-config:jar:2.5.0-b42 - https://javaee.github.io/glassfish/)
+ (CDDL 1.1) (GPL2 w/ CPE) hk2-core (org.glassfish.hk2:hk2-core:jar:2.5.0-b42 - https://javaee.github.io/glassfish/)
+ (CDDL 1.1) (GPL2 w/ CPE) hk2-runlevel (org.glassfish.hk2:hk2-runlevel:jar:2.5.0-b42 - https://javaee.github.io/glassfish/)
+ (CDDL 1.1) (GPL2 w/ CPE) spring-bridge (org.glassfish.hk2:spring-bridge:jar:2.5.0-b42 - https://javaee.github.io/glassfish/)
+ (CDDL 1.1) (GPL2 w/ CPE) javax.inject:1 as OSGi bundle (org.glassfish.hk2.external:javax.inject:jar:2.4.0-b25 - https://hk2.java.net/external/javax.inject)
+ (CDDL 1.1) (GPL2 w/ CPE) javax.ws.rs-api (javax.ws.rs:javax.ws.rs-api:jar:2.1 - http://jax-rs-spec.java.net)
+ (CDDL 1.1) (GPL2 w/ CPE) javax.el (org.glassfish:javax.el:jar:3.0.1-b08 - https://github.com/javaee/el-spec)
+ (CDDL 1.1) (GPL2 w/ CPE) jersey-bean-validation (org.glassfish.jersey.ext:jersey-bean-validation:jar:2.26 - https://jersey.github.io/)
+ (CDDL 1.1) (GPL2 w/ CPE) jersey-client (org.glassfish.jersey.core:jersey-client:jar:2.26 - https://jersey.github.io/)
+ (CDDL 1.1) (GPL2 w/ CPE) jersey-common (org.glassfish.jersey.core:jersey-common:jar:2.26 - https://jersey.github.io/)
+ (CDDL 1.1) (GPL2 w/ CPE) jersey-container-servlet-core (org.glassfish.jersey.containers:jersey-container-servlet-core:jar:2.26 - https://jersey.github.io/)
+ (CDDL 1.1) (GPL2 w/ CPE) jersey-entity-filtering (org.glassfish.jersey.ext:jersey-entity-filtering:jar:2.26 - https://jersey.github.io/)
+ (CDDL 1.1) (GPL2 w/ CPE) jersey-hk2 (org.glassfish.jersey.inject:jersey-hk2:jar:2.26 - https://jersey.github.io/)
+ (CDDL 1.1) (GPL2 w/ CPE) jersey-media-jaxb (org.glassfish.jersey.media:jersey-media-jaxb:jar:2.26 - https://jersey.github.io/)
+ (CDDL 1.1) (GPL2 w/ CPE) jersey-media-json-jackson (org.glassfish.jersey.media:jersey-media-json-jackson:jar:2.26 - https://jersey.github.io/)
+ (CDDL 1.1) (GPL2 w/ CPE) jersey-server (org.glassfish.jersey.core:jersey-server:jar:2.26 - https://jersey.github.io/)
+ (CDDL 1.1) (GPL2 w/ CPE) jersey-spring4 (org.glassfish.jersey.ext:jersey-spring4:jar:2.26 - https://jersey.github.io/)
+ (CDDL 1.1) (GPL2 w/ CPE) OSGi resource locator bundle (org.glassfish.hk2:osgi-resource-locator:jar:1.0.1 - http://glassfish.org/osgi-resource-locator)
+
+
+************************
+Common Development and Distribution License 1.0
+************************
+
+The following binary components are provided under the Common Development and Distribution License 1.0. See project link for details.
+
+ (CDDL 1.0) JavaBeans Activation Framework (JAF) (javax.activation:activation:jar:1.1 - http://java.sun.com/products/javabeans/jaf/index.jsp)
+
+
+************************
+Eclipse Public License 1.0
+************************
+
+The following binary components are provided under the Eclipse Public License 1.0. See project link for details.
+
+ (EPL 1.0)(MPL 2.0) H2 Database (com.h2database:h2:jar:1.3.176 - http://www.h2database.com/html/license.html)
+ (EPL 1.0)(LGPL 2.1) Logback Classic (ch.qos.logback:logback-classic:jar:1.2.3 - http://logback.qos.ch/)
+ (EPL 1.0)(LGPL 2.1) Logback Core (ch.qos.logback:logback-core:jar:1.2.3 - http://logback.qos.ch/)
+ (EPL 1.0) AspectJ Weaver (org.aspectj:aspectjweaver:jar:1.8.13 - http://www.eclipse.org/aspectj/)
diff --git a/nifi-registry-toolkit/nifi-registry-toolkit-assembly/pom.xml b/nifi-registry-toolkit/nifi-registry-toolkit-assembly/pom.xml
new file mode 100644
index 0000000..dc1c0ed
--- /dev/null
+++ b/nifi-registry-toolkit/nifi-registry-toolkit-assembly/pom.xml
@@ -0,0 +1,68 @@
+<?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.registry</groupId>
+ <artifactId>nifi-registry-toolkit</artifactId>
+ <version>0.4.0-SNAPSHOT</version>
+ </parent>
+ <artifactId>nifi-registry-toolkit-assembly</artifactId>
+ <packaging>pom</packaging>
+ <description>This is the assembly for the Apache NiFi Registry Toolkit</description>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <configuration>
+ <finalName>nifi-registry-toolkit-${project.version}</finalName>
+ </configuration>
+ <executions>
+ <execution>
+ <id>make shared resource</id>
+ <goals>
+ <goal>single</goal>
+ </goals>
+ <phase>package</phase>
+ <configuration>
+ <archiverConfig>
+ <defaultDirectoryMode>0755</defaultDirectoryMode>
+ <directoryMode>0755</directoryMode>
+ <fileMode>0644</fileMode>
+ </archiverConfig>
+ <descriptors>
+ <descriptor>src/main/assembly/dependencies.xml</descriptor>
+ </descriptors>
+ <tarLongFileMode>posix</tarLongFileMode>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.nifi.registry</groupId>
+ <artifactId>nifi-registry-toolkit-persistence</artifactId>
+ <version>0.4.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>ch.qos.logback</groupId>
+ <artifactId>logback-classic</artifactId>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/nifi-registry-toolkit/nifi-registry-toolkit-assembly/src/main/assembly/dependencies.xml b/nifi-registry-toolkit/nifi-registry-toolkit-assembly/src/main/assembly/dependencies.xml
new file mode 100644
index 0000000..a5ac13f
--- /dev/null
+++ b/nifi-registry-toolkit/nifi-registry-toolkit-assembly/src/main/assembly/dependencies.xml
@@ -0,0 +1,65 @@
+<?xml version="1.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.
+ -->
+<assembly>
+ <id>bin</id>
+ <formats>
+ <format>dir</format>
+ <format>zip</format>
+ <format>tar.gz</format>
+ </formats>
+ <includeBaseDirectory>true</includeBaseDirectory>
+ <baseDirectory>nifi-registry-toolkit-${project.version}</baseDirectory>
+
+ <dependencySets>
+ <!-- Write out all dependency artifacts to lib directory -->
+ <dependencySet>
+ <outputDirectory>lib</outputDirectory>
+ <useProjectArtifact>false</useProjectArtifact>
+ <directoryMode>0770</directoryMode>
+ <fileMode>0660</fileMode>
+ </dependencySet>
+ </dependencySets>
+ <fileSets>
+ <fileSet>
+ <directory>${project.basedir}/src/main/resources/bin</directory>
+ <outputDirectory>bin/</outputDirectory>
+ <fileMode>0700</fileMode>
+ </fileSet>
+ <fileSet>
+ <directory>${project.basedir}/src/main/resources/classpath</directory>
+ <outputDirectory>classpath/</outputDirectory>
+ <fileMode>0600</fileMode>
+ </fileSet>
+ </fileSets>
+ <files>
+ <file>
+ <source>./LICENSE</source>
+ <outputDirectory>./</outputDirectory>
+ <destName>LICENSE</destName>
+ <fileMode>0644</fileMode>
+ <filtered>true</filtered>
+ </file>
+ <file>
+ <source>./NOTICE</source>
+ <outputDirectory>./</outputDirectory>
+ <destName>NOTICE</destName>
+ <fileMode>0644</fileMode>
+ <filtered>true</filtered>
+ </file>
+ </files>
+</assembly>
diff --git a/nifi-registry-toolkit/nifi-registry-toolkit-assembly/src/main/resources/bin/persistence-toolkit.bat b/nifi-registry-toolkit/nifi-registry-toolkit-assembly/src/main/resources/bin/persistence-toolkit.bat
new file mode 100644
index 0000000..f9bcb02
--- /dev/null
+++ b/nifi-registry-toolkit/nifi-registry-toolkit-assembly/src/main/resources/bin/persistence-toolkit.bat
@@ -0,0 +1,41 @@
+@echo off
+rem
+rem Licensed to the Apache Software Foundation (ASF) under one or more
+rem contributor license agreements. See the NOTICE file distributed with
+rem this work for additional information regarding copyright ownership.
+rem The ASF licenses this file to You under the Apache License, Version 2.0
+rem (the "License"); you may not use this file except in compliance with
+rem the License. You may obtain a copy of the License at
+rem
+rem http://www.apache.org/licenses/LICENSE-2.0
+rem
+rem Unless required by applicable law or agreed to in writing, software
+rem distributed under the License is distributed on an "AS IS" BASIS,
+rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+rem See the License for the specific language governing permissions and
+rem limitations under the License.
+rem
+
+rem Use JAVA_HOME if it's set; otherwise, just use java
+
+if "%JAVA_HOME%" == "" goto noJavaHome
+if not exist "%JAVA_HOME%\bin\java.exe" goto noJavaHome
+set JAVA_EXE=%JAVA_HOME%\bin\java.exe
+goto startConfig
+
+:noJavaHome
+echo The JAVA_HOME environment variable is not defined correctly.
+echo Instead the PATH will be used to find the java executable.
+echo.
+set JAVA_EXE=java
+goto startConfig
+
+:startConfig
+set LIB_DIR=%~dp0..\classpath;%~dp0..\lib
+
+if "%JAVA_OPTS%" == "" set JAVA_OPTS=-Xms12m -Xmx24m
+
+SET JAVA_PARAMS=-cp %LIB_DIR%\* %JAVA_OPTS% org.apache.nifi.registry.toolkit.persistence.FlowPersistenceProviderMigrator
+
+cmd.exe /C ""%JAVA_EXE%" %JAVA_PARAMS% %* ""
+
diff --git a/nifi-registry-toolkit/nifi-registry-toolkit-assembly/src/main/resources/bin/persistence-toolkit.sh b/nifi-registry-toolkit/nifi-registry-toolkit-assembly/src/main/resources/bin/persistence-toolkit.sh
new file mode 100644
index 0000000..ee85e23
--- /dev/null
+++ b/nifi-registry-toolkit/nifi-registry-toolkit-assembly/src/main/resources/bin/persistence-toolkit.sh
@@ -0,0 +1,120 @@
+#!/bin/sh
+#
+# 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.
+#
+#
+
+# Script structure inspired from Apache Karaf and other Apache projects with similar startup approaches
+
+SCRIPT_DIR=$(dirname "$0")
+SCRIPT_NAME=$(basename "$0")
+NIFI_REGISTRY_TOOLKIT_HOME=$(cd "${SCRIPT_DIR}" && cd .. && pwd)
+PROGNAME=$(basename "$0")
+
+
+warn() {
+ echo "${PROGNAME}: $*"
+}
+
+die() {
+ warn "$*"
+ exit 1
+}
+
+detectOS() {
+ # OS specific support (must be 'true' or 'false').
+ cygwin=false;
+ aix=false;
+ os400=false;
+ darwin=false;
+ case "$(uname)" in
+ CYGWIN*)
+ cygwin=true
+ ;;
+ AIX*)
+ aix=true
+ ;;
+ OS400*)
+ os400=true
+ ;;
+ Darwin)
+ darwin=true
+ ;;
+ esac
+ # For AIX, set an environment variable
+ if ${aix}; then
+ export LDR_CNTRL=MAXDATA=0xB0000000@DSA
+ echo ${LDR_CNTRL}
+ fi
+}
+
+locateJava() {
+ # Setup the Java Virtual Machine
+ if $cygwin ; then
+ [ -n "${JAVA}" ] && JAVA=$(cygpath --unix "${JAVA}")
+ [ -n "${JAVA_HOME}" ] && JAVA_HOME=$(cygpath --unix "${JAVA_HOME}")
+ fi
+
+ if [ "x${JAVA}" = "x" ] && [ -r /etc/gentoo-release ] ; then
+ JAVA_HOME=$(java-config --jre-home)
+ fi
+ if [ "x${JAVA}" = "x" ]; then
+ if [ "x${JAVA_HOME}" != "x" ]; then
+ if [ ! -d "${JAVA_HOME}" ]; then
+ die "JAVA_HOME is not valid: ${JAVA_HOME}"
+ fi
+ JAVA="${JAVA_HOME}/bin/java"
+ else
+ warn "JAVA_HOME not set; results may vary"
+ JAVA=$(type java)
+ JAVA=$(expr "${JAVA}" : '.* \(/.*\)$')
+ if [ "x${JAVA}" = "x" ]; then
+ die "java command not found"
+ fi
+ fi
+ fi
+}
+
+init() {
+ # Determine if there is special OS handling we must perform
+ detectOS
+
+ # Locate the Java VM to execute
+ locateJava "$1"
+}
+
+run() {
+ LIBS="${NIFI_REGISTRY_TOOLKIT_HOME}/lib/*"
+
+ sudo_cmd_prefix=""
+ if $cygwin; then
+ NIFI_REGISTRY_TOOLKIT_HOME=$(cygpath --path --windows "${NIFI_REGISTRY_TOOLKIT_HOME}")
+ CLASSPATH="$NIFI_REGISTRY_TOOLKIT_HOME/classpath;$(cygpath --path --windows "${LIBS}")"
+ else
+ CLASSPATH="$NIFI_REGISTRY_TOOLKIT_HOME/classpath:${LIBS}"
+ fi
+
+ export JAVA_HOME="$JAVA_HOME"
+ export NIFI_REGISTRY_TOOLKIT_HOME="$NIFI_REGISTRY_TOOLKIT_HOME"
+
+ umask 0077
+ echo "$CLASSPATH"
+ exec "${JAVA}" -cp "${CLASSPATH}" ${JAVA_OPTS:--Xms12m -Xmx256m} org.apache.nifi.registry.toolkit.persistence.FlowPersistenceProviderMigrator "$@"
+}
+
+
+init "$1"
+run "$@"
diff --git a/nifi-registry-toolkit/nifi-registry-toolkit-assembly/src/main/resources/classpath/log4j.properties b/nifi-registry-toolkit/nifi-registry-toolkit-assembly/src/main/resources/classpath/log4j.properties
new file mode 100644
index 0000000..7fbee6a
--- /dev/null
+++ b/nifi-registry-toolkit/nifi-registry-toolkit-assembly/src/main/resources/classpath/log4j.properties
@@ -0,0 +1,22 @@
+#
+# 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.
+#
+
+log4j.rootLogger=INFO,console
+
+log4j.appender.console=org.apache.log4j.ConsoleAppender
+log4j.appender.console.layout=org.apache.log4j.PatternLayout
+log4j.appender.console.layout.ConversionPattern=%d{yyyy/MM/dd HH:mm:ss} %p [%t] %c: %m%n
\ No newline at end of file
diff --git a/nifi-registry-toolkit/nifi-registry-toolkit-persistence/pom.xml b/nifi-registry-toolkit/nifi-registry-toolkit-persistence/pom.xml
new file mode 100644
index 0000000..2fd7661
--- /dev/null
+++ b/nifi-registry-toolkit/nifi-registry-toolkit-persistence/pom.xml
@@ -0,0 +1,55 @@
+<?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/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.nifi.registry</groupId>
+ <artifactId>nifi-registry-toolkit</artifactId>
+ <version>0.4.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>nifi-registry-toolkit-persistence</artifactId>
+ <packaging>jar</packaging>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.nifi.registry</groupId>
+ <artifactId>nifi-registry-framework</artifactId>
+ <version>0.4.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.nifi.registry</groupId>
+ <artifactId>nifi-registry-provider-api</artifactId>
+ <version>0.4.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.nifi.registry</groupId>
+ <artifactId>nifi-registry-security-api</artifactId>
+ <version>0.4.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.nifi.registry</groupId>
+ <artifactId>nifi-registry-runtime</artifactId>
+ <version>0.4.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-cli</groupId>
+ <artifactId>commons-cli</artifactId>
+ <version>1.4</version>
+ </dependency>
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-core</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/nifi-registry-toolkit/nifi-registry-toolkit-persistence/src/main/java/org/apache/nifi/registry/toolkit/persistence/FlowPersistenceProviderMigrator.java b/nifi-registry-toolkit/nifi-registry-toolkit-persistence/src/main/java/org/apache/nifi/registry/toolkit/persistence/FlowPersistenceProviderMigrator.java
new file mode 100644
index 0000000..7130880
--- /dev/null
+++ b/nifi-registry-toolkit/nifi-registry-toolkit-persistence/src/main/java/org/apache/nifi/registry/toolkit/persistence/FlowPersistenceProviderMigrator.java
@@ -0,0 +1,106 @@
+/*
+ * 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.registry.toolkit.persistence;
+
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.CommandLineParser;
+import org.apache.commons.cli.DefaultParser;
+import org.apache.commons.cli.HelpFormatter;
+import org.apache.commons.cli.Options;
+import org.apache.commons.cli.ParseException;
+import org.apache.nifi.registry.NiFiRegistry;
+import org.apache.nifi.registry.db.DataSourceFactory;
+import org.apache.nifi.registry.db.DatabaseMetadataService;
+import org.apache.nifi.registry.db.entity.BucketEntity;
+import org.apache.nifi.registry.db.entity.FlowEntity;
+import org.apache.nifi.registry.db.entity.FlowSnapshotEntity;
+import org.apache.nifi.registry.extension.ExtensionManager;
+import org.apache.nifi.registry.flow.FlowPersistenceProvider;
+import org.apache.nifi.registry.properties.NiFiRegistryProperties;
+import org.apache.nifi.registry.provider.StandardProviderFactory;
+import org.apache.nifi.registry.provider.flow.StandardFlowSnapshotContext;
+import org.apache.nifi.registry.service.DataModelMapper;
+import org.apache.nifi.registry.service.MetadataService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.jdbc.core.JdbcTemplate;
+
+public class FlowPersistenceProviderMigrator {
+ private static final Logger log = LoggerFactory.getLogger(FlowPersistenceProviderMigrator.class);
+ public static final int PARSE_EXCEPTION = 1;
+
+ public void doMigrate(MetadataService fromMetadata, FlowPersistenceProvider fromProvider, FlowPersistenceProvider toProvider) {
+ for (BucketEntity bucket : fromMetadata.getAllBuckets()) {
+ for (FlowEntity flow : fromMetadata.getFlowsByBucket(bucket.getId())) {
+ for (FlowSnapshotEntity flowSnapshot : fromMetadata.getSnapshots(flow.getId())) {
+ StandardFlowSnapshotContext context = new StandardFlowSnapshotContext.Builder(
+ DataModelMapper.map(bucket),
+ DataModelMapper.map(bucket, flow),
+ DataModelMapper.map(bucket, flowSnapshot)).build();
+
+ int version = flowSnapshot.getVersion();
+
+ toProvider.saveFlowContent(context, fromProvider.getFlowContent(bucket.getId(), flow.getId(), version));
+
+ log.info("Migrated flow {} version {}", flow.getName(), version);
+ }
+ }
+ }
+ }
+
+ public static void main(String[] args) {
+ Options options = new Options();
+ options.addOption("t", "to", true, "Providers xml to migrate to.");
+ CommandLineParser parser = new DefaultParser();
+
+ CommandLine commandLine = null;
+ try {
+ commandLine = parser.parse(options, args);
+ } catch (ParseException e) {
+ log.error("Unable to parse command line.", e);
+
+ new HelpFormatter().printHelp("persistence-toolkit [args]", options);
+
+ System.exit(PARSE_EXCEPTION);
+ }
+
+ NiFiRegistryProperties fromProperties = NiFiRegistry.initializeProperties(NiFiRegistry.getMasterKeyProvider());
+
+ DatabaseMetadataService fromMetadataService = new DatabaseMetadataService(new JdbcTemplate(new DataSourceFactory(fromProperties).getDataSource()));
+ FlowPersistenceProvider fromPersistenceProvider = createFlowPersistenceProvider(fromProperties);
+ FlowPersistenceProvider toPersistenceProvider = createFlowPersistenceProvider(createToProperties(commandLine, fromProperties));
+
+ new FlowPersistenceProviderMigrator().doMigrate(fromMetadataService, fromPersistenceProvider, toPersistenceProvider);
+ }
+
+ private static NiFiRegistryProperties createToProperties(CommandLine commandLine, NiFiRegistryProperties fromProperties) {
+ NiFiRegistryProperties toProperties = new NiFiRegistryProperties();
+ for (String propertyKey : fromProperties.getPropertyKeys()) {
+ toProperties.setProperty(propertyKey, fromProperties.getProperty(propertyKey));
+ }
+ toProperties.setProperty(NiFiRegistryProperties.PROVIDERS_CONFIGURATION_FILE, commandLine.getOptionValue('t'));
+ return toProperties;
+ }
+
+ private static FlowPersistenceProvider createFlowPersistenceProvider(NiFiRegistryProperties niFiRegistryProperties) {
+ ExtensionManager fromExtensionManager = new ExtensionManager(niFiRegistryProperties);
+ fromExtensionManager.discoverExtensions();
+ StandardProviderFactory fromProviderFactory = new StandardProviderFactory(niFiRegistryProperties, fromExtensionManager);
+ fromProviderFactory.initialize();
+ return fromProviderFactory.getFlowPersistenceProvider();
+ }
+}
\ No newline at end of file
diff --git a/nifi-registry-toolkit/nifi-registry-toolkit-persistence/src/test/java/org/apache/nifi/registry/toolkit/persistence/FlowPersistenceProviderMigratorTest.java b/nifi-registry-toolkit/nifi-registry-toolkit-persistence/src/test/java/org/apache/nifi/registry/toolkit/persistence/FlowPersistenceProviderMigratorTest.java
new file mode 100644
index 0000000..8361708
--- /dev/null
+++ b/nifi-registry-toolkit/nifi-registry-toolkit-persistence/src/test/java/org/apache/nifi/registry/toolkit/persistence/FlowPersistenceProviderMigratorTest.java
@@ -0,0 +1,155 @@
+/*
+ * 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.registry.toolkit.persistence;
+
+import org.apache.nifi.registry.db.entity.BucketEntity;
+import org.apache.nifi.registry.db.entity.FlowEntity;
+import org.apache.nifi.registry.db.entity.FlowSnapshotEntity;
+import org.apache.nifi.registry.flow.FlowPersistenceProvider;
+import org.apache.nifi.registry.provider.flow.StandardFlowSnapshotContext;
+import org.apache.nifi.registry.service.DataModelMapper;
+import org.apache.nifi.registry.service.MetadataService;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.AdditionalMatchers;
+
+import java.nio.charset.StandardCharsets;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.TreeMap;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.mockito.ArgumentMatchers.anyInt;
+import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.verifyNoMoreInteractions;
+import static org.mockito.Mockito.when;
+
+public class FlowPersistenceProviderMigratorTest {
+ private MetadataService metadataService;
+ private FlowPersistenceProvider fromProvider;
+ private FlowPersistenceProvider toProvider;
+
+ private Map<String, BucketEntity> buckets;
+ private Map<String, Map<String, FlowEntity>> bucketFlows;
+ private Map<String, BucketEntity> flowBuckets;
+ private Map<String, List<FlowSnapshotEntity>> flowSnapshots;
+
+ @Before
+ public void setup() {
+ metadataService = mock(MetadataService.class);
+ fromProvider = mock(FlowPersistenceProvider.class);
+ toProvider = mock(FlowPersistenceProvider.class);
+
+ buckets = new TreeMap<>();
+ bucketFlows = new HashMap<>();
+ flowBuckets = new HashMap<>();
+ flowSnapshots = new HashMap<>();
+
+ when(metadataService.getAllBuckets()).thenAnswer(invocation -> new ArrayList<>(buckets.values()));
+ when(metadataService.getFlowsByBucket(anyString())).thenAnswer(invocation -> new ArrayList<>(bucketFlows.get(invocation.<String>getArgument(0)).values()));
+ when(metadataService.getSnapshots(anyString())).thenAnswer(invocation -> new ArrayList<>(flowSnapshots.get(invocation.<String>getArgument(0))));
+ when(fromProvider.getFlowContent(anyString(), anyString(), anyInt())).thenAnswer(invocation -> {
+ FlowSnapshotEntity flowSnapshotEntity = flowSnapshots.get(invocation.<String>getArgument(1)).get(invocation.<Integer>getArgument(2) - 1);
+ assertEquals(invocation.getArgument(2), flowSnapshotEntity.getVersion());
+ FlowEntity flowEntity = bucketFlows.get(invocation.<String>getArgument(0)).get(invocation.<String>getArgument(1));
+ assertEquals(invocation.getArgument(0), flowEntity.getBucketId());
+ assertNotNull(buckets.get(invocation.<String>getArgument(0)));
+ return getContent(invocation.getArgument(0), invocation.getArgument(1), invocation.getArgument(2));
+ });
+ }
+
+ private byte[] getContent(String bucketId, String flowId, int version) {
+ return (bucketId + "-" + flowId + "-" + version).getBytes(StandardCharsets.UTF_8);
+ }
+
+ @Test
+ public void testMigration() {
+ createBucket("bucket1");
+ BucketEntity bucket2 = createBucket("bucket2");
+ BucketEntity bucket3 = createBucket("bucket3");
+
+ FlowEntity flow1 = createFlow(bucket2, "flow1");
+ FlowEntity flow2 = createFlow(bucket3, "flow2");
+ FlowEntity flow3 = createFlow(bucket3, "flow3");
+
+ List<FlowSnapshotEntity> snapshots = Arrays.asList(
+ createSnapshot(flow1, 1),
+ createSnapshot(flow2, 1),
+ createSnapshot(flow2, 2),
+ createSnapshot(flow3, 1),
+ createSnapshot(flow3, 2),
+ createSnapshot(flow3, 3));
+
+ new FlowPersistenceProviderMigrator().doMigrate(metadataService, fromProvider, toProvider);
+
+ for (FlowSnapshotEntity snapshot : snapshots) {
+ verifyMigrate(snapshot);
+ }
+
+ verifyNoMoreInteractions(toProvider);
+ }
+
+ private BucketEntity createBucket(String id) {
+ BucketEntity bucketEntity = new BucketEntity();
+ bucketEntity.setId(id);
+ bucketEntity.setName(id + "Name");
+ bucketEntity.setCreated(new Date());
+ buckets.put(id, bucketEntity);
+ bucketFlows.put(id, new TreeMap<>());
+ return bucketEntity;
+ }
+
+ private FlowEntity createFlow(BucketEntity bucketEntity, String id) {
+ FlowEntity flowEntity = new FlowEntity();
+ flowEntity.setBucketId(bucketEntity.getId());
+ flowEntity.setId(id);
+ flowEntity.setName(id + "Name");
+ flowEntity.setCreated(new Date());
+ flowEntity.setModified(new Date());
+ bucketFlows.get(bucketEntity.getId()).put(id, flowEntity);
+ flowBuckets.put(id, bucketEntity);
+ flowSnapshots.put(id, new ArrayList<>());
+ return flowEntity;
+ }
+
+ private FlowSnapshotEntity createSnapshot(FlowEntity flowEntity, int version) {
+ FlowSnapshotEntity flowSnapshotEntity = new FlowSnapshotEntity();
+ flowSnapshotEntity.setFlowId(flowEntity.getId());
+ flowSnapshotEntity.setVersion(version);
+ flowSnapshotEntity.setCreated(new Date());
+ flowSnapshots.get(flowEntity.getId()).add(flowSnapshotEntity);
+ return flowSnapshotEntity;
+ }
+
+ private void verifyMigrate(FlowSnapshotEntity flowSnapshotEntity) {
+ BucketEntity bucketEntity = flowBuckets.get(flowSnapshotEntity.getFlowId());
+ FlowEntity flowEntity = bucketFlows.get(bucketEntity.getId()).get(flowSnapshotEntity.getFlowId());
+ verify(toProvider).saveFlowContent(eq(new StandardFlowSnapshotContext.Builder(
+ DataModelMapper.map(bucketEntity),
+ DataModelMapper.map(bucketEntity, flowEntity),
+ DataModelMapper.map(bucketEntity, flowSnapshotEntity)).build()),
+ AdditionalMatchers.aryEq(getContent(bucketEntity.getId(), flowSnapshotEntity.getFlowId(), flowSnapshotEntity.getVersion())));
+ }
+}
diff --git a/nifi-registry-toolkit/pom.xml b/nifi-registry-toolkit/pom.xml
new file mode 100644
index 0000000..e069ebe
--- /dev/null
+++ b/nifi-registry-toolkit/pom.xml
@@ -0,0 +1,31 @@
+<?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.registry</groupId>
+ <artifactId>nifi-registry</artifactId>
+ <version>0.4.0-SNAPSHOT</version>
+ </parent>
+ <artifactId>nifi-registry-toolkit</artifactId>
+ <packaging>pom</packaging>
+ <description>Command line tooling for setup and maintenance tasks of the NiFi Registry.</description>
+ <modules>
+ <module>nifi-registry-toolkit-persistence</module>
+ <module>nifi-registry-toolkit-assembly</module>
+ </modules>
+</project>
diff --git a/pom.xml b/pom.xml
index 25fa752..89df4b6 100644
--- a/pom.xml
+++ b/pom.xml
@@ -33,6 +33,7 @@
<module>nifi-registry-core</module>
<module>nifi-registry-extensions</module>
<module>nifi-registry-assembly</module>
+ <module>nifi-registry-toolkit</module>
</modules>
<url>https://nifi.apache.org/registry.html</url>
<organization>