mirror of https://github.com/apache/nifi.git
NIFI-1876 Implemented PropertyDescriptorDTO merging
NIFI-1876 Updated PermissionsDTO to use boolean primitives instead of Boolean objects for read and write permission Removed ISE throwing from EntityFactory, it will rely on null checks instead This closes #694 Signed-off-by: jpercivall <joepercivall@yahoo.com>
This commit is contained in:
parent
e81147c92a
commit
bbdd087d77
|
@ -1,3 +1,19 @@
|
||||||
|
/*
|
||||||
|
* 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.dto;
|
package org.apache.nifi.web.api.dto;
|
||||||
|
|
||||||
import com.wordnik.swagger.annotations.ApiModelProperty;
|
import com.wordnik.swagger.annotations.ApiModelProperty;
|
||||||
|
|
|
@ -26,8 +26,8 @@ import javax.xml.bind.annotation.XmlType;
|
||||||
@XmlType(name = "permission")
|
@XmlType(name = "permission")
|
||||||
public class PermissionsDTO implements ReadablePermission, WritablePermission {
|
public class PermissionsDTO implements ReadablePermission, WritablePermission {
|
||||||
|
|
||||||
private Boolean canRead;
|
private boolean canRead = false;
|
||||||
private Boolean canWrite;
|
private boolean canWrite = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Indicates whether the user can read a given resource.
|
* @return Indicates whether the user can read a given resource.
|
||||||
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
/*
|
||||||
|
* 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.cluster.manager;
|
||||||
|
|
||||||
|
import org.apache.nifi.web.api.entity.AllowableValueEntity;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
|
||||||
|
public class AllowableValueEntityMerger {
|
||||||
|
public static void merge(AllowableValueEntity clientAllowableValue, Collection<AllowableValueEntity> allowableValues) {
|
||||||
|
for (AllowableValueEntity allowableValue : allowableValues) {
|
||||||
|
if (clientAllowableValue.getCanRead() && !allowableValue.getCanRead()) {
|
||||||
|
clientAllowableValue.setAllowableValue(allowableValue.getAllowableValue());
|
||||||
|
clientAllowableValue.setCanRead(allowableValue.getCanRead());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -21,9 +21,11 @@ import org.apache.nifi.controller.service.ControllerServiceState;
|
||||||
import org.apache.nifi.web.api.dto.ControllerServiceDTO;
|
import org.apache.nifi.web.api.dto.ControllerServiceDTO;
|
||||||
import org.apache.nifi.web.api.dto.ControllerServiceReferencingComponentDTO;
|
import org.apache.nifi.web.api.dto.ControllerServiceReferencingComponentDTO;
|
||||||
import org.apache.nifi.web.api.dto.PermissionsDTO;
|
import org.apache.nifi.web.api.dto.PermissionsDTO;
|
||||||
|
import org.apache.nifi.web.api.dto.PropertyDescriptorDTO;
|
||||||
import org.apache.nifi.web.api.entity.ControllerServiceEntity;
|
import org.apache.nifi.web.api.entity.ControllerServiceEntity;
|
||||||
import org.apache.nifi.web.api.entity.ControllerServiceReferencingComponentEntity;
|
import org.apache.nifi.web.api.entity.ControllerServiceReferencingComponentEntity;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
@ -58,6 +60,7 @@ public class ControllerServiceEntityMerger implements ComponentEntityMerger<Cont
|
||||||
final Map<String, Set<NodeIdentifier>> validationErrorMap = new HashMap<>();
|
final Map<String, Set<NodeIdentifier>> validationErrorMap = new HashMap<>();
|
||||||
final Set<ControllerServiceReferencingComponentEntity> referencingComponents = clientDto.getReferencingComponents();
|
final Set<ControllerServiceReferencingComponentEntity> referencingComponents = clientDto.getReferencingComponents();
|
||||||
final Map<NodeIdentifier, Set<ControllerServiceReferencingComponentEntity>> nodeReferencingComponentsMap = new HashMap<>();
|
final Map<NodeIdentifier, Set<ControllerServiceReferencingComponentEntity>> nodeReferencingComponentsMap = new HashMap<>();
|
||||||
|
final Map<String, Map<NodeIdentifier, PropertyDescriptorDTO>> propertyDescriptorMap = new HashMap<>();
|
||||||
|
|
||||||
String state = null;
|
String state = null;
|
||||||
for (final Map.Entry<NodeIdentifier, ControllerServiceDTO> nodeEntry : dtoMap.entrySet()) {
|
for (final Map.Entry<NodeIdentifier, ControllerServiceDTO> nodeEntry : dtoMap.entrySet()) {
|
||||||
|
@ -79,6 +82,25 @@ public class ControllerServiceEntityMerger implements ComponentEntityMerger<Cont
|
||||||
|
|
||||||
// merge the validation errors
|
// merge the validation errors
|
||||||
ErrorMerger.mergeErrors(validationErrorMap, nodeId, nodeControllerService.getValidationErrors());
|
ErrorMerger.mergeErrors(validationErrorMap, nodeId, nodeControllerService.getValidationErrors());
|
||||||
|
|
||||||
|
// aggregate the property descriptors
|
||||||
|
final Map<String, PropertyDescriptorDTO> descriptors = nodeControllerService.getDescriptors();
|
||||||
|
if (descriptors != null) {
|
||||||
|
descriptors.values().stream().forEach(propertyDescriptor -> {
|
||||||
|
propertyDescriptorMap.computeIfAbsent(propertyDescriptor.getName(), nodeIdToPropertyDescriptor -> new HashMap<>()).put(nodeId, propertyDescriptor);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// merge property descriptors
|
||||||
|
for (Map<NodeIdentifier, PropertyDescriptorDTO> propertyDescriptorByNodeId : propertyDescriptorMap.values()) {
|
||||||
|
final Collection<PropertyDescriptorDTO> nodePropertyDescriptors = propertyDescriptorByNodeId.values();
|
||||||
|
if (!nodePropertyDescriptors.isEmpty()) {
|
||||||
|
// get the name of the property descriptor and find that descriptor being returned to the client
|
||||||
|
final PropertyDescriptorDTO propertyDescriptor = nodePropertyDescriptors.iterator().next();
|
||||||
|
final PropertyDescriptorDTO clientPropertyDescriptor = clientDto.getDescriptors().get(propertyDescriptor.getName());
|
||||||
|
PropertyDescriptorDtoMerger.merge(clientPropertyDescriptor, propertyDescriptorByNodeId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -108,32 +130,34 @@ public class ControllerServiceEntityMerger implements ComponentEntityMerger<Cont
|
||||||
for (final ControllerServiceReferencingComponentEntity nodeReferencingComponentEntity : nodeReferencingComponents) {
|
for (final ControllerServiceReferencingComponentEntity nodeReferencingComponentEntity : nodeReferencingComponents) {
|
||||||
final ControllerServiceReferencingComponentDTO nodeReferencingComponent = nodeReferencingComponentEntity.getComponent();
|
final ControllerServiceReferencingComponentDTO nodeReferencingComponent = nodeReferencingComponentEntity.getComponent();
|
||||||
|
|
||||||
// handle active thread counts
|
if (nodeReferencingComponentEntity.getPermissions().getCanRead()) {
|
||||||
if (nodeReferencingComponent.getActiveThreadCount() != null && nodeReferencingComponent.getActiveThreadCount() > 0) {
|
// handle active thread counts
|
||||||
final Integer current = activeThreadCounts.get(nodeReferencingComponent.getId());
|
if (nodeReferencingComponent.getActiveThreadCount() != null && nodeReferencingComponent.getActiveThreadCount() > 0) {
|
||||||
if (current == null) {
|
final Integer current = activeThreadCounts.get(nodeReferencingComponent.getId());
|
||||||
activeThreadCounts.put(nodeReferencingComponent.getId(), nodeReferencingComponent.getActiveThreadCount());
|
if (current == null) {
|
||||||
} else {
|
activeThreadCounts.put(nodeReferencingComponent.getId(), nodeReferencingComponent.getActiveThreadCount());
|
||||||
activeThreadCounts.put(nodeReferencingComponent.getId(), nodeReferencingComponent.getActiveThreadCount() + current);
|
} else {
|
||||||
|
activeThreadCounts.put(nodeReferencingComponent.getId(), nodeReferencingComponent.getActiveThreadCount() + current);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// handle controller service state
|
// handle controller service state
|
||||||
final String state = states.get(nodeReferencingComponent.getId());
|
final String state = states.get(nodeReferencingComponent.getId());
|
||||||
if (state == null) {
|
if (state == null) {
|
||||||
if (ControllerServiceState.DISABLING.name().equals(nodeReferencingComponent.getState())) {
|
if (ControllerServiceState.DISABLING.name().equals(nodeReferencingComponent.getState())) {
|
||||||
states.put(nodeReferencingComponent.getId(), ControllerServiceState.DISABLING.name());
|
states.put(nodeReferencingComponent.getId(), ControllerServiceState.DISABLING.name());
|
||||||
} else if (ControllerServiceState.ENABLING.name().equals(nodeReferencingComponent.getState())) {
|
} else if (ControllerServiceState.ENABLING.name().equals(nodeReferencingComponent.getState())) {
|
||||||
states.put(nodeReferencingComponent.getId(), ControllerServiceState.ENABLING.name());
|
states.put(nodeReferencingComponent.getId(), ControllerServiceState.ENABLING.name());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// handle read permissions
|
// handle read permissions
|
||||||
final PermissionsDTO mergedPermissions = canReads.get(nodeReferencingComponent.getId());
|
final PermissionsDTO mergedPermissions = canReads.get(nodeReferencingComponentEntity.getId());
|
||||||
final PermissionsDTO permissions = nodeReferencingComponentEntity.getPermissions();
|
final PermissionsDTO permissions = nodeReferencingComponentEntity.getPermissions();
|
||||||
if (permissions != null) {
|
if (permissions != null) {
|
||||||
if (mergedPermissions == null) {
|
if (mergedPermissions == null) {
|
||||||
canReads.put(nodeReferencingComponent.getId(), permissions);
|
canReads.put(nodeReferencingComponentEntity.getId(), permissions);
|
||||||
} else {
|
} else {
|
||||||
PermissionsDtoMerger.mergePermissions(mergedPermissions, permissions);
|
PermissionsDtoMerger.mergePermissions(mergedPermissions, permissions);
|
||||||
}
|
}
|
||||||
|
@ -156,6 +180,20 @@ public class ControllerServiceEntityMerger implements ComponentEntityMerger<Cont
|
||||||
if (state != null) {
|
if (state != null) {
|
||||||
referencingComponent.getComponent().setState(state);
|
referencingComponent.getComponent().setState(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final Map<NodeIdentifier, ControllerServiceReferencingComponentEntity> nodeEntities = new HashMap<>();
|
||||||
|
referencingComponentMap.entrySet().forEach(entry -> {
|
||||||
|
final NodeIdentifier nodeIdentifier = entry.getKey();
|
||||||
|
final Set<ControllerServiceReferencingComponentEntity> nodeControllerServiceReferencingComponents = entry.getValue();
|
||||||
|
|
||||||
|
nodeControllerServiceReferencingComponents.forEach(nodeControllerServiceReferencingComponent -> {
|
||||||
|
if (referencingComponent.getId() != null && referencingComponent.getId().equals(nodeControllerServiceReferencingComponent.getId())) {
|
||||||
|
nodeEntities.put(nodeIdentifier, nodeControllerServiceReferencingComponent);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
mergeControllerServiceReferencingComponent(referencingComponent, nodeEntities);
|
||||||
} else {
|
} else {
|
||||||
referencingComponent.setPermissions(permissions);
|
referencingComponent.setPermissions(permissions);
|
||||||
referencingComponent.setComponent(null);
|
referencingComponent.setComponent(null);
|
||||||
|
@ -163,4 +201,35 @@ public class ControllerServiceEntityMerger implements ComponentEntityMerger<Cont
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void mergeControllerServiceReferencingComponent(ControllerServiceReferencingComponentEntity clientEntity, Map<NodeIdentifier,
|
||||||
|
ControllerServiceReferencingComponentEntity> nodeEntities) {
|
||||||
|
final Map<String, Map<NodeIdentifier, PropertyDescriptorDTO>> propertyDescriptorMap = new HashMap<>();
|
||||||
|
|
||||||
|
final Map<NodeIdentifier, Set<ControllerServiceReferencingComponentEntity>> nodeReferencingComponentsMap = new HashMap<>();
|
||||||
|
|
||||||
|
// aggregate the property descriptors
|
||||||
|
for (Map.Entry<NodeIdentifier, ControllerServiceReferencingComponentEntity> entry : nodeEntities.entrySet()) {
|
||||||
|
final NodeIdentifier nodeIdentifier = entry.getKey();
|
||||||
|
final ControllerServiceReferencingComponentEntity nodeEntity = entry.getValue();
|
||||||
|
nodeEntity.getComponent().getDescriptors().values().stream().forEach(propertyDescriptor -> {
|
||||||
|
propertyDescriptorMap.computeIfAbsent(propertyDescriptor.getName(), nodeIdToPropertyDescriptor -> new HashMap<>()).put(nodeIdentifier, propertyDescriptor);
|
||||||
|
});
|
||||||
|
nodeReferencingComponentsMap.put(nodeIdentifier, nodeEntity.getComponent().getReferencingComponents());
|
||||||
|
}
|
||||||
|
|
||||||
|
// merge property descriptors
|
||||||
|
for (Map<NodeIdentifier, PropertyDescriptorDTO> propertyDescriptorByNodeId : propertyDescriptorMap.values()) {
|
||||||
|
final Collection<PropertyDescriptorDTO> nodePropertyDescriptors = propertyDescriptorByNodeId.values();
|
||||||
|
if (!nodePropertyDescriptors.isEmpty()) {
|
||||||
|
// get the name of the property descriptor and find that descriptor being returned to the client
|
||||||
|
final PropertyDescriptorDTO propertyDescriptor = nodePropertyDescriptors.iterator().next();
|
||||||
|
final PropertyDescriptorDTO clientPropertyDescriptor = clientEntity.getComponent().getDescriptors().get(propertyDescriptor.getName());
|
||||||
|
PropertyDescriptorDtoMerger.merge(clientPropertyDescriptor, propertyDescriptorByNodeId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
final Set<ControllerServiceReferencingComponentEntity> referencingComponents = clientEntity.getComponent().getReferencingComponents();
|
||||||
|
mergeControllerServiceReferences(referencingComponents, nodeReferencingComponentsMap);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,9 +18,11 @@ package org.apache.nifi.cluster.manager;
|
||||||
|
|
||||||
import org.apache.nifi.cluster.protocol.NodeIdentifier;
|
import org.apache.nifi.cluster.protocol.NodeIdentifier;
|
||||||
import org.apache.nifi.web.api.dto.ProcessorDTO;
|
import org.apache.nifi.web.api.dto.ProcessorDTO;
|
||||||
|
import org.apache.nifi.web.api.dto.PropertyDescriptorDTO;
|
||||||
import org.apache.nifi.web.api.dto.status.ProcessorStatusDTO;
|
import org.apache.nifi.web.api.dto.status.ProcessorStatusDTO;
|
||||||
import org.apache.nifi.web.api.entity.ProcessorEntity;
|
import org.apache.nifi.web.api.entity.ProcessorEntity;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
@ -70,14 +72,29 @@ public class ProcessorEntityMerger implements ComponentEntityMerger<ProcessorEnt
|
||||||
}
|
}
|
||||||
|
|
||||||
final Map<String, Set<NodeIdentifier>> validationErrorMap = new HashMap<>();
|
final Map<String, Set<NodeIdentifier>> validationErrorMap = new HashMap<>();
|
||||||
|
final Map<String, Map<NodeIdentifier, PropertyDescriptorDTO>> propertyDescriptorMap = new HashMap<>();
|
||||||
|
|
||||||
for (final Map.Entry<NodeIdentifier, ProcessorDTO> nodeEntry : dtoMap.entrySet()) {
|
for (final Map.Entry<NodeIdentifier, ProcessorDTO> nodeEntry : dtoMap.entrySet()) {
|
||||||
final ProcessorDTO nodeProcessor = nodeEntry.getValue();
|
final ProcessorDTO nodeProcessor = nodeEntry.getValue();
|
||||||
|
|
||||||
// merge the validation errors, if authorized
|
// merge the validation errors and aggregate the property descriptors, if authorized
|
||||||
if (nodeProcessor != null) {
|
if (nodeProcessor != null) {
|
||||||
final NodeIdentifier nodeId = nodeEntry.getKey();
|
final NodeIdentifier nodeId = nodeEntry.getKey();
|
||||||
ErrorMerger.mergeErrors(validationErrorMap, nodeId, nodeProcessor.getValidationErrors());
|
ErrorMerger.mergeErrors(validationErrorMap, nodeId, nodeProcessor.getValidationErrors());
|
||||||
|
nodeProcessor.getConfig().getDescriptors().values().stream().forEach(propertyDescriptor -> {
|
||||||
|
propertyDescriptorMap.computeIfAbsent(propertyDescriptor.getName(), nodeIdToPropertyDescriptor -> new HashMap<>()).put(nodeId, propertyDescriptor);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// merge property descriptors
|
||||||
|
for (Map<NodeIdentifier, PropertyDescriptorDTO> propertyDescriptorByNodeId : propertyDescriptorMap.values()) {
|
||||||
|
final Collection<PropertyDescriptorDTO> nodePropertyDescriptors = propertyDescriptorByNodeId.values();
|
||||||
|
if (!nodePropertyDescriptors.isEmpty()) {
|
||||||
|
// get the name of the property descriptor and find that descriptor being returned to the client
|
||||||
|
final PropertyDescriptorDTO propertyDescriptor = nodePropertyDescriptors.iterator().next();
|
||||||
|
final PropertyDescriptorDTO clientPropertyDescriptor = clientDto.getConfig().getDescriptors().get(propertyDescriptor.getName());
|
||||||
|
PropertyDescriptorDtoMerger.merge(clientPropertyDescriptor, propertyDescriptorByNodeId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,52 @@
|
||||||
|
/*
|
||||||
|
* 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.cluster.manager;
|
||||||
|
|
||||||
|
import org.apache.nifi.cluster.protocol.NodeIdentifier;
|
||||||
|
import org.apache.nifi.web.api.dto.PropertyDescriptorDTO;
|
||||||
|
import org.apache.nifi.web.api.entity.AllowableValueEntity;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class PropertyDescriptorDtoMerger {
|
||||||
|
public static void merge(PropertyDescriptorDTO clientPropertyDescriptor, Map<NodeIdentifier, PropertyDescriptorDTO> dtoMap) {
|
||||||
|
final Map<Integer, List<AllowableValueEntity>> allowableValueMap = new HashMap<>();
|
||||||
|
|
||||||
|
// values are guaranteed to be in order, so map each allowable value for each property descriptor across all node IDs to the index of the value in the descriptor's list of allowable values
|
||||||
|
for (final Map.Entry<NodeIdentifier, PropertyDescriptorDTO> nodeEntry : dtoMap.entrySet()) {
|
||||||
|
final PropertyDescriptorDTO nodePropertyDescriptor = nodeEntry.getValue();
|
||||||
|
final List<AllowableValueEntity> nodePropertyDescriptorAllowableValues = nodePropertyDescriptor.getAllowableValues();
|
||||||
|
if (clientPropertyDescriptor != nodePropertyDescriptor && nodePropertyDescriptorAllowableValues != null) {
|
||||||
|
nodePropertyDescriptorAllowableValues.stream().forEach(allowableValueEntity -> {
|
||||||
|
allowableValueMap.computeIfAbsent(nodePropertyDescriptorAllowableValues.indexOf(allowableValueEntity), propertyDescriptorToAllowableValue -> new ArrayList<>())
|
||||||
|
.add(allowableValueEntity);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// for each AllowableValueEntity in this PropertyDescriptorDTO, get the corresponding AVs previously aggregated and merge them.
|
||||||
|
final List<AllowableValueEntity> clientPropertyDescriptorAllowableValues = clientPropertyDescriptor.getAllowableValues();
|
||||||
|
if (clientPropertyDescriptorAllowableValues != null) {
|
||||||
|
for (AllowableValueEntity clientAllowableValueEntity : clientPropertyDescriptorAllowableValues) {
|
||||||
|
AllowableValueEntityMerger.merge(clientAllowableValueEntity, allowableValueMap.get(clientPropertyDescriptorAllowableValues.indexOf(clientAllowableValueEntity)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -17,9 +17,11 @@
|
||||||
package org.apache.nifi.cluster.manager;
|
package org.apache.nifi.cluster.manager;
|
||||||
|
|
||||||
import org.apache.nifi.cluster.protocol.NodeIdentifier;
|
import org.apache.nifi.cluster.protocol.NodeIdentifier;
|
||||||
|
import org.apache.nifi.web.api.dto.PropertyDescriptorDTO;
|
||||||
import org.apache.nifi.web.api.dto.ReportingTaskDTO;
|
import org.apache.nifi.web.api.dto.ReportingTaskDTO;
|
||||||
import org.apache.nifi.web.api.entity.ReportingTaskEntity;
|
import org.apache.nifi.web.api.entity.ReportingTaskEntity;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
@ -51,6 +53,7 @@ public class ReportingTaskEntityMerger implements ComponentEntityMerger<Reportin
|
||||||
}
|
}
|
||||||
|
|
||||||
final Map<String, Set<NodeIdentifier>> validationErrorMap = new HashMap<>();
|
final Map<String, Set<NodeIdentifier>> validationErrorMap = new HashMap<>();
|
||||||
|
final Map<String, Map<NodeIdentifier, PropertyDescriptorDTO>> propertyDescriptorMap = new HashMap<>();
|
||||||
|
|
||||||
int activeThreadCount = 0;
|
int activeThreadCount = 0;
|
||||||
for (final Map.Entry<NodeIdentifier, ReportingTaskDTO> nodeEntry : dtoMap.entrySet()) {
|
for (final Map.Entry<NodeIdentifier, ReportingTaskDTO> nodeEntry : dtoMap.entrySet()) {
|
||||||
|
@ -66,6 +69,22 @@ public class ReportingTaskEntityMerger implements ComponentEntityMerger<Reportin
|
||||||
|
|
||||||
// merge the validation errors
|
// merge the validation errors
|
||||||
ErrorMerger.mergeErrors(validationErrorMap, nodeId, nodeReportingTask.getValidationErrors());
|
ErrorMerger.mergeErrors(validationErrorMap, nodeId, nodeReportingTask.getValidationErrors());
|
||||||
|
|
||||||
|
// aggregate the property descriptors
|
||||||
|
nodeReportingTask.getDescriptors().values().stream().forEach(propertyDescriptor -> {
|
||||||
|
propertyDescriptorMap.computeIfAbsent(propertyDescriptor.getName(), nodeIdToPropertyDescriptor -> new HashMap<>()).put(nodeId, propertyDescriptor);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// merge property descriptors
|
||||||
|
for (Map<NodeIdentifier, PropertyDescriptorDTO> propertyDescriptorByNodeId : propertyDescriptorMap.values()) {
|
||||||
|
final Collection<PropertyDescriptorDTO> nodePropertyDescriptors = propertyDescriptorByNodeId.values();
|
||||||
|
if (!nodePropertyDescriptors.isEmpty()) {
|
||||||
|
// get the name of the property descriptor and find that descriptor being returned to the client
|
||||||
|
final PropertyDescriptorDTO propertyDescriptor = nodePropertyDescriptors.iterator().next();
|
||||||
|
final PropertyDescriptorDTO clientPropertyDescriptor = clientDto.getDescriptors().get(propertyDescriptor.getName());
|
||||||
|
PropertyDescriptorDtoMerger.merge(clientPropertyDescriptor, propertyDescriptorByNodeId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
/*
|
|
||||||
/*
|
/*
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
* contributor license agreements. See the NOTICE file distributed with
|
* contributor license agreements. See the NOTICE file distributed with
|
||||||
|
|
|
@ -2502,7 +2502,9 @@ public final class DtoFactory {
|
||||||
dto.setAllowableValues(null);
|
dto.setAllowableValues(null);
|
||||||
} else {
|
} else {
|
||||||
final List<AllowableValueEntity> allowableValues = new ArrayList<>();
|
final List<AllowableValueEntity> allowableValues = new ArrayList<>();
|
||||||
for (final String serviceIdentifier : controllerServiceProvider.getControllerServiceIdentifiers(serviceDefinition, groupId)) {
|
final List<String> controllerServiceIdentifiers = new ArrayList<>(controllerServiceProvider.getControllerServiceIdentifiers(serviceDefinition, groupId));
|
||||||
|
Collections.sort(controllerServiceIdentifiers, Collator.getInstance(Locale.US));
|
||||||
|
for (final String serviceIdentifier : controllerServiceIdentifiers) {
|
||||||
final ControllerServiceNode service = controllerServiceProvider.getControllerServiceNode(serviceIdentifier);
|
final ControllerServiceNode service = controllerServiceProvider.getControllerServiceNode(serviceIdentifier);
|
||||||
final boolean isServiceAuthorized = service.isAuthorized(authorizer, RequestAction.READ, NiFiUserUtils.getNiFiUser());
|
final boolean isServiceAuthorized = service.isAuthorized(authorizer, RequestAction.READ, NiFiUserUtils.getNiFiUser());
|
||||||
final String displayName = isServiceAuthorized ? service.getName() : serviceIdentifier;
|
final String displayName = isServiceAuthorized ? service.getName() : serviceIdentifier;
|
||||||
|
|
|
@ -67,8 +67,6 @@ import java.util.List;
|
||||||
|
|
||||||
public final class EntityFactory {
|
public final class EntityFactory {
|
||||||
|
|
||||||
private static final String NO_PERMISSIONS_MESSAGE = "No permissions were associated with this request";
|
|
||||||
|
|
||||||
public StatusHistoryEntity createStatusHistoryEntity(final StatusHistoryDTO statusHistory, final PermissionsDTO permissions) {
|
public StatusHistoryEntity createStatusHistoryEntity(final StatusHistoryDTO statusHistory, final PermissionsDTO permissions) {
|
||||||
final StatusHistoryEntity entity = new StatusHistoryEntity();
|
final StatusHistoryEntity entity = new StatusHistoryEntity();
|
||||||
entity.setCanRead(permissions.getCanRead());
|
entity.setCanRead(permissions.getCanRead());
|
||||||
|
@ -85,6 +83,7 @@ public final class EntityFactory {
|
||||||
|
|
||||||
public ProcessorStatusSnapshotEntity createProcessorStatusSnapshotEntity(final ProcessorStatusSnapshotDTO status, final PermissionsDTO permissions) {
|
public ProcessorStatusSnapshotEntity createProcessorStatusSnapshotEntity(final ProcessorStatusSnapshotDTO status, final PermissionsDTO permissions) {
|
||||||
final ProcessorStatusSnapshotEntity entity = new ProcessorStatusSnapshotEntity();
|
final ProcessorStatusSnapshotEntity entity = new ProcessorStatusSnapshotEntity();
|
||||||
|
entity.setId(status.getId());
|
||||||
entity.setCanRead(permissions.getCanRead());
|
entity.setCanRead(permissions.getCanRead());
|
||||||
entity.setProcessorStatusSnapshot(status); // always set the status, as it's always allowed... just need to provide permission context for merging responses
|
entity.setProcessorStatusSnapshot(status); // always set the status, as it's always allowed... just need to provide permission context for merging responses
|
||||||
return entity;
|
return entity;
|
||||||
|
@ -99,6 +98,7 @@ public final class EntityFactory {
|
||||||
|
|
||||||
public ConnectionStatusSnapshotEntity createConnectionStatusSnapshotEntity(final ConnectionStatusSnapshotDTO status, final PermissionsDTO permissions) {
|
public ConnectionStatusSnapshotEntity createConnectionStatusSnapshotEntity(final ConnectionStatusSnapshotDTO status, final PermissionsDTO permissions) {
|
||||||
final ConnectionStatusSnapshotEntity entity = new ConnectionStatusSnapshotEntity();
|
final ConnectionStatusSnapshotEntity entity = new ConnectionStatusSnapshotEntity();
|
||||||
|
entity.setId(status.getId());
|
||||||
entity.setCanRead(permissions.getCanRead());
|
entity.setCanRead(permissions.getCanRead());
|
||||||
entity.setConnectionStatusSnapshot(status); // always set the status, as it's always allowed... just need to provide permission context for merging responses
|
entity.setConnectionStatusSnapshot(status); // always set the status, as it's always allowed... just need to provide permission context for merging responses
|
||||||
return entity;
|
return entity;
|
||||||
|
@ -113,6 +113,7 @@ public final class EntityFactory {
|
||||||
|
|
||||||
public ProcessGroupStatusSnapshotEntity createProcessGroupStatusSnapshotEntity(final ProcessGroupStatusSnapshotDTO status, final PermissionsDTO permissions) {
|
public ProcessGroupStatusSnapshotEntity createProcessGroupStatusSnapshotEntity(final ProcessGroupStatusSnapshotDTO status, final PermissionsDTO permissions) {
|
||||||
final ProcessGroupStatusSnapshotEntity entity = new ProcessGroupStatusSnapshotEntity();
|
final ProcessGroupStatusSnapshotEntity entity = new ProcessGroupStatusSnapshotEntity();
|
||||||
|
entity.setId(status.getId());
|
||||||
entity.setCanRead(permissions.getCanRead());
|
entity.setCanRead(permissions.getCanRead());
|
||||||
entity.setProcessGroupStatusSnapshot(status); // always set the status, as it's always allowed... just need to provide permission context for merging responses
|
entity.setProcessGroupStatusSnapshot(status); // always set the status, as it's always allowed... just need to provide permission context for merging responses
|
||||||
return entity;
|
return entity;
|
||||||
|
@ -127,6 +128,7 @@ public final class EntityFactory {
|
||||||
|
|
||||||
public RemoteProcessGroupStatusSnapshotEntity createRemoteProcessGroupStatusSnapshotEntity(final RemoteProcessGroupStatusSnapshotDTO status, final PermissionsDTO permissions) {
|
public RemoteProcessGroupStatusSnapshotEntity createRemoteProcessGroupStatusSnapshotEntity(final RemoteProcessGroupStatusSnapshotDTO status, final PermissionsDTO permissions) {
|
||||||
final RemoteProcessGroupStatusSnapshotEntity entity = new RemoteProcessGroupStatusSnapshotEntity();
|
final RemoteProcessGroupStatusSnapshotEntity entity = new RemoteProcessGroupStatusSnapshotEntity();
|
||||||
|
entity.setId(status.getId());
|
||||||
entity.setCanRead(permissions.getCanRead());
|
entity.setCanRead(permissions.getCanRead());
|
||||||
entity.setRemoteProcessGroupStatusSnapshot(status); // always set the status, as it's always allowed... just need to provide permission context for merging responses
|
entity.setRemoteProcessGroupStatusSnapshot(status); // always set the status, as it's always allowed... just need to provide permission context for merging responses
|
||||||
return entity;
|
return entity;
|
||||||
|
@ -141,21 +143,19 @@ public final class EntityFactory {
|
||||||
|
|
||||||
public PortStatusSnapshotEntity createPortStatusSnapshotEntity(final PortStatusSnapshotDTO status, final PermissionsDTO permissions) {
|
public PortStatusSnapshotEntity createPortStatusSnapshotEntity(final PortStatusSnapshotDTO status, final PermissionsDTO permissions) {
|
||||||
final PortStatusSnapshotEntity entity = new PortStatusSnapshotEntity();
|
final PortStatusSnapshotEntity entity = new PortStatusSnapshotEntity();
|
||||||
|
entity.setId(status.getId());
|
||||||
entity.setCanRead(permissions.getCanRead());
|
entity.setCanRead(permissions.getCanRead());
|
||||||
entity.setPortStatusSnapshot(status); // always set the status, as it's always allowed... just need to provide permission context for merging responses
|
entity.setPortStatusSnapshot(status); // always set the status, as it's always allowed... just need to provide permission context for merging responses
|
||||||
return entity;
|
return entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ControllerConfigurationEntity createControllerConfigurationEntity(final ControllerConfigurationDTO dto, final RevisionDTO revision, final PermissionsDTO permissions) {
|
public ControllerConfigurationEntity createControllerConfigurationEntity(final ControllerConfigurationDTO dto, final RevisionDTO revision, final PermissionsDTO permissions) {
|
||||||
if (permissions == null || permissions.getCanRead() == null) {
|
|
||||||
throw new IllegalStateException(NO_PERMISSIONS_MESSAGE);
|
|
||||||
}
|
|
||||||
final ControllerConfigurationEntity entity = new ControllerConfigurationEntity();
|
final ControllerConfigurationEntity entity = new ControllerConfigurationEntity();
|
||||||
entity.setRevision(revision);
|
entity.setRevision(revision);
|
||||||
entity.setCurrentTime(new Date());
|
entity.setCurrentTime(new Date());
|
||||||
if (dto != null) {
|
if (dto != null) {
|
||||||
entity.setPermissions(permissions);
|
entity.setPermissions(permissions);
|
||||||
if (permissions.getCanRead()) {
|
if (permissions != null && permissions.getCanRead()) {
|
||||||
entity.setComponent(dto);
|
entity.setComponent(dto);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -163,9 +163,6 @@ public final class EntityFactory {
|
||||||
}
|
}
|
||||||
|
|
||||||
public ProcessGroupFlowEntity createProcessGroupFlowEntity(final ProcessGroupFlowDTO dto, final PermissionsDTO permissions) {
|
public ProcessGroupFlowEntity createProcessGroupFlowEntity(final ProcessGroupFlowDTO dto, final PermissionsDTO permissions) {
|
||||||
if (permissions == null || permissions.getCanRead() == null) {
|
|
||||||
throw new IllegalStateException(NO_PERMISSIONS_MESSAGE);
|
|
||||||
}
|
|
||||||
final ProcessGroupFlowEntity entity = new ProcessGroupFlowEntity();
|
final ProcessGroupFlowEntity entity = new ProcessGroupFlowEntity();
|
||||||
entity.setProcessGroupFlow(dto);
|
entity.setProcessGroupFlow(dto);
|
||||||
entity.setPermissions(permissions);
|
entity.setPermissions(permissions);
|
||||||
|
@ -175,9 +172,6 @@ public final class EntityFactory {
|
||||||
public ProcessorEntity createProcessorEntity(final ProcessorDTO dto, final RevisionDTO revision, final PermissionsDTO permissions,
|
public ProcessorEntity createProcessorEntity(final ProcessorDTO dto, final RevisionDTO revision, final PermissionsDTO permissions,
|
||||||
final ProcessorStatusDTO status, final List<BulletinDTO> bulletins) {
|
final ProcessorStatusDTO status, final List<BulletinDTO> bulletins) {
|
||||||
|
|
||||||
if (permissions == null || permissions.getCanRead() == null) {
|
|
||||||
throw new IllegalStateException(NO_PERMISSIONS_MESSAGE);
|
|
||||||
}
|
|
||||||
final ProcessorEntity entity = new ProcessorEntity();
|
final ProcessorEntity entity = new ProcessorEntity();
|
||||||
entity.setRevision(revision);
|
entity.setRevision(revision);
|
||||||
if (dto != null) {
|
if (dto != null) {
|
||||||
|
@ -186,7 +180,7 @@ public final class EntityFactory {
|
||||||
entity.setId(dto.getId());
|
entity.setId(dto.getId());
|
||||||
entity.setInputRequirement(dto.getInputRequirement());
|
entity.setInputRequirement(dto.getInputRequirement());
|
||||||
entity.setPosition(dto.getPosition());
|
entity.setPosition(dto.getPosition());
|
||||||
if (permissions.getCanRead()) {
|
if (permissions != null && permissions.getCanRead()) {
|
||||||
entity.setComponent(dto);
|
entity.setComponent(dto);
|
||||||
entity.setBulletins(bulletins);
|
entity.setBulletins(bulletins);
|
||||||
}
|
}
|
||||||
|
@ -195,9 +189,6 @@ public final class EntityFactory {
|
||||||
}
|
}
|
||||||
|
|
||||||
public PortEntity createPortEntity(final PortDTO dto, final RevisionDTO revision, final PermissionsDTO permissions, final PortStatusDTO status, final List<BulletinDTO> bulletins) {
|
public PortEntity createPortEntity(final PortDTO dto, final RevisionDTO revision, final PermissionsDTO permissions, final PortStatusDTO status, final List<BulletinDTO> bulletins) {
|
||||||
if (permissions == null || permissions.getCanRead() == null) {
|
|
||||||
throw new IllegalStateException(NO_PERMISSIONS_MESSAGE);
|
|
||||||
}
|
|
||||||
final PortEntity entity = new PortEntity();
|
final PortEntity entity = new PortEntity();
|
||||||
entity.setRevision(revision);
|
entity.setRevision(revision);
|
||||||
if (dto != null) {
|
if (dto != null) {
|
||||||
|
@ -206,7 +197,7 @@ public final class EntityFactory {
|
||||||
entity.setId(dto.getId());
|
entity.setId(dto.getId());
|
||||||
entity.setPosition(dto.getPosition());
|
entity.setPosition(dto.getPosition());
|
||||||
entity.setPortType(dto.getType());
|
entity.setPortType(dto.getType());
|
||||||
if (permissions.getCanRead()) {
|
if (permissions != null && permissions.getCanRead()) {
|
||||||
entity.setComponent(dto);
|
entity.setComponent(dto);
|
||||||
entity.setBulletins(bulletins);
|
entity.setBulletins(bulletins);
|
||||||
}
|
}
|
||||||
|
@ -216,10 +207,6 @@ public final class EntityFactory {
|
||||||
|
|
||||||
public ProcessGroupEntity createProcessGroupEntity(final ProcessGroupDTO dto, final RevisionDTO revision, final PermissionsDTO permissions,
|
public ProcessGroupEntity createProcessGroupEntity(final ProcessGroupDTO dto, final RevisionDTO revision, final PermissionsDTO permissions,
|
||||||
final ProcessGroupStatusDTO status, final List<BulletinDTO> bulletins) {
|
final ProcessGroupStatusDTO status, final List<BulletinDTO> bulletins) {
|
||||||
|
|
||||||
if (permissions == null || permissions.getCanRead() == null) {
|
|
||||||
throw new IllegalStateException(NO_PERMISSIONS_MESSAGE);
|
|
||||||
}
|
|
||||||
final ProcessGroupEntity entity = new ProcessGroupEntity();
|
final ProcessGroupEntity entity = new ProcessGroupEntity();
|
||||||
entity.setRevision(revision);
|
entity.setRevision(revision);
|
||||||
entity.setCurrentTime(new Date());
|
entity.setCurrentTime(new Date());
|
||||||
|
@ -245,9 +232,6 @@ public final class EntityFactory {
|
||||||
}
|
}
|
||||||
|
|
||||||
public LabelEntity createLabelEntity(final LabelDTO dto, final RevisionDTO revision, final PermissionsDTO permissions) {
|
public LabelEntity createLabelEntity(final LabelDTO dto, final RevisionDTO revision, final PermissionsDTO permissions) {
|
||||||
if (permissions == null || permissions.getCanRead() == null) {
|
|
||||||
throw new IllegalStateException(NO_PERMISSIONS_MESSAGE);
|
|
||||||
}
|
|
||||||
final LabelEntity entity = new LabelEntity();
|
final LabelEntity entity = new LabelEntity();
|
||||||
entity.setRevision(revision);
|
entity.setRevision(revision);
|
||||||
if (dto != null) {
|
if (dto != null) {
|
||||||
|
@ -260,7 +244,7 @@ public final class EntityFactory {
|
||||||
dimensions.setWidth(dto.getWidth());
|
dimensions.setWidth(dto.getWidth());
|
||||||
entity.setDimensions(dimensions);
|
entity.setDimensions(dimensions);
|
||||||
|
|
||||||
if (permissions.getCanRead()) {
|
if (permissions != null && permissions.getCanRead()) {
|
||||||
entity.setComponent(dto);
|
entity.setComponent(dto);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -268,16 +252,13 @@ public final class EntityFactory {
|
||||||
}
|
}
|
||||||
|
|
||||||
public UserEntity createUserEntity(final UserDTO dto, final RevisionDTO revision, final PermissionsDTO permissions) {
|
public UserEntity createUserEntity(final UserDTO dto, final RevisionDTO revision, final PermissionsDTO permissions) {
|
||||||
if (permissions == null || permissions.getCanRead() == null) {
|
|
||||||
throw new IllegalStateException(NO_PERMISSIONS_MESSAGE);
|
|
||||||
}
|
|
||||||
final UserEntity entity = new UserEntity();
|
final UserEntity entity = new UserEntity();
|
||||||
entity.setRevision(revision);
|
entity.setRevision(revision);
|
||||||
if (dto != null) {
|
if (dto != null) {
|
||||||
entity.setPermissions(permissions);
|
entity.setPermissions(permissions);
|
||||||
entity.setId(dto.getId());
|
entity.setId(dto.getId());
|
||||||
|
|
||||||
if (permissions.getCanRead()) {
|
if (permissions != null && permissions.getCanRead()) {
|
||||||
entity.setComponent(dto);
|
entity.setComponent(dto);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -285,16 +266,13 @@ public final class EntityFactory {
|
||||||
}
|
}
|
||||||
|
|
||||||
public TenantEntity createTenantEntity(final TenantDTO dto, final RevisionDTO revision, final PermissionsDTO permissions) {
|
public TenantEntity createTenantEntity(final TenantDTO dto, final RevisionDTO revision, final PermissionsDTO permissions) {
|
||||||
if (permissions == null || permissions.getCanRead() == null) {
|
|
||||||
throw new IllegalStateException(NO_PERMISSIONS_MESSAGE);
|
|
||||||
}
|
|
||||||
final TenantEntity entity = new TenantEntity();
|
final TenantEntity entity = new TenantEntity();
|
||||||
entity.setRevision(revision);
|
entity.setRevision(revision);
|
||||||
if (dto != null) {
|
if (dto != null) {
|
||||||
entity.setPermissions(permissions);
|
entity.setPermissions(permissions);
|
||||||
entity.setId(dto.getId());
|
entity.setId(dto.getId());
|
||||||
|
|
||||||
if (permissions.getCanRead()) {
|
if (permissions != null && permissions.getCanRead()) {
|
||||||
entity.setComponent(dto);
|
entity.setComponent(dto);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -302,16 +280,13 @@ public final class EntityFactory {
|
||||||
}
|
}
|
||||||
|
|
||||||
public AccessPolicySummaryEntity createAccessPolicySummaryEntity(final AccessPolicySummaryDTO dto, final RevisionDTO revision, final PermissionsDTO permissions) {
|
public AccessPolicySummaryEntity createAccessPolicySummaryEntity(final AccessPolicySummaryDTO dto, final RevisionDTO revision, final PermissionsDTO permissions) {
|
||||||
if (permissions == null || permissions.getCanRead() == null) {
|
|
||||||
throw new IllegalStateException(NO_PERMISSIONS_MESSAGE);
|
|
||||||
}
|
|
||||||
final AccessPolicySummaryEntity entity = new AccessPolicySummaryEntity();
|
final AccessPolicySummaryEntity entity = new AccessPolicySummaryEntity();
|
||||||
entity.setRevision(revision);
|
entity.setRevision(revision);
|
||||||
if (dto != null) {
|
if (dto != null) {
|
||||||
entity.setPermissions(permissions);
|
entity.setPermissions(permissions);
|
||||||
entity.setId(dto.getId());
|
entity.setId(dto.getId());
|
||||||
|
|
||||||
if (permissions.getCanRead()) {
|
if (permissions != null && permissions.getCanRead()) {
|
||||||
entity.setComponent(dto);
|
entity.setComponent(dto);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -319,16 +294,13 @@ public final class EntityFactory {
|
||||||
}
|
}
|
||||||
|
|
||||||
public UserGroupEntity createUserGroupEntity(final UserGroupDTO dto, final RevisionDTO revision, final PermissionsDTO permissions) {
|
public UserGroupEntity createUserGroupEntity(final UserGroupDTO dto, final RevisionDTO revision, final PermissionsDTO permissions) {
|
||||||
if (permissions == null || permissions.getCanRead() == null) {
|
|
||||||
throw new IllegalStateException(NO_PERMISSIONS_MESSAGE);
|
|
||||||
}
|
|
||||||
final UserGroupEntity entity = new UserGroupEntity();
|
final UserGroupEntity entity = new UserGroupEntity();
|
||||||
entity.setRevision(revision);
|
entity.setRevision(revision);
|
||||||
if (dto != null) {
|
if (dto != null) {
|
||||||
entity.setPermissions(permissions);
|
entity.setPermissions(permissions);
|
||||||
entity.setId(dto.getId());
|
entity.setId(dto.getId());
|
||||||
|
|
||||||
if (permissions.getCanRead()) {
|
if (permissions != null && permissions.getCanRead()) {
|
||||||
entity.setComponent(dto);
|
entity.setComponent(dto);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -336,9 +308,6 @@ public final class EntityFactory {
|
||||||
}
|
}
|
||||||
|
|
||||||
public AccessPolicyEntity createAccessPolicyEntity(final AccessPolicyDTO dto, final RevisionDTO revision, final PermissionsDTO permissions) {
|
public AccessPolicyEntity createAccessPolicyEntity(final AccessPolicyDTO dto, final RevisionDTO revision, final PermissionsDTO permissions) {
|
||||||
if (permissions == null || permissions.getCanRead() == null) {
|
|
||||||
throw new IllegalStateException(NO_PERMISSIONS_MESSAGE);
|
|
||||||
}
|
|
||||||
final AccessPolicyEntity entity = new AccessPolicyEntity();
|
final AccessPolicyEntity entity = new AccessPolicyEntity();
|
||||||
entity.setRevision(revision);
|
entity.setRevision(revision);
|
||||||
entity.setGenerated(new Date());
|
entity.setGenerated(new Date());
|
||||||
|
@ -346,7 +315,7 @@ public final class EntityFactory {
|
||||||
entity.setPermissions(permissions);
|
entity.setPermissions(permissions);
|
||||||
entity.setId(dto.getId());
|
entity.setId(dto.getId());
|
||||||
|
|
||||||
if (permissions.getCanRead()) {
|
if (permissions != null && permissions.getCanRead()) {
|
||||||
entity.setComponent(dto);
|
entity.setComponent(dto);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -354,16 +323,13 @@ public final class EntityFactory {
|
||||||
}
|
}
|
||||||
|
|
||||||
public FunnelEntity createFunnelEntity(final FunnelDTO dto, final RevisionDTO revision, final PermissionsDTO permissions) {
|
public FunnelEntity createFunnelEntity(final FunnelDTO dto, final RevisionDTO revision, final PermissionsDTO permissions) {
|
||||||
if (permissions == null || permissions.getCanRead() == null) {
|
|
||||||
throw new IllegalStateException(NO_PERMISSIONS_MESSAGE);
|
|
||||||
}
|
|
||||||
final FunnelEntity entity = new FunnelEntity();
|
final FunnelEntity entity = new FunnelEntity();
|
||||||
entity.setRevision(revision);
|
entity.setRevision(revision);
|
||||||
if (dto != null) {
|
if (dto != null) {
|
||||||
entity.setPermissions(permissions);
|
entity.setPermissions(permissions);
|
||||||
entity.setId(dto.getId());
|
entity.setId(dto.getId());
|
||||||
entity.setPosition(dto.getPosition());
|
entity.setPosition(dto.getPosition());
|
||||||
if (permissions.getCanRead()) {
|
if (permissions != null && permissions.getCanRead()) {
|
||||||
entity.setComponent(dto);
|
entity.setComponent(dto);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -371,9 +337,6 @@ public final class EntityFactory {
|
||||||
}
|
}
|
||||||
|
|
||||||
public ConnectionEntity createConnectionEntity(final ConnectionDTO dto, final RevisionDTO revision, final PermissionsDTO permissions, final ConnectionStatusDTO status) {
|
public ConnectionEntity createConnectionEntity(final ConnectionDTO dto, final RevisionDTO revision, final PermissionsDTO permissions, final ConnectionStatusDTO status) {
|
||||||
if (permissions == null || permissions.getCanRead() == null) {
|
|
||||||
throw new IllegalStateException(NO_PERMISSIONS_MESSAGE);
|
|
||||||
}
|
|
||||||
final ConnectionEntity entity = new ConnectionEntity();
|
final ConnectionEntity entity = new ConnectionEntity();
|
||||||
entity.setRevision(revision);
|
entity.setRevision(revision);
|
||||||
if (dto != null) {
|
if (dto != null) {
|
||||||
|
@ -390,7 +353,7 @@ public final class EntityFactory {
|
||||||
entity.setDestinationId(dto.getDestination().getId());
|
entity.setDestinationId(dto.getDestination().getId());
|
||||||
entity.setDestinationGroupId(dto.getDestination().getGroupId());
|
entity.setDestinationGroupId(dto.getDestination().getGroupId());
|
||||||
entity.setDestinationType(dto.getDestination().getType());
|
entity.setDestinationType(dto.getDestination().getType());
|
||||||
if (permissions.getCanRead()) {
|
if (permissions != null && permissions.getCanRead()) {
|
||||||
entity.setComponent(dto);
|
entity.setComponent(dto);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -399,10 +362,6 @@ public final class EntityFactory {
|
||||||
|
|
||||||
public RemoteProcessGroupEntity createRemoteProcessGroupEntity(final RemoteProcessGroupDTO dto, final RevisionDTO revision, final PermissionsDTO permissions,
|
public RemoteProcessGroupEntity createRemoteProcessGroupEntity(final RemoteProcessGroupDTO dto, final RevisionDTO revision, final PermissionsDTO permissions,
|
||||||
final RemoteProcessGroupStatusDTO status, final List<BulletinDTO> bulletins) {
|
final RemoteProcessGroupStatusDTO status, final List<BulletinDTO> bulletins) {
|
||||||
|
|
||||||
if (permissions == null || permissions.getCanRead() == null) {
|
|
||||||
throw new IllegalStateException(NO_PERMISSIONS_MESSAGE);
|
|
||||||
}
|
|
||||||
final RemoteProcessGroupEntity entity = new RemoteProcessGroupEntity();
|
final RemoteProcessGroupEntity entity = new RemoteProcessGroupEntity();
|
||||||
entity.setRevision(revision);
|
entity.setRevision(revision);
|
||||||
if (dto != null) {
|
if (dto != null) {
|
||||||
|
@ -412,7 +371,7 @@ public final class EntityFactory {
|
||||||
entity.setPosition(dto.getPosition());
|
entity.setPosition(dto.getPosition());
|
||||||
entity.setInputPortCount(dto.getInputPortCount());
|
entity.setInputPortCount(dto.getInputPortCount());
|
||||||
entity.setOutputPortCount(dto.getOutputPortCount());
|
entity.setOutputPortCount(dto.getOutputPortCount());
|
||||||
if (permissions.getCanRead()) {
|
if (permissions != null && permissions.getCanRead()) {
|
||||||
entity.setComponent(dto);
|
entity.setComponent(dto);
|
||||||
entity.setBulletins(bulletins);
|
entity.setBulletins(bulletins);
|
||||||
}
|
}
|
||||||
|
@ -421,15 +380,12 @@ public final class EntityFactory {
|
||||||
}
|
}
|
||||||
|
|
||||||
public RemoteProcessGroupPortEntity createRemoteProcessGroupPortEntity(final RemoteProcessGroupPortDTO dto, final RevisionDTO revision, final PermissionsDTO permissions) {
|
public RemoteProcessGroupPortEntity createRemoteProcessGroupPortEntity(final RemoteProcessGroupPortDTO dto, final RevisionDTO revision, final PermissionsDTO permissions) {
|
||||||
if (permissions == null || permissions.getCanRead() == null) {
|
|
||||||
throw new IllegalStateException(NO_PERMISSIONS_MESSAGE);
|
|
||||||
}
|
|
||||||
final RemoteProcessGroupPortEntity entity = new RemoteProcessGroupPortEntity();
|
final RemoteProcessGroupPortEntity entity = new RemoteProcessGroupPortEntity();
|
||||||
entity.setRevision(revision);
|
entity.setRevision(revision);
|
||||||
if (dto != null) {
|
if (dto != null) {
|
||||||
entity.setPermissions(permissions);
|
entity.setPermissions(permissions);
|
||||||
entity.setId(dto.getId());
|
entity.setId(dto.getId());
|
||||||
if (permissions.getCanRead()) {
|
if (permissions != null && permissions.getCanRead()) {
|
||||||
entity.setRemoteProcessGroupPort(dto);
|
entity.setRemoteProcessGroupPort(dto);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -444,15 +400,12 @@ public final class EntityFactory {
|
||||||
}
|
}
|
||||||
|
|
||||||
public ReportingTaskEntity createReportingTaskEntity(final ReportingTaskDTO dto, final RevisionDTO revision, final PermissionsDTO permissions, final List<BulletinDTO> bulletins) {
|
public ReportingTaskEntity createReportingTaskEntity(final ReportingTaskDTO dto, final RevisionDTO revision, final PermissionsDTO permissions, final List<BulletinDTO> bulletins) {
|
||||||
if (permissions == null || permissions.getCanRead() == null) {
|
|
||||||
throw new IllegalStateException(NO_PERMISSIONS_MESSAGE);
|
|
||||||
}
|
|
||||||
final ReportingTaskEntity entity = new ReportingTaskEntity();
|
final ReportingTaskEntity entity = new ReportingTaskEntity();
|
||||||
entity.setRevision(revision);
|
entity.setRevision(revision);
|
||||||
if (dto != null) {
|
if (dto != null) {
|
||||||
entity.setPermissions(permissions);
|
entity.setPermissions(permissions);
|
||||||
entity.setId(dto.getId());
|
entity.setId(dto.getId());
|
||||||
if (permissions.getCanRead()) {
|
if (permissions != null && permissions.getCanRead()) {
|
||||||
entity.setComponent(dto);
|
entity.setComponent(dto);
|
||||||
entity.setBulletins(bulletins);
|
entity.setBulletins(bulletins);
|
||||||
}
|
}
|
||||||
|
@ -462,16 +415,13 @@ public final class EntityFactory {
|
||||||
}
|
}
|
||||||
|
|
||||||
public ControllerServiceEntity createControllerServiceEntity(final ControllerServiceDTO dto, final RevisionDTO revision, final PermissionsDTO permissions, final List<BulletinDTO> bulletins) {
|
public ControllerServiceEntity createControllerServiceEntity(final ControllerServiceDTO dto, final RevisionDTO revision, final PermissionsDTO permissions, final List<BulletinDTO> bulletins) {
|
||||||
if (permissions == null || permissions.getCanRead() == null) {
|
|
||||||
throw new IllegalStateException(NO_PERMISSIONS_MESSAGE);
|
|
||||||
}
|
|
||||||
final ControllerServiceEntity entity = new ControllerServiceEntity();
|
final ControllerServiceEntity entity = new ControllerServiceEntity();
|
||||||
entity.setRevision(revision);
|
entity.setRevision(revision);
|
||||||
if (dto != null) {
|
if (dto != null) {
|
||||||
entity.setPermissions(permissions);
|
entity.setPermissions(permissions);
|
||||||
entity.setId(dto.getId());
|
entity.setId(dto.getId());
|
||||||
entity.setPosition(dto.getPosition());
|
entity.setPosition(dto.getPosition());
|
||||||
if (permissions.getCanRead()) {
|
if (permissions != null && permissions.getCanRead()) {
|
||||||
entity.setComponent(dto);
|
entity.setComponent(dto);
|
||||||
entity.setBulletins(bulletins);
|
entity.setBulletins(bulletins);
|
||||||
}
|
}
|
||||||
|
@ -481,16 +431,12 @@ public final class EntityFactory {
|
||||||
|
|
||||||
public ControllerServiceReferencingComponentEntity createControllerServiceReferencingComponentEntity(
|
public ControllerServiceReferencingComponentEntity createControllerServiceReferencingComponentEntity(
|
||||||
final ControllerServiceReferencingComponentDTO dto, final RevisionDTO revision, final PermissionsDTO permissions) {
|
final ControllerServiceReferencingComponentDTO dto, final RevisionDTO revision, final PermissionsDTO permissions) {
|
||||||
|
|
||||||
if (permissions == null || permissions.getCanRead() == null) {
|
|
||||||
throw new IllegalStateException(NO_PERMISSIONS_MESSAGE);
|
|
||||||
}
|
|
||||||
final ControllerServiceReferencingComponentEntity entity = new ControllerServiceReferencingComponentEntity();
|
final ControllerServiceReferencingComponentEntity entity = new ControllerServiceReferencingComponentEntity();
|
||||||
entity.setRevision(revision);
|
entity.setRevision(revision);
|
||||||
if (dto != null) {
|
if (dto != null) {
|
||||||
entity.setPermissions(permissions);
|
entity.setPermissions(permissions);
|
||||||
entity.setId(dto.getId());
|
entity.setId(dto.getId());
|
||||||
if (permissions.getCanRead()) {
|
if (permissions != null && permissions.getCanRead()) {
|
||||||
entity.setComponent(dto);
|
entity.setComponent(dto);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -499,14 +445,11 @@ public final class EntityFactory {
|
||||||
}
|
}
|
||||||
|
|
||||||
public FlowBreadcrumbEntity createFlowBreadcrumbEntity(final FlowBreadcrumbDTO dto, final PermissionsDTO permissions) {
|
public FlowBreadcrumbEntity createFlowBreadcrumbEntity(final FlowBreadcrumbDTO dto, final PermissionsDTO permissions) {
|
||||||
if (permissions == null || permissions.getCanRead() == null) {
|
|
||||||
throw new IllegalStateException(NO_PERMISSIONS_MESSAGE);
|
|
||||||
}
|
|
||||||
final FlowBreadcrumbEntity entity = new FlowBreadcrumbEntity();
|
final FlowBreadcrumbEntity entity = new FlowBreadcrumbEntity();
|
||||||
if (dto != null) {
|
if (dto != null) {
|
||||||
entity.setPermissions(permissions);
|
entity.setPermissions(permissions);
|
||||||
entity.setId(dto.getId());
|
entity.setId(dto.getId());
|
||||||
if (permissions.getCanRead()) {
|
if (permissions != null && permissions.getCanRead()) {
|
||||||
entity.setBreadcrumb(dto);
|
entity.setBreadcrumb(dto);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue