NIFI-6612:

- Updating context menu to only show the Parameters menu item when the user has the appropriate permissions.
This commit is contained in:
Matt Gilman 2019-09-06 16:51:56 -04:00 committed by Mark Payne
parent f867e92606
commit 625d4a13ca
23 changed files with 268 additions and 84 deletions

View File

@ -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;
}
}

View File

@ -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<String, String> 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;
}
}

View File

@ -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;
}
}

View File

@ -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<ParameterContextReferenceDTO> {
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;
}
}

View File

@ -54,7 +54,7 @@ public class ProcessGroupEntity extends ComponentEntity implements Permissible<P
private Integer publicInputPortCount;
private Integer publicOutputPortCount;
private String parameterContextId;
private ParameterContextReferenceEntity parameterContext;
/**
* The ProcessGroupDTO that is being serialized.
@ -320,12 +320,12 @@ public class ProcessGroupEntity extends ComponentEntity implements Permissible<P
this.syncFailureCount = syncFailureCount;
}
@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;
}
}

View File

@ -42,7 +42,7 @@ public class ParameterContextMerger {
final NodeIdentifier nodeId = entry.getKey();
final ParameterContextEntity entity = entry.getValue();
PermissionsDtoMerger.mergePermissions(entity.getPermissions(), entity.getPermissions());
PermissionsDtoMerger.mergePermissions(target.getPermissions(), entity.getPermissions());
if (entity.getComponent() == null) {
target.setComponent(null);

View File

@ -20,8 +20,10 @@ import org.apache.nifi.cluster.protocol.NodeIdentifier;
import org.apache.nifi.web.api.dto.ProcessGroupDTO;
import org.apache.nifi.web.api.dto.VersionControlInformationDTO;
import org.apache.nifi.web.api.dto.status.ProcessGroupStatusDTO;
import org.apache.nifi.web.api.entity.ParameterContextReferenceEntity;
import org.apache.nifi.web.api.entity.ProcessGroupEntity;
import java.util.HashMap;
import java.util.Map;
public class ProcessGroupEntityMerger implements ComponentEntityMerger<ProcessGroupEntity>, ComponentEntityStatusMerger<ProcessGroupStatusDTO> {
@ -29,11 +31,37 @@ public class ProcessGroupEntityMerger implements ComponentEntityMerger<ProcessGr
@Override
public void merge(ProcessGroupEntity clientEntity, Map<NodeIdentifier, ProcessGroupEntity> entityMap) {
ComponentEntityMerger.super.merge(clientEntity, entityMap);
final Map<NodeIdentifier, ProcessGroupDTO> dtoMap = new HashMap<>();
for (Map.Entry<NodeIdentifier, ProcessGroupEntity> 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<NodeIdentifier, ProcessGroupDTO> 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<NodeIdentifier, ProcessGroupDTO> entry : dtoMap.entrySet()) {
final ProcessGroupDTO dto = entry.getValue();
final ParameterContextReferenceEntity parameterContextReferenceEntity = dto.getParameterContext();
PermissionsDtoMerger.mergePermissions(clientParameterContextEntity.getPermissions(), parameterContextReferenceEntity.getPermissions());
}
}
}

View File

@ -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);
}

View File

@ -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);

View File

@ -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);

View File

@ -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);
}

View File

@ -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<String, String> 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;
}

View File

@ -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);

View File

@ -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) {

View File

@ -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);
}
},

View File

@ -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();
},
/**

View File

@ -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;
},
/**

View File

@ -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;
};

View File

@ -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;
}
});

View File

@ -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
};
}

View File

@ -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;
}
});
},

View File

@ -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<StringResult> {
return "";
}
final ParameterContextReferenceDTO parameterContextReference = processGroup.getParameterContext();
final ParameterContextReferenceEntity parameterContextReference = processGroup.getParameterContext();
if (parameterContextReference == null) {
return "";
}

View File

@ -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<VoidResult> {
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();