[
https://issues.apache.org/jira/browse/NIFI-1781?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15296647#comment-15296647
]
ASF GitHub Bot commented on NIFI-1781:
--------------------------------------
Github user mcgilman commented on a diff in the pull request:
https://github.com/apache/nifi/pull/461#discussion_r64250889
--- Diff:
nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/StandardNiFiServiceFacade.java
---
@@ -568,164 +699,50 @@ public void verifyDeleteReportingTask(String
reportingTaskId) {
@Override
- public void verifyUpdateSnippet(SnippetDTO snippetDto) {
+ public void verifyUpdateSnippet(SnippetDTO snippetDto, final
Set<String> affectedComponentIds) {
try {
// if snippet does not exist, then the update request is
likely creating it
// so we don't verify since it will fail
if (snippetDAO.hasSnippet(snippetDto.getId())) {
snippetDAO.verifyUpdate(snippetDto);
}
} catch (final Exception e) {
- revisionManager.cancelClaim(snippetDto.getId());
+ affectedComponentIds.forEach(id ->
revisionManager.cancelClaim(snippetDto.getId()));
throw e;
}
}
- private Set<Revision> getRevisionsForGroup(final String groupId) {
- final Set<Revision> revisions = new HashSet<>();
-
- revisions.add(revisionManager.getRevision(groupId));
- final ProcessGroup processGroup =
processGroupDAO.getProcessGroup(groupId);
- if (processGroup == null) {
- throw new IllegalArgumentException("Snippet contains a
reference to Process Group with ID " + groupId + " but no Process Group exists
with that ID");
- }
-
- processGroup.getConnections().stream().map(c ->
c.getIdentifier()).map(id -> revisionManager.getRevision(id)).forEach(rev ->
revisions.add(rev));
- processGroup.getFunnels().stream().map(c ->
c.getIdentifier()).map(id -> revisionManager.getRevision(id)).forEach(rev ->
revisions.add(rev));
- processGroup.getInputPorts().stream().map(c ->
c.getIdentifier()).map(id -> revisionManager.getRevision(id)).forEach(rev ->
revisions.add(rev));
- processGroup.getOutputPorts().stream().map(c ->
c.getIdentifier()).map(id -> revisionManager.getRevision(id)).forEach(rev ->
revisions.add(rev));
- processGroup.getLabels().stream().map(c ->
c.getIdentifier()).map(id -> revisionManager.getRevision(id)).forEach(rev ->
revisions.add(rev));
- processGroup.getProcessors().stream().map(c ->
c.getIdentifier()).map(id -> revisionManager.getRevision(id)).forEach(rev ->
revisions.add(rev));
- processGroup.getRemoteProcessGroups().stream().map(c ->
c.getIdentifier()).map(id -> revisionManager.getRevision(id)).forEach(rev ->
revisions.add(rev));
- processGroup.getProcessGroups().stream().map(c ->
c.getIdentifier()).forEach(id -> revisions.addAll(getRevisionsForGroup(id)));
-
- return revisions;
- }
-
- private Set<Revision> getRevisionsForSnippet(final SnippetDTO
snippetDto) {
- final Set<Revision> requiredRevisions = new HashSet<>();
-
requiredRevisions.add(revisionManager.getRevision(snippetDto.getId()));
- snippetDto.getConnections().entrySet().stream()
- .map(entry -> new Revision(entry.getValue().getVersion(),
entry.getValue().getClientId(), entry.getKey()))
- .forEach(rev -> requiredRevisions.add(rev));
-
- snippetDto.getFunnels().entrySet().stream()
- .map(entry -> new Revision(entry.getValue().getVersion(),
entry.getValue().getClientId(), entry.getKey()))
- .forEach(rev -> requiredRevisions.add(rev));
-
- snippetDto.getInputPorts().entrySet().stream()
- .map(entry -> new Revision(entry.getValue().getVersion(),
entry.getValue().getClientId(), entry.getKey()))
- .forEach(rev -> requiredRevisions.add(rev));
-
- snippetDto.getOutputPorts().entrySet().stream()
- .map(entry -> new Revision(entry.getValue().getVersion(),
entry.getValue().getClientId(), entry.getKey()))
- .forEach(rev -> requiredRevisions.add(rev));
-
- snippetDto.getLabels().entrySet().stream()
- .map(entry -> new Revision(entry.getValue().getVersion(),
entry.getValue().getClientId(), entry.getKey()))
- .forEach(rev -> requiredRevisions.add(rev));
-
- snippetDto.getProcessors().entrySet().stream()
- .map(entry -> new Revision(entry.getValue().getVersion(),
entry.getValue().getClientId(), entry.getKey()))
- .forEach(rev -> requiredRevisions.add(rev));
-
- snippetDto.getRemoteProcessGroups().entrySet().stream()
- .map(entry -> new Revision(entry.getValue().getVersion(),
entry.getValue().getClientId(), entry.getKey()))
- .forEach(rev -> requiredRevisions.add(rev));
-
- for (final String groupId :
snippetDto.getProcessGroups().keySet()) {
- requiredRevisions.addAll(getRevisionsForGroup(groupId));
- }
-
- return requiredRevisions;
- }
-
- private ProcessGroup getGroup(final String groupId) {
- return revisionManager.get(groupId, rev ->
processGroupDAO.getProcessGroup(groupId));
- }
-
@Override
- public UpdateResult<SnippetEntity> updateSnippet(final Revision
revision, final SnippetDTO snippetDto) {
- // if label does not exist, then create new label
- if (snippetDAO.hasSnippet(snippetDto.getId()) == false) {
- return new UpdateResult<>(createSnippet(snippetDto), true);
- }
-
- final Set<Revision> requiredRevisions =
getRevisionsForSnippet(snippetDto);
-
- // if the parent group is specified in the request, ensure write
access to it as it could be moving the components in the snippet
- final String requestProcessGroupIdentifier =
snippetDto.getParentGroupId();
- if (requestProcessGroupIdentifier != null) {
- final ProcessGroup requestProcessGroup =
processGroupDAO.getProcessGroup(requestProcessGroupIdentifier);
- requestProcessGroup.authorize(authorizer, RequestAction.WRITE);
- }
-
+ public SnippetEntity updateSnippet(final Set<Revision> revisions,
final SnippetDTO snippetDto) {
--- End diff --
Will do!
> Update UI to reflect component level authorization
> --------------------------------------------------
>
> Key: NIFI-1781
> URL: https://issues.apache.org/jira/browse/NIFI-1781
> Project: Apache NiFi
> Issue Type: Sub-task
> Components: Core UI
> Reporter: Matt Gilman
> Assignee: Matt Gilman
> Fix For: 1.0.0
>
> Attachments: 0001-NIFI-1781.patch, nifi-component-samples.png,
> nifi-sample-flow.png
>
>
> - Update to UI to visual access level per component
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)