diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/ParameterContextReferenceDTO.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/ParameterContextReferenceDTO.java index 9d6241f16b..96c6d9f158 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/ParameterContextReferenceDTO.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/ParameterContextReferenceDTO.java @@ -23,6 +23,7 @@ import javax.xml.bind.annotation.XmlType; @XmlType(name = "parameterContextReference") public class ParameterContextReferenceDTO { private String id; + private String name; public void setId(String id) { this.id = id; @@ -32,4 +33,13 @@ public class ParameterContextReferenceDTO { public String getId() { return id; } + + @ApiModelProperty("The name of the Parameter Context") + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } } diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/ProcessGroupDTO.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/ProcessGroupDTO.java index f5a4e353b8..349d0bb31b 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/ProcessGroupDTO.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/ProcessGroupDTO.java @@ -18,6 +18,7 @@ package org.apache.nifi.web.api.dto; import io.swagger.annotations.ApiModelProperty; import org.apache.nifi.web.api.dto.util.NumberUtil; +import org.apache.nifi.web.api.entity.ParameterContextReferenceEntity; import javax.xml.bind.annotation.XmlType; import java.util.Map; @@ -32,7 +33,7 @@ public class ProcessGroupDTO extends ComponentDTO { private String comments; private Map variables; private VersionControlInformationDTO versionControlInformation; - private ParameterContextReferenceDTO parameterContext; + private ParameterContextReferenceEntity parameterContext; private Integer runningCount; private Integer stoppedCount; @@ -344,11 +345,11 @@ public class ProcessGroupDTO extends ComponentDTO { } @ApiModelProperty("The Parameter Context that this Process Group is bound to.") - public ParameterContextReferenceDTO getParameterContext() { + public ParameterContextReferenceEntity getParameterContext() { return parameterContext; } - public void setParameterContext(final ParameterContextReferenceDTO parameterContext) { + public void setParameterContext(final ParameterContextReferenceEntity parameterContext) { this.parameterContext = parameterContext; } } diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/flow/ProcessGroupFlowDTO.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/flow/ProcessGroupFlowDTO.java index 479375e425..dd2a3ffc05 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/flow/ProcessGroupFlowDTO.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/flow/ProcessGroupFlowDTO.java @@ -19,6 +19,7 @@ package org.apache.nifi.web.api.dto.flow; import io.swagger.annotations.ApiModelProperty; import org.apache.nifi.web.api.dto.util.TimeAdapter; import org.apache.nifi.web.api.entity.FlowBreadcrumbEntity; +import org.apache.nifi.web.api.entity.ParameterContextReferenceEntity; import javax.xml.bind.annotation.XmlType; import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; @@ -33,7 +34,7 @@ public class ProcessGroupFlowDTO { private String id; private String uri; private String parentGroupId; - private String parameterContextId; + private ParameterContextReferenceEntity parameterContext; private FlowBreadcrumbEntity breadcrumb; private FlowDTO flow; private Date lastRefreshed; @@ -127,12 +128,12 @@ public class ProcessGroupFlowDTO { this.lastRefreshed = lastRefreshed; } - @ApiModelProperty("The ID of the Parameter Context, or null if no Parameter Context has been bound to the Process Group") - public String getParameterContextId() { - return parameterContextId; + @ApiModelProperty("The Parameter Context, or null if no Parameter Context has been bound to the Process Group") + public ParameterContextReferenceEntity getParameterContext() { + return parameterContext; } - public void setParameterContextId(String parameterContextId) { - this.parameterContextId = parameterContextId; + public void setParameterContext(ParameterContextReferenceEntity parameterContext) { + this.parameterContext = parameterContext; } } diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ParameterContextReferenceEntity.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ParameterContextReferenceEntity.java new file mode 100644 index 0000000000..ee05877b80 --- /dev/null +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ParameterContextReferenceEntity.java @@ -0,0 +1,79 @@ +/* + * 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.ParameterContextReferenceDTO; +import org.apache.nifi.web.api.dto.PermissionsDTO; + +import javax.xml.bind.annotation.XmlRootElement; + +/** + * A serialized representation of this class can be placed in the entity body of a request or response to or from the API. This particular entity holds a reference to a ParameterContextReferenceDTO. + */ +@XmlRootElement(name = "parameterContextReferenceEntity") +public class ParameterContextReferenceEntity implements Permissible { + + private String id; + private PermissionsDTO permissions; + private ParameterContextReferenceDTO component; + + /** + * The id for this component. + * + * @return The id + */ + @ApiModelProperty( + value = "The id of the component." + ) + public String getId() { + return this.id; + } + + public void setId(final String id) { + this.id = id; + } + + /** + * The permissions for this component. + * + * @return The permissions + */ + @ApiModelProperty( + value = "The permissions for this component." + ) + public PermissionsDTO getPermissions() { + return permissions; + } + + public void setPermissions(PermissionsDTO permissions) { + this.permissions = permissions; + } + + /** + * The ParameterContextReferenceDTO that is being serialized. + * + * @return The ParameterContextReferenceDTO object + */ + public ParameterContextReferenceDTO getComponent() { + return component; + } + + public void setComponent(ParameterContextReferenceDTO component) { + this.component = component; + } +} diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ProcessGroupEntity.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ProcessGroupEntity.java index 5defa7f7da..11cdc5187d 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ProcessGroupEntity.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ProcessGroupEntity.java @@ -54,7 +54,7 @@ public class ProcessGroupEntity extends ComponentEntity implements Permissible

, ComponentEntityStatusMerger { @@ -29,11 +31,37 @@ public class ProcessGroupEntityMerger implements ComponentEntityMerger entityMap) { ComponentEntityMerger.super.merge(clientEntity, entityMap); + + final Map dtoMap = new HashMap<>(); for (Map.Entry entry : entityMap.entrySet()) { - final ProcessGroupEntity entityStatus = entry.getValue(); - if (entityStatus != clientEntity) { + final ProcessGroupEntity entity = entry.getValue(); + if (entity != clientEntity) { mergeStatus(clientEntity.getStatus(), clientEntity.getPermissions().getCanRead(), entry.getValue().getStatus(), entry.getValue().getPermissions().getCanRead(), entry.getKey()); - mergeVersionControlInformation(clientEntity, entityStatus); + mergeVersionControlInformation(clientEntity, entity); + } + + dtoMap.put(entry.getKey(), entity.getComponent()); + } + + mergeDtos(clientEntity.getComponent(), dtoMap); + } + + private static void mergeDtos(final ProcessGroupDTO clientDto, final Map dtoMap) { + // if unauthorized for the client dto, simple return + if (clientDto == null) { + return; + } + + // get the parameter context if configured + final ParameterContextReferenceEntity clientParameterContextEntity = clientDto.getParameterContext(); + + // if this process group is bound to a parameter context, merge the permissions from the other nodes + if (clientParameterContextEntity != null) { + for (Map.Entry entry : dtoMap.entrySet()) { + final ProcessGroupDTO dto = entry.getValue(); + final ParameterContextReferenceEntity parameterContextReferenceEntity = dto.getParameterContext(); + + PermissionsDtoMerger.mergePermissions(clientParameterContextEntity.getPermissions(), parameterContextReferenceEntity.getPermissions()); } } } diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/StandardFlowSnippet.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/StandardFlowSnippet.java index c18522dfe0..a65583f8e5 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/StandardFlowSnippet.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/StandardFlowSnippet.java @@ -56,7 +56,6 @@ import org.apache.nifi.web.api.dto.ControllerServiceDTO; import org.apache.nifi.web.api.dto.FlowSnippetDTO; import org.apache.nifi.web.api.dto.FunnelDTO; import org.apache.nifi.web.api.dto.LabelDTO; -import org.apache.nifi.web.api.dto.ParameterContextReferenceDTO; import org.apache.nifi.web.api.dto.PortDTO; import org.apache.nifi.web.api.dto.PositionDTO; import org.apache.nifi.web.api.dto.ProcessGroupDTO; @@ -66,6 +65,7 @@ import org.apache.nifi.web.api.dto.RelationshipDTO; import org.apache.nifi.web.api.dto.RemoteProcessGroupContentsDTO; import org.apache.nifi.web.api.dto.RemoteProcessGroupDTO; import org.apache.nifi.web.api.dto.RemoteProcessGroupPortDTO; +import org.apache.nifi.web.api.entity.ParameterContextReferenceEntity; import java.util.ArrayList; import java.util.Collections; @@ -458,9 +458,9 @@ public class StandardFlowSnippet implements FlowSnippet { childGroup.setVariables(groupDTO.getVariables()); } - final ParameterContextReferenceDTO parameterContextReferenceDto = groupDTO.getParameterContext(); - if (parameterContextReferenceDto != null) { - final ParameterContext parameterContext = flowManager.getParameterContextManager().getParameterContext(parameterContextReferenceDto.getId()); + final ParameterContextReferenceEntity parameterContextReference = groupDTO.getParameterContext(); + if (parameterContextReference != null) { + final ParameterContext parameterContext = flowManager.getParameterContextManager().getParameterContext(parameterContextReference.getId()); if (parameterContext != null) { childGroup.setParameterContext(parameterContext); } diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/StandardFlowSynchronizer.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/StandardFlowSynchronizer.java index 6d970db9cf..c14c2dff1c 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/StandardFlowSynchronizer.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/StandardFlowSynchronizer.java @@ -86,7 +86,6 @@ import org.apache.nifi.web.api.dto.FlowSnippetDTO; import org.apache.nifi.web.api.dto.FunnelDTO; import org.apache.nifi.web.api.dto.LabelDTO; import org.apache.nifi.web.api.dto.ParameterContextDTO; -import org.apache.nifi.web.api.dto.ParameterContextReferenceDTO; import org.apache.nifi.web.api.dto.ParameterDTO; import org.apache.nifi.web.api.dto.PortDTO; import org.apache.nifi.web.api.dto.PositionDTO; @@ -97,6 +96,7 @@ import org.apache.nifi.web.api.dto.RemoteProcessGroupDTO; import org.apache.nifi.web.api.dto.ReportingTaskDTO; import org.apache.nifi.web.api.dto.TemplateDTO; import org.apache.nifi.web.api.dto.VersionControlInformationDTO; +import org.apache.nifi.web.api.entity.ParameterContextReferenceEntity; import org.apache.nifi.web.api.entity.ParameterEntity; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -1161,7 +1161,7 @@ public class StandardFlowSynchronizer implements FlowSynchronizer { group.setComments(comments); } - final ParameterContextReferenceDTO parameterContextReference = dto.getParameterContext(); + final ParameterContextReferenceEntity parameterContextReference = dto.getParameterContext(); if (parameterContextReference != null && parameterContextReference.getId() != null) { final String parameterContextId = parameterContextReference.getId(); final ParameterContext parameterContext = parameterContextManager.getParameterContext(parameterContextId); diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/serialization/FlowFromDOMFactory.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/serialization/FlowFromDOMFactory.java index fa8bb8a50a..e64e573bfd 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/serialization/FlowFromDOMFactory.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/serialization/FlowFromDOMFactory.java @@ -37,7 +37,6 @@ import org.apache.nifi.web.api.dto.FlowSnippetDTO; import org.apache.nifi.web.api.dto.FunnelDTO; import org.apache.nifi.web.api.dto.LabelDTO; import org.apache.nifi.web.api.dto.ParameterContextDTO; -import org.apache.nifi.web.api.dto.ParameterContextReferenceDTO; import org.apache.nifi.web.api.dto.ParameterDTO; import org.apache.nifi.web.api.dto.PortDTO; import org.apache.nifi.web.api.dto.PositionDTO; @@ -47,6 +46,7 @@ import org.apache.nifi.web.api.dto.ProcessorDTO; import org.apache.nifi.web.api.dto.RemoteProcessGroupDTO; import org.apache.nifi.web.api.dto.ReportingTaskDTO; import org.apache.nifi.web.api.dto.VersionControlInformationDTO; +import org.apache.nifi.web.api.entity.ParameterContextReferenceEntity; import org.apache.nifi.web.api.entity.ParameterEntity; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -198,7 +198,7 @@ public class FlowFromDOMFactory { dto.setVersionControlInformation(getVersionControlInformation(versionControlInfoElement)); final String parameterContextId = getString(element, "parameterContextId"); - final ParameterContextReferenceDTO parameterContextReference = new ParameterContextReferenceDTO(); + final ParameterContextReferenceEntity parameterContextReference = new ParameterContextReferenceEntity(); parameterContextReference.setId(parameterContextId); dto.setParameterContext(parameterContextReference); diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/ProcessGroupResource.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/ProcessGroupResource.java index af2bec0d7e..89bb31368f 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/ProcessGroupResource.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/ProcessGroupResource.java @@ -67,7 +67,6 @@ import org.apache.nifi.web.api.dto.ConnectionDTO; import org.apache.nifi.web.api.dto.ControllerServiceDTO; import org.apache.nifi.web.api.dto.DtoFactory; import org.apache.nifi.web.api.dto.FlowSnippetDTO; -import org.apache.nifi.web.api.dto.ParameterContextReferenceDTO; import org.apache.nifi.web.api.dto.PortDTO; import org.apache.nifi.web.api.dto.PositionDTO; import org.apache.nifi.web.api.dto.ProcessGroupDTO; @@ -98,6 +97,7 @@ import org.apache.nifi.web.api.entity.InstantiateTemplateRequestEntity; import org.apache.nifi.web.api.entity.LabelEntity; import org.apache.nifi.web.api.entity.LabelsEntity; import org.apache.nifi.web.api.entity.OutputPortsEntity; +import org.apache.nifi.web.api.entity.ParameterContextReferenceEntity; import org.apache.nifi.web.api.entity.PortEntity; import org.apache.nifi.web.api.entity.ProcessGroupEntity; import org.apache.nifi.web.api.entity.ProcessGroupsEntity; @@ -478,13 +478,13 @@ public class ProcessGroupResource extends ApplicationResource { authorizable.authorize(authorizer, RequestAction.WRITE, user); // Ensure that user has READ permission on current Parameter Context (if any) because user is un-binding. - final ParameterContextReferenceDTO referencedParamContext = requestProcessGroupDTO.getParameterContext(); + final ParameterContextReferenceEntity referencedParamContext = requestProcessGroupDTO.getParameterContext(); if (referencedParamContext != null) { // Lookup the current Parameter Context and determine whether or not the Parameter Context is changing final String groupId = requestProcessGroupDTO.getId(); final ProcessGroupEntity currentGroupEntity = serviceFacade.getProcessGroup(groupId); final ProcessGroupDTO groupDto = currentGroupEntity.getComponent(); - final ParameterContextReferenceDTO currentParamContext = groupDto.getParameterContext(); + final ParameterContextReferenceEntity currentParamContext = groupDto.getParameterContext(); final String currentParamContextId = currentParamContext == null ? null : currentParamContext.getId(); final boolean parameterContextChanging = !Objects.equals(referencedParamContext.getId(), currentParamContextId); @@ -1776,7 +1776,7 @@ public class ProcessGroupResource extends ApplicationResource { processGroup.authorize(authorizer, RequestAction.WRITE, user); // If request specifies a Parameter Context, need to authorize that user has READ policy for the Parameter Context. - final ParameterContextReferenceDTO referencedParamContext = requestProcessGroupEntity.getComponent().getParameterContext(); + final ParameterContextReferenceEntity referencedParamContext = requestProcessGroupEntity.getComponent().getParameterContext(); if (referencedParamContext != null && referencedParamContext.getId() != null) { lookup.getParameterContext(referencedParamContext.getId()).authorize(authorizer, RequestAction.READ, user); } 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 3be7ae765d..b1822d60fd 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 @@ -219,6 +219,7 @@ import org.apache.nifi.web.api.entity.ComponentReferenceEntity; import org.apache.nifi.web.api.entity.ConnectionStatusSnapshotEntity; import org.apache.nifi.web.api.entity.ControllerServiceEntity; import org.apache.nifi.web.api.entity.FlowBreadcrumbEntity; +import org.apache.nifi.web.api.entity.ParameterContextReferenceEntity; import org.apache.nifi.web.api.entity.ParameterEntity; import org.apache.nifi.web.api.entity.PortEntity; import org.apache.nifi.web.api.entity.PortStatusSnapshotEntity; @@ -2142,7 +2143,21 @@ public final class DtoFactory { } final ParameterContext parameterContext = group.getParameterContext(); - dto.setParameterContextId(parameterContext == null ? null : parameterContext.getIdentifier()); + if (parameterContext != null) { + dto.setParameterContext(entityFactory.createParameterReferenceEntity(createParameterContextReference(parameterContext), createPermissionsDto(parameterContext))); + } + return dto; + } + + public ParameterContextReferenceDTO createParameterContextReference(final ParameterContext parameterContext) { + if (parameterContext == null) { + return null; + } + + final ParameterContextReferenceDTO dto = new ParameterContextReferenceDTO(); + dto.setId(parameterContext.getIdentifier()); + dto.setName(parameterContext.getName()); + return dto; } @@ -2409,9 +2424,10 @@ public final class DtoFactory { dto.setVersionedComponentId(group.getVersionedComponentId().orElse(null)); dto.setVersionControlInformation(createVersionControlInformationDto(group)); - final ParameterContextReferenceDTO parameterContextReference = new ParameterContextReferenceDTO(); - parameterContextReference.setId(group.getParameterContext() == null ? null : group.getParameterContext().getIdentifier()); - dto.setParameterContext(parameterContextReference); + final ParameterContext parameterContext = group.getParameterContext(); + if (parameterContext != null) { + dto.setParameterContext(entityFactory.createParameterReferenceEntity(createParameterContextReference(parameterContext), createPermissionsDto(parameterContext))); + } final Map variables = group.getVariableRegistry().getVariableMap().entrySet().stream() .collect(Collectors.toMap(entry -> entry.getKey().getName(), Entry::getValue)); @@ -4234,13 +4250,35 @@ public final class DtoFactory { return copy; } - public ParameterContextReferenceDTO copy(final ParameterContextReferenceDTO original) { + public ParameterContextReferenceEntity copy(final ParameterContextReferenceEntity original) { if (original == null) { return null; } - final ParameterContextReferenceDTO copy = new ParameterContextReferenceDTO(); + final ParameterContextReferenceEntity copy = new ParameterContextReferenceEntity(); copy.setId(original.getId()); + copy.setPermissions(copy(original.getPermissions())); + + if (original.getComponent() != null) { + final ParameterContextReferenceDTO dtoOriginal = original.getComponent(); + + final ParameterContextReferenceDTO dtoCopy = new ParameterContextReferenceDTO(); + dtoCopy.setId(dtoOriginal.getId()); + dtoCopy.setName(dtoOriginal.getName()); + copy.setComponent(dtoCopy); + } + + return copy; + } + + public PermissionsDTO copy(final PermissionsDTO original) { + if (original == null) { + return null; + } + + final PermissionsDTO copy = new PermissionsDTO(); + copy.setCanRead(original.getCanRead()); + copy.setCanWrite(original.getCanWrite()); return copy; } 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/EntityFactory.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/dto/EntityFactory.java index 08c28d1341..ab004c0c66 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/dto/EntityFactory.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/dto/EntityFactory.java @@ -52,6 +52,7 @@ import org.apache.nifi.web.api.entity.FlowBreadcrumbEntity; import org.apache.nifi.web.api.entity.FunnelEntity; import org.apache.nifi.web.api.entity.LabelEntity; import org.apache.nifi.web.api.entity.ParameterContextEntity; +import org.apache.nifi.web.api.entity.ParameterContextReferenceEntity; import org.apache.nifi.web.api.entity.PortEntity; import org.apache.nifi.web.api.entity.PortStatusEntity; import org.apache.nifi.web.api.entity.PortStatusSnapshotEntity; @@ -269,9 +270,9 @@ public final class EntityFactory { entity.setLocallyModifiedAndStaleCount(dto.getLocallyModifiedAndStaleCount()); entity.setSyncFailureCount(dto.getSyncFailureCount()); - final ParameterContextReferenceDTO parameterContextReference = dto.getParameterContext(); + final ParameterContextReferenceEntity parameterContextReference = dto.getParameterContext(); if (parameterContextReference != null) { - entity.setParameterContextId(parameterContextReference.getId()); + entity.setParameterContext(parameterContextReference); } if (dto.getVersionControlInformation() != null) { @@ -425,6 +426,19 @@ public final class EntityFactory { return entity; } + public ParameterContextReferenceEntity createParameterReferenceEntity(final ParameterContextReferenceDTO dto, final PermissionsDTO permissions) { + final ParameterContextReferenceEntity entity = new ParameterContextReferenceEntity(); + if (dto != null) { + entity.setPermissions(permissions); + entity.setId(dto.getId()); + + if (permissions != null && permissions.getCanRead()) { + entity.setComponent(dto); + } + } + return entity; + } + public FunnelEntity createFunnelEntity(final FunnelDTO dto, final RevisionDTO revision, final PermissionsDTO permissions) { final FunnelEntity entity = new FunnelEntity(); entity.setRevision(revision); 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 e8957dd201..858db087ed 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 @@ -36,10 +36,10 @@ import org.apache.nifi.registry.flow.VersionedProcessGroup; import org.apache.nifi.registry.flow.mapping.NiFiRegistryFlowMapper; import org.apache.nifi.remote.RemoteGroupPort; import org.apache.nifi.web.ResourceNotFoundException; -import org.apache.nifi.web.api.dto.ParameterContextReferenceDTO; import org.apache.nifi.web.api.dto.ProcessGroupDTO; import org.apache.nifi.web.api.dto.VariableRegistryDTO; import org.apache.nifi.web.api.dto.VersionControlInformationDTO; +import org.apache.nifi.web.api.entity.ParameterContextReferenceEntity; import org.apache.nifi.web.api.entity.VariableEntity; import org.apache.nifi.web.dao.ProcessGroupDAO; @@ -78,7 +78,7 @@ public class StandardProcessGroupDAO extends ComponentDAO implements ProcessGrou group.setPosition(new Position(processGroup.getPosition().getX(), processGroup.getPosition().getY())); } - final ParameterContextReferenceDTO parameterContextReference = processGroup.getParameterContext(); + final ParameterContextReferenceEntity parameterContextReference = processGroup.getParameterContext(); if (parameterContextReference != null && parameterContextReference.getId() != null) { final ParameterContext parameterContext = flowController.getFlowManager().getParameterContextManager().getParameterContext(parameterContextReference.getId()); group.setParameterContext(parameterContext); @@ -98,7 +98,7 @@ public class StandardProcessGroupDAO extends ComponentDAO implements ProcessGrou @Override public void verifyUpdate(final ProcessGroupDTO processGroup) { - final ParameterContextReferenceDTO parameterContextReference = processGroup.getParameterContext(); + final ParameterContextReferenceEntity parameterContextReference = processGroup.getParameterContext(); if (parameterContextReference == null) { return; } @@ -336,7 +336,7 @@ public class StandardProcessGroupDAO extends ComponentDAO implements ProcessGrou final String name = processGroupDTO.getName(); final String comments = processGroupDTO.getComments(); - final ParameterContextReferenceDTO parameterContextReference = processGroupDTO.getParameterContext(); + final ParameterContextReferenceEntity parameterContextReference = processGroupDTO.getParameterContext(); if (parameterContextReference != null) { final String parameterContextId = parameterContextReference.getId(); if (parameterContextId == null) { diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-actions.js b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-actions.js index 3d0c9d0f15..ec3e254aec 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-actions.js +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-actions.js @@ -1411,18 +1411,19 @@ * @param {selection} selection */ openParameterContext: function (selection) { - var pcid; + var parameterContext; + if (selection.empty()) { - pcid = nfCanvasUtils.getParameterContextId(); + parameterContext = nfCanvasUtils.getParameterContext(); } else if (selection.size() === 1) { if (nfCanvasUtils.isProcessGroup(selection)) { var pg = selection.datum(); - pcid = pg.component.parameterContext.id; + parameterContext = pg.parameterContext; } } - if (nfCommon.isDefinedAndNotNull(pcid)) { - nfParameterContexts.showParameterContext(pcid); + if (nfCommon.isDefinedAndNotNull(parameterContext)) { + nfParameterContexts.showParameterContext(parameterContext.id); } }, diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-canvas-utils.js b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-canvas-utils.js index 5241263cf7..2a5d573132 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-canvas-utils.js +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-canvas-utils.js @@ -2089,19 +2089,19 @@ }, /** - * Set the parameter context id. + * Set the parameter context. * - * @argument {string} pcid The parameter context id + * @argument {string} pc The parameter context */ - setParameterContextId: function (pcid) { - return nfCanvas.setParameterContextId(pcid); + setParameterContext: function (pc) { + return nfCanvas.setParameterContext(pc); }, /** - * Get the parameter context id. + * Get the parameter context. */ - getParameterContextId: function () { - return nfCanvas.getParameterContextId(); + getParameterContext: function () { + return nfCanvas.getParameterContext(); }, /** diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-canvas.js b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-canvas.js index 67b7a54265..ae0dd12b5b 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-canvas.js +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-canvas.js @@ -86,7 +86,7 @@ var polling = false; var allowPageRefresh = false; var groupId = 'root'; - var parameterContextId; + var parameterContext; var groupName = null; var permissions = null; var parentGroupId = null; @@ -150,7 +150,7 @@ // set the group and parameter context details nfCanvas.setGroupId(processGroupFlow.id); - nfCanvas.setParameterContextId(processGroupFlow.parameterContextId); + nfCanvas.setParameterContext(processGroupFlow.parameterContext); // get the current group name from the breadcrumb var breadcrumb = processGroupFlow.breadcrumb; @@ -220,7 +220,7 @@ var changeProcessGroup = function (processGroupId, options) { // capture the current group id to reset to in case of failure var currentProcessGroup = nfCanvas.getGroupId(); - var currentParameterContext = nfCanvas.getParameterContextId(); + var currentParameterContext = nfCanvas.getParameterContext(); // update process group id and attempt to reload nfCanvas.setGroupId(processGroupId); @@ -230,7 +230,7 @@ processGroupXhr .fail(function (xhr, status, error) { nfCanvas.setGroupId(currentProcessGroup); - nfCanvas.setParameterContextId(currentParameterContext); + nfCanvas.setParameterContext(currentParameterContext); }); return processGroupXhr; @@ -908,19 +908,19 @@ }, /** - * Set the parameter context id. + * Set the parameter context. * - * @argument {string} pcid The parameter context id + * @argument {string} pc The parameter context */ - setParameterContextId: function (pcid) { - parameterContextId = pcid; + setParameterContext: function (pc) { + parameterContext = pc; }, /** * Get the parameter context id. */ - getParameterContextId: function () { - return parameterContextId; + getParameterContext: function () { + return parameterContext; }, /** diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-context-menu.js b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-context-menu.js index 9cbd904e2f..78e3e943e4 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-context-menu.js +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-context-menu.js @@ -87,12 +87,19 @@ * @param {selection} selection The selection of currently selected components */ var hasParameterContext = function (selection) { + var parameterContext; + if (selection.empty()) { - return !nfCommon.isUndefinedOrNull(nfCanvasUtils.getParameterContextId()); + parameterContext = nfCanvasUtils.getParameterContext(); } else if (nfCanvasUtils.isProcessGroup(selection)) { var pg = selection.datum(); - return !nfCommon.isUndefinedOrNull(pg.component.parameterContext.id); + parameterContext = pg.parameterContext; } + + if (nfCommon.isDefinedAndNotNull(parameterContext)) { + return nfCommon.isDefinedAndNotNull(parameterContext) && parameterContext.permissions.canRead === true; + } + return false; }; diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-controller-service.js b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-controller-service.js index c80d8c59cf..84c1175269 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-controller-service.js +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-controller-service.js @@ -1519,21 +1519,21 @@ var getParameters = function (propertyDescriptor, groupId) { return $.Deferred(function (deferred) { if (nfCommon.isDefinedAndNotNull(groupId)) { - var parameterContextId; + var parameterContext; // attempt to identify the parameter context id, conditional based on whether // the user is configuring the current process group if (groupId === nfCanvasUtils.getGroupId()) { - parameterContextId = nfCanvasUtils.getParameterContextId(); + parameterContext = nfCanvasUtils.getParameterContext(); } else { var parentProcessGroup = nfCanvasUtils.getComponentByType('ProcessGroup').get(groupId); - parameterContextId = parentProcessGroup.parameterContextId; + parameterContext = parentProcessGroup.parameterContext; } - if (nfCommon.isDefinedAndNotNull(parameterContextId)) { + if (nfCommon.isDefinedAndNotNull(parameterContext)) { $.ajax({ type: 'GET', - url: '../nifi-api/parameter-contexts/' + parameterContextId, + url: '../nifi-api/parameter-contexts/' + encodeURIComponent(parameterContext.id), dataType: 'json' }).done(function (response) { var sensitive = nfCommon.isSensitiveProperty(propertyDescriptor); @@ -1877,14 +1877,18 @@ return goToServiceFromProperty(serviceTable); }, getParameterContextId: function (groupId) { + var parameterContext; + // attempt to identify the parameter context id, conditional based on whether // the user is configuring the current process group if (_.isNil(groupId) || groupId === nfCanvasUtils.getGroupId()) { - return nfCanvasUtils.getParameterContextId(); + parameterContext = nfCanvasUtils.getParameterContext(); } else { var parentProcessGroup = nfCanvasUtils.getComponentByType('ProcessGroup').get(groupId); - return parentProcessGroup.parameterContextId; + parameterContext = parentProcessGroup.parameterContext; } + + return nfCommon.isDefinedAndNotNull(parameterContext) ? parameterContext.id : null; } }); diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-process-group-configuration.js b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-process-group-configuration.js index 43e84f28d0..efe0ea31fb 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-process-group-configuration.js +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-process-group-configuration.js @@ -408,9 +408,9 @@ }; // populate the parameter context - if (processGroupResult.permissions.canRead && $.isEmptyObject(processGroupResult.component.parameterContext) === false) { + if (nfCommon.isDefinedAndNotNull(processGroupResult.parameterContext)) { comboOptions.selectedOption = { - value: processGroupResult.component.parameterContext.id + value: processGroupResult.parameterContext.id }; } diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-processor-configuration.js b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-processor-configuration.js index 90cd05fe48..dfb3c398e6 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-processor-configuration.js +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-processor-configuration.js @@ -633,12 +633,12 @@ return $.Deferred(function (deferred) { if (nfCommon.isDefinedAndNotNull(groupId)) { // processors being configured must be in the current group - var parameterContextId = nfCanvasUtils.getParameterContextId(); + var parameterContext = nfCanvasUtils.getParameterContext(); - if (nfCommon.isDefinedAndNotNull(parameterContextId)) { + if (nfCommon.isDefinedAndNotNull(parameterContext)) { $.ajax({ type: 'GET', - url: '../nifi-api/parameter-contexts/' + parameterContextId, + url: '../nifi-api/parameter-contexts/' + encodeURIComponent(parameterContext.id), dataType: 'json' }).done(function (response) { var sensitive = nfCommon.isSensitiveProperty(propertyDescriptor); @@ -662,7 +662,8 @@ goToServiceDeferred: goToServiceFromProperty, getParameterContextId: function (groupId) { // processors being configured must be in the current group - return nfCanvasUtils.getParameterContextId(); + var parameterContext = nfCanvasUtils.getParameterContext(); + return nfCommon.isDefinedAndNotNull(parameterContext) ? parameterContext.id : null; } }); }, diff --git a/nifi-toolkit/nifi-toolkit-cli/src/main/java/org/apache/nifi/toolkit/cli/impl/command/nifi/pg/PGGetParamContext.java b/nifi-toolkit/nifi-toolkit-cli/src/main/java/org/apache/nifi/toolkit/cli/impl/command/nifi/pg/PGGetParamContext.java index de0d5aea01..8ebaae277d 100644 --- a/nifi-toolkit/nifi-toolkit-cli/src/main/java/org/apache/nifi/toolkit/cli/impl/command/nifi/pg/PGGetParamContext.java +++ b/nifi-toolkit/nifi-toolkit-cli/src/main/java/org/apache/nifi/toolkit/cli/impl/command/nifi/pg/PGGetParamContext.java @@ -26,8 +26,8 @@ import org.apache.nifi.toolkit.cli.impl.command.CommandOption; import org.apache.nifi.toolkit.cli.impl.command.nifi.AbstractNiFiCommand; import org.apache.nifi.toolkit.cli.impl.result.StringResult; import org.apache.nifi.util.StringUtils; -import org.apache.nifi.web.api.dto.ParameterContextReferenceDTO; import org.apache.nifi.web.api.dto.ProcessGroupDTO; +import org.apache.nifi.web.api.entity.ParameterContextReferenceEntity; import org.apache.nifi.web.api.entity.ProcessGroupEntity; import java.io.IOException; @@ -66,7 +66,7 @@ public class PGGetParamContext extends AbstractNiFiCommand { return ""; } - final ParameterContextReferenceDTO parameterContextReference = processGroup.getParameterContext(); + final ParameterContextReferenceEntity parameterContextReference = processGroup.getParameterContext(); if (parameterContextReference == null) { return ""; } diff --git a/nifi-toolkit/nifi-toolkit-cli/src/main/java/org/apache/nifi/toolkit/cli/impl/command/nifi/pg/PGSetParamContext.java b/nifi-toolkit/nifi-toolkit-cli/src/main/java/org/apache/nifi/toolkit/cli/impl/command/nifi/pg/PGSetParamContext.java index 7cb6d9bbb1..f369cd290f 100644 --- a/nifi-toolkit/nifi-toolkit-cli/src/main/java/org/apache/nifi/toolkit/cli/impl/command/nifi/pg/PGSetParamContext.java +++ b/nifi-toolkit/nifi-toolkit-cli/src/main/java/org/apache/nifi/toolkit/cli/impl/command/nifi/pg/PGSetParamContext.java @@ -25,8 +25,8 @@ import org.apache.nifi.toolkit.cli.impl.client.nifi.ProcessGroupClient; import org.apache.nifi.toolkit.cli.impl.command.CommandOption; import org.apache.nifi.toolkit.cli.impl.command.nifi.AbstractNiFiCommand; import org.apache.nifi.toolkit.cli.impl.result.VoidResult; -import org.apache.nifi.web.api.dto.ParameterContextReferenceDTO; import org.apache.nifi.web.api.dto.ProcessGroupDTO; +import org.apache.nifi.web.api.entity.ParameterContextReferenceEntity; import org.apache.nifi.web.api.entity.ProcessGroupEntity; import java.io.IOException; @@ -60,7 +60,7 @@ public class PGSetParamContext extends AbstractNiFiCommand { final ProcessGroupClient pgClient = client.getProcessGroupClient(); final ProcessGroupEntity pgEntity = pgClient.getProcessGroup(pgId); - final ParameterContextReferenceDTO parameterContextReference = new ParameterContextReferenceDTO(); + final ParameterContextReferenceEntity parameterContextReference = new ParameterContextReferenceEntity(); parameterContextReference.setId(paramContextId); final ProcessGroupDTO updatedDTO = new ProcessGroupDTO();