NIFI-4436: - Added the import dialog for importing a versioned flow into a new process group. - Added the change version dialog for upgrading/downgrading a versioned flow.
Project: http://git-wip-us.apache.org/repos/asf/nifi/repo Commit: http://git-wip-us.apache.org/repos/asf/nifi/commit/696d583b Tree: http://git-wip-us.apache.org/repos/asf/nifi/tree/696d583b Diff: http://git-wip-us.apache.org/repos/asf/nifi/diff/696d583b Branch: refs/heads/master Commit: 696d583b148b60d41853add8d3e2d24b4ff907f3 Parents: 6aa8b5c Author: Matt Gilman <[email protected]> Authored: Wed Nov 1 17:21:04 2017 -0400 Committer: Bryan Bende <[email protected]> Committed: Mon Jan 8 12:44:52 2018 -0500 ---------------------------------------------------------------------- .../nifi/web/api/dto/FlowConfigurationDTO.java | 14 - .../api/dto/VersionControlInformationDTO.java | 10 + .../nifi/web/api/entity/CurrentUserEntity.java | 14 + .../StartVersionControlRequestEntity.java | 48 + .../web/api/entity/VersionedFlowEntity.java | 11 - .../VersionedFlowSnapshotMetadataEntity.java | 47 + .../VersionedFlowSnapshotMetadataSetEntity.java | 38 + .../web/api/entity/VersionedFlowsEntity.java | 38 + .../org/apache/nifi/web/NiFiServiceFacade.java | 62 +- .../nifi/web/StandardNiFiServiceFacade.java | 158 ++- .../apache/nifi/web/api/ControllerResource.java | 67 +- .../org/apache/nifi/web/api/FlowResource.java | 128 ++- .../apache/nifi/web/api/VersionsResource.java | 91 +- .../org/apache/nifi/web/api/dto/DtoFactory.java | 5 +- .../apache/nifi/web/dao/ProcessGroupDAO.java | 7 + .../org/apache/nifi/web/dao/RegistryDAO.java | 16 +- .../nifi/web/dao/impl/FlowRegistryDAO.java | 59 +- .../web/dao/impl/StandardProcessGroupDAO.java | 22 + .../src/main/resources/nifi-web-api-context.xml | 2 - .../src/main/webapp/WEB-INF/pages/canvas.jsp | 1 + .../canvas/import-flow-version-dialog.jsp | 44 + .../WEB-INF/partials/canvas/navigation.jsp | 4 +- .../canvas/new-process-group-dialog.jsp | 3 + .../canvas/new-remote-process-group-dialog.jsp | 2 +- .../canvas/registry-configuration-dialog.jsp | 4 +- .../canvas/save-flow-version-dialog.jsp | 20 +- .../nifi-web-ui/src/main/webapp/css/dialog.css | 18 +- .../header/components/nf-ng-group-component.js | 32 +- .../src/main/webapp/js/nf/canvas/nf-actions.js | 23 +- .../webapp/js/nf/canvas/nf-canvas-bootstrap.js | 3 +- .../main/webapp/js/nf/canvas/nf-canvas-utils.js | 7 - .../src/main/webapp/js/nf/canvas/nf-canvas.js | 18 - .../main/webapp/js/nf/canvas/nf-context-menu.js | 16 +- .../main/webapp/js/nf/canvas/nf-flow-version.js | 1036 +++++++++++++++--- .../src/main/webapp/js/nf/canvas/nf-settings.js | 23 +- .../src/main/webapp/js/nf/nf-common.js | 11 + 36 files changed, 1698 insertions(+), 404 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/nifi/blob/696d583b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/FlowConfigurationDTO.java ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/FlowConfigurationDTO.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/FlowConfigurationDTO.java index 03e1a7d..d7a0c83 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/FlowConfigurationDTO.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/FlowConfigurationDTO.java @@ -32,7 +32,6 @@ public class FlowConfigurationDTO { private Boolean supportsManagedAuthorizer; private Boolean supportsConfigurableAuthorizer; private Boolean supportsConfigurableUsersAndGroups; - private Boolean supportsFlowVersioning; private Long autoRefreshIntervalSeconds; private Date currentTime; @@ -129,17 +128,4 @@ public class FlowConfigurationDTO { this.timeOffset = timeOffset; } - /** - * @return whether this NiFi is configured for support flow versioning - */ - @ApiModelProperty( - value = "Whether this NiFi supports flow versioning." - ) - public Boolean getSupportsFlowVersioning() { - return supportsFlowVersioning; - } - - public void setSupportsFlowVersioning(Boolean supportsFlowVersioning) { - this.supportsFlowVersioning = supportsFlowVersioning; - } } http://git-wip-us.apache.org/repos/asf/nifi/blob/696d583b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/VersionControlInformationDTO.java ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/VersionControlInformationDTO.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/VersionControlInformationDTO.java index d27e830..e9aa246 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/VersionControlInformationDTO.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/VersionControlInformationDTO.java @@ -27,6 +27,7 @@ public class VersionControlInformationDTO { private String registryId; private String bucketId; private String flowId; + private String flowName; private Integer version; private Boolean modified; private Boolean current; @@ -67,6 +68,15 @@ public class VersionControlInformationDTO { this.flowId = flowId; } + @ApiModelProperty("The name of the flow") + public String getFlowName() { + return flowName; + } + + public void setFlowName(String flowName) { + this.flowName = flowName; + } + @ApiModelProperty("The version of the flow") public Integer getVersion() { return version; http://git-wip-us.apache.org/repos/asf/nifi/blob/696d583b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/CurrentUserEntity.java ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/CurrentUserEntity.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/CurrentUserEntity.java index 6b8e28f..8121ce4 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/CurrentUserEntity.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/CurrentUserEntity.java @@ -38,6 +38,8 @@ public class CurrentUserEntity extends Entity { private PermissionsDTO systemPermissions; private PermissionsDTO restrictedComponentsPermissions; + private boolean canVersionFlows; + /** * @return the user identity being serialized */ @@ -145,4 +147,16 @@ public class CurrentUserEntity extends Entity { public void setRestrictedComponentsPermissions(PermissionsDTO restrictedComponentsPermissions) { this.restrictedComponentsPermissions = restrictedComponentsPermissions; } + + /** + * @return whether the current user can version flows + */ + @ApiModelProperty("Whether the current user can version flows.") + public boolean isCanVersionFlows() { + return canVersionFlows; + } + + public void setCanVersionFlows(boolean canVersionFlows) { + this.canVersionFlows = canVersionFlows; + } } http://git-wip-us.apache.org/repos/asf/nifi/blob/696d583b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/StartVersionControlRequestEntity.java ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/StartVersionControlRequestEntity.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/StartVersionControlRequestEntity.java new file mode 100644 index 0000000..0876140 --- /dev/null +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/StartVersionControlRequestEntity.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.web.api.entity; + +import io.swagger.annotations.ApiModelProperty; +import org.apache.nifi.web.api.dto.RevisionDTO; +import org.apache.nifi.web.api.dto.VersionedFlowDTO; + +import javax.xml.bind.annotation.XmlRootElement; + +@XmlRootElement(name = "versionedFlow") +public class StartVersionControlRequestEntity extends Entity { + private VersionedFlowDTO versionedFlow; + private RevisionDTO processGroupRevision; + + @ApiModelProperty("The versioned flow") + public VersionedFlowDTO getVersionedFlow() { + return versionedFlow; + } + + public void setVersionedFlow(VersionedFlowDTO versionedFLow) { + this.versionedFlow = versionedFLow; + } + + @ApiModelProperty("The Revision of the Process Group under Version Control") + public RevisionDTO getProcessGroupRevision() { + return processGroupRevision; + } + + public void setProcessGroupRevision(final RevisionDTO revision) { + this.processGroupRevision = revision; + } +} http://git-wip-us.apache.org/repos/asf/nifi/blob/696d583b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/VersionedFlowEntity.java ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/VersionedFlowEntity.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/VersionedFlowEntity.java index b94255a..4a43826 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/VersionedFlowEntity.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/VersionedFlowEntity.java @@ -18,7 +18,6 @@ package org.apache.nifi.web.api.entity; import io.swagger.annotations.ApiModelProperty; -import org.apache.nifi.web.api.dto.RevisionDTO; import org.apache.nifi.web.api.dto.VersionedFlowDTO; import javax.xml.bind.annotation.XmlRootElement; @@ -26,7 +25,6 @@ import javax.xml.bind.annotation.XmlRootElement; @XmlRootElement(name = "versionedFlow") public class VersionedFlowEntity extends Entity { private VersionedFlowDTO versionedFlow; - private RevisionDTO processGroupRevision; @ApiModelProperty("The versioned flow") public VersionedFlowDTO getVersionedFlow() { @@ -36,13 +34,4 @@ public class VersionedFlowEntity extends Entity { public void setVersionedFlow(VersionedFlowDTO versionedFLow) { this.versionedFlow = versionedFLow; } - - @ApiModelProperty("The Revision of the Process Group under Version Control") - public RevisionDTO getProcessGroupRevision() { - return processGroupRevision; - } - - public void setProcessGroupRevision(final RevisionDTO revision) { - this.processGroupRevision = revision; - } } http://git-wip-us.apache.org/repos/asf/nifi/blob/696d583b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/VersionedFlowSnapshotMetadataEntity.java ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/VersionedFlowSnapshotMetadataEntity.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/VersionedFlowSnapshotMetadataEntity.java new file mode 100644 index 0000000..29b57cc --- /dev/null +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/VersionedFlowSnapshotMetadataEntity.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.web.api.entity; + +import io.swagger.annotations.ApiModelProperty; +import org.apache.nifi.registry.flow.VersionedFlowSnapshotMetadata; + +import javax.xml.bind.annotation.XmlRootElement; + +@XmlRootElement(name = "versionedFlowSnapshotMetadata") +public class VersionedFlowSnapshotMetadataEntity extends Entity { + private VersionedFlowSnapshotMetadata versionedFlowSnapshotMetadata; + private String registryId; + + @ApiModelProperty("The collection of versioned flow snapshot metadata") + public VersionedFlowSnapshotMetadata getVersionedFlowSnapshotMetadata() { + return versionedFlowSnapshotMetadata; + } + + public void setVersionedFlowMetadata(VersionedFlowSnapshotMetadata versionedFlowSnapshotMetadata) { + this.versionedFlowSnapshotMetadata = versionedFlowSnapshotMetadata; + } + + @ApiModelProperty("The ID of the Registry that this flow belongs to") + public String getRegistryId() { + return registryId; + } + + public void setRegistryId(String registryId) { + this.registryId = registryId; + } +} http://git-wip-us.apache.org/repos/asf/nifi/blob/696d583b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/VersionedFlowSnapshotMetadataSetEntity.java ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/VersionedFlowSnapshotMetadataSetEntity.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/VersionedFlowSnapshotMetadataSetEntity.java new file mode 100644 index 0000000..d49b40f --- /dev/null +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/VersionedFlowSnapshotMetadataSetEntity.java @@ -0,0 +1,38 @@ +/* + * 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.api.entity; + +import javax.xml.bind.annotation.XmlRootElement; +import java.util.Set; + +@XmlRootElement(name = "versionedFlowSnapshotMetadataSetEntity") +public class VersionedFlowSnapshotMetadataSetEntity extends Entity { + + private Set<VersionedFlowSnapshotMetadataEntity> versionedFlowSnapshotMetadataSet; + + /** + * @return collection of VersionedFlowSnapshotMetadataEntity's that are being serialized + */ + public Set<VersionedFlowSnapshotMetadataEntity> getVersionedFlowSnapshotMetadataSet() { + return versionedFlowSnapshotMetadataSet; + } + + public void setVersionedFlowSnapshotMetadataSet(Set<VersionedFlowSnapshotMetadataEntity> versionedFlowSnapshotMetadataSet) { + this.versionedFlowSnapshotMetadataSet = versionedFlowSnapshotMetadataSet; + } + +} http://git-wip-us.apache.org/repos/asf/nifi/blob/696d583b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/VersionedFlowsEntity.java ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/VersionedFlowsEntity.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/VersionedFlowsEntity.java new file mode 100644 index 0000000..1104eae --- /dev/null +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/VersionedFlowsEntity.java @@ -0,0 +1,38 @@ +/* + * 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.api.entity; + +import javax.xml.bind.annotation.XmlRootElement; +import java.util.Set; + +@XmlRootElement(name = "versionedFlowsEntity") +public class VersionedFlowsEntity extends Entity { + + private Set<VersionedFlowEntity> versionedFlows; + + /** + * @return collection of VersionedEntity's that are being serialized + */ + public Set<VersionedFlowEntity> getVersionedFlows() { + return versionedFlows; + } + + public void setVersionedFlows(Set<VersionedFlowEntity> versionedFlows) { + this.versionedFlows = versionedFlows; + } + +} http://git-wip-us.apache.org/repos/asf/nifi/blob/696d583b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/NiFiServiceFacade.java ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/NiFiServiceFacade.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/NiFiServiceFacade.java index d851677..e299059 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/NiFiServiceFacade.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/NiFiServiceFacade.java @@ -77,6 +77,7 @@ import org.apache.nifi.web.api.entity.AccessPolicyEntity; import org.apache.nifi.web.api.entity.ActionEntity; import org.apache.nifi.web.api.entity.ActivateControllerServicesEntity; import org.apache.nifi.web.api.entity.AffectedComponentEntity; +import org.apache.nifi.web.api.entity.BucketEntity; import org.apache.nifi.web.api.entity.BulletinEntity; import org.apache.nifi.web.api.entity.ConnectionEntity; import org.apache.nifi.web.api.entity.ConnectionStatusEntity; @@ -103,6 +104,7 @@ import org.apache.nifi.web.api.entity.RemoteProcessGroupStatusEntity; import org.apache.nifi.web.api.entity.ReportingTaskEntity; import org.apache.nifi.web.api.entity.ScheduleComponentsEntity; import org.apache.nifi.web.api.entity.SnippetEntity; +import org.apache.nifi.web.api.entity.StartVersionControlRequestEntity; import org.apache.nifi.web.api.entity.StatusHistoryEntity; import org.apache.nifi.web.api.entity.TemplateEntity; import org.apache.nifi.web.api.entity.UserEntity; @@ -111,6 +113,7 @@ import org.apache.nifi.web.api.entity.VariableRegistryEntity; import org.apache.nifi.web.api.entity.VersionControlComponentMappingEntity; import org.apache.nifi.web.api.entity.VersionControlInformationEntity; import org.apache.nifi.web.api.entity.VersionedFlowEntity; +import org.apache.nifi.web.api.entity.VersionedFlowSnapshotMetadataEntity; import java.io.IOException; import java.util.Date; @@ -1300,7 +1303,7 @@ public interface NiFiServiceFacade { * @return a VersionControlComponentMappingEntity that contains the information needed to notify a Process Group where it is tracking to and map * component ID's to their Versioned Component ID's */ - VersionControlComponentMappingEntity registerFlowWithFlowRegistry(String groupId, VersionedFlowEntity requestEntity); + VersionControlComponentMappingEntity registerFlowWithFlowRegistry(String groupId, StartVersionControlRequestEntity requestEntity); /** * Adds the given snapshot to the already existing Versioned Flow, which resides in the given Flow Registry with the given id @@ -1854,7 +1857,7 @@ public interface NiFiServiceFacade { * @param registryDTO The registry DTO * @return The reporting task DTO */ - RegistryEntity createRegistry(Revision revision, RegistryDTO registryDTO); + RegistryEntity createRegistryClient(Revision revision, RegistryDTO registryDTO); /** * Gets a registry with the specified id. @@ -1862,14 +1865,52 @@ public interface NiFiServiceFacade { * @param registryId id * @return entity */ - RegistryEntity getRegistry(String registryId); + RegistryEntity getRegistryClient(String registryId); /** - * Gets all registries. + * Returns all registry clients. * + * @return registry clients + */ + Set<RegistryEntity> getRegistryClients(); + + /** + * Gets all registries for the current user. + * + * @param user current user * @return registries */ - Set<RegistryEntity> getRegistries(); + Set<RegistryEntity> getRegistriesForUser(NiFiUser user); + + /** + * Gets all buckets for a given registry. + * + * @param registryId registry id + * @param user current user + * @return the buckets + */ + Set<BucketEntity> getBucketsForUser(String registryId, NiFiUser user); + + /** + * Gets the flows for the current user for the specified registry and bucket. + * + * @param registryId registry id + * @param bucketId bucket id + * @param user current user + * @return the flows + */ + Set<VersionedFlowEntity> getFlowsForUser(String registryId, String bucketId, NiFiUser user); + + /** + * Gets the versions of the specified registry, bucket, and flow for the current user. + * + * @param registryId registry id + * @param bucketId bucket id + * @param flowId flow id + * @param user current user + * @return the versions of the flow + */ + Set<VersionedFlowSnapshotMetadataEntity> getFlowVersionsForUser(String registryId, String bucketId, String flowId, NiFiUser user); /** * Updates the specified registry using the specified revision. @@ -1878,7 +1919,7 @@ public interface NiFiServiceFacade { * @param registryDTO the registry dto * @return the updated registry registry entity */ - RegistryEntity updateRegistry(Revision revision, RegistryDTO registryDTO); + RegistryEntity updateRegistryClient(Revision revision, RegistryDTO registryDTO); /** * Deletes the specified registry using the specified revision. @@ -1887,7 +1928,14 @@ public interface NiFiServiceFacade { * @param registryId id * @return the deleted registry entity */ - RegistryEntity deleteRegistry(Revision revision, String registryId); + RegistryEntity deleteRegistryClient(Revision revision, String registryId); + + /** + * Verifies the specified registry can be removed. + * + * @param registryId the registry id + */ + void verifyDeleteRegistry(String registryId); // ---------------------------------------- // History methods http://git-wip-us.apache.org/repos/asf/nifi/blob/696d583b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/StandardNiFiServiceFacade.java ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/StandardNiFiServiceFacade.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/StandardNiFiServiceFacade.java index 2b5b5c3..a319f27 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/StandardNiFiServiceFacade.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/StandardNiFiServiceFacade.java @@ -16,32 +16,8 @@ */ package org.apache.nifi.web; -import java.io.IOException; -import java.nio.charset.StandardCharsets; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.Comparator; -import java.util.Date; -import java.util.HashMap; -import java.util.HashSet; -import java.util.LinkedHashMap; -import java.util.LinkedHashSet; -import java.util.List; -import java.util.ListIterator; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; -import java.util.Set; -import java.util.UUID; -import java.util.function.Function; -import java.util.function.Supplier; -import java.util.stream.Collectors; - -import javax.ws.rs.WebApplicationException; -import javax.ws.rs.core.Response; - +import com.google.common.collect.Sets; +import org.apache.commons.collections4.CollectionUtils; import org.apache.nifi.action.Action; import org.apache.nifi.action.Component; import org.apache.nifi.action.FlowChangeAction; @@ -111,15 +87,17 @@ import org.apache.nifi.history.History; import org.apache.nifi.history.HistoryQuery; import org.apache.nifi.history.PreviousValue; import org.apache.nifi.registry.ComponentVariableRegistry; +import org.apache.nifi.registry.bucket.Bucket; import org.apache.nifi.registry.flow.FlowRegistry; import org.apache.nifi.registry.flow.FlowRegistryClient; -import org.apache.nifi.registry.flow.VersionedFlowCoordinates; import org.apache.nifi.registry.flow.UnknownResourceException; import org.apache.nifi.registry.flow.VersionControlInformation; import org.apache.nifi.registry.flow.VersionedComponent; import org.apache.nifi.registry.flow.VersionedConnection; import org.apache.nifi.registry.flow.VersionedFlow; +import org.apache.nifi.registry.flow.VersionedFlowCoordinates; import org.apache.nifi.registry.flow.VersionedFlowSnapshot; +import org.apache.nifi.registry.flow.VersionedFlowSnapshotMetadata; import org.apache.nifi.registry.flow.VersionedProcessGroup; import org.apache.nifi.registry.flow.diff.ComparableDataFlow; import org.apache.nifi.registry.flow.diff.DifferenceType; @@ -144,6 +122,7 @@ import org.apache.nifi.util.NiFiProperties; import org.apache.nifi.web.api.dto.AccessPolicyDTO; import org.apache.nifi.web.api.dto.AccessPolicySummaryDTO; import org.apache.nifi.web.api.dto.AffectedComponentDTO; +import org.apache.nifi.web.api.dto.BucketDTO; import org.apache.nifi.web.api.dto.BulletinBoardDTO; import org.apache.nifi.web.api.dto.BulletinDTO; import org.apache.nifi.web.api.dto.BulletinQueryDTO; @@ -215,6 +194,7 @@ import org.apache.nifi.web.api.entity.AccessPolicySummaryEntity; import org.apache.nifi.web.api.entity.ActionEntity; import org.apache.nifi.web.api.entity.ActivateControllerServicesEntity; import org.apache.nifi.web.api.entity.AffectedComponentEntity; +import org.apache.nifi.web.api.entity.BucketEntity; import org.apache.nifi.web.api.entity.BulletinEntity; import org.apache.nifi.web.api.entity.ComponentReferenceEntity; import org.apache.nifi.web.api.entity.ConnectionEntity; @@ -253,7 +233,9 @@ import org.apache.nifi.web.api.entity.VariableEntity; import org.apache.nifi.web.api.entity.VariableRegistryEntity; import org.apache.nifi.web.api.entity.VersionControlComponentMappingEntity; import org.apache.nifi.web.api.entity.VersionControlInformationEntity; +import org.apache.nifi.web.api.entity.StartVersionControlRequestEntity; import org.apache.nifi.web.api.entity.VersionedFlowEntity; +import org.apache.nifi.web.api.entity.VersionedFlowSnapshotMetadataEntity; import org.apache.nifi.web.controller.ControllerFacade; import org.apache.nifi.web.dao.AccessPolicyDAO; import org.apache.nifi.web.dao.ConnectionDAO; @@ -282,7 +264,30 @@ import org.apache.nifi.web.util.SnippetUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import com.google.common.collect.Sets; +import javax.ws.rs.WebApplicationException; +import javax.ws.rs.core.Response; +import java.io.IOException; +import java.nio.charset.StandardCharsets; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.Comparator; +import java.util.Date; +import java.util.HashMap; +import java.util.HashSet; +import java.util.LinkedHashMap; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.ListIterator; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import java.util.Set; +import java.util.UUID; +import java.util.function.Function; +import java.util.function.Supplier; +import java.util.stream.Collectors; /** * Implementation of NiFiServiceFacade that performs revision checking. @@ -2268,7 +2273,7 @@ public class StandardNiFiServiceFacade implements NiFiServiceFacade { @Override - public RegistryEntity createRegistry(Revision revision, RegistryDTO registryDTO) { + public RegistryEntity createRegistryClient(Revision revision, RegistryDTO registryDTO) { final NiFiUser user = NiFiUserUtils.getNiFiUser(); // read lock on the containing group @@ -2292,7 +2297,7 @@ public class StandardNiFiServiceFacade implements NiFiServiceFacade { } @Override - public RegistryEntity getRegistry(final String registryId) { + public RegistryEntity getRegistryClient(final String registryId) { final FlowRegistry registry = registryDAO.getFlowRegistry(registryId); return createRegistryEntity(registry); } @@ -2319,15 +2324,90 @@ public class StandardNiFiServiceFacade implements NiFiServiceFacade { return entity; } + private BucketEntity createBucketEntity(final Bucket bucket) { + if (bucket == null) { + return null; + } + + final BucketDTO dto = new BucketDTO(); + dto.setId(bucket.getIdentifier()); + dto.setName(bucket.getName()); + dto.setDescription(bucket.getDescription()); + dto.setCreated(bucket.getCreatedTimestamp()); + + final BucketEntity entity = new BucketEntity(); + entity.setBucket(dto); + + return entity; + } + + private VersionedFlowEntity createVersionedFlowEntity(final String registryId, final VersionedFlow versionedFlow) { + if (versionedFlow == null) { + return null; + } + + final VersionedFlowDTO dto = new VersionedFlowDTO(); + dto.setRegistryId(registryId); + dto.setBucketId(versionedFlow.getBucketIdentifier()); + dto.setFlowId(versionedFlow.getIdentifier()); + dto.setFlowName(versionedFlow.getName()); + dto.setDescription(versionedFlow.getDescription()); + + final VersionedFlowEntity entity = new VersionedFlowEntity(); + entity.setVersionedFlow(dto); + + return entity; + } + + private VersionedFlowSnapshotMetadataEntity createVersionedFlowSnapshotMetadataEntity(final String registryId, final VersionedFlowSnapshotMetadata metadata) { + if (metadata == null) { + return null; + } + + final VersionedFlowSnapshotMetadataEntity entity = new VersionedFlowSnapshotMetadataEntity(); + entity.setRegistryId(registryId); + entity.setVersionedFlowMetadata(metadata); + + return entity; + } + @Override - public Set<RegistryEntity> getRegistries() { + public Set<RegistryEntity> getRegistryClients() { return registryDAO.getFlowRegistries().stream() .map(this::createRegistryEntity) .collect(Collectors.toSet()); } @Override - public RegistryEntity updateRegistry(Revision revision, RegistryDTO registryDTO) { + public Set<RegistryEntity> getRegistriesForUser(final NiFiUser user) { + return registryDAO.getFlowRegistriesForUser(user).stream() + .map(this::createRegistryEntity) + .collect(Collectors.toSet()); + } + + @Override + public Set<BucketEntity> getBucketsForUser(final String registryId, final NiFiUser user) { + return registryDAO.getBucketsForUser(registryId, user).stream() + .map(this::createBucketEntity) + .collect(Collectors.toSet()); + } + + @Override + public Set<VersionedFlowEntity> getFlowsForUser(String registryId, String bucketId, NiFiUser user) { + return registryDAO.getFlowsForUser(registryId, bucketId, user).stream() + .map(vf -> createVersionedFlowEntity(registryId, vf)) + .collect(Collectors.toSet()); + } + + @Override + public Set<VersionedFlowSnapshotMetadataEntity> getFlowVersionsForUser(String registryId, String bucketId, String flowId, NiFiUser user) { + return registryDAO.getFlowVersionsForUser(registryId, bucketId, flowId, user).stream() + .map(md -> createVersionedFlowSnapshotMetadataEntity(registryId, md)) + .collect(Collectors.toSet()); + } + + @Override + public RegistryEntity updateRegistryClient(Revision revision, RegistryDTO registryDTO) { final RevisionClaim revisionClaim = new StandardRevisionClaim(revision); final NiFiUser user = NiFiUserUtils.getNiFiUser(); @@ -2350,7 +2430,12 @@ public class StandardNiFiServiceFacade implements NiFiServiceFacade { } @Override - public RegistryEntity deleteRegistry(final Revision revision, final String registryId) { + public void verifyDeleteRegistry(String registryId) { + processGroupDAO.verifyDeleteFlowRegistry(registryId); + } + + @Override + public RegistryEntity deleteRegistryClient(final Revision revision, final String registryId) { final RevisionClaim claim = new StandardRevisionClaim(revision); final NiFiUser user = NiFiUserUtils.getNiFiUser(); @@ -3340,6 +3425,10 @@ public class StandardNiFiServiceFacade implements NiFiServiceFacade { entity.setPoliciesPermissions(dtoFactory.createPermissionsDto(authorizableLookup.getPolicies())); entity.setSystemPermissions(dtoFactory.createPermissionsDto(authorizableLookup.getSystem())); entity.setRestrictedComponentsPermissions(dtoFactory.createPermissionsDto(authorizableLookup.getRestrictedComponents())); + + // TODO - update to be user specific + entity.setCanVersionFlows(CollectionUtils.isNotEmpty(flowRegistryClient.getRegistryIdentifiers())); + return entity; } @@ -3538,7 +3627,7 @@ public class StandardNiFiServiceFacade implements NiFiServiceFacade { } @Override - public VersionControlComponentMappingEntity registerFlowWithFlowRegistry(final String groupId, final VersionedFlowEntity requestEntity) { + public VersionControlComponentMappingEntity registerFlowWithFlowRegistry(final String groupId, final StartVersionControlRequestEntity requestEntity) { // Create a VersionedProcessGroup snapshot of the flow as it is currently. final InstantiatedVersionedProcessGroup versionedProcessGroup = createFlowSnapshot(groupId); @@ -3584,6 +3673,7 @@ public class StandardNiFiServiceFacade implements NiFiServiceFacade { vci.setBucketId(registeredFlow.getBucketIdentifier()); vci.setCurrent(true); vci.setFlowId(registeredFlow.getIdentifier()); + vci.setFlowName(registeredFlow.getName()); vci.setGroupId(groupId); vci.setModified(false); vci.setRegistryId(registryId); http://git-wip-us.apache.org/repos/asf/nifi/blob/696d583b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/ControllerResource.java ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/ControllerResource.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/ControllerResource.java index 959d06d..356d231 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/ControllerResource.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/ControllerResource.java @@ -46,6 +46,7 @@ import org.apache.nifi.web.api.entity.ControllerServiceEntity; import org.apache.nifi.web.api.entity.Entity; import org.apache.nifi.web.api.entity.HistoryEntity; import org.apache.nifi.web.api.entity.NodeEntity; +import org.apache.nifi.web.api.entity.RegistriesEntity; import org.apache.nifi.web.api.entity.RegistryEntity; import org.apache.nifi.web.api.entity.ReportingTaskEntity; import org.apache.nifi.web.api.request.ClientIdParameter; @@ -69,6 +70,7 @@ import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import java.net.URI; import java.util.Date; +import java.util.Set; /** * RESTful endpoint for managing a Flow Controller. @@ -93,7 +95,7 @@ public class ControllerResource extends ApplicationResource { * @return dtos */ public RegistryEntity populateRemainingRegistryEntityContent(final RegistryEntity registryEntity) { - registryEntity.setUri(generateResourceUri("controller", "registries", registryEntity.getId())); + registryEntity.setUri(generateResourceUri("controller", "registry-clients", registryEntity.getId())); return registryEntity; } @@ -310,6 +312,36 @@ public class ControllerResource extends ApplicationResource { // registries // ---------- + @GET + @Consumes(MediaType.WILDCARD) + @Produces(MediaType.APPLICATION_JSON) + @Path("registry-clients") + @ApiOperation(value = "Gets the listing of available registry clients", response = RegistriesEntity.class, authorizations = { + @Authorization(value = "Read - /flow") + }) + @ApiResponses(value = { + @ApiResponse(code = 400, message = "NiFi was unable to complete the request because it was invalid. The request should not be retried without modification."), + @ApiResponse(code = 401, message = "Client could not be authenticated."), + @ApiResponse(code = 403, message = "Client is not authorized to make this request."), + @ApiResponse(code = 404, message = "The specified resource could not be found."), + @ApiResponse(code = 409, message = "The request was valid but NiFi was not in the appropriate state to process it. Retrying the same request later may be successful.") + }) + public Response getRegistryClients() { + authorizeController(RequestAction.READ); + + if (isReplicateRequest()) { + return replicate(HttpMethod.GET); + } + + final Set<RegistryEntity> registries = serviceFacade.getRegistryClients(); + registries.forEach(registry -> populateRemainingRegistryEntityContent(registry)); + + final RegistriesEntity registryEntities = new RegistriesEntity(); + registryEntities.setRegistries(registries); + + return generateOkResponse(registryEntities).build(); + } + /** * Creates a new Registry. * @@ -320,9 +352,9 @@ public class ControllerResource extends ApplicationResource { @POST @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) - @Path("registries") + @Path("registry-clients") @ApiOperation( - value = "Creates a new registry", + value = "Creates a new registry client", response = RegistryEntity.class, authorizations = { @Authorization(value = "Write - /controller") @@ -336,8 +368,7 @@ public class ControllerResource extends ApplicationResource { @ApiResponse(code = 409, message = "The request was valid but NiFi was not in the appropriate state to process it. Retrying the same request later may be successful.") } ) - - public Response createRegistry( + public Response createRegistryClient( @Context final HttpServletRequest httpServletRequest, @ApiParam( value = "The registry configuration details.", @@ -376,7 +407,7 @@ public class ControllerResource extends ApplicationResource { // create the reporting task and generate the json final Revision revision = getRevision(registryEntity, registry.getId()); - final RegistryEntity entity = serviceFacade.createRegistry(revision, registry); + final RegistryEntity entity = serviceFacade.createRegistryClient(revision, registry); populateRemainingRegistryEntityContent(entity); // build the response @@ -394,9 +425,9 @@ public class ControllerResource extends ApplicationResource { @GET @Consumes(MediaType.WILDCARD) @Produces(MediaType.APPLICATION_JSON) - @Path("/registries/{id}") + @Path("/registry-clients/{id}") @ApiOperation( - value = "Gets a registry", + value = "Gets a registry client", response = RegistryEntity.class, authorizations = { @Authorization(value = "Read - /controller") @@ -426,7 +457,7 @@ public class ControllerResource extends ApplicationResource { authorizeController(RequestAction.READ); // get the registry - final RegistryEntity entity = serviceFacade.getRegistry(id); + final RegistryEntity entity = serviceFacade.getRegistryClient(id); populateRemainingRegistryEntityContent(entity); return generateOkResponse(entity).build(); @@ -443,9 +474,9 @@ public class ControllerResource extends ApplicationResource { @PUT @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) - @Path("/registries/{id}") + @Path("/registry-clients/{id}") @ApiOperation( - value = "Updates a registry", + value = "Updates a registry client", response = RegistryEntity.class, authorizations = { @Authorization(value = "Write - /controller") @@ -460,7 +491,7 @@ public class ControllerResource extends ApplicationResource { @ApiResponse(code = 409, message = "The request was valid but NiFi was not in the appropriate state to process it. Retrying the same request later may be successful.") } ) - public Response updateControllerService( + public Response updateRegistryClient( @Context HttpServletRequest httpServletRequest, @ApiParam( value = "The registry id.", @@ -505,7 +536,7 @@ public class ControllerResource extends ApplicationResource { final RegistryDTO registry = registryEntity.getComponent(); // update the controller service - final RegistryEntity entity = serviceFacade.updateRegistry(revision, registry); + final RegistryEntity entity = serviceFacade.updateRegistryClient(revision, registry); populateRemainingRegistryEntityContent(entity); return generateOkResponse(entity).build(); @@ -528,9 +559,9 @@ public class ControllerResource extends ApplicationResource { @DELETE @Consumes(MediaType.WILDCARD) @Produces(MediaType.APPLICATION_JSON) - @Path("/registries/{id}") + @Path("/registry-clients/{id}") @ApiOperation( - value = "Deletes a reistry", + value = "Deletes a registry client", response = RegistryEntity.class, authorizations = { @Authorization(value = "Write - /controller") @@ -545,7 +576,7 @@ public class ControllerResource extends ApplicationResource { @ApiResponse(code = 409, message = "The request was valid but NiFi was not in the appropriate state to process it. Retrying the same request later may be successful.") } ) - public Response deleteRegistry( + public Response deleteRegistryClient( @Context HttpServletRequest httpServletRequest, @ApiParam( value = "The revision is used to verify the client is working with the latest version of the flow.", @@ -579,10 +610,10 @@ public class ControllerResource extends ApplicationResource { lookup -> { authorizeController(RequestAction.WRITE); }, - null, + () -> serviceFacade.verifyDeleteRegistry(id), (revision, registryEntity) -> { // delete the specified registry - final RegistryEntity entity = serviceFacade.deleteRegistry(revision, registryEntity.getId()); + final RegistryEntity entity = serviceFacade.deleteRegistryClient(revision, registryEntity.getId()); return generateOkResponse(entity).build(); } ); http://git-wip-us.apache.org/repos/asf/nifi/blob/696d583b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/FlowResource.java ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/FlowResource.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/FlowResource.java index 3e9be6d..b8bdc14 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/FlowResource.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/FlowResource.java @@ -39,18 +39,13 @@ import org.apache.nifi.controller.service.ControllerServiceNode; import org.apache.nifi.controller.service.ControllerServiceState; import org.apache.nifi.groups.ProcessGroup; import org.apache.nifi.nar.NarClassLoaders; -import org.apache.nifi.registry.bucket.Bucket; -import org.apache.nifi.registry.flow.FlowRegistry; -import org.apache.nifi.registry.flow.FlowRegistryClient; import org.apache.nifi.util.NiFiProperties; import org.apache.nifi.web.IllegalClusterResourceRequestException; -import org.apache.nifi.web.NiFiCoreException; import org.apache.nifi.web.NiFiServiceFacade; import org.apache.nifi.web.ResourceNotFoundException; import org.apache.nifi.web.Revision; import org.apache.nifi.web.api.dto.AboutDTO; import org.apache.nifi.web.api.dto.BannerDTO; -import org.apache.nifi.web.api.dto.BucketDTO; import org.apache.nifi.web.api.dto.BulletinBoardDTO; import org.apache.nifi.web.api.dto.BulletinQueryDTO; import org.apache.nifi.web.api.dto.ClusterDTO; @@ -102,6 +97,10 @@ import org.apache.nifi.web.api.entity.SearchResultsEntity; import org.apache.nifi.web.api.entity.StatusHistoryEntity; import org.apache.nifi.web.api.entity.TemplateEntity; import org.apache.nifi.web.api.entity.TemplatesEntity; +import org.apache.nifi.web.api.entity.VersionedFlowEntity; +import org.apache.nifi.web.api.entity.VersionedFlowSnapshotMetadataEntity; +import org.apache.nifi.web.api.entity.VersionedFlowSnapshotMetadataSetEntity; +import org.apache.nifi.web.api.entity.VersionedFlowsEntity; import org.apache.nifi.web.api.request.BulletinBoardPatternParameter; import org.apache.nifi.web.api.request.DateTimeParameter; import org.apache.nifi.web.api.request.IntegerParameter; @@ -121,7 +120,6 @@ import javax.ws.rs.WebApplicationException; import javax.ws.rs.core.Context; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; -import java.io.IOException; import java.util.ArrayList; import java.util.Date; import java.util.EnumSet; @@ -158,11 +156,8 @@ public class FlowResource extends ApplicationResource { private TemplateResource templateResource; private ProcessGroupResource processGroupResource; private ControllerServiceResource controllerServiceResource; - private ControllerResource controllerResource; private ReportingTaskResource reportingTaskResource; - private FlowRegistryClient flowRegistryClient; - public FlowResource() { super(); } @@ -1351,12 +1346,7 @@ public class FlowResource extends ApplicationResource { public Response getRegistries() { authorizeFlow(); - if (isReplicateRequest()) { - return replicate(HttpMethod.GET); - } - - final Set<RegistryEntity> registries = serviceFacade.getRegistries(); - registries.forEach(registry -> controllerResource.populateRemainingRegistryEntityContent(registry)); + final Set<RegistryEntity> registries = serviceFacade.getRegistriesForUser(NiFiUserUtils.getNiFiUser()); final RegistriesEntity registryEntities = new RegistriesEntity(); registryEntities.setRegistries(registries); @@ -1387,39 +1377,89 @@ public class FlowResource extends ApplicationResource { authorizeFlow(); - try { - final FlowRegistry flowRegistry = flowRegistryClient.getFlowRegistry(id); - if (flowRegistry == null) { - throw new IllegalArgumentException("The specified registry id is unknown to this NiFi."); - } + final Set<BucketEntity> buckets = serviceFacade.getBucketsForUser(id, NiFiUserUtils.getNiFiUser()); - final Set<Bucket> userBuckets = flowRegistry.getBuckets(NiFiUserUtils.getNiFiUser()); + final BucketsEntity bucketsEntity = new BucketsEntity(); + bucketsEntity.setBuckets(buckets); - final BucketsEntity bucketsEntity = new BucketsEntity(); + return generateOkResponse(bucketsEntity).build(); + } - if (userBuckets != null) { + @GET + @Consumes(MediaType.WILDCARD) + @Produces(MediaType.APPLICATION_JSON) + @Path("registries/{registry-id}/buckets/{bucket-id}/flows") + @ApiOperation(value = "Gets the flows from the specified registry and bucket for the current user", response = BucketsEntity.class, authorizations = { + @Authorization(value = "Read - /flow") + }) + @ApiResponses(value = { + @ApiResponse(code = 400, message = "NiFi was unable to complete the request because it was invalid. The request should not be retried without modification."), + @ApiResponse(code = 401, message = "Client could not be authenticated."), + @ApiResponse(code = 403, message = "Client is not authorized to make this request."), + @ApiResponse(code = 404, message = "The specified resource could not be found."), + @ApiResponse(code = 409, message = "The request was valid but NiFi was not in the appropriate state to process it. Retrying the same request later may be successful.") + }) + public Response getFlows( + @ApiParam( + value = "The registry id.", + required = true + ) + @PathParam("registry-id") String registryId, + @ApiParam( + value = "The bucket id.", + required = true + ) + @PathParam("bucket-id") String bucketId) { - final Set<BucketEntity> bucketSet = new HashSet<>(); - for (final Bucket userBucket : userBuckets) { - final BucketDTO bucket = new BucketDTO(); - bucket.setId(userBucket.getIdentifier()); - bucket.setName(userBucket.getName()); - bucket.setDescription(userBucket.getDescription()); - bucket.setCreated(userBucket.getCreatedTimestamp()); + authorizeFlow(); - final BucketEntity bucketEntity = new BucketEntity(); - bucketEntity.setBucket(bucket); + final Set<VersionedFlowEntity> versionedFlows = serviceFacade.getFlowsForUser(registryId, bucketId, NiFiUserUtils.getNiFiUser()); - bucketSet.add(bucketEntity); - } + final VersionedFlowsEntity versionedFlowsEntity = new VersionedFlowsEntity(); + versionedFlowsEntity.setVersionedFlows(versionedFlows); - bucketsEntity.setBuckets(bucketSet); - } + return generateOkResponse(versionedFlowsEntity).build(); + } - return generateOkResponse(bucketsEntity).build(); - } catch (final IOException ioe) { - throw new NiFiCoreException("Unable to obtain bucket listing: " + ioe.getMessage(), ioe); - } + @GET + @Consumes(MediaType.WILDCARD) + @Produces(MediaType.APPLICATION_JSON) + @Path("registries/{registry-id}/buckets/{bucket-id}/flows/{flow-id}/versions") + @ApiOperation(value = "Gets the flow versions from the specified registry and bucket for the specified flow for the current user", response = BucketsEntity.class, authorizations = { + @Authorization(value = "Read - /flow") + }) + @ApiResponses(value = { + @ApiResponse(code = 400, message = "NiFi was unable to complete the request because it was invalid. The request should not be retried without modification."), + @ApiResponse(code = 401, message = "Client could not be authenticated."), + @ApiResponse(code = 403, message = "Client is not authorized to make this request."), + @ApiResponse(code = 404, message = "The specified resource could not be found."), + @ApiResponse(code = 409, message = "The request was valid but NiFi was not in the appropriate state to process it. Retrying the same request later may be successful.") + }) + public Response getVersions( + @ApiParam( + value = "The registry id.", + required = true + ) + @PathParam("registry-id") String registryId, + @ApiParam( + value = "The bucket id.", + required = true + ) + @PathParam("bucket-id") String bucketId, + @ApiParam( + value = "The flow id.", + required = true + ) + @PathParam("flow-id") String flowId) { + + authorizeFlow(); + + final Set<VersionedFlowSnapshotMetadataEntity> versionedFlowSnapshotMetadataSet = serviceFacade.getFlowVersionsForUser(registryId, bucketId, flowId, NiFiUserUtils.getNiFiUser()); + + final VersionedFlowSnapshotMetadataSetEntity versionedFlowSnapshotMetadataSetEntity = new VersionedFlowSnapshotMetadataSetEntity(); + versionedFlowSnapshotMetadataSetEntity.setVersionedFlowSnapshotMetadataSet(versionedFlowSnapshotMetadataSet); + + return generateOkResponse(versionedFlowSnapshotMetadataSetEntity).build(); } // -------------- @@ -2629,10 +2669,6 @@ public class FlowResource extends ApplicationResource { this.processGroupResource = processGroupResource; } - public void setControllerResource(ControllerResource controllerResource) { - this.controllerResource = controllerResource; - } - public void setControllerServiceResource(ControllerServiceResource controllerServiceResource) { this.controllerServiceResource = controllerServiceResource; } @@ -2644,8 +2680,4 @@ public class FlowResource extends ApplicationResource { public void setAuthorizer(Authorizer authorizer) { this.authorizer = authorizer; } - - public void setFlowRegistryClient(FlowRegistryClient flowRegistryClient) { - this.flowRegistryClient = flowRegistryClient; - } } http://git-wip-us.apache.org/repos/asf/nifi/blob/696d583b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/VersionsResource.java ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/VersionsResource.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/VersionsResource.java index 27216a4..b010bf3 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/VersionsResource.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/VersionsResource.java @@ -17,39 +17,12 @@ package org.apache.nifi.web.api; -import java.io.IOException; -import java.net.URI; -import java.net.URISyntaxException; -import java.util.Collections; -import java.util.Date; -import java.util.HashMap; -import java.util.HashSet; -import java.util.LinkedHashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.UUID; -import java.util.concurrent.TimeUnit; -import java.util.function.Consumer; -import java.util.function.Function; -import java.util.stream.Collectors; - -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.DefaultValue; -import javax.ws.rs.GET; -import javax.ws.rs.HttpMethod; -import javax.ws.rs.POST; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.MultivaluedHashMap; -import javax.ws.rs.core.Response; -import javax.ws.rs.core.Response.Status; - +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import io.swagger.annotations.ApiResponse; +import io.swagger.annotations.ApiResponses; +import io.swagger.annotations.Authorization; import org.apache.commons.lang3.StringUtils; import org.apache.nifi.authorization.AuthorizableLookup; import org.apache.nifi.authorization.Authorizer; @@ -58,6 +31,7 @@ import org.apache.nifi.authorization.resource.Authorizable; import org.apache.nifi.authorization.user.NiFiUser; import org.apache.nifi.authorization.user.NiFiUserUtils; import org.apache.nifi.cluster.manager.NodeResponse; +import org.apache.nifi.controller.FlowController; import org.apache.nifi.controller.ScheduledState; import org.apache.nifi.controller.service.ControllerServiceState; import org.apache.nifi.registry.flow.ComponentType; @@ -83,7 +57,7 @@ import org.apache.nifi.web.api.entity.AffectedComponentEntity; import org.apache.nifi.web.api.entity.ProcessGroupEntity; import org.apache.nifi.web.api.entity.VersionControlComponentMappingEntity; import org.apache.nifi.web.api.entity.VersionControlInformationEntity; -import org.apache.nifi.web.api.entity.VersionedFlowEntity; +import org.apache.nifi.web.api.entity.StartVersionControlRequestEntity; import org.apache.nifi.web.api.entity.VersionedFlowSnapshotEntity; import org.apache.nifi.web.api.entity.VersionedFlowUpdateRequestEntity; import org.apache.nifi.web.api.request.ClientIdParameter; @@ -96,12 +70,37 @@ import org.apache.nifi.web.util.Pause; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import io.swagger.annotations.ApiParam; -import io.swagger.annotations.ApiResponse; -import io.swagger.annotations.ApiResponses; -import io.swagger.annotations.Authorization; +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.DefaultValue; +import javax.ws.rs.GET; +import javax.ws.rs.HttpMethod; +import javax.ws.rs.POST; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.MultivaluedHashMap; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.Response.Status; +import java.io.IOException; +import java.net.URI; +import java.net.URISyntaxException; +import java.util.Collections; +import java.util.Date; +import java.util.HashMap; +import java.util.HashSet; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.UUID; +import java.util.concurrent.TimeUnit; +import java.util.function.Consumer; +import java.util.function.Function; +import java.util.stream.Collectors; @Path("/versions") @Api(value = "/versions", description = "Endpoint for managing version control for a flow") @@ -368,7 +367,7 @@ public class VersionsResource extends ApplicationResource { }) public Response startVersionControl( @ApiParam("The process group id.") @PathParam("id") final String groupId, - @ApiParam(value = "The versioned flow details.", required = true) final VersionedFlowEntity requestEntity) throws IOException { + @ApiParam(value = "The versioned flow details.", required = true) final StartVersionControlRequestEntity requestEntity) throws IOException { // Verify the request final RevisionDTO revisionDto = requestEntity.getProcessGroupRevision(); @@ -390,6 +389,12 @@ public class VersionsResource extends ApplicationResource { throw new IllegalArgumentException("The Registry ID must be supplied."); } + // ensure we're not attempting to version the root group + final ProcessGroupEntity root = serviceFacade.getProcessGroup(FlowController.ROOT_GROUP_ID_ALIAS); + if (root.getId().equals(groupId)) { + throw new IllegalArgumentException("The Root Process Group cannot be versioned."); + } + if (isReplicateRequest()) { // We first have to obtain a "lock" on all nodes in the cluster so that multiple Version Control requests // are not being made simultaneously. We do this by making a POST to /nifi-api/versions/start-requests. @@ -688,6 +693,7 @@ public class VersionsResource extends ApplicationResource { versionControlInfoDto.setBucketId(snapshotMetadata.getBucketIdentifier()); versionControlInfoDto.setCurrent(true); versionControlInfoDto.setFlowId(snapshotMetadata.getFlowIdentifier()); + versionControlInfoDto.setFlowName(snapshotMetadata.getFlowName()); versionControlInfoDto.setGroupId(groupId); versionControlInfoDto.setModified(false); versionControlInfoDto.setVersion(snapshotMetadata.getVersion()); @@ -1139,12 +1145,13 @@ public class VersionsResource extends ApplicationResource { updateRequestDto.setLastUpdated(new Date()); updateRequestDto.setProcessGroupId(groupId); updateRequestDto.setRequestId(requestId); - updateRequestDto.setUri(generateResourceUri("versions", "update-requests", requestId)); + updateRequestDto.setUri(generateResourceUri("versions", "revert-requests", requestId)); final VersionedFlowUpdateRequestEntity updateRequestEntity = new VersionedFlowUpdateRequestEntity(); updateRequestEntity.setProcessGroupRevision(revisionDto); updateRequestEntity.setRequest(updateRequestDto); + request.markComplete(currentVersionEntity); return generateOkResponse(updateRequestEntity).build(); } http://git-wip-us.apache.org/repos/asf/nifi/blob/696d583b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/dto/DtoFactory.java ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/dto/DtoFactory.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/dto/DtoFactory.java index 8e0f0c7..3639b18 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/dto/DtoFactory.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/dto/DtoFactory.java @@ -16,7 +16,6 @@ */ package org.apache.nifi.web.api.dto; -import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.ClassUtils; import org.apache.commons.lang3.StringUtils; import org.apache.nifi.action.Action; @@ -245,7 +244,6 @@ public final class DtoFactory { dto.setSupportsManagedAuthorizer(AuthorizerCapabilityDetection.isManagedAuthorizer(authorizer)); dto.setSupportsConfigurableUsersAndGroups(AuthorizerCapabilityDetection.isConfigurableUserGroupProvider(authorizer)); dto.setSupportsConfigurableAuthorizer(AuthorizerCapabilityDetection.isConfigurableAccessPolicyProvider(authorizer)); - dto.setSupportsFlowVersioning(CollectionUtils.isNotEmpty(flowRegistryClient.getRegistryIdentifiers())); final Date now = new Date(); dto.setTimeOffset(TimeZone.getDefault().getOffset(now.getTime())); @@ -2191,6 +2189,8 @@ public final class DtoFactory { dto.setRegistryId(versionControlInfo.getRegistryIdentifier()); dto.setBucketId(versionControlInfo.getBucketIdentifier()); dto.setFlowId(versionControlInfo.getFlowIdentifier()); + // TODO - need to get flow name here + dto.setFlowName(group.getName()); dto.setVersion(versionControlInfo.getVersion()); dto.setCurrent(versionControlInfo.getCurrent().orElse(null)); dto.setModified(versionControlInfo.getModified().orElse(null)); @@ -3409,6 +3409,7 @@ public final class DtoFactory { copy.setRegistryId(original.getRegistryId()); copy.setBucketId(original.getBucketId()); copy.setFlowId(original.getFlowId()); + copy.setFlowName(original.getFlowName()); copy.setVersion(original.getVersion()); copy.setCurrent(original.getCurrent()); copy.setModified(original.getModified()); http://git-wip-us.apache.org/repos/asf/nifi/blob/696d583b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/dao/ProcessGroupDAO.java ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/dao/ProcessGroupDAO.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/dao/ProcessGroupDAO.java index 650d4b3..7cf61ea 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/dao/ProcessGroupDAO.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/dao/ProcessGroupDAO.java @@ -159,6 +159,13 @@ public interface ProcessGroupDAO { void verifyDelete(String groupId); /** + * Verifies the specified registry can be removed. + * + * @param registryId registry id + */ + void verifyDeleteFlowRegistry(String registryId); + + /** * Deletes the specified process group. * * @param groupId The process group id http://git-wip-us.apache.org/repos/asf/nifi/blob/696d583b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/dao/RegistryDAO.java ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/dao/RegistryDAO.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/dao/RegistryDAO.java index 83b5c6d..8c22ff4 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/dao/RegistryDAO.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/dao/RegistryDAO.java @@ -17,11 +17,15 @@ package org.apache.nifi.web.dao; -import java.util.Set; - +import org.apache.nifi.authorization.user.NiFiUser; +import org.apache.nifi.registry.bucket.Bucket; import org.apache.nifi.registry.flow.FlowRegistry; +import org.apache.nifi.registry.flow.VersionedFlow; +import org.apache.nifi.registry.flow.VersionedFlowSnapshotMetadata; import org.apache.nifi.web.api.dto.RegistryDTO; +import java.util.Set; + public interface RegistryDAO { FlowRegistry createFlowRegistry(RegistryDTO registryDto); @@ -30,6 +34,14 @@ public interface RegistryDAO { Set<FlowRegistry> getFlowRegistries(); + Set<FlowRegistry> getFlowRegistriesForUser(NiFiUser user); + + Set<Bucket> getBucketsForUser(String registry, NiFiUser user); + + Set<VersionedFlow> getFlowsForUser(String registryId, String bucketId, NiFiUser user); + + Set<VersionedFlowSnapshotMetadata> getFlowVersionsForUser(String registryId, String bucketId, String flowId, NiFiUser user); + FlowRegistry removeFlowRegistry(String registryId); } http://git-wip-us.apache.org/repos/asf/nifi/blob/696d583b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/dao/impl/FlowRegistryDAO.java ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/dao/impl/FlowRegistryDAO.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/dao/impl/FlowRegistryDAO.java index eb2ac76..19f2de4 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/dao/impl/FlowRegistryDAO.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/dao/impl/FlowRegistryDAO.java @@ -17,15 +17,21 @@ package org.apache.nifi.web.dao.impl; -import java.util.Set; -import java.util.stream.Collectors; - +import org.apache.nifi.authorization.user.NiFiUser; +import org.apache.nifi.registry.bucket.Bucket; import org.apache.nifi.registry.flow.FlowRegistry; import org.apache.nifi.registry.flow.FlowRegistryClient; +import org.apache.nifi.registry.flow.VersionedFlow; +import org.apache.nifi.registry.flow.VersionedFlowSnapshotMetadata; +import org.apache.nifi.web.NiFiCoreException; import org.apache.nifi.web.ResourceNotFoundException; import org.apache.nifi.web.api.dto.RegistryDTO; import org.apache.nifi.web.dao.RegistryDAO; +import java.io.IOException; +import java.util.Set; +import java.util.stream.Collectors; + public class FlowRegistryDAO implements RegistryDAO { private FlowRegistryClient flowRegistryClient; @@ -52,6 +58,53 @@ public class FlowRegistryDAO implements RegistryDAO { } @Override + public Set<FlowRegistry> getFlowRegistriesForUser(final NiFiUser user) { + // TODO - implement to be user specific + return getFlowRegistries(); + } + + @Override + public Set<Bucket> getBucketsForUser(final String registryId, final NiFiUser user) { + try { + final FlowRegistry flowRegistry = flowRegistryClient.getFlowRegistry(registryId); + if (flowRegistry == null) { + throw new IllegalArgumentException("The specified registry id is unknown to this NiFi."); + } + + return flowRegistry.getBuckets(user); + } catch (final IOException ioe) { + throw new NiFiCoreException("Unable to obtain bucket listing: " + ioe.getMessage(), ioe); + } + } + + + @Override + public Set<VersionedFlow> getFlowsForUser(String registryId, String bucketId, NiFiUser user) { + final Set<Bucket> bucketsForUser = getBucketsForUser(registryId, user); + + // TODO - implement getBucket(bucketId, user) + final Bucket bucket = bucketsForUser.stream().filter(b -> b.getIdentifier().equals(bucketId)).findFirst().orElse(null); + if (bucket == null) { + throw new IllegalArgumentException("The specified bucket is not available."); + } + + return bucket.getVersionedFlows(); + } + + @Override + public Set<VersionedFlowSnapshotMetadata> getFlowVersionsForUser(String registryId, String bucketId, String flowId, NiFiUser user) { + final Set<VersionedFlow> flowsForUser = getFlowsForUser(registryId, bucketId, user); + + // TODO - implement getFlow(bucketId, flowId, user) + final VersionedFlow versionedFlow = flowsForUser.stream().filter(vf -> vf.getIdentifier().equals(flowId)).findFirst().orElse(null); + if (versionedFlow == null) { + throw new IllegalArgumentException("The specified flow is not available."); + } + + return versionedFlow.getSnapshotMetadata(); + } + + @Override public FlowRegistry removeFlowRegistry(final String registryId) { final FlowRegistry registry = flowRegistryClient.removeFlowRegistry(registryId); if (registry == null) { http://git-wip-us.apache.org/repos/asf/nifi/blob/696d583b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/dao/impl/StandardProcessGroupDAO.java ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/dao/impl/StandardProcessGroupDAO.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/dao/impl/StandardProcessGroupDAO.java index 7828337..963220e 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/dao/impl/StandardProcessGroupDAO.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/dao/impl/StandardProcessGroupDAO.java @@ -39,9 +39,11 @@ import org.apache.nifi.web.dao.ProcessGroupDAO; import java.util.Collections; import java.util.HashMap; import java.util.Map; +import java.util.Objects; import java.util.Set; import java.util.concurrent.CompletableFuture; import java.util.concurrent.Future; +import java.util.stream.Collectors; public class StandardProcessGroupDAO extends ComponentDAO implements ProcessGroupDAO { @@ -295,6 +297,26 @@ public class StandardProcessGroupDAO extends ComponentDAO implements ProcessGrou } @Override + public void verifyDeleteFlowRegistry(String registryId) { + final ProcessGroup rootGroup = flowController.getRootGroup(); + + final VersionControlInformation versionControlInformation = rootGroup.getVersionControlInformation(); + if (versionControlInformation != null && versionControlInformation.getRegistryIdentifier().equals(registryId)) { + throw new IllegalStateException("The Registry cannot be removed because a Process Group currently under version control is tracking to it."); + } + + final Set<VersionControlInformation> trackedVersionControlInformation = rootGroup.findAllProcessGroups().stream() + .map(group -> group.getVersionControlInformation()) + .filter(Objects::nonNull) + .filter(vci -> vci.getRegistryIdentifier().equals(registryId)) + .collect(Collectors.toSet()); + + if (!trackedVersionControlInformation.isEmpty()) { + throw new IllegalStateException("The Registry cannot be removed because a Process Group currently under version control is tracking to it."); + } + } + + @Override public void deleteProcessGroup(String processGroupId) { // get the group ProcessGroup group = locateProcessGroup(flowController, processGroupId); http://git-wip-us.apache.org/repos/asf/nifi/blob/696d583b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/resources/nifi-web-api-context.xml ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/resources/nifi-web-api-context.xml b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/resources/nifi-web-api-context.xml index e71de67..43843ef 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/resources/nifi-web-api-context.xml +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/resources/nifi-web-api-context.xml @@ -213,7 +213,6 @@ <property name="remoteProcessGroupResource" ref="remoteProcessGroupResource"/> <property name="connectionResource" ref="connectionResource"/> <property name="templateResource" ref="templateResource"/> - <property name="controllerResource" ref="controllerResource"/> <property name="controllerServiceResource" ref="controllerServiceResource"/> <property name="reportingTaskResource" ref="reportingTaskResource"/> <property name="processGroupResource" ref="processGroupResource"/> @@ -221,7 +220,6 @@ <property name="clusterCoordinator" ref="clusterCoordinator"/> <property name="requestReplicator" ref="requestReplicator" /> <property name="flowController" ref="flowController" /> - <property name="flowRegistryClient" ref="flowRegistryClient" /> </bean> <bean id="resourceResource" class="org.apache.nifi.web.api.ResourceResource" scope="singleton"> <property name="serviceFacade" ref="serviceFacade"/> http://git-wip-us.apache.org/repos/asf/nifi/blob/696d583b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/pages/canvas.jsp ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/pages/canvas.jsp b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/pages/canvas.jsp index c57b76f..258bdad 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/pages/canvas.jsp +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/pages/canvas.jsp @@ -116,6 +116,7 @@ <jsp:include page="/WEB-INF/partials/canvas/fill-color-dialog.jsp"/> <jsp:include page="/WEB-INF/partials/canvas/connections-dialog.jsp"/> <jsp:include page="/WEB-INF/partials/canvas/save-flow-version-dialog.jsp"/> + <jsp:include page="/WEB-INF/partials/canvas/import-flow-version-dialog.jsp"/> <jsp:include page="/WEB-INF/partials/canvas/registry-configuration-dialog.jsp"/> <div id="canvas-container" class="unselectable"></div> <div id="canvas-tooltips"> http://git-wip-us.apache.org/repos/asf/nifi/blob/696d583b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/partials/canvas/import-flow-version-dialog.jsp ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/partials/canvas/import-flow-version-dialog.jsp b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/partials/canvas/import-flow-version-dialog.jsp new file mode 100644 index 0000000..5169c7c --- /dev/null +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/partials/canvas/import-flow-version-dialog.jsp @@ -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. +--%> +<%@ page contentType="text/html" pageEncoding="UTF-8" session="false" %> +<div id="import-flow-version-dialog" layout="column" class="hidden large-dialog"> + <div class="dialog-content"> + <div class="setting"> + <div class="setting-name">Registry</div> + <div class="setting-field"> + <div id="import-flow-version-registry-combo"></div> + <div id="import-flow-version-registry" class="hidden"></div> + </div> + </div> + <div class="setting"> + <div class="setting-name">Location</div> + <div class="setting-field"> + <div id="import-flow-version-bucket-combo"></div> + <div id="import-flow-version-bucket" class="hidden"></div> + </div> + </div> + <div class="setting"> + <div class="setting-name">Name</div> + <div class="setting-field"> + <span id="import-flow-version-process-group-id" class="hidden"></span> + <div id="import-flow-version-name-combo"></div> + <div id="import-flow-version-name" class="hidden"></div> + </div> + </div> + <div id="import-flow-version-table"></div> + </div> +</div> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/nifi/blob/696d583b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/partials/canvas/navigation.jsp ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/partials/canvas/navigation.jsp b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/partials/canvas/navigation.jsp index 0732b3d..86f4ba3 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/partials/canvas/navigation.jsp +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/partials/canvas/navigation.jsp @@ -128,13 +128,13 @@ <div class="button-spacer-large"> </div> <div id="operate-template" class="action-button" title="Create Template"> <button ng-click="appCtrl.nf.Actions['template'](appCtrl.nf.CanvasUtils.getSelection());" - ng-disabled="!(appCtrl.nf.CanvasUtils.canWrite() && (appCtrl.nf.CanvasUtils.getSelection().empty() || appCtrl.nf.CanvasUtils.canRead(appCtrl.nf.CanvasUtils.getSelection())));"> + ng-disabled="!(appCtrl.nf.CanvasUtils.canWriteCurrentGroup() && (appCtrl.nf.CanvasUtils.getSelection().empty() || appCtrl.nf.CanvasUtils.canRead(appCtrl.nf.CanvasUtils.getSelection())));"> <div class="graph-control-action-icon icon icon-template-save"></div></button> </div> <div class="button-spacer-small"> </div> <div id="operate-template-upload" class="action-button" title="Upload Template"> <button ng-click="appCtrl.nf.Actions['uploadTemplate']();" - ng-disabled="!(appCtrl.nf.CanvasUtils.canWrite() && appCtrl.nf.CanvasUtils.getSelection().empty());"> + ng-disabled="!(appCtrl.nf.CanvasUtils.canWriteCurrentGroup() && appCtrl.nf.CanvasUtils.getSelection().empty());"> <div class="graph-control-action-icon icon icon-template-import"></div></button> </div> <div class="clear"></div> http://git-wip-us.apache.org/repos/asf/nifi/blob/696d583b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/partials/canvas/new-process-group-dialog.jsp ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/partials/canvas/new-process-group-dialog.jsp b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/partials/canvas/new-process-group-dialog.jsp index cb538c6..3f1b6a0 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/partials/canvas/new-process-group-dialog.jsp +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/WEB-INF/partials/canvas/new-process-group-dialog.jsp @@ -23,5 +23,8 @@ <input id="new-process-group-name" type="text"/> </div> </div> + <div class="setting"> + <span id="import-process-group-link" class="link"><i class="fa fa-cloud-download" aria-hidden="true" style="margin-left: 5px; margin-right: 5px;"></i>Import version...</span> + </div> </div> </div> \ No newline at end of file
