NIFI-1554:

- Populating component entities in the REST API to decouple key fields from the configuration DTOs.
- Added initial support for components in UI when access isn't allowed. Formal styling to come later.
This commit is contained in:
Matt Gilman 2016-04-29 14:49:13 -04:00
parent a4409d366c
commit ff98d823e2
167 changed files with 5203 additions and 3821 deletions

View File

@ -29,7 +29,7 @@ public interface Resource {
String getIdentifier();
/**
* The name of this resource.
* The name of this resource. May be null.
*
* @return name of this resource
*/

View File

@ -21,40 +21,6 @@
<version>1.0.0-SNAPSHOT</version>
</parent>
<artifactId>nifi-administration</artifactId>
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
</resource>
<resource>
<directory>src/main/xsd</directory>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxb2-maven-plugin</artifactId>
<executions>
<execution>
<id>current</id>
<goals>
<goal>xjc</goal>
</goals>
<configuration>
<packageName>org.apache.nifi.authorization.generated</packageName>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<configuration>
<excludes>**/authorization/generated/*.java,</excludes>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.apache.nifi</groupId>
@ -116,9 +82,5 @@
<groupId>org.apache.commons</groupId>
<artifactId>commons-collections4</artifactId>
</dependency>
<dependency>
<groupId>org.apache.nifi</groupId>
<artifactId>nifi-expression-language</artifactId>
</dependency>
</dependencies>
</project>

View File

@ -16,6 +16,8 @@
*/
package org.apache.nifi.user;
import org.apache.nifi.authorization.user.NiFiUser;
import java.util.Set;
/**

View File

@ -18,11 +18,6 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd">
<!-- user/entity authorizer -->
<bean id="authorizer" class="org.apache.nifi.authorization.AuthorizerFactoryBean">
<property name="properties" ref="nifiProperties"/>
</bean>
<!-- initialize the user key data source -->
<bean id="keyDataSource" class="org.apache.nifi.admin.KeyDataSourceFactoryBean" destroy-method="shutdown">
<property name="properties" ref="nifiProperties"/>

View File

@ -0,0 +1,62 @@
/*
* 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;
import com.wordnik.swagger.annotations.ApiModelProperty;
import javax.xml.bind.annotation.XmlType;
/**
* Details for the access configuration.
*/
@XmlType(name = "accessPolicy")
public class AccessPolicyDTO {
private Boolean canRead;
private Boolean canWrite;
/**
* @return Indicates whether the user can read a given resource.
*/
@ApiModelProperty(
value = "Indicates whether the user can read a given resource.",
readOnly = true
)
public Boolean getCanRead() {
return canRead;
}
public void setCanRead(Boolean canRead) {
this.canRead = canRead;
}
/**
* @return Indicates whether the user can write a given resource.
*/
@ApiModelProperty(
value = "Indicates whether the user can write a given resource.",
readOnly = true
)
public Boolean getCanWrite() {
return canWrite;
}
public void setCanWrite(Boolean canWrite) {
this.canWrite = canWrite;
}
}

View File

@ -22,25 +22,13 @@ import javax.xml.bind.annotation.XmlType;
/**
* Base class for all nifi components.
*/
@XmlType(name = "nifiComponent")
public class NiFiComponentDTO {
@XmlType(name = "component")
public class ComponentDTO {
private String id;
private String uri;
private PositionDTO position;
private String parentGroupId;
public NiFiComponentDTO() {
}
public NiFiComponentDTO(final String id) {
this.id = id;
}
public NiFiComponentDTO(final String id, final double x, final double y) {
this.id = id;
this.position = new PositionDTO(x, y);
}
private PositionDTO position;
/**
* The id for this component.
@ -88,19 +76,19 @@ public class NiFiComponentDTO {
this.uri = uri;
}
public void setPosition(final PositionDTO position) {
this.position = position;
}
/**
* The position of this component in the UI if applicable, null otherwise.
*
* @return The position
*/
@ApiModelProperty(
value = "The position of this component in the UI if applicable."
value = "The position of this component in the UI if applicable."
)
public PositionDTO getPosition() {
return position;
}
public void setPosition(final PositionDTO position) {
this.position = position;
}
}

View File

@ -25,7 +25,7 @@ import javax.xml.bind.annotation.XmlType;
* A connection between two connectable components.
*/
@XmlType(name = "connection")
public class ConnectionDTO extends NiFiComponentDTO {
public class ConnectionDTO extends ComponentDTO {
private ConnectableDTO source;
private ConnectableDTO destination;

View File

@ -26,7 +26,7 @@ import javax.xml.bind.annotation.XmlType;
* A Controller Service that can be shared by other components
*/
@XmlType(name = "controllerService")
public class ControllerServiceDTO extends NiFiComponentDTO {
public class ControllerServiceDTO extends ComponentDTO {
private String name;
private String type;

View File

@ -0,0 +1,61 @@
/*
* 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;
import com.wordnik.swagger.annotations.ApiModelProperty;
import javax.xml.bind.annotation.XmlType;
/**
* A position on the canvas.
*/
@XmlType(name = "dimensions")
public class DimensionsDTO {
private Double width;
private Double height;
/* getters / setters */
/**
* @return height of the label in pixels when at a 1:1 scale
*/
@ApiModelProperty(
value = "The height of the label in pixels when at a 1:1 scale."
)
public Double getHeight() {
return height;
}
public void setHeight(Double height) {
this.height = height;
}
/**
* @return width of the label in pixels when at a 1:1 scale
*/
@ApiModelProperty(
value = "The width of the label in pixels when at a 1:1 scale."
)
public Double getWidth() {
return width;
}
public void setWidth(Double width) {
this.width = width;
}
}

View File

@ -22,7 +22,7 @@ import javax.xml.bind.annotation.XmlType;
* Details of a funnel.
*/
@XmlType(name = "funnel")
public class FunnelDTO extends NiFiComponentDTO {
public class FunnelDTO extends ComponentDTO {
public FunnelDTO() {
}

View File

@ -25,7 +25,7 @@ import javax.xml.bind.annotation.XmlType;
* Details of a label.
*/
@XmlType(name = "label")
public class LabelDTO extends NiFiComponentDTO {
public class LabelDTO extends ComponentDTO {
private String label;

View File

@ -25,7 +25,7 @@ import javax.xml.bind.annotation.XmlType;
* The details for a port within this NiFi flow.
*/
@XmlType(name = "port")
public class PortDTO extends NiFiComponentDTO {
public class PortDTO extends ComponentDTO {
private String name;
private String comments;

View File

@ -23,14 +23,12 @@ import javax.xml.bind.annotation.XmlType;
* The details for a process group within this NiFi flow.
*/
@XmlType(name = "processGroup")
public class ProcessGroupDTO extends NiFiComponentDTO {
public class ProcessGroupDTO extends ComponentDTO {
private String name;
private String comments;
private Boolean running;
private ProcessGroupDTO parent;
private Integer runningCount;
private Integer stoppedCount;
private Integer invalidCount;
@ -63,22 +61,6 @@ public class ProcessGroupDTO extends NiFiComponentDTO {
this.name = name;
}
/**
* This Process Group's parent
*
* @return This Process Group's parent
*/
@ApiModelProperty(
value = "The part of the process group."
)
public ProcessGroupDTO getParent() {
return parent;
}
public void setParent(ProcessGroupDTO parent) {
this.parent = parent;
}
/**
* @return comments for this process group
*/

View File

@ -26,7 +26,7 @@ import javax.xml.bind.annotation.XmlType;
* Details for a processor within this NiFi.
*/
@XmlType(name = "processor")
public class ProcessorDTO extends NiFiComponentDTO {
public class ProcessorDTO extends ComponentDTO {
private String name;
private String type;

View File

@ -27,7 +27,7 @@ import org.apache.nifi.web.api.dto.util.DateTimeAdapter;
* Details of a remote process group in this NiFi.
*/
@XmlType(name = "remoteProcessGroup")
public class RemoteProcessGroupDTO extends NiFiComponentDTO {
public class RemoteProcessGroupDTO extends ComponentDTO {
private String targetUri;
private Boolean targetSecure;

View File

@ -26,7 +26,7 @@ import javax.xml.bind.annotation.XmlType;
* Component that is capable of reporting internal NiFi state to an external service
*/
@XmlType(name = "reportingTask")
public class ReportingTaskDTO extends NiFiComponentDTO {
public class ReportingTaskDTO extends ComponentDTO {
private String name;
private String type;

View File

@ -17,9 +17,10 @@
package org.apache.nifi.web.api.dto;
import com.wordnik.swagger.annotations.ApiModelProperty;
import javax.xml.bind.annotation.XmlType;
import java.util.HashSet;
import java.util.Set;
import javax.xml.bind.annotation.XmlType;
/**
* The contents of a snippet of a flow.
@ -42,8 +43,6 @@ public class SnippetDTO {
private Set<String> labels = new HashSet<>();
private Set<String> funnels = new HashSet<>();
private FlowSnippetDTO contents;
/**
* @return id of this snippet
*/
@ -230,18 +229,4 @@ public class SnippetDTO {
this.remoteProcessGroups = remoteProcessGroups;
}
/**
* @return the contents of the configuration for this snippet
*/
@ApiModelProperty(
value = "The contents of the configuration for the snippet."
)
public FlowSnippetDTO getContents() {
return contents;
}
public void setContents(FlowSnippetDTO contents) {
this.contents = contents;
}
}

View File

@ -0,0 +1,80 @@
/*
* 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.flow;
import com.wordnik.swagger.annotations.ApiModelProperty;
import javax.xml.bind.annotation.XmlType;
/**
* Breadcrumb for the flow.
*/
@XmlType(name = "flowBreadcrumb")
public class FlowBreadcrumbDTO {
private String id;
private String name;
private FlowBreadcrumbDTO parentBreadcrumb;
/**
* The id for this group.
*
* @return The id
*/
@ApiModelProperty(
value = "The id of the group."
)
public String getId() {
return this.id;
}
public void setId(final String id) {
this.id = id;
}
/**
* The name for this group.
*
* @return The name
*/
@ApiModelProperty(
value = "The id of the group."
)
public String getName() {
return this.name;
}
public void setName(final String name) {
this.name = name;
}
/**
* The parent breadcrumb for this breadcrumb.
*
* @return The parent breadcrumb for this breadcrumb
*/
@ApiModelProperty(
value = "The parent breadcrumb for this breadcrumb."
)
public FlowBreadcrumbDTO getParentBreadcrumb() {
return parentBreadcrumb;
}
public void setParentBreadcrumb(FlowBreadcrumbDTO parentBreadcrumb) {
this.parentBreadcrumb = parentBreadcrumb;
}
}

View File

@ -0,0 +1,174 @@
/*
* 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.flow;
import com.wordnik.swagger.annotations.ApiModelProperty;
import org.apache.nifi.web.api.entity.ConnectionEntity;
import org.apache.nifi.web.api.entity.ControllerServiceEntity;
import org.apache.nifi.web.api.entity.FunnelEntity;
import org.apache.nifi.web.api.entity.LabelEntity;
import org.apache.nifi.web.api.entity.PortEntity;
import org.apache.nifi.web.api.entity.ProcessGroupEntity;
import org.apache.nifi.web.api.entity.ProcessorEntity;
import org.apache.nifi.web.api.entity.RemoteProcessGroupEntity;
import javax.xml.bind.annotation.XmlType;
import java.util.LinkedHashSet;
import java.util.Set;
/**
* The structure of the flow.
*/
@XmlType(name = "flow")
public class FlowDTO {
private Set<ProcessGroupEntity> processGroups = new LinkedHashSet<>();
private Set<RemoteProcessGroupEntity> remoteProcessGroups = new LinkedHashSet<>();
private Set<ProcessorEntity> processors = new LinkedHashSet<>();
private Set<PortEntity> inputPorts = new LinkedHashSet<>();
private Set<PortEntity> outputPorts = new LinkedHashSet<>();
private Set<ConnectionEntity> connections = new LinkedHashSet<>();
private Set<LabelEntity> labels = new LinkedHashSet<>();
private Set<FunnelEntity> funnels = new LinkedHashSet<>();
private Set<ControllerServiceEntity> controllerServices = new LinkedHashSet<>();
/**
* @return connections in this flow
*/
@ApiModelProperty(
value = "The connections in this flow."
)
public Set<ConnectionEntity> getConnections() {
return connections;
}
public void setConnections(Set<ConnectionEntity> connections) {
this.connections = connections;
}
/**
* @return input ports in this flow
*/
@ApiModelProperty(
value = "The input ports in this flow."
)
public Set<PortEntity> getInputPorts() {
return inputPorts;
}
public void setInputPorts(Set<PortEntity> inputPorts) {
this.inputPorts = inputPorts;
}
/**
* @return labels in this flow
*/
@ApiModelProperty(
value = "The labels in this flow."
)
public Set<LabelEntity> getLabels() {
return labels;
}
public void setLabels(Set<LabelEntity> labels) {
this.labels = labels;
}
/**
* @return funnels in this flow
*/
@ApiModelProperty(
value = "The funnels in this flow."
)
public Set<FunnelEntity> getFunnels() {
return funnels;
}
public void setFunnels(Set<FunnelEntity> funnels) {
this.funnels = funnels;
}
/**
* @return output ports in this flow
*/
@ApiModelProperty(
value = "The output ports in this flow."
)
public Set<PortEntity> getOutputPorts() {
return outputPorts;
}
public void setOutputPorts(Set<PortEntity> outputPorts) {
this.outputPorts = outputPorts;
}
/**
* @return process groups in this flow
*/
@ApiModelProperty(
value = "The process groups in this flow."
)
public Set<ProcessGroupEntity> getProcessGroups() {
return processGroups;
}
public void setProcessGroups(Set<ProcessGroupEntity> processGroups) {
this.processGroups = processGroups;
}
/**
* @return processors in this flow
*/
@ApiModelProperty(
value = "The processors in this flow."
)
public Set<ProcessorEntity> getProcessors() {
return processors;
}
public void setProcessors(Set<ProcessorEntity> processors) {
this.processors = processors;
}
/**
* @return remote process groups in this flow
*/
@ApiModelProperty(
value = "The remote process groups in this flow."
)
public Set<RemoteProcessGroupEntity> getRemoteProcessGroups() {
return remoteProcessGroups;
}
public void setRemoteProcessGroups(Set<RemoteProcessGroupEntity> remoteProcessGroups) {
this.remoteProcessGroups = remoteProcessGroups;
}
/**
* @return the Controller Services in this flow
*/
@ApiModelProperty(
value = "The controller services in this flow."
)
public Set<ControllerServiceEntity> getControllerServices() {
return controllerServices;
}
public void setControllerServices(Set<ControllerServiceEntity> controllerServices) {
this.controllerServices = controllerServices;
}
}

View File

@ -0,0 +1,112 @@
/*
* 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.flow;
import com.wordnik.swagger.annotations.ApiModelProperty;
import javax.xml.bind.annotation.XmlType;
/**
* The NiFi flow starting at a given Process Group.
*/
@XmlType(name = "processGroupflow")
public class ProcessGroupFlowDTO {
private String id;
private String uri;
private String parentGroupId;
private FlowBreadcrumbDTO breadcrumb;
private FlowDTO flow;
/**
* @return contents of this process group. This field will be populated if the request is marked verbose
*/
@ApiModelProperty(
value = "The flow structure starting at this Process Group."
)
public FlowDTO getFlow() {
return flow;
}
public void setFlow(FlowDTO flow) {
this.flow = flow;
}
/**
* 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 breadcrumb for this ProcessGroup flow.
*
* @return The breadcrumb for this ProcessGroup flow
*/
@ApiModelProperty(
value = "The breadcrumb of the process group."
)
public FlowBreadcrumbDTO getBreadcrumb() {
return breadcrumb;
}
public void setBreadcrumb(FlowBreadcrumbDTO breadcrumb) {
this.breadcrumb = breadcrumb;
}
/**
* @return id for the parent group of this component if applicable, null otherwise
*/
@ApiModelProperty(
value = "The id of parent process group of this component if applicable."
)
public String getParentGroupId() {
return parentGroupId;
}
public void setParentGroupId(String parentGroupId) {
this.parentGroupId = parentGroupId;
}
/**
* The uri for linking to this component in this NiFi.
*
* @return The uri
*/
@ApiModelProperty(
value = "The URI for futures requests to the component."
)
public String getUri() {
return uri;
}
public void setUri(String uri) {
this.uri = uri;
}
}

View File

@ -0,0 +1,119 @@
/*
* 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 com.wordnik.swagger.annotations.ApiModelProperty;
import org.apache.nifi.web.api.dto.AccessPolicyDTO;
import org.apache.nifi.web.api.dto.PositionDTO;
import org.apache.nifi.web.api.dto.RevisionDTO;
import javax.xml.bind.annotation.XmlRootElement;
/**
* A base type for request/response entities.
*/
@XmlRootElement(name = "entity")
public class ComponentEntity extends Entity {
private RevisionDTO revision;
private String id;
private String uri;
private PositionDTO position;
private AccessPolicyDTO accessPolicy;
/**
* @return revision for this request/response
*/
@ApiModelProperty(
value = "The revision for this request/response. The revision is required for any mutable flow requests and is included in all responses."
)
public RevisionDTO getRevision() {
if (revision == null) {
return new RevisionDTO();
} else {
return revision;
}
}
public void setRevision(RevisionDTO revision) {
this.revision = revision;
}
/**
* 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 uri for linking to this component in this NiFi.
*
* @return The uri
*/
@ApiModelProperty(
value = "The URI for futures requests to the component."
)
public String getUri() {
return uri;
}
public void setUri(String uri) {
this.uri = uri;
}
/**
* The position of this component in the UI if applicable, null otherwise.
*
* @return The position
*/
@ApiModelProperty(
value = "The position of this component in the UI if applicable."
)
public PositionDTO getPosition() {
return position;
}
public void setPosition(PositionDTO position) {
this.position = position;
}
/**
* The access policy for this component.
*
* @return The access policy
*/
@ApiModelProperty(
value = "The access policy for this component."
)
public AccessPolicyDTO getAccessPolicy() {
return accessPolicy;
}
public void setAccessPolicy(AccessPolicyDTO accessPolicy) {
this.accessPolicy = accessPolicy;
}
}

View File

@ -16,26 +16,119 @@
*/
package org.apache.nifi.web.api.entity;
import javax.xml.bind.annotation.XmlRootElement;
import com.wordnik.swagger.annotations.ApiModelProperty;
import org.apache.nifi.web.api.dto.ConnectionDTO;
import org.apache.nifi.web.api.dto.PositionDTO;
import javax.xml.bind.annotation.XmlRootElement;
import java.util.List;
/**
* A serialized representation of this class can be placed in the entity body of a response to the API. This particular entity holds a reference to a ConnectionDTO.
*/
@XmlRootElement(name = "connectionEntity")
public class ConnectionEntity extends Entity {
public class ConnectionEntity extends ComponentEntity {
private ConnectionDTO connection;
private ConnectionDTO component;
private List<PositionDTO> bends;
private Integer labelIndex;
private String sourceId;
private String sourceGroupId;
private String destinationId;
private String destinationGroupId;
/**
* @return RelationshipDTO that is being serialized
*/
public ConnectionDTO getConnection() {
return connection;
public ConnectionDTO getComponent() {
return component;
}
public void setConnection(ConnectionDTO connection) {
this.connection = connection;
public void setComponent(ConnectionDTO component) {
this.component = component;
}
/**
* @return position of the bend points on this connection
*/
@ApiModelProperty(
value = "The bend points on the connection."
)
public List<PositionDTO> getBends() {
return bends;
}
public void setBends(List<PositionDTO> bends) {
this.bends = bends;
}
/**
* @return The index of control point that the connection label should be placed over
*/
@ApiModelProperty(
value = "The index of the bend point where to place the connection label."
)
public Integer getLabelIndex() {
return labelIndex;
}
public void setLabelIndex(Integer labelIndex) {
this.labelIndex = labelIndex;
}
/**
* @return The identifier of the source of this connection
*/
@ApiModelProperty(
value = "The identifier of the source of this connection."
)
public String getSourceId() {
return sourceId;
}
public void setSourceId(String sourceId) {
this.sourceId = sourceId;
}
/**
* @return The identifier of the destination of this connection
*/
@ApiModelProperty(
value = "The identifier of the destination of this connection."
)
public String getDestinationId() {
return destinationId;
}
public void setDestinationId(String destinationId) {
this.destinationId = destinationId;
}
/**
* @return The identifier of the group of the source of this connection
*/
@ApiModelProperty(
value = "The identifier of the group of the source of this connection."
)
public String getSourceGroupId() {
return sourceGroupId;
}
public void setSourceGroupId(String sourceGroupId) {
this.sourceGroupId = sourceGroupId;
}
/**
* @return The identifier of the group of the destination of this connection
*/
@ApiModelProperty(
value = "The identifier of the group of the destination of this connection."
)
public String getDestinationGroupId() {
return destinationGroupId;
}
public void setDestinationGroupId(String destinationGroupId) {
this.destinationGroupId = destinationGroupId;
}
}

View File

@ -16,27 +16,25 @@
*/
package org.apache.nifi.web.api.entity;
import javax.xml.bind.annotation.XmlRootElement;
import java.util.Set;
import javax.xml.bind.annotation.XmlRootElement;
import org.apache.nifi.web.api.dto.ConnectionDTO;
/**
* A serialized representation of this class can be placed in the entity body of a response to the API. This particular entity holds a reference to a list of ConnectionDTOs.
* A serialized representation of this class can be placed in the entity body of a response to the API. This particular entity holds a reference to a list of ConnectionEntitys.
*/
@XmlRootElement(name = "connectionsEntity")
public class ConnectionsEntity extends Entity {
private Set<ConnectionDTO> connections;
private Set<ConnectionEntity> connections;
/**
* @return list of ConnectionDTOs that are being serialized
* @return list of ConnectionEntitys that are being serialized
*/
public Set<ConnectionDTO> getConnections() {
public Set<ConnectionEntity> getConnections() {
return connections;
}
public void setConnections(Set<ConnectionDTO> connections) {
public void setConnections(Set<ConnectionEntity> connections) {
this.connections = connections;
}

View File

@ -23,7 +23,7 @@ import org.apache.nifi.web.api.dto.ControllerServiceDTO;
* A serialized representation of this class can be placed in the entity body of a response to the API. This particular entity holds a reference to a controller service.
*/
@XmlRootElement(name = "controllerServiceEntity")
public class ControllerServiceEntity extends Entity {
public class ControllerServiceEntity extends ComponentEntity {
private ControllerServiceDTO controllerService;

View File

@ -17,9 +17,10 @@
package org.apache.nifi.web.api.entity;
import com.wordnik.swagger.annotations.ApiModelProperty;
import javax.xml.bind.annotation.XmlRootElement;
import org.apache.nifi.web.api.dto.RevisionDTO;
import javax.xml.bind.annotation.XmlRootElement;
/**
* A base type for request/response entities.
*/
@ -34,6 +35,7 @@ public class Entity {
@ApiModelProperty(
value = "The revision for this request/response. The revision is required for any mutable flow requests and is included in all responses."
)
@Deprecated
public RevisionDTO getRevision() {
if (revision == null) {
return new RevisionDTO();
@ -42,6 +44,7 @@ public class Entity {
}
}
@Deprecated
public void setRevision(RevisionDTO revision) {
this.revision = revision;
}

View File

@ -16,26 +16,29 @@
*/
package org.apache.nifi.web.api.entity;
import org.apache.nifi.web.api.dto.flow.FlowDTO;
import javax.xml.bind.annotation.XmlRootElement;
import org.apache.nifi.web.api.dto.PortDTO;
/**
* A serialized representation of this class can be placed in the entity body of a response to the API. This particular entity holds a reference to an output PortDTO.
* 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 FlowDTO.
*/
@XmlRootElement(name = "outputPortEntity")
public class OutputPortEntity extends Entity {
@XmlRootElement(name = "flowEntity")
public class FlowEntity extends Entity {
private PortDTO outputPort;
private FlowDTO flow;
/**
* @return output PortDTO that are being serialized
* The FlowDTO that is being serialized.
*
* @return The FlowDTO object
*/
public PortDTO getOutputPort() {
return outputPort;
public FlowDTO getFlow() {
return flow;
}
public void setOutputPort(PortDTO outputPort) {
this.outputPort = outputPort;
public void setFlow(FlowDTO flow) {
this.flow = flow;
}
}

View File

@ -23,21 +23,21 @@ import org.apache.nifi.web.api.dto.FunnelDTO;
* 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 FunnelDTO.
*/
@XmlRootElement(name = "funnelEntity")
public class FunnelEntity extends Entity {
public class FunnelEntity extends ComponentEntity {
private FunnelDTO funnel;
private FunnelDTO component;
/**
* The FunnelDTO that is being serialized.
*
* @return The FunnelDTO object
*/
public FunnelDTO getFunnel() {
return funnel;
public FunnelDTO getComponent() {
return component;
}
public void setFunnel(FunnelDTO funnel) {
this.funnel = funnel;
public void setComponent(FunnelDTO component) {
this.component = component;
}
}

View File

@ -16,27 +16,25 @@
*/
package org.apache.nifi.web.api.entity;
import javax.xml.bind.annotation.XmlRootElement;
import java.util.Set;
import javax.xml.bind.annotation.XmlRootElement;
import org.apache.nifi.web.api.dto.FunnelDTO;
/**
* A serialized representation of this class can be placed in the entity body of a response to the API. This particular entity holds a reference to a list of FunnelDTOs.
* A serialized representation of this class can be placed in the entity body of a response to the API. This particular entity holds a reference to a list of FunnelEntitys.
*/
@XmlRootElement(name = "funnelsEntity")
public class FunnelsEntity extends Entity {
private Set<FunnelDTO> funnels;
private Set<FunnelEntity> funnels;
/**
* @return collection of FunnelDTOs that are being serialized
* @return collection of FunnelEntitys that are being serialized
*/
public Set<FunnelDTO> getFunnels() {
public Set<FunnelEntity> getFunnels() {
return funnels;
}
public void setFunnels(Set<FunnelDTO> labels) {
public void setFunnels(Set<FunnelEntity> labels) {
this.funnels = labels;
}

View File

@ -16,27 +16,25 @@
*/
package org.apache.nifi.web.api.entity;
import javax.xml.bind.annotation.XmlRootElement;
import java.util.Set;
import javax.xml.bind.annotation.XmlRootElement;
import org.apache.nifi.web.api.dto.PortDTO;
/**
* A serialized representation of this class can be placed in the entity body of a response to the API. This particular entity holds a reference to a list of input PortDTOs.
* A serialized representation of this class can be placed in the entity body of a response to the API. This particular entity holds a reference to a list of input InputPortEntitys.
*/
@XmlRootElement(name = "inputPortsEntity")
public class InputPortsEntity extends Entity {
private Set<PortDTO> inputPorts;
private Set<PortEntity> inputPorts;
/**
* @return collection of input PortDTOs that are being serialized
* @return collection of input InputPortEntitys that are being serialized
*/
public Set<PortDTO> getInputPorts() {
public Set<PortEntity> getInputPorts() {
return inputPorts;
}
public void setInputPorts(Set<PortDTO> inputPorts) {
public void setInputPorts(Set<PortEntity> inputPorts) {
this.inputPorts = inputPorts;
}

View File

@ -16,28 +16,43 @@
*/
package org.apache.nifi.web.api.entity;
import javax.xml.bind.annotation.XmlRootElement;
import org.apache.nifi.web.api.dto.DimensionsDTO;
import org.apache.nifi.web.api.dto.LabelDTO;
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 LabelDTO.
*/
@XmlRootElement(name = "labelEntity")
public class LabelEntity extends Entity {
public class LabelEntity extends ComponentEntity {
private LabelDTO label;
private DimensionsDTO dimensions;
private LabelDTO component;
/**
* The LabelDTO that is being serialized.
*
* @return The LabelDTO object
*/
public LabelDTO getLabel() {
return label;
public LabelDTO getComponent() {
return component;
}
public void setLabel(LabelDTO label) {
this.label = label;
public void setComponent(LabelDTO component) {
this.component = component;
}
/**
* The dimensions of this label.
*
* @return The dimensions
*/
public DimensionsDTO getDimensions() {
return dimensions;
}
public void setDimensions(DimensionsDTO dimensions) {
this.dimensions = dimensions;
}
}

View File

@ -16,27 +16,25 @@
*/
package org.apache.nifi.web.api.entity;
import javax.xml.bind.annotation.XmlRootElement;
import java.util.Set;
import javax.xml.bind.annotation.XmlRootElement;
import org.apache.nifi.web.api.dto.LabelDTO;
/**
* A serialized representation of this class can be placed in the entity body of a response to the API. This particular entity holds a reference to a list of LabelDTOs.
* A serialized representation of this class can be placed in the entity body of a response to the API. This particular entity holds a reference to a list of LabelEntity's.
*/
@XmlRootElement(name = "labelsEntity")
public class LabelsEntity extends Entity {
private Set<LabelDTO> labels;
private Set<LabelEntity> labels;
/**
* @return collection of LabelDTOs that are being serialized
* @return collection of LabelEntity's that are being serialized
*/
public Set<LabelDTO> getLabels() {
public Set<LabelEntity> getLabels() {
return labels;
}
public void setLabels(Set<LabelDTO> labels) {
public void setLabels(Set<LabelEntity> labels) {
this.labels = labels;
}

View File

@ -16,27 +16,25 @@
*/
package org.apache.nifi.web.api.entity;
import javax.xml.bind.annotation.XmlRootElement;
import java.util.Set;
import javax.xml.bind.annotation.XmlRootElement;
import org.apache.nifi.web.api.dto.PortDTO;
/**
* A serialized representation of this class can be placed in the entity body of a response to the API. This particular entity holds a reference to a list of output PortDTOs.
* A serialized representation of this class can be placed in the entity body of a response to the API. This particular entity holds a reference to a list of output OutputPortEntitys.
*/
@XmlRootElement(name = "outputPortsEntity")
public class OutputPortsEntity extends Entity {
private Set<PortDTO> outputPorts;
private Set<PortEntity> outputPorts;
/**
* @return collection of output PortDTOs that are being serialized
* @return collection of output OutputPortEntitys that are being serialized
*/
public Set<PortDTO> getOutputPorts() {
public Set<PortEntity> getOutputPorts() {
return outputPorts;
}
public void setOutputPorts(Set<PortDTO> outputPorts) {
public void setOutputPorts(Set<PortEntity> outputPorts) {
this.outputPorts = outputPorts;
}

View File

@ -16,26 +16,35 @@
*/
package org.apache.nifi.web.api.entity;
import javax.xml.bind.annotation.XmlRootElement;
import org.apache.nifi.web.api.dto.PortDTO;
import javax.xml.bind.annotation.XmlRootElement;
/**
* A serialized representation of this class can be placed in the entity body of a response to the API. This particular entity holds a reference to an input PortDTO.
*/
@XmlRootElement(name = "inputPortEntity")
public class InputPortEntity extends Entity {
@XmlRootElement(name = "portEntity")
public class PortEntity extends ComponentEntity {
private PortDTO inputPort;
private PortDTO component;
private String portType;
/**
* @return input PortDTO that are being serialized
*/
public PortDTO getInputPort() {
return inputPort;
public PortDTO getComponent() {
return component;
}
public void setInputPort(PortDTO inputPort) {
this.inputPort = inputPort;
public void setComponent(PortDTO component) {
this.component = component;
}
public String getPortType() {
return portType;
}
public void setPortType(String portType) {
this.portType = portType;
}
}

View File

@ -23,21 +23,21 @@ import org.apache.nifi.web.api.dto.ProcessGroupDTO;
* 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 ProcessGroupDTO.
*/
@XmlRootElement(name = "processGroupEntity")
public class ProcessGroupEntity extends Entity {
public class ProcessGroupEntity extends ComponentEntity {
private ProcessGroupDTO processGroup;
private ProcessGroupDTO component;
/**
* The ProcessGroupDTO that is being serialized.
*
* @return The ControllerDTO object
*/
public ProcessGroupDTO getProcessGroup() {
return processGroup;
public ProcessGroupDTO getComponent() {
return component;
}
public void setProcessGroup(ProcessGroupDTO controller) {
this.processGroup = controller;
public void setComponent(ProcessGroupDTO component) {
this.component = component;
}
}

View File

@ -0,0 +1,44 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.nifi.web.api.entity;
import org.apache.nifi.web.api.dto.flow.ProcessGroupFlowDTO;
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 ProcessGroupFlowDTO.
*/
@XmlRootElement(name = "processGroupFlowEntity")
public class ProcessGroupFlowEntity extends Entity {
private ProcessGroupFlowDTO processGroupFlow;
/**
* The ProcessGroupFlowDTO that is being serialized.
*
* @return The ProcessGroupFlowDTO object
*/
public ProcessGroupFlowDTO getProcessGroupFlow() {
return processGroupFlow;
}
public void setProcessGroupFlow(ProcessGroupFlowDTO flow) {
this.processGroupFlow = flow;
}
}

View File

@ -16,28 +16,27 @@
*/
package org.apache.nifi.web.api.entity;
import java.util.Set;
import javax.xml.bind.annotation.XmlRootElement;
import org.apache.nifi.web.api.dto.ProcessGroupDTO;
import java.util.Set;
/**
* 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 set of ProcessGroupDTOs.
* 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 set of ProcessGroupEntitys.
*/
@XmlRootElement(name = "processGroupsEntity")
public class ProcessGroupsEntity extends Entity {
private Set<ProcessGroupDTO> processGroups;
private Set<ProcessGroupEntity> processGroups;
/**
* The ProcessGroupDTO that is being serialized.
* The ProcessGroupEntity that is being serialized.
*
* @return The ProcessGroupDTOs
* @return The ProcessGroupEntitys
*/
public Set<ProcessGroupDTO> getProcessGroups() {
public Set<ProcessGroupEntity> getProcessGroups() {
return processGroups;
}
public void setProcessGroups(Set<ProcessGroupDTO> processGroups) {
public void setProcessGroups(Set<ProcessGroupEntity> processGroups) {
this.processGroups = processGroups;
}

View File

@ -16,28 +16,29 @@
*/
package org.apache.nifi.web.api.entity;
import javax.xml.bind.annotation.XmlRootElement;
import org.apache.nifi.web.api.dto.ProcessorDTO;
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 ProcessorDTO.
*/
@XmlRootElement(name = "processorEntity")
public class ProcessorEntity extends Entity {
public class ProcessorEntity extends ComponentEntity {
private ProcessorDTO processor;
private ProcessorDTO component;
/**
* The ProcessorDTO that is being serialized.
*
* @return The ProcessorDTO object
*/
public ProcessorDTO getProcessor() {
return processor;
public ProcessorDTO getComponent() {
return component;
}
public void setProcessor(ProcessorDTO processor) {
this.processor = processor;
public void setComponent(ProcessorDTO component) {
this.component = component;
}
}

View File

@ -16,27 +16,25 @@
*/
package org.apache.nifi.web.api.entity;
import javax.xml.bind.annotation.XmlRootElement;
import java.util.Set;
import javax.xml.bind.annotation.XmlRootElement;
import org.apache.nifi.web.api.dto.ProcessorDTO;
/**
* A serialized representation of this class can be placed in the entity body of a response to the API. This particular entity holds a reference to a list of ProcessorDTOs.
* A serialized representation of this class can be placed in the entity body of a response to the API. This particular entity holds a reference to a list of ProcessorEntity's.
*/
@XmlRootElement(name = "processorsEntity")
public class ProcessorsEntity extends Entity {
private Set<ProcessorDTO> processors;
private Set<ProcessorEntity> processors;
/**
* @return collection of ProcessorDTOs that are being serialized
* @return collection of ProcessorEntity's that are being serialized
*/
public Set<ProcessorDTO> getProcessors() {
public Set<ProcessorEntity> getProcessors() {
return processors;
}
public void setProcessors(Set<ProcessorDTO> processors) {
public void setProcessors(Set<ProcessorEntity> processors) {
this.processors = processors;
}

View File

@ -23,21 +23,21 @@ import org.apache.nifi.web.api.dto.RemoteProcessGroupDTO;
* 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 RemoteProcessGroupDTO.
*/
@XmlRootElement(name = "remoteProcessGroupEntity")
public class RemoteProcessGroupEntity extends Entity {
public class RemoteProcessGroupEntity extends ComponentEntity {
private RemoteProcessGroupDTO remoteProcessGroup;
private RemoteProcessGroupDTO component;
/**
* The RemoteProcessGroupDTO that is being serialized.
*
* @return The RemoteProcessGroupDTO object
*/
public RemoteProcessGroupDTO getRemoteProcessGroup() {
return remoteProcessGroup;
public RemoteProcessGroupDTO getComponent() {
return component;
}
public void setRemoteProcessGroup(RemoteProcessGroupDTO remoteProcessGroup) {
this.remoteProcessGroup = remoteProcessGroup;
public void setComponent(RemoteProcessGroupDTO component) {
this.component = component;
}
}

View File

@ -16,27 +16,25 @@
*/
package org.apache.nifi.web.api.entity;
import javax.xml.bind.annotation.XmlRootElement;
import java.util.Set;
import javax.xml.bind.annotation.XmlRootElement;
import org.apache.nifi.web.api.dto.RemoteProcessGroupDTO;
/**
* A serialized representation of this class can be placed in the entity body of a response to the API. This particular entity holds a reference to a list of RemoteProcessGroupDTOs.
* A serialized representation of this class can be placed in the entity body of a response to the API. This particular entity holds a reference to a list of RemoteProcessGroupEntitys.
*/
@XmlRootElement(name = "remoteProcessGroupsEntity")
public class RemoteProcessGroupsEntity extends Entity {
private Set<RemoteProcessGroupDTO> remoteProcessGroups;
private Set<RemoteProcessGroupEntity> remoteProcessGroups;
/**
* @return collection of RemoteProcessGroupDTOs that are being serialized
* @return collection of RemoteProcessGroupEntitys that are being serialized
*/
public Set<RemoteProcessGroupDTO> getRemoteProcessGroups() {
public Set<RemoteProcessGroupEntity> getRemoteProcessGroups() {
return remoteProcessGroups;
}
public void setRemoteProcessGroups(Set<RemoteProcessGroupDTO> remoteProcessGroups) {
public void setRemoteProcessGroups(Set<RemoteProcessGroupEntity> remoteProcessGroups) {
this.remoteProcessGroups = remoteProcessGroups;
}

View File

@ -28,7 +28,6 @@
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="R"/>
<xs:enumeration value="W"/>
<xs:enumeration value="RW"/>
</xs:restriction>
</xs:simpleType>

View File

@ -21,11 +21,68 @@
<version>1.0.0-SNAPSHOT</version>
</parent>
<artifactId>nifi-framework-authorization</artifactId>
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
</resource>
<resource>
<directory>src/main/xsd</directory>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxb2-maven-plugin</artifactId>
<executions>
<execution>
<id>current</id>
<goals>
<goal>xjc</goal>
</goals>
<configuration>
<packageName>org.apache.nifi.authorization.generated</packageName>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<configuration>
<excludes>**/authorization/generated/*.java,</excludes>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.apache.nifi</groupId>
<artifactId>nifi-api</artifactId>
</dependency>
<dependency>
<groupId>org.apache.nifi</groupId>
<artifactId>nifi-expression-language</artifactId>
</dependency>
<dependency>
<groupId>org.apache.nifi</groupId>
<artifactId>nifi-properties</artifactId>
</dependency>
<dependency>
<groupId>org.apache.nifi</groupId>
<artifactId>nifi-nar-utils</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-core</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,39 @@
/*
* 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.authorization;
/**
* Represents any error that might occur while authorizing user requests.
*/
public class AccessDeniedException extends RuntimeException {
public AccessDeniedException(Throwable cause) {
super(cause);
}
public AccessDeniedException(String message, Throwable cause) {
super(message, cause);
}
public AccessDeniedException(String message) {
super(message);
}
public AccessDeniedException() {
}
}

View File

@ -81,38 +81,37 @@ public class AuthorizerFactoryBean implements FactoryBean, DisposableBean, Autho
@Override
public Object getObject() throws Exception {
if (authorizer == null) {
// look up the authorizer to use
final String authorizerIdentifier = properties.getProperty(NiFiProperties.SECURITY_USER_AUTHORIZER);
// ensure the authorizer class name was specified
if (StringUtils.isBlank(authorizerIdentifier)) {
// if configured for ssl, the authorizer must be specified
if (properties.getSslPort() != null) {
throw new Exception("When running securely, the authorizer identifier must be specified in the nifi properties file.");
}
if (properties.getSslPort() == null) {
// use a default authorizer... only allowable when running not securely
authorizer = createDefaultAuthorizer();
} else {
final Authorizers authorizerConfiguration = loadAuthorizersConfiguration();
// look up the authorizer to use
final String authorizerIdentifier = properties.getProperty(NiFiProperties.SECURITY_USER_AUTHORIZER);
// create each authorizer
for (final org.apache.nifi.authorization.generated.Authorizer authorizer : authorizerConfiguration.getAuthorizer()) {
authorizers.put(authorizer.getIdentifier(), createAuthorizer(authorizer.getIdentifier(), authorizer.getClazz()));
}
// ensure the authorizer class name was specified
if (StringUtils.isBlank(authorizerIdentifier)) {
throw new Exception("When running securely, the authorizer identifier must be specified in the nifi properties file.");
} else {
final Authorizers authorizerConfiguration = loadAuthorizersConfiguration();
// configure each authorizer
for (final org.apache.nifi.authorization.generated.Authorizer provider : authorizerConfiguration.getAuthorizer()) {
final Authorizer instance = authorizers.get(provider.getIdentifier());
instance.onConfigured(loadAuthorizerConfiguration(provider));
}
// create each authorizer
for (final org.apache.nifi.authorization.generated.Authorizer authorizer : authorizerConfiguration.getAuthorizer()) {
authorizers.put(authorizer.getIdentifier(), createAuthorizer(authorizer.getIdentifier(), authorizer.getClazz()));
}
// get the authorizer instance
authorizer = getAuthorizer(authorizerIdentifier);
// configure each authorizer
for (final org.apache.nifi.authorization.generated.Authorizer provider : authorizerConfiguration.getAuthorizer()) {
final Authorizer instance = authorizers.get(provider.getIdentifier());
instance.onConfigured(loadAuthorizerConfiguration(provider));
}
// ensure it was found
if (authorizer == null) {
throw new Exception(String.format("The specified authorizer '%s' could not be found.", authorizerIdentifier));
// get the authorizer instance
authorizer = getAuthorizer(authorizerIdentifier);
// ensure it was found
if (authorizer == null) {
throw new Exception(String.format("The specified authorizer '%s' could not be found.", authorizerIdentifier));
}
}
}
}

View File

@ -0,0 +1,129 @@
/*
* 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.authorization.resource;
import org.apache.nifi.authorization.AccessDeniedException;
import org.apache.nifi.authorization.AuthorizationRequest;
import org.apache.nifi.authorization.AuthorizationResult;
import org.apache.nifi.authorization.AuthorizationResult.Result;
import org.apache.nifi.authorization.Authorizer;
import org.apache.nifi.authorization.RequestAction;
import org.apache.nifi.authorization.Resource;
import org.apache.nifi.authorization.user.NiFiUser;
import org.apache.nifi.authorization.user.NiFiUserUtils;
public interface Authorizable {
/**
* The parent for this Authorizable. May be null.
*
* @return the parent authorizable or null
*/
Authorizable getParentAuthorizable();
/**
* The Resource for this Authorizable.
*
* @return the parent resource
*/
Resource getResource();
/**
* Returns whether the current user is authorized for the specified action on the specified resource. This
* method does not imply the user is directly attempting to access the specified resource. If the user is
* attempting a direct access use Authorizable.authorize().
*
* @param authorizer authorizer
* @param action action
* @return is authorized
*/
default boolean isAuthorized(Authorizer authorizer, RequestAction action) {
return Result.Approved.equals(checkAuthorization(authorizer, action).getResult());
}
/**
* Returns the result of an authorization request for the current user for the specified action on the specified
* resource. This method does not imply the user is directly attempting to access the specified resource. If the user is
* attempting a direct access use Authorizable.authorize().
*
* @param authorizer authorizer
* @param action action
* @return is authorized
*/
default AuthorizationResult checkAuthorization(Authorizer authorizer, RequestAction action) {
final NiFiUser user = NiFiUserUtils.getNiFiUser();
// TODO - include user details context
// build the request
final AuthorizationRequest request = new AuthorizationRequest.Builder()
.identity(user.getIdentity())
.anonymous(user.isAnonymous())
.accessAttempt(false)
.action(action)
.resource(getResource())
.build();
// perform the authorization
final AuthorizationResult result = authorizer.authorize(request);
// verify the results
if (Result.ResourceNotFound.equals(result.getResult())) {
final Authorizable parent = getParentAuthorizable();
if (parent == null) {
return AuthorizationResult.denied();
} else {
return parent.checkAuthorization(authorizer, action);
}
} else {
return result;
}
}
/**
* Authorizes the current user for the specified action on the specified resource. This method does imply the user is
* directly accessing the specified resource.
*
* @param authorizer authorizer
* @param action action
*/
default void authorize(Authorizer authorizer, RequestAction action) throws AccessDeniedException {
final NiFiUser user = NiFiUserUtils.getNiFiUser();
// TODO - include user details context
final AuthorizationRequest request = new AuthorizationRequest.Builder()
.identity(user.getIdentity())
.anonymous(user.isAnonymous())
.accessAttempt(true)
.action(action)
.resource(getResource())
.build();
final AuthorizationResult result = authorizer.authorize(request);
if (Result.ResourceNotFound.equals(result.getResult())) {
final Authorizable parent = getParentAuthorizable();
if (parent == null) {
throw new AccessDeniedException("Access is denied");
} else {
parent.authorize(authorizer, action);
}
} else if (Result.Denied.equals(result.getResult())) {
throw new AccessDeniedException(result.getExplanation());
}
}
}

View File

@ -203,7 +203,6 @@ public final class ResourceFactory {
public static Resource getComponentResource(final ResourceType resourceType, final String identifier, final String name) {
Objects.requireNonNull(resourceType, "The resource must be specified.");
Objects.requireNonNull(identifier, "The component identifier must be specified.");
Objects.requireNonNull(name, "The component name must be specified.");
return new Resource() {
@Override

View File

@ -20,6 +20,7 @@ public enum ResourceType {
Processor("/processors"),
InputPort("/input-ports"),
OutputPort("/output-ports"),
Funnel("/funnel"),
Connection("/connections"),
ProcessGroup("/process-groups"),
RemoteProcessGroup("/remote-process-groups"),

View File

@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.nifi.user;
package org.apache.nifi.authorization.user;
import java.io.Serializable;
import java.util.Objects;

View File

@ -14,10 +14,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.nifi.web.security.user;
package org.apache.nifi.authorization.user;
import org.apache.commons.lang3.StringUtils;
import org.apache.nifi.user.NiFiUser;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

View File

@ -14,13 +14,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.nifi.web.security.user;
package org.apache.nifi.authorization.user;
import java.util.HashSet;
import java.util.Set;
import org.apache.nifi.user.NiFiUser;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.context.SecurityContext;
import org.springframework.security.core.context.SecurityContextHolder;
@ -30,32 +26,6 @@ import org.springframework.security.core.context.SecurityContextHolder;
*/
public final class NiFiUserUtils {
/**
* Return the authorities for the current user.
*
* @return authorities
*/
public static Set<String> getAuthorities() {
Set<GrantedAuthority> grantedAuthorities = new HashSet<>();
SecurityContext context = SecurityContextHolder.getContext();
if (context != null) {
Authentication authentication = context.getAuthentication();
if (authentication != null) {
// get the authorities for the user of the current request
grantedAuthorities.addAll(authentication.getAuthorities());
}
}
// convert to a list of authorities
Set<String> authorities = new HashSet<>(grantedAuthorities.size());
for (GrantedAuthority grantedAuthority : grantedAuthorities) {
authorities.add(grantedAuthority.getAuthority());
}
return authorities;
}
/**
* Returns the current NiFiUser or null if the current user is not a NiFiUser.
*

View File

@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
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.
-->
<beans default-lazy-init="true"
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd">
<!-- user/entity authorizer -->
<bean id="authorizer" class="org.apache.nifi.authorization.AuthorizerFactoryBean">
<property name="properties" ref="nifiProperties"/>
</bean>
</beans>

View File

@ -3071,7 +3071,7 @@ public class WebClusterManager implements HttpClusterManager, ProtocolHandler, C
if (hasSuccessfulClientResponse && isProcessorEndpoint(uri, method)) {
final ProcessorEntity responseEntity = clientResponse.getClientResponse().getEntity(ProcessorEntity.class);
final ProcessorDTO processor = responseEntity.getProcessor();
final ProcessorDTO processor = responseEntity.getComponent();
final Map<NodeIdentifier, ProcessorDTO> processorMap = new HashMap<>();
for (final NodeResponse nodeResponse : updatedNodesMap.values()) {
@ -3080,7 +3080,7 @@ public class WebClusterManager implements HttpClusterManager, ProtocolHandler, C
}
final ProcessorEntity nodeResponseEntity = nodeResponse == clientResponse ? responseEntity : nodeResponse.getClientResponse().getEntity(ProcessorEntity.class);
final ProcessorDTO nodeProcessor = nodeResponseEntity.getProcessor();
final ProcessorDTO nodeProcessor = nodeResponseEntity.getComponent();
processorMap.put(nodeResponse.getNodeId(), nodeProcessor);
}
@ -3088,7 +3088,7 @@ public class WebClusterManager implements HttpClusterManager, ProtocolHandler, C
clientResponse = new NodeResponse(clientResponse, responseEntity);
} else if (hasSuccessfulClientResponse && isProcessorsEndpoint(uri, method)) {
final ProcessorsEntity responseEntity = clientResponse.getClientResponse().getEntity(ProcessorsEntity.class);
final Set<ProcessorDTO> processors = responseEntity.getProcessors();
final Set<ProcessorEntity> processors = responseEntity.getProcessors();
final Map<String, Map<NodeIdentifier, ProcessorDTO>> processorMap = new HashMap<>();
for (final NodeResponse nodeResponse : updatedNodesMap.values()) {
@ -3097,31 +3097,31 @@ public class WebClusterManager implements HttpClusterManager, ProtocolHandler, C
}
final ProcessorsEntity nodeResponseEntity = nodeResponse == clientResponse ? responseEntity : nodeResponse.getClientResponse().getEntity(ProcessorsEntity.class);
final Set<ProcessorDTO> nodeProcessors = nodeResponseEntity.getProcessors();
final Set<ProcessorEntity> nodeProcessors = nodeResponseEntity.getProcessors();
for (final ProcessorDTO nodeProcessor : nodeProcessors) {
Map<NodeIdentifier, ProcessorDTO> innerMap = processorMap.get(nodeProcessor.getId());
for (final ProcessorEntity nodeProcessor : nodeProcessors) {
Map<NodeIdentifier, ProcessorDTO> innerMap = processorMap.get(nodeProcessor.getComponent().getId());
if (innerMap == null) {
innerMap = new HashMap<>();
processorMap.put(nodeProcessor.getId(), innerMap);
processorMap.put(nodeProcessor.getComponent().getId(), innerMap);
}
innerMap.put(nodeResponse.getNodeId(), nodeProcessor);
innerMap.put(nodeResponse.getNodeId(), nodeProcessor.getComponent());
}
}
for (final ProcessorDTO processor : processors) {
final String procId = processor.getId();
for (final ProcessorEntity processor : processors) {
final String procId = processor.getComponent().getId();
final Map<NodeIdentifier, ProcessorDTO> mergeMap = processorMap.get(procId);
mergeProcessorValidationErrors(processor, mergeMap);
mergeProcessorValidationErrors(processor.getComponent(), mergeMap);
}
// create a new client response
clientResponse = new NodeResponse(clientResponse, responseEntity);
} else if (hasSuccessfulClientResponse && isProcessGroupEndpoint(uri, method)) {
final ProcessGroupEntity responseEntity = clientResponse.getClientResponse().getEntity(ProcessGroupEntity.class);
final ProcessGroupDTO responseDto = responseEntity.getProcessGroup();
final ProcessGroupDTO responseDto = responseEntity.getComponent();
final FlowSnippetDTO contents = responseDto.getContents();
if (contents == null) {
@ -3138,7 +3138,7 @@ public class WebClusterManager implements HttpClusterManager, ProtocolHandler, C
}
final ProcessGroupEntity nodeResponseEntity = nodeResponse == clientResponse ? responseEntity : nodeResponse.getClientResponse().getEntity(ProcessGroupEntity.class);
final ProcessGroupDTO nodeProcessGroup = nodeResponseEntity.getProcessGroup();
final ProcessGroupDTO nodeProcessGroup = nodeResponseEntity.getComponent();
for (final ProcessorDTO nodeProcessor : nodeProcessGroup.getContents().getProcessors()) {
Map<NodeIdentifier, ProcessorDTO> innerMap = processorMap.get(nodeProcessor.getId());
@ -3242,7 +3242,7 @@ public class WebClusterManager implements HttpClusterManager, ProtocolHandler, C
clientResponse = new NodeResponse(clientResponse, responseEntity);
} else if (hasSuccessfulClientResponse && isRemoteProcessGroupEndpoint(uri, method)) {
final RemoteProcessGroupEntity responseEntity = clientResponse.getClientResponse().getEntity(RemoteProcessGroupEntity.class);
final RemoteProcessGroupDTO remoteProcessGroup = responseEntity.getRemoteProcessGroup();
final RemoteProcessGroupDTO remoteProcessGroup = responseEntity.getComponent();
final Map<NodeIdentifier, RemoteProcessGroupDTO> remoteProcessGroupMap = new HashMap<>();
for (final NodeResponse nodeResponse : updatedNodesMap.values()) {
@ -3251,7 +3251,7 @@ public class WebClusterManager implements HttpClusterManager, ProtocolHandler, C
}
final RemoteProcessGroupEntity nodeResponseEntity = nodeResponse == clientResponse ? responseEntity : nodeResponse.getClientResponse().getEntity(RemoteProcessGroupEntity.class);
final RemoteProcessGroupDTO nodeRemoteProcessGroup = nodeResponseEntity.getRemoteProcessGroup();
final RemoteProcessGroupDTO nodeRemoteProcessGroup = nodeResponseEntity.getComponent();
remoteProcessGroupMap.put(nodeResponse.getNodeId(), nodeRemoteProcessGroup);
}
@ -3260,7 +3260,7 @@ public class WebClusterManager implements HttpClusterManager, ProtocolHandler, C
clientResponse = new NodeResponse(clientResponse, responseEntity);
} else if (hasSuccessfulClientResponse && isRemoteProcessGroupsEndpoint(uri, method)) {
final RemoteProcessGroupsEntity responseEntity = clientResponse.getClientResponse().getEntity(RemoteProcessGroupsEntity.class);
final Set<RemoteProcessGroupDTO> remoteProcessGroups = responseEntity.getRemoteProcessGroups();
final Set<RemoteProcessGroupEntity> remoteProcessGroups = responseEntity.getRemoteProcessGroups();
final Map<String, Map<NodeIdentifier, RemoteProcessGroupDTO>> remoteProcessGroupMap = new HashMap<>();
for (final NodeResponse nodeResponse : updatedNodesMap.values()) {
@ -3269,24 +3269,24 @@ public class WebClusterManager implements HttpClusterManager, ProtocolHandler, C
}
final RemoteProcessGroupsEntity nodeResponseEntity = nodeResponse == clientResponse ? responseEntity : nodeResponse.getClientResponse().getEntity(RemoteProcessGroupsEntity.class);
final Set<RemoteProcessGroupDTO> nodeRemoteProcessGroups = nodeResponseEntity.getRemoteProcessGroups();
final Set<RemoteProcessGroupEntity> nodeRemoteProcessGroups = nodeResponseEntity.getRemoteProcessGroups();
for (final RemoteProcessGroupDTO nodeRemoteProcessGroup : nodeRemoteProcessGroups) {
for (final RemoteProcessGroupEntity nodeRemoteProcessGroup : nodeRemoteProcessGroups) {
Map<NodeIdentifier, RemoteProcessGroupDTO> innerMap = remoteProcessGroupMap.get(nodeRemoteProcessGroup.getId());
if (innerMap == null) {
innerMap = new HashMap<>();
remoteProcessGroupMap.put(nodeRemoteProcessGroup.getId(), innerMap);
}
innerMap.put(nodeResponse.getNodeId(), nodeRemoteProcessGroup);
innerMap.put(nodeResponse.getNodeId(), nodeRemoteProcessGroup.getComponent());
}
}
for (final RemoteProcessGroupDTO remoteProcessGroup : remoteProcessGroups) {
for (final RemoteProcessGroupEntity remoteProcessGroup : remoteProcessGroups) {
final String remoteProcessGroupId = remoteProcessGroup.getId();
final Map<NodeIdentifier, RemoteProcessGroupDTO> mergeMap = remoteProcessGroupMap.get(remoteProcessGroupId);
mergeRemoteProcessGroup(remoteProcessGroup, mergeMap);
mergeRemoteProcessGroup(remoteProcessGroup.getComponent(), mergeMap);
}
// create a new client response

View File

@ -50,5 +50,9 @@
<groupId>org.quartz-scheduler</groupId>
<artifactId>quartz</artifactId>
</dependency>
<dependency>
<groupId>org.apache.nifi</groupId>
<artifactId>nifi-framework-authorization</artifactId>
</dependency>
</dependencies>
</project>

View File

@ -21,6 +21,7 @@ import java.util.List;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import org.apache.nifi.authorization.resource.Authorizable;
import org.apache.nifi.components.ValidationResult;
import org.apache.nifi.controller.Triggerable;
import org.apache.nifi.groups.ProcessGroup;
@ -31,7 +32,7 @@ import org.apache.nifi.scheduling.SchedulingStrategy;
/**
* Represents a connectable component to which or from which data can flow.
*/
public interface Connectable extends Triggerable {
public interface Connectable extends Triggerable, Authorizable {
/**
* @return the unique identifier for this <code>Connectable</code>

View File

@ -20,13 +20,14 @@ import java.util.Collection;
import java.util.List;
import java.util.Set;
import org.apache.nifi.authorization.resource.Authorizable;
import org.apache.nifi.controller.queue.FlowFileQueue;
import org.apache.nifi.controller.repository.FlowFileRecord;
import org.apache.nifi.groups.ProcessGroup;
import org.apache.nifi.processor.FlowFileFilter;
import org.apache.nifi.processor.Relationship;
public interface Connection {
public interface Connection extends Authorizable {
void enqueue(FlowFileRecord flowFile);

View File

@ -16,7 +16,25 @@
*/
package org.apache.nifi.controller;
import static java.util.Objects.requireNonNull;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import org.apache.nifi.authorization.Resource;
import org.apache.nifi.authorization.resource.Authorizable;
import org.apache.nifi.authorization.resource.ResourceFactory;
import org.apache.nifi.authorization.resource.ResourceType;
import org.apache.nifi.components.ValidationResult;
import org.apache.nifi.connectable.Connectable;
import org.apache.nifi.connectable.ConnectableType;
import org.apache.nifi.connectable.Connection;
import org.apache.nifi.connectable.Port;
import org.apache.nifi.connectable.Position;
import org.apache.nifi.groups.ProcessGroup;
import org.apache.nifi.processor.ProcessContext;
import org.apache.nifi.processor.ProcessSession;
import org.apache.nifi.processor.ProcessSessionFactory;
import org.apache.nifi.processor.Relationship;
import org.apache.nifi.processor.exception.ProcessException;
import org.apache.nifi.util.FormatUtils;
import java.util.ArrayList;
import java.util.Collection;
@ -32,22 +50,7 @@ import java.util.concurrent.atomic.AtomicReference;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
import org.apache.nifi.components.ValidationResult;
import org.apache.nifi.connectable.Connectable;
import org.apache.nifi.connectable.ConnectableType;
import org.apache.nifi.connectable.Connection;
import org.apache.nifi.connectable.Port;
import org.apache.nifi.connectable.Position;
import org.apache.nifi.groups.ProcessGroup;
import org.apache.nifi.processor.ProcessContext;
import org.apache.nifi.processor.ProcessSession;
import org.apache.nifi.processor.ProcessSessionFactory;
import org.apache.nifi.processor.Relationship;
import org.apache.nifi.processor.exception.ProcessException;
import org.apache.nifi.util.FormatUtils;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import static java.util.Objects.requireNonNull;
public abstract class AbstractPort implements Port {
@ -142,6 +145,17 @@ public abstract class AbstractPort implements Port {
this.name.set(name);
}
@Override
public Authorizable getParentAuthorizable() {
return getProcessGroup();
}
@Override
public Resource getResource() {
final ResourceType resourceType = ConnectableType.INPUT_PORT.equals(getConnectableType()) ? ResourceType.InputPort : ResourceType.OutputPort;
return ResourceFactory.getComponentResource(resourceType, getIdentifier(), getName());
}
@Override
public ProcessGroup getProcessGroup() {
return processGroup.get();

View File

@ -16,13 +16,6 @@
*/
package org.apache.nifi.controller;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.Callable;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;
import org.apache.nifi.annotation.behavior.InputRequirement.Requirement;
import org.apache.nifi.connectable.Connectable;
import org.apache.nifi.controller.service.ControllerServiceNode;
@ -35,6 +28,13 @@ import org.apache.nifi.scheduling.SchedulingStrategy;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.Callable;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;
public abstract class ProcessorNode extends AbstractConfiguredComponent implements Connectable {
private static final Logger logger = LoggerFactory.getLogger(ProcessorNode.class);

View File

@ -16,22 +16,12 @@
*/
package org.apache.nifi.controller;
import static java.util.Objects.requireNonNull;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.atomic.AtomicReference;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import org.apache.nifi.authorization.Resource;
import org.apache.nifi.authorization.resource.Authorizable;
import org.apache.nifi.authorization.resource.ResourceFactory;
import org.apache.nifi.authorization.resource.ResourceType;
import org.apache.nifi.components.ValidationResult;
import org.apache.nifi.connectable.Connectable;
import org.apache.nifi.connectable.ConnectableType;
@ -48,8 +38,21 @@ import org.apache.nifi.processor.exception.ProcessException;
import org.apache.nifi.scheduling.SchedulingStrategy;
import org.apache.nifi.util.FormatUtils;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.atomic.AtomicReference;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
import static java.util.Objects.requireNonNull;
public class StandardFunnel implements Funnel {
@ -116,6 +119,16 @@ public class StandardFunnel implements Funnel {
return (Relationship.ANONYMOUS.getName().equals(relationshipName)) ? Relationship.ANONYMOUS : null;
}
@Override
public Authorizable getParentAuthorizable() {
return getProcessGroup();
}
@Override
public Resource getResource() {
return ResourceFactory.getComponentResource(ResourceType.Funnel, getIdentifier(), getName());
}
@Override
public void addConnection(final Connection connection) throws IllegalArgumentException {
writeLock.lock();

View File

@ -18,11 +18,12 @@ package org.apache.nifi.controller.label;
import java.util.Map;
import org.apache.nifi.authorization.resource.Authorizable;
import org.apache.nifi.connectable.Position;
import org.apache.nifi.connectable.Size;
import org.apache.nifi.groups.ProcessGroup;
public interface Label {
public interface Label extends Authorizable {
String getIdentifier();

View File

@ -20,6 +20,7 @@ import java.util.Collection;
import java.util.List;
import java.util.Set;
import org.apache.nifi.authorization.resource.Authorizable;
import org.apache.nifi.connectable.Connectable;
import org.apache.nifi.connectable.Connection;
import org.apache.nifi.connectable.Funnel;
@ -40,7 +41,7 @@ import org.apache.nifi.processor.Processor;
* <p>
* MUST BE THREAD-SAFE</p>
*/
public interface ProcessGroup {
public interface ProcessGroup extends Authorizable {
/**
* @return a reference to this ProcessGroup's parent. This will be

View File

@ -21,12 +21,13 @@ import java.util.Date;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import org.apache.nifi.authorization.resource.Authorizable;
import org.apache.nifi.connectable.Position;
import org.apache.nifi.controller.exception.CommunicationsException;
import org.apache.nifi.events.EventReporter;
import org.apache.nifi.remote.RemoteGroupPort;
public interface RemoteProcessGroup {
public interface RemoteProcessGroup extends Authorizable {
String getIdentifier();

View File

@ -16,18 +16,14 @@
*/
package org.apache.nifi.connectable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.atomic.AtomicReference;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.apache.nifi.authorization.Resource;
import org.apache.nifi.authorization.resource.Authorizable;
import org.apache.nifi.authorization.resource.ResourceFactory;
import org.apache.nifi.authorization.resource.ResourceType;
import org.apache.nifi.controller.ProcessScheduler;
import org.apache.nifi.controller.StandardFlowFileQueue;
import org.apache.nifi.controller.queue.FlowFileQueue;
@ -42,6 +38,17 @@ import org.apache.nifi.processor.Relationship;
import org.apache.nifi.provenance.ProvenanceEventRepository;
import org.apache.nifi.util.NiFiProperties;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.Collectors;
/**
* Models a connection between connectable components. A connection may contain one or more relationships that map the source component to the destination component.
*/
@ -94,6 +101,27 @@ public final class StandardConnection implements Connection {
this.name.set(name);
}
@Override
public Authorizable getParentAuthorizable() {
return getSource();
}
@Override
public Resource getResource() {
String name = getName();
final Collection<Relationship> relationships = getRelationships();
if (name == null && CollectionUtils.isNotEmpty(relationships)) {
name = StringUtils.join(relationships.stream().map(relationship -> relationship.getName()).collect(Collectors.toSet()), ", ");
}
if (name == null) {
name = "Connection";
}
return ResourceFactory.getComponentResource(ResourceType.Connection, getIdentifier(), name);
}
@Override
public List<Position> getBendPoints() {
return bendPoints.get();

View File

@ -16,29 +16,6 @@
*/
package org.apache.nifi.controller;
import static java.util.Objects.requireNonNull;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.atomic.AtomicReference;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.apache.nifi.annotation.behavior.EventDriven;
@ -53,6 +30,10 @@ import org.apache.nifi.annotation.documentation.CapabilityDescription;
import org.apache.nifi.annotation.lifecycle.OnScheduled;
import org.apache.nifi.annotation.lifecycle.OnStopped;
import org.apache.nifi.annotation.lifecycle.OnUnscheduled;
import org.apache.nifi.authorization.Resource;
import org.apache.nifi.authorization.resource.Authorizable;
import org.apache.nifi.authorization.resource.ResourceFactory;
import org.apache.nifi.authorization.resource.ResourceType;
import org.apache.nifi.components.ValidationContext;
import org.apache.nifi.components.ValidationResult;
import org.apache.nifi.connectable.Connectable;
@ -79,6 +60,29 @@ import org.quartz.CronExpression;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.atomic.AtomicReference;
import static java.util.Objects.requireNonNull;
/**
* ProcessorNode provides thread-safe access to a FlowFileProcessor as it exists
* within a controlled flow. This node keeps track of the processor, its
@ -194,6 +198,16 @@ public class StandardProcessorNode extends ProcessorNode implements Connectable
return comments.get();
}
@Override
public Authorizable getParentAuthorizable() {
return getProcessGroup();
}
@Override
public Resource getResource() {
return ResourceFactory.getComponentResource(ResourceType.Processor, getIdentifier(), getName());
}
/**
* Provides and opportunity to retain information about this particular
* processor instance

View File

@ -16,16 +16,19 @@
*/
package org.apache.nifi.controller.label;
import org.apache.nifi.controller.label.Label;
import org.apache.nifi.authorization.Resource;
import org.apache.nifi.authorization.resource.Authorizable;
import org.apache.nifi.authorization.resource.ResourceFactory;
import org.apache.nifi.authorization.resource.ResourceType;
import org.apache.nifi.connectable.Position;
import org.apache.nifi.connectable.Size;
import org.apache.nifi.groups.ProcessGroup;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.atomic.AtomicReference;
import org.apache.nifi.connectable.Position;
import org.apache.nifi.connectable.Size;
import org.apache.nifi.groups.ProcessGroup;
public class StandardLabel implements Label {
private final String identifier;
@ -76,6 +79,16 @@ public class StandardLabel implements Label {
return identifier;
}
@Override
public Authorizable getParentAuthorizable() {
return getProcessGroup();
}
@Override
public Resource getResource() {
return ResourceFactory.getComponentResource(ResourceType.Label, getIdentifier(),"Label");
}
public Map<String, String> getStyle() {
return style.get();
}

View File

@ -52,7 +52,7 @@ 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.NiFiComponentDTO;
import org.apache.nifi.web.api.dto.ComponentDTO;
import org.apache.nifi.web.api.dto.PortDTO;
import org.apache.nifi.web.api.dto.ProcessGroupDTO;
import org.apache.nifi.web.api.dto.ProcessorConfigDTO;
@ -321,9 +321,9 @@ public final class FingerprintFactory {
}
private StringBuilder addSnippetFingerprint(final StringBuilder builder, final FlowSnippetDTO snippet) {
final Comparator<NiFiComponentDTO> componentComparator = new Comparator<NiFiComponentDTO>() {
final Comparator<ComponentDTO> componentComparator = new Comparator<ComponentDTO>() {
@Override
public int compare(final NiFiComponentDTO o1, final NiFiComponentDTO o2) {
public int compare(final ComponentDTO o1, final ComponentDTO o2) {
if (o1 == null && o2 == null) {
return 0;
}

View File

@ -16,26 +16,16 @@
*/
package org.apache.nifi.groups;
import static java.util.Objects.requireNonNull;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.concurrent.atomic.AtomicReference;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import org.apache.nifi.annotation.lifecycle.OnRemoved;
import org.apache.nifi.annotation.lifecycle.OnShutdown;
import org.apache.nifi.authorization.Resource;
import org.apache.nifi.authorization.resource.Authorizable;
import org.apache.nifi.authorization.resource.ResourceFactory;
import org.apache.nifi.authorization.resource.ResourceType;
import org.apache.nifi.components.PropertyDescriptor;
import org.apache.nifi.components.state.StateManager;
import org.apache.nifi.components.state.StateManagerProvider;
@ -66,6 +56,20 @@ import org.apache.nifi.util.ReflectionUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.concurrent.atomic.AtomicReference;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
import static java.util.Objects.requireNonNull;
public final class StandardProcessGroup implements ProcessGroup {
private final String id;
@ -118,6 +122,16 @@ public final class StandardProcessGroup implements ProcessGroup {
parent.set(newParent);
}
@Override
public Authorizable getParentAuthorizable() {
return getParent();
}
@Override
public Resource getResource() {
return ResourceFactory.getComponentResource(ResourceType.ProcessGroup, getIdentifier(), getName());
}
@Override
public String getIdentifier() {
return id;

View File

@ -16,31 +16,14 @@
*/
package org.apache.nifi.remote;
import static java.util.Objects.requireNonNull;
import java.io.File;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicReference;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
import javax.net.ssl.SSLContext;
import javax.ws.rs.core.Response;
import com.sun.jersey.api.client.ClientHandlerException;
import com.sun.jersey.api.client.ClientResponse;
import com.sun.jersey.api.client.ClientResponse.Status;
import com.sun.jersey.api.client.UniformInterfaceException;
import org.apache.nifi.authorization.Resource;
import org.apache.nifi.authorization.resource.Authorizable;
import org.apache.nifi.authorization.resource.ResourceFactory;
import org.apache.nifi.authorization.resource.ResourceType;
import org.apache.nifi.connectable.ConnectableType;
import org.apache.nifi.connectable.Connection;
import org.apache.nifi.connectable.Port;
@ -67,10 +50,29 @@ import org.apache.nifi.web.api.entity.ControllerEntity;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.sun.jersey.api.client.ClientHandlerException;
import com.sun.jersey.api.client.ClientResponse;
import com.sun.jersey.api.client.ClientResponse.Status;
import com.sun.jersey.api.client.UniformInterfaceException;
import javax.net.ssl.SSLContext;
import javax.ws.rs.core.Response;
import java.io.File;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicReference;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
import static java.util.Objects.requireNonNull;
/**
* Represents the Root Process Group of a remote NiFi Instance. Holds information about that remote instance, as well as {@link IncomingPort}s and {@link OutgoingPort}s for communicating with the
@ -203,6 +205,16 @@ public class StandardRemoteProcessGroup implements RemoteProcessGroup {
return id;
}
@Override
public Authorizable getParentAuthorizable() {
return getProcessGroup();
}
@Override
public Resource getResource() {
return ResourceFactory.getComponentResource(ResourceType.RemoteProcessGroup, getIdentifier(), getName());
}
@Override
public ProcessGroup getProcessGroup() {
return processGroup.get();

View File

@ -26,7 +26,7 @@ import java.util.Map;
import org.apache.nifi.web.api.dto.ConnectionDTO;
import org.apache.nifi.web.api.dto.FlowSnippetDTO;
import org.apache.nifi.web.api.dto.NiFiComponentDTO;
import org.apache.nifi.web.api.dto.ComponentDTO;
import org.apache.nifi.web.api.dto.PositionDTO;
/**
@ -50,7 +50,7 @@ public final class SnippetUtils {
final Collection<ConnectionDTO> connections = getConnections(snippet);
// get the components and their positions from the template contents
final Collection<NiFiComponentDTO> components = getComponents(snippet);
final Collection<ComponentDTO> components = getComponents(snippet);
// only perform the operation if there are components in this snippet
if (connections.isEmpty() && components.isEmpty()) {
@ -58,7 +58,7 @@ public final class SnippetUtils {
}
// get the component positions from the snippet contents
final Map<NiFiComponentDTO, PositionDTO> componentPositionLookup = getPositionLookup(components);
final Map<ComponentDTO, PositionDTO> componentPositionLookup = getPositionLookup(components);
final Map<ConnectionDTO, List<PositionDTO>> connectionPositionLookup = getConnectionPositionLookup(connections);
final PositionDTO currentOrigin = getOrigin(componentPositionLookup.values(), connectionPositionLookup.values());
@ -101,8 +101,8 @@ public final class SnippetUtils {
* @param contents snippet
* @return component dtos
*/
private static Collection<NiFiComponentDTO> getComponents(FlowSnippetDTO contents) {
final Collection<NiFiComponentDTO> components = new HashSet<>();
private static Collection<ComponentDTO> getComponents(FlowSnippetDTO contents) {
final Collection<ComponentDTO> components = new HashSet<>();
// add all components
if (contents.getInputPorts() != null) {
@ -136,11 +136,11 @@ public final class SnippetUtils {
* @param components components
* @return component and position map
*/
private static Map<NiFiComponentDTO, PositionDTO> getPositionLookup(Collection<NiFiComponentDTO> components) {
final Map<NiFiComponentDTO, PositionDTO> positionLookup = new HashMap<>();
private static Map<ComponentDTO, PositionDTO> getPositionLookup(Collection<ComponentDTO> components) {
final Map<ComponentDTO, PositionDTO> positionLookup = new HashMap<>();
// determine the position for each component
for (final NiFiComponentDTO component : components) {
for (final ComponentDTO component : components) {
positionLookup.put(component, new PositionDTO(component.getPosition().getX(), component.getPosition().getY()));
}
@ -223,9 +223,9 @@ public final class SnippetUtils {
* @param componentPositionLookup lookup
* @param connectionPositionLookup lookup
*/
private static void applyUpdatedPositions(final Map<NiFiComponentDTO, PositionDTO> componentPositionLookup, final Map<ConnectionDTO, List<PositionDTO>> connectionPositionLookup) {
for (final Map.Entry<NiFiComponentDTO, PositionDTO> entry : componentPositionLookup.entrySet()) {
final NiFiComponentDTO component = entry.getKey();
private static void applyUpdatedPositions(final Map<ComponentDTO, PositionDTO> componentPositionLookup, final Map<ConnectionDTO, List<PositionDTO>> connectionPositionLookup) {
for (final Map.Entry<ComponentDTO, PositionDTO> entry : componentPositionLookup.entrySet()) {
final ComponentDTO component = entry.getKey();
final PositionDTO position = entry.getValue();
component.setPosition(position);
}

View File

@ -161,7 +161,6 @@ public class StandardFlowServiceTest {
return;
}
assertEquals(expected.getParent(), actual.getParent());
Assert.assertEquals(expected.getComments(), actual.getComments());
assertEquals(expected.getContents(), actual.getContents());
}

View File

@ -17,12 +17,6 @@
package org.apache.nifi.controller.state.providers.zookeeper;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import javax.net.ssl.SSLContext;
import org.apache.curator.test.TestingServer;
import org.apache.nifi.attribute.expression.language.StandardPropertyValue;
import org.apache.nifi.components.PropertyDescriptor;
@ -36,6 +30,11 @@ import org.junit.Before;
import org.junit.Test;
import org.testng.Assert;
import javax.net.ssl.SSLContext;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
public class TestZooKeeperStateProvider extends AbstractTestStateProvider {
private StateProvider provider;
@ -147,7 +146,7 @@ public class TestZooKeeperStateProvider extends AbstractTestStateProvider {
} catch (final StateTooLargeException stle) {
// expected behavior.
} catch (final Exception e) {
Assert.fail("Expected StateTooLargeException");
Assert.fail("Expected StateTooLargeException", e);
}
}

View File

@ -29,6 +29,7 @@ import java.util.concurrent.atomic.AtomicReference;
import javax.net.ssl.SSLContext;
import org.apache.nifi.authorization.resource.Authorizable;
import org.apache.nifi.components.ValidationResult;
import org.apache.nifi.connectable.ConnectableType;
import org.apache.nifi.connectable.Connection;
@ -107,6 +108,11 @@ public class StandardRemoteGroupPort extends RemoteGroupPort {
return getConnectableType() == ConnectableType.REMOTE_OUTPUT_PORT;
}
@Override
public Authorizable getParentAuthorizable() {
return getRemoteProcessGroup();
}
@Override
public void shutdown() {
super.shutdown();

View File

@ -21,12 +21,12 @@ import org.apache.nifi.action.Component;
import org.apache.nifi.action.FlowChangeAction;
import org.apache.nifi.action.Operation;
import org.apache.nifi.action.component.details.FlowChangeExtensionDetails;
import org.apache.nifi.authorization.user.NiFiUserUtils;
import org.apache.nifi.components.state.StateMap;
import org.apache.nifi.controller.ProcessorNode;
import org.apache.nifi.controller.ReportingTaskNode;
import org.apache.nifi.controller.service.ControllerServiceNode;
import org.apache.nifi.user.NiFiUser;
import org.apache.nifi.web.security.user.NiFiUserUtils;
import org.apache.nifi.authorization.user.NiFiUser;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;

View File

@ -24,8 +24,8 @@ import org.apache.nifi.action.Component;
import org.apache.nifi.action.FlowChangeAction;
import org.apache.nifi.action.Operation;
import org.apache.nifi.action.details.FlowChangeConfigureDetails;
import org.apache.nifi.web.security.user.NiFiUserUtils;
import org.apache.nifi.user.NiFiUser;
import org.apache.nifi.authorization.user.NiFiUser;
import org.apache.nifi.authorization.user.NiFiUserUtils;
import org.apache.nifi.web.controller.ControllerFacade;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;

View File

@ -30,13 +30,13 @@ import org.apache.nifi.action.Operation;
import org.apache.nifi.action.component.details.FlowChangeExtensionDetails;
import org.apache.nifi.action.details.ActionDetails;
import org.apache.nifi.action.details.FlowChangeConfigureDetails;
import org.apache.nifi.authorization.user.NiFiUserUtils;
import org.apache.nifi.components.PropertyDescriptor;
import org.apache.nifi.controller.ConfiguredComponent;
import org.apache.nifi.controller.ProcessorNode;
import org.apache.nifi.controller.ReportingTaskNode;
import org.apache.nifi.controller.ScheduledState;
import org.apache.nifi.web.security.user.NiFiUserUtils;
import org.apache.nifi.user.NiFiUser;
import org.apache.nifi.authorization.user.NiFiUser;
import org.apache.nifi.controller.service.ControllerServiceNode;
import org.apache.nifi.controller.service.ControllerServiceReference;
import org.apache.nifi.controller.service.ControllerServiceState;

View File

@ -23,9 +23,9 @@ import org.apache.nifi.action.Component;
import org.apache.nifi.action.FlowChangeAction;
import org.apache.nifi.action.Operation;
import org.apache.nifi.action.details.ActionDetails;
import org.apache.nifi.authorization.user.NiFiUserUtils;
import org.apache.nifi.connectable.Funnel;
import org.apache.nifi.web.security.user.NiFiUserUtils;
import org.apache.nifi.user.NiFiUser;
import org.apache.nifi.authorization.user.NiFiUser;
import org.apache.nifi.web.dao.FunnelDAO;
import org.aspectj.lang.ProceedingJoinPoint;

View File

@ -23,14 +23,14 @@ import org.apache.nifi.action.FlowChangeAction;
import org.apache.nifi.action.Operation;
import org.apache.nifi.action.details.ActionDetails;
import org.apache.nifi.action.details.FlowChangeConfigureDetails;
import org.apache.nifi.authorization.user.NiFiUserUtils;
import org.apache.nifi.connectable.ConnectableType;
import org.apache.nifi.connectable.Port;
import org.apache.nifi.controller.ScheduledState;
import org.apache.nifi.remote.RootGroupPort;
import org.apache.nifi.user.NiFiUser;
import org.apache.nifi.authorization.user.NiFiUser;
import org.apache.nifi.web.api.dto.PortDTO;
import org.apache.nifi.web.dao.PortDAO;
import org.apache.nifi.web.security.user.NiFiUserUtils;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;

View File

@ -26,9 +26,9 @@ import org.apache.nifi.action.Operation;
import org.apache.nifi.action.details.ActionDetails;
import org.apache.nifi.action.details.FlowChangeConfigureDetails;
import org.apache.nifi.action.details.FlowChangeMoveDetails;
import org.apache.nifi.authorization.user.NiFiUserUtils;
import org.apache.nifi.groups.ProcessGroup;
import org.apache.nifi.web.security.user.NiFiUserUtils;
import org.apache.nifi.user.NiFiUser;
import org.apache.nifi.authorization.user.NiFiUser;
import org.apache.nifi.web.api.dto.ProcessGroupDTO;
import org.apache.nifi.web.dao.ProcessGroupDAO;
import org.aspectj.lang.ProceedingJoinPoint;

View File

@ -34,12 +34,12 @@ import org.apache.nifi.action.Operation;
import org.apache.nifi.action.component.details.FlowChangeExtensionDetails;
import org.apache.nifi.action.details.ActionDetails;
import org.apache.nifi.action.details.FlowChangeConfigureDetails;
import org.apache.nifi.authorization.user.NiFiUserUtils;
import org.apache.nifi.components.PropertyDescriptor;
import org.apache.nifi.controller.ProcessorNode;
import org.apache.nifi.controller.ScheduledState;
import org.apache.nifi.processor.Relationship;
import org.apache.nifi.web.security.user.NiFiUserUtils;
import org.apache.nifi.user.NiFiUser;
import org.apache.nifi.authorization.user.NiFiUser;
import org.apache.nifi.web.api.dto.ProcessorConfigDTO;
import org.apache.nifi.web.api.dto.ProcessorDTO;
import org.apache.nifi.web.dao.ProcessorDAO;

View File

@ -32,6 +32,7 @@ import org.apache.nifi.action.details.ActionDetails;
import org.apache.nifi.action.details.ConnectDetails;
import org.apache.nifi.action.details.FlowChangeConfigureDetails;
import org.apache.nifi.action.details.FlowChangeConnectDetails;
import org.apache.nifi.authorization.user.NiFiUserUtils;
import org.apache.nifi.connectable.Connectable;
import org.apache.nifi.connectable.Connection;
import org.apache.nifi.connectable.Funnel;
@ -42,8 +43,7 @@ import org.apache.nifi.flowfile.FlowFilePrioritizer;
import org.apache.nifi.processor.Relationship;
import org.apache.nifi.remote.RemoteGroupPort;
import org.apache.nifi.remote.TransferDirection;
import org.apache.nifi.web.security.user.NiFiUserUtils;
import org.apache.nifi.user.NiFiUser;
import org.apache.nifi.authorization.user.NiFiUser;
import org.apache.nifi.web.api.dto.ConnectionDTO;
import org.apache.nifi.web.dao.ConnectionDAO;

View File

@ -23,14 +23,14 @@ import org.apache.nifi.action.Operation;
import org.apache.nifi.action.component.details.FlowChangeRemoteProcessGroupDetails;
import org.apache.nifi.action.details.ActionDetails;
import org.apache.nifi.action.details.FlowChangeConfigureDetails;
import org.apache.nifi.authorization.user.NiFiUserUtils;
import org.apache.nifi.groups.RemoteProcessGroup;
import org.apache.nifi.remote.RemoteGroupPort;
import org.apache.nifi.user.NiFiUser;
import org.apache.nifi.authorization.user.NiFiUser;
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.dao.RemoteProcessGroupDAO;
import org.apache.nifi.web.security.user.NiFiUserUtils;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;

View File

@ -30,11 +30,11 @@ import org.apache.nifi.action.Operation;
import org.apache.nifi.action.component.details.FlowChangeExtensionDetails;
import org.apache.nifi.action.details.ActionDetails;
import org.apache.nifi.action.details.FlowChangeConfigureDetails;
import org.apache.nifi.authorization.user.NiFiUserUtils;
import org.apache.nifi.components.PropertyDescriptor;
import org.apache.nifi.controller.ReportingTaskNode;
import org.apache.nifi.controller.ScheduledState;
import org.apache.nifi.web.security.user.NiFiUserUtils;
import org.apache.nifi.user.NiFiUser;
import org.apache.nifi.authorization.user.NiFiUser;
import org.apache.nifi.web.api.dto.ReportingTaskDTO;
import org.apache.nifi.web.dao.ReportingTaskDAO;
import org.aspectj.lang.ProceedingJoinPoint;

View File

@ -26,6 +26,7 @@ import org.apache.nifi.action.component.details.FlowChangeExtensionDetails;
import org.apache.nifi.action.component.details.FlowChangeRemoteProcessGroupDetails;
import org.apache.nifi.action.details.ConnectDetails;
import org.apache.nifi.action.details.FlowChangeConnectDetails;
import org.apache.nifi.authorization.user.NiFiUserUtils;
import org.apache.nifi.connectable.ConnectableType;
import org.apache.nifi.connectable.Connection;
import org.apache.nifi.connectable.Funnel;
@ -34,7 +35,7 @@ import org.apache.nifi.controller.ProcessorNode;
import org.apache.nifi.controller.Snippet;
import org.apache.nifi.groups.ProcessGroup;
import org.apache.nifi.groups.RemoteProcessGroup;
import org.apache.nifi.user.NiFiUser;
import org.apache.nifi.authorization.user.NiFiUser;
import org.apache.nifi.web.api.dto.ConnectableDTO;
import org.apache.nifi.web.api.dto.ConnectionDTO;
import org.apache.nifi.web.api.dto.FlowSnippetDTO;
@ -51,7 +52,6 @@ import org.apache.nifi.web.dao.ProcessGroupDAO;
import org.apache.nifi.web.dao.ProcessorDAO;
import org.apache.nifi.web.dao.RemoteProcessGroupDAO;
import org.apache.nifi.web.dao.SnippetDAO;
import org.apache.nifi.web.security.user.NiFiUserUtils;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;

View File

@ -34,7 +34,6 @@ import org.apache.nifi.web.api.dto.CountersDTO;
import org.apache.nifi.web.api.dto.DocumentedTypeDTO;
import org.apache.nifi.web.api.dto.DropRequestDTO;
import org.apache.nifi.web.api.dto.FlowFileDTO;
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.ListingRequestDTO;
@ -54,6 +53,8 @@ import org.apache.nifi.web.api.dto.TemplateDTO;
import org.apache.nifi.web.api.dto.action.ActionDTO;
import org.apache.nifi.web.api.dto.action.HistoryDTO;
import org.apache.nifi.web.api.dto.action.HistoryQueryDTO;
import org.apache.nifi.web.api.dto.flow.FlowDTO;
import org.apache.nifi.web.api.dto.flow.ProcessGroupFlowDTO;
import org.apache.nifi.web.api.dto.provenance.ProvenanceDTO;
import org.apache.nifi.web.api.dto.provenance.ProvenanceEventDTO;
import org.apache.nifi.web.api.dto.provenance.ProvenanceOptionsDTO;
@ -66,6 +67,13 @@ import org.apache.nifi.web.api.dto.status.ProcessGroupStatusDTO;
import org.apache.nifi.web.api.dto.status.ProcessorStatusDTO;
import org.apache.nifi.web.api.dto.status.RemoteProcessGroupStatusDTO;
import org.apache.nifi.web.api.dto.status.StatusHistoryDTO;
import org.apache.nifi.web.api.entity.ConnectionEntity;
import org.apache.nifi.web.api.entity.FunnelEntity;
import org.apache.nifi.web.api.entity.LabelEntity;
import org.apache.nifi.web.api.entity.PortEntity;
import org.apache.nifi.web.api.entity.ProcessGroupEntity;
import org.apache.nifi.web.api.entity.ProcessorEntity;
import org.apache.nifi.web.api.entity.RemoteProcessGroupEntity;
import java.util.Date;
import java.util.List;
@ -318,7 +326,7 @@ public interface NiFiServiceFacade {
* @param originY y
* @return snapshot
*/
ConfigurationSnapshot<FlowSnippetDTO> createTemplateInstance(Revision revision, String groupId, Double originX, Double originY, String templateId);
ConfigurationSnapshot<FlowDTO> createTemplateInstance(Revision revision, String groupId, Double originX, Double originY, String templateId);
/**
* Gets the template with the specified id.
@ -361,7 +369,7 @@ public interface NiFiServiceFacade {
* @param processorDTO The processor DTO
* @return The new processor DTO
*/
ConfigurationSnapshot<ProcessorDTO> createProcessor(Revision revision, String groupId, ProcessorDTO processorDTO);
ProcessorEntity createProcessor(Revision revision, String groupId, ProcessorDTO processorDTO);
/**
* Gets the Processor transfer object for the specified id.
@ -369,7 +377,7 @@ public interface NiFiServiceFacade {
* @param id Id of the processor to return
* @return The Processor transfer object
*/
ProcessorDTO getProcessor(String id);
ProcessorEntity getProcessor(String id);
/**
* Gets the processor status.
@ -402,7 +410,7 @@ public interface NiFiServiceFacade {
* @param groupId group
* @return List of all the Processor transfer object
*/
Set<ProcessorDTO> getProcessors(String groupId);
Set<ProcessorEntity> getProcessors(String groupId);
/**
* Verifies the specified processor can be updated.
@ -418,7 +426,7 @@ public interface NiFiServiceFacade {
* @param processorDTO The processorDTO
* @return The updated processor
*/
ConfigurationSnapshot<ProcessorDTO> updateProcessor(Revision revision, ProcessorDTO processorDTO);
UpdateResult<ProcessorEntity> updateProcessor(Revision revision, ProcessorDTO processorDTO);
/**
* Verifies the specified processor can be removed.
@ -434,7 +442,7 @@ public interface NiFiServiceFacade {
* @param processorId The processor id to delete
* @return snapshot
*/
ConfigurationSnapshot<Void> deleteProcessor(Revision revision, String processorId);
ProcessorEntity deleteProcessor(Revision revision, String processorId);
// ----------------------------------------
// Connections methods
@ -446,7 +454,7 @@ public interface NiFiServiceFacade {
* @param groupId group
* @return The Connection transfer objects
*/
Set<ConnectionDTO> getConnections(String groupId);
Set<ConnectionEntity> getConnections(String groupId);
/**
* Gets the specified Connection transfer object.
@ -454,7 +462,7 @@ public interface NiFiServiceFacade {
* @param connectionId The ID of the connection
* @return The Connection transfer object
*/
ConnectionDTO getConnection(String connectionId);
ConnectionEntity getConnection(String connectionId);
/**
* Gets the status of the specified connection.
@ -480,7 +488,7 @@ public interface NiFiServiceFacade {
* @param connectionDTO The Connection DTO
* @return The Connection DTO
*/
ConfigurationSnapshot<ConnectionDTO> createConnection(Revision revision, String groupId, ConnectionDTO connectionDTO);
ConnectionEntity createConnection(Revision revision, String groupId, ConnectionDTO connectionDTO);
/**
* Determines if this connection can be listed.
@ -511,7 +519,7 @@ public interface NiFiServiceFacade {
* @param connectionDTO The Connection DTO
* @return The Connection DTO
*/
ConfigurationSnapshot<ConnectionDTO> updateConnection(Revision revision, ConnectionDTO connectionDTO);
UpdateResult<ConnectionEntity> updateConnection(Revision revision, ConnectionDTO connectionDTO);
/**
* Determines if this connection can be removed.
@ -527,7 +535,7 @@ public interface NiFiServiceFacade {
* @param connectionId The ID of the connection
* @return snapshot
*/
ConfigurationSnapshot<Void> deleteConnection(Revision revision, String connectionId);
ConnectionEntity deleteConnection(Revision revision, String connectionId);
/**
* Creates a new flow file drop request.
@ -603,7 +611,7 @@ public interface NiFiServiceFacade {
* @param inputPortDTO The input PortDTO
* @return snapshot
*/
ConfigurationSnapshot<PortDTO> createInputPort(Revision revision, String groupId, PortDTO inputPortDTO);
PortEntity createInputPort(Revision revision, String groupId, PortDTO inputPortDTO);
/**
* Gets an input port.
@ -611,7 +619,7 @@ public interface NiFiServiceFacade {
* @param inputPortId The input port id
* @return port
*/
PortDTO getInputPort(String inputPortId);
PortEntity getInputPort(String inputPortId);
/**
* Gets all input ports in a given group.
@ -619,7 +627,7 @@ public interface NiFiServiceFacade {
* @param groupId The id of the group
* @return port
*/
Set<PortDTO> getInputPorts(String groupId);
Set<PortEntity> getInputPorts(String groupId);
/**
* Gets the input port status.
@ -643,7 +651,7 @@ public interface NiFiServiceFacade {
* @param inputPortDTO The input PortDTO
* @return snapshort
*/
ConfigurationSnapshot<PortDTO> updateInputPort(Revision revision, PortDTO inputPortDTO);
UpdateResult<PortEntity> updateInputPort(Revision revision, PortDTO inputPortDTO);
/**
* Determines if the input port could be deleted.
@ -659,7 +667,7 @@ public interface NiFiServiceFacade {
* @param inputPortId The id of the input port
* @return snapshot
*/
ConfigurationSnapshot<Void> deleteInputPort(Revision revision, String inputPortId);
PortEntity deleteInputPort(Revision revision, String inputPortId);
// ----------------------------------------
// OutputPort methods
@ -672,7 +680,7 @@ public interface NiFiServiceFacade {
* @param outputPortDTO The output PortDTO
* @return snapshot
*/
ConfigurationSnapshot<PortDTO> createOutputPort(Revision revision, String groupId, PortDTO outputPortDTO);
PortEntity createOutputPort(Revision revision, String groupId, PortDTO outputPortDTO);
/**
* Gets an output port.
@ -680,7 +688,7 @@ public interface NiFiServiceFacade {
* @param outputPortId The output port id
* @return port
*/
PortDTO getOutputPort(String outputPortId);
PortEntity getOutputPort(String outputPortId);
/**
* Gets all output ports in a given group.
@ -688,7 +696,7 @@ public interface NiFiServiceFacade {
* @param groupId The id of the group
* @return ports
*/
Set<PortDTO> getOutputPorts(String groupId);
Set<PortEntity> getOutputPorts(String groupId);
/**
* Gets the output port status.
@ -712,7 +720,7 @@ public interface NiFiServiceFacade {
* @param outputPortDTO The output PortDTO
* @return snapshot
*/
ConfigurationSnapshot<PortDTO> updateOutputPort(Revision revision, PortDTO outputPortDTO);
UpdateResult<PortEntity> updateOutputPort(Revision revision, PortDTO outputPortDTO);
/**
* Determines if the output port could be deleted.
@ -728,7 +736,19 @@ public interface NiFiServiceFacade {
* @param outputPortId The id of the output port
* @return snapshot
*/
ConfigurationSnapshot<Void> deleteOutputPort(Revision revision, String outputPortId);
PortEntity deleteOutputPort(Revision revision, String outputPortId);
// ----------------------------------------
// Flow methods
// ----------------------------------------
/**
* Returns the flow.
*
* @param groupId group
* @param recurse recurse
* @return the flow
*/
ConfigurationSnapshot<ProcessGroupFlowDTO> getProcessGroupFlow(String groupId, boolean recurse);
// ----------------------------------------
// ProcessGroup methods
@ -741,16 +761,15 @@ public interface NiFiServiceFacade {
* @param processGroupDTO The ProcessGroupDTO
* @return snapshot
*/
ConfigurationSnapshot<ProcessGroupDTO> createProcessGroup(String parentGroupId, Revision revision, ProcessGroupDTO processGroupDTO);
ProcessGroupEntity createProcessGroup(String parentGroupId, Revision revision, ProcessGroupDTO processGroupDTO);
/**
* Returns the process group.
*
* @param groupId group
* @param recurse recurse
* @return ProcessGroup transfer object
*/
ConfigurationSnapshot<ProcessGroupDTO> getProcessGroup(String groupId, boolean recurse);
ProcessGroupEntity getProcessGroup(String groupId);
/**
* Gets all process groups in the specified parent group.
@ -758,7 +777,7 @@ public interface NiFiServiceFacade {
* @param parentGroupId The id of the parent group
* @return process group
*/
Set<ProcessGroupDTO> getProcessGroups(String parentGroupId);
Set<ProcessGroupEntity> getProcessGroups(String parentGroupId);
/**
* Verifies the specified process group can be updated.
@ -774,7 +793,7 @@ public interface NiFiServiceFacade {
* @param processGroupDTO The ProcessGroupDTO
* @return snapshot
*/
ConfigurationSnapshot<ProcessGroupDTO> updateProcessGroup(Revision revision, ProcessGroupDTO processGroupDTO);
UpdateResult<ProcessGroupEntity> updateProcessGroup(Revision revision, ProcessGroupDTO processGroupDTO);
/**
* Verifies the specified process group can be removed.
@ -790,7 +809,7 @@ public interface NiFiServiceFacade {
* @param groupId The id of the process group
* @return snapshot
*/
ConfigurationSnapshot<Void> deleteProcessGroup(Revision revision, String groupId);
ProcessGroupEntity deleteProcessGroup(Revision revision, String groupId);
// ----------------------------------------
// RemoteProcessGroup methods
@ -803,7 +822,7 @@ public interface NiFiServiceFacade {
* @param remoteProcessGroupDTO The RemoteProcessGroupDTO
* @return snapshot
*/
ConfigurationSnapshot<RemoteProcessGroupDTO> createRemoteProcessGroup(Revision revision, String groupId, RemoteProcessGroupDTO remoteProcessGroupDTO);
RemoteProcessGroupEntity createRemoteProcessGroup(Revision revision, String groupId, RemoteProcessGroupDTO remoteProcessGroupDTO);
/**
* Gets a remote process group.
@ -811,7 +830,7 @@ public interface NiFiServiceFacade {
* @param remoteProcessGroupId The id of the remote process group
* @return group
*/
RemoteProcessGroupDTO getRemoteProcessGroup(String remoteProcessGroupId);
RemoteProcessGroupEntity getRemoteProcessGroup(String remoteProcessGroupId);
/**
* Gets all remote process groups in the a given parent group.
@ -819,7 +838,7 @@ public interface NiFiServiceFacade {
* @param groupId The id of the parent group
* @return group
*/
Set<RemoteProcessGroupDTO> getRemoteProcessGroups(String groupId);
Set<RemoteProcessGroupEntity> getRemoteProcessGroups(String groupId);
/**
* Gets the remote process group status.
@ -867,7 +886,7 @@ public interface NiFiServiceFacade {
* @param remoteProcessGroupDTO The RemoteProcessGroupDTO
* @return snapshot
*/
ConfigurationSnapshot<RemoteProcessGroupDTO> updateRemoteProcessGroup(Revision revision, RemoteProcessGroupDTO remoteProcessGroupDTO);
UpdateResult<RemoteProcessGroupEntity> updateRemoteProcessGroup(Revision revision, RemoteProcessGroupDTO remoteProcessGroupDTO);
/**
* Updates the specified remote process groups input port.
@ -903,7 +922,7 @@ public interface NiFiServiceFacade {
* @param remoteProcessGroupId The id of the remote process group
* @return snapshot
*/
ConfigurationSnapshot<Void> deleteRemoteProcessGroup(Revision revision, String remoteProcessGroupId);
RemoteProcessGroupEntity deleteRemoteProcessGroup(Revision revision, String remoteProcessGroupId);
// ----------------------------------------
// Funnel methods
@ -916,7 +935,7 @@ public interface NiFiServiceFacade {
* @param funnelDTO funnel
* @return The funnel DTO
*/
ConfigurationSnapshot<FunnelDTO> createFunnel(Revision revision, String groupId, FunnelDTO funnelDTO);
FunnelEntity createFunnel(Revision revision, String groupId, FunnelDTO funnelDTO);
/**
* Gets the specified funnel.
@ -924,7 +943,7 @@ public interface NiFiServiceFacade {
* @param funnelId The funnel id
* @return The funnel transfer object
*/
FunnelDTO getFunnel(String funnelId);
FunnelEntity getFunnel(String funnelId);
/**
* Gets all of the funnels.
@ -932,7 +951,7 @@ public interface NiFiServiceFacade {
* @param groupId group
* @return The funnel transfer objects
*/
Set<FunnelDTO> getFunnels(String groupId);
Set<FunnelEntity> getFunnels(String groupId);
/**
* Updates the specified label.
@ -941,7 +960,7 @@ public interface NiFiServiceFacade {
* @param funnelDTO The funnel DTO
* @return The funnel DTO
*/
ConfigurationSnapshot<FunnelDTO> updateFunnel(Revision revision, FunnelDTO funnelDTO);
UpdateResult<FunnelEntity> updateFunnel(Revision revision, FunnelDTO funnelDTO);
/**
* Verifies the specified funnel can be deleted.
@ -957,7 +976,7 @@ public interface NiFiServiceFacade {
* @param funnelId The funnel id
* @return snapshot
*/
ConfigurationSnapshot<Void> deleteFunnel(Revision revision, String funnelId);
FunnelEntity deleteFunnel(Revision revision, String funnelId);
// ----------------------------------------
// Component state methods
@ -1046,7 +1065,7 @@ public interface NiFiServiceFacade {
* @param labelDTO The label DTO
* @return The label DTO
*/
ConfigurationSnapshot<LabelDTO> createLabel(Revision revision, String groupId, LabelDTO labelDTO);
LabelEntity createLabel(Revision revision, String groupId, LabelDTO labelDTO);
/**
* Gets the specified label.
@ -1054,7 +1073,7 @@ public interface NiFiServiceFacade {
* @param labelId The label id
* @return The label transfer object
*/
LabelDTO getLabel(String labelId);
LabelEntity getLabel(String labelId);
/**
* Gets all of the labels.
@ -1062,7 +1081,7 @@ public interface NiFiServiceFacade {
* @param groupId group
* @return The label transfer objects
*/
Set<LabelDTO> getLabels(String groupId);
Set<LabelEntity> getLabels(String groupId);
/**
* Updates the specified label.
@ -1071,7 +1090,7 @@ public interface NiFiServiceFacade {
* @param labelDTO The label DTO
* @return The label DTO
*/
ConfigurationSnapshot<LabelDTO> updateLabel(Revision revision, LabelDTO labelDTO);
UpdateResult<LabelEntity> updateLabel(Revision revision, LabelDTO labelDTO);
/**
* Deletes the specified label.
@ -1080,7 +1099,7 @@ public interface NiFiServiceFacade {
* @param labelId The label id
* @return snapshot
*/
ConfigurationSnapshot<Void> deleteLabel(Revision revision, String labelId);
LabelEntity deleteLabel(Revision revision, String labelId);
// ----------------------------------------
// Controller Services methods
@ -1294,7 +1313,7 @@ public interface NiFiServiceFacade {
* @param originY y
* @return snapshot
*/
ConfigurationSnapshot<FlowSnippetDTO> copySnippet(Revision revision, String groupId, String snippetId, Double originX, Double originY);
ConfigurationSnapshot<FlowDTO> copySnippet(Revision revision, String groupId, String snippetId, Double originX, Double originY);
/**
* Creates a new snippet.

View File

@ -27,6 +27,7 @@ import org.springframework.context.annotation.ImportResource;
@Import({NiFiWebApiSecurityConfiguration.class})
@ImportResource({"classpath:nifi-context.xml",
"classpath:nifi-administration-context.xml",
"classpath:nifi-framework-authorization-context.xml",
"classpath:nifi-cluster-manager-context.xml",
"classpath:nifi-cluster-protocol-context.xml",
"classpath:nifi-web-security-context.xml",

View File

@ -20,6 +20,8 @@ import com.sun.jersey.api.client.ClientResponse;
import com.sun.jersey.api.client.ClientResponse.Status;
import com.sun.jersey.core.util.MultivaluedMapImpl;
import org.apache.commons.lang3.StringUtils;
import org.apache.nifi.authorization.AccessDeniedException;
import org.apache.nifi.authorization.user.NiFiUserDetails;
import org.apache.nifi.cluster.manager.NodeResponse;
import org.apache.nifi.cluster.manager.exception.UnknownNodeException;
import org.apache.nifi.cluster.manager.impl.WebClusterManager;
@ -27,11 +29,9 @@ import org.apache.nifi.cluster.node.Node;
import org.apache.nifi.cluster.protocol.NodeIdentifier;
import org.apache.nifi.controller.repository.claim.ContentDirection;
import org.apache.nifi.util.NiFiProperties;
import org.apache.nifi.web.security.user.NiFiUserDetails;
import org.apache.nifi.web.util.WebUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.security.access.AccessDeniedException;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;

View File

@ -25,12 +25,14 @@ import org.apache.nifi.action.Operation;
import org.apache.nifi.action.component.details.FlowChangeExtensionDetails;
import org.apache.nifi.action.details.FlowChangeConfigureDetails;
import org.apache.nifi.admin.service.AuditService;
import org.apache.nifi.authorization.user.NiFiUserDetails;
import org.apache.nifi.authorization.user.NiFiUserUtils;
import org.apache.nifi.cluster.manager.NodeResponse;
import org.apache.nifi.cluster.manager.impl.WebClusterManager;
import org.apache.nifi.controller.ControllerService;
import org.apache.nifi.controller.ControllerServiceLookup;
import org.apache.nifi.controller.reporting.ReportingTaskProvider;
import org.apache.nifi.user.NiFiUser;
import org.apache.nifi.authorization.user.NiFiUser;
import org.apache.nifi.util.NiFiProperties;
import org.apache.nifi.web.api.dto.ControllerServiceDTO;
import org.apache.nifi.web.api.dto.ProcessorConfigDTO;
@ -40,8 +42,6 @@ import org.apache.nifi.web.api.dto.RevisionDTO;
import org.apache.nifi.web.api.entity.ControllerServiceEntity;
import org.apache.nifi.web.api.entity.ProcessorEntity;
import org.apache.nifi.web.api.entity.ReportingTaskEntity;
import org.apache.nifi.web.security.user.NiFiUserDetails;
import org.apache.nifi.web.security.user.NiFiUserUtils;
import org.apache.nifi.web.util.ClientResponseUtils;
import org.apache.nifi.web.util.WebUtils;
import org.slf4j.Logger;
@ -288,7 +288,7 @@ public class StandardNiFiWebConfigurationContext implements NiFiWebConfiguration
// create the request URL
URI requestUrl;
try {
String path = "/nifi-api/cluster/processors/" + URLEncoder.encode(id, "UTF-8");
String path = "/nifi-api/processors/" + URLEncoder.encode(id, "UTF-8");
requestUrl = new URI(requestContext.getScheme(), null, "localhost", 0, path, null, null);
} catch (final URISyntaxException | UnsupportedEncodingException use) {
throw new ClusterRequestException(use);
@ -309,9 +309,9 @@ public class StandardNiFiWebConfigurationContext implements NiFiWebConfiguration
if (entity == null) {
entity = nodeResponse.getClientResponse().getEntity(ProcessorEntity.class);
}
processor = entity.getProcessor();
processor = entity.getComponent();
} else {
processor = serviceFacade.getProcessor(id);
processor = serviceFacade.getProcessor(id).getComponent();
}
// return the processor info
@ -328,7 +328,7 @@ public class StandardNiFiWebConfigurationContext implements NiFiWebConfiguration
// create the request URL
URI requestUrl;
try {
String path = "/nifi-api/cluster/processors/" + URLEncoder.encode(id, "UTF-8");
String path = "/nifi-api/processors/" + URLEncoder.encode(id, "UTF-8");
requestUrl = new URI(requestContext.getScheme(), null, "localhost", 0, path, null, null);
} catch (final URISyntaxException | UnsupportedEncodingException use) {
throw new ClusterRequestException(use);
@ -345,7 +345,7 @@ public class StandardNiFiWebConfigurationContext implements NiFiWebConfiguration
// create the processor dto
ProcessorDTO processorDto = new ProcessorDTO();
processorEntity.setProcessor(processorDto);
processorEntity.setComponent(processorDto);
processorDto.setId(id);
// create the processor configuration with the given annotation data
@ -368,7 +368,7 @@ public class StandardNiFiWebConfigurationContext implements NiFiWebConfiguration
if (entity == null) {
entity = nodeResponse.getClientResponse().getEntity(ProcessorEntity.class);
}
processor = entity.getProcessor();
processor = entity.getComponent();
} else {
final ConfigurationSnapshot<ProcessorDTO> response = serviceFacade.setProcessorAnnotationData(revision, id, annotationData);
processor = response.getConfiguration();

View File

@ -25,18 +25,18 @@ import org.apache.nifi.action.Operation;
import org.apache.nifi.action.component.details.FlowChangeExtensionDetails;
import org.apache.nifi.action.details.FlowChangeConfigureDetails;
import org.apache.nifi.admin.service.AuditService;
import org.apache.nifi.authorization.user.NiFiUserDetails;
import org.apache.nifi.authorization.user.NiFiUserUtils;
import org.apache.nifi.cluster.manager.NodeResponse;
import org.apache.nifi.cluster.manager.impl.WebClusterManager;
import org.apache.nifi.controller.ControllerService;
import org.apache.nifi.controller.ControllerServiceLookup;
import org.apache.nifi.user.NiFiUser;
import org.apache.nifi.authorization.user.NiFiUser;
import org.apache.nifi.util.NiFiProperties;
import org.apache.nifi.web.api.dto.ProcessorConfigDTO;
import org.apache.nifi.web.api.dto.ProcessorDTO;
import org.apache.nifi.web.api.dto.RevisionDTO;
import org.apache.nifi.web.api.entity.ProcessorEntity;
import org.apache.nifi.web.security.user.NiFiUserDetails;
import org.apache.nifi.web.security.user.NiFiUserUtils;
import org.apache.nifi.web.util.ClientResponseUtils;
import org.apache.nifi.web.util.WebUtils;
import org.slf4j.Logger;
@ -166,7 +166,7 @@ public class StandardNiFiWebContext implements NiFiWebContext {
// create the request URL
URI requestUrl;
try {
String path = "/nifi-api/cluster/processors/" + URLEncoder.encode(processorId, "UTF-8");
String path = "/nifi-api/processors/" + URLEncoder.encode(processorId, "UTF-8");
requestUrl = new URI(config.getScheme(), null, "localhost", 0, path, null, null);
} catch (final URISyntaxException | UnsupportedEncodingException use) {
throw new ClusterRequestException(use);
@ -200,9 +200,9 @@ public class StandardNiFiWebContext implements NiFiWebContext {
if (entity == null) {
entity = nodeResponse.getClientResponse().getEntity(ProcessorEntity.class);
}
processor = entity.getProcessor();
processor = entity.getComponent();
} else {
processor = serviceFacade.getProcessor(processorId);
processor = serviceFacade.getProcessor(processorId).getComponent();
}
// return the processor info
@ -233,7 +233,7 @@ public class StandardNiFiWebContext implements NiFiWebContext {
// create the request URL
URI requestUrl;
try {
String path = "/nifi-api/cluster/processors/" + URLEncoder.encode(processorId, "UTF-8");
String path = "/nifi-api/processors/" + URLEncoder.encode(processorId, "UTF-8");
requestUrl = new URI(config.getScheme(), null, "localhost", 0, path, null, null);
} catch (final URISyntaxException | UnsupportedEncodingException use) {
throw new ClusterRequestException(use);
@ -250,7 +250,7 @@ public class StandardNiFiWebContext implements NiFiWebContext {
// create the processor dto
ProcessorDTO processorDto = new ProcessorDTO();
processorEntity.setProcessor(processorDto);
processorEntity.setComponent(processorDto);
processorDto.setId(processorId);
// create the processor configuration with the given annotation data

View File

@ -0,0 +1,40 @@
/*
* 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;
/**
* Result from an update operation.
*/
@SuppressWarnings("serial")
public class UpdateResult<T> {
private final T result;
private final boolean isNew;
public UpdateResult(T result, boolean isNew) {
this.result = result;
this.isNew = isNew;
}
public T getResult() {
return result;
}
public boolean isNew() {
return isNew;
}
}

View File

@ -29,8 +29,10 @@ import org.apache.nifi.authentication.LoginCredentials;
import org.apache.nifi.authentication.LoginIdentityProvider;
import org.apache.nifi.authentication.exception.IdentityAccessException;
import org.apache.nifi.authentication.exception.InvalidLoginCredentialsException;
import org.apache.nifi.authorization.AccessDeniedException;
import org.apache.nifi.authorization.user.NiFiUser;
import org.apache.nifi.authorization.user.NiFiUserUtils;
import org.apache.nifi.security.util.CertificateUtils;
import org.apache.nifi.user.NiFiUser;
import org.apache.nifi.util.FormatUtils;
import org.apache.nifi.util.NiFiProperties;
import org.apache.nifi.web.api.dto.AccessConfigurationDTO;
@ -48,12 +50,10 @@ import org.apache.nifi.web.security.kerberos.KerberosService;
import org.apache.nifi.web.security.otp.OtpService;
import org.apache.nifi.web.security.token.LoginAuthenticationToken;
import org.apache.nifi.web.security.token.OtpAuthenticationToken;
import org.apache.nifi.web.security.user.NiFiUserUtils;
import org.apache.nifi.web.security.x509.X509CertificateExtractor;
import org.apache.nifi.web.security.x509.X509IdentityProvider;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.security.access.AccessDeniedException;
import org.springframework.security.authentication.AccountStatusException;
import org.springframework.security.authentication.AuthenticationServiceException;
import org.springframework.security.core.Authentication;

View File

@ -26,6 +26,7 @@ import org.apache.commons.lang3.builder.ToStringStyle;
import org.apache.nifi.action.Action;
import org.apache.nifi.action.FlowChangeAction;
import org.apache.nifi.action.Operation;
import org.apache.nifi.authorization.user.NiFiUserDetails;
import org.apache.nifi.cluster.context.ClusterContext;
import org.apache.nifi.cluster.context.ClusterContextThreadLocal;
import org.apache.nifi.cluster.manager.impl.WebClusterManager;
@ -33,7 +34,6 @@ import org.apache.nifi.util.NiFiProperties;
import org.apache.nifi.web.api.entity.Entity;
import org.apache.nifi.web.api.request.ClientIdParameter;
import org.apache.nifi.web.security.jwt.JwtAuthenticationFilter;
import org.apache.nifi.web.security.user.NiFiUserDetails;
import org.apache.nifi.web.util.WebUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

View File

@ -24,34 +24,23 @@ import com.wordnik.swagger.annotations.ApiResponse;
import com.wordnik.swagger.annotations.ApiResponses;
import com.wordnik.swagger.annotations.Authorization;
import org.apache.commons.lang3.StringUtils;
import org.apache.nifi.cluster.manager.impl.WebClusterManager;
import org.apache.nifi.cluster.node.Node;
import org.apache.nifi.util.NiFiProperties;
import org.apache.nifi.web.ConfigurationSnapshot;
import org.apache.nifi.web.IllegalClusterResourceRequestException;
import org.apache.nifi.web.NiFiServiceFacade;
import org.apache.nifi.web.Revision;
import org.apache.nifi.web.api.dto.ClusterDTO;
import org.apache.nifi.web.api.dto.NodeDTO;
import org.apache.nifi.web.api.dto.ProcessorConfigDTO;
import org.apache.nifi.web.api.dto.ProcessorDTO;
import org.apache.nifi.web.api.dto.RevisionDTO;
import org.apache.nifi.web.api.dto.search.NodeSearchResultDTO;
import org.apache.nifi.web.api.entity.ClusterEntity;
import org.apache.nifi.web.api.entity.ClusterSearchResultsEntity;
import org.apache.nifi.web.api.entity.ProcessorEntity;
import org.apache.nifi.web.api.request.ClientIdParameter;
import org.apache.nifi.web.api.request.LongParameter;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.Consumes;
import javax.ws.rs.DefaultValue;
import javax.ws.rs.FormParam;
import javax.ws.rs.GET;
import javax.ws.rs.HEAD;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.Context;
@ -233,218 +222,6 @@ public class ClusterResource extends ApplicationResource {
throw new IllegalClusterResourceRequestException("Only a cluster manager can process the request.");
}
/**
* Gets the processor.
*
* @param clientId Optional client id. If the client id is not specified, a new one will be generated. This value (whether specified or generated) is included in the response.
* @param id The id of the processor
* @return A processorEntity
*/
@GET
@Consumes(MediaType.WILDCARD)
@Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
@Path("/processors/{id}")
// TODO - @PreAuthorize("hasAnyRole('ROLE_MONITOR', 'ROLE_DFM', 'ROLE_ADMIN')")
@ApiOperation(
value = "Gets the specified processor",
response = ProcessorEntity.class,
authorizations = {
@Authorization(value = "Read Only", type = "ROLE_MONITOR"),
@Authorization(value = "DFM", type = "ROLE_DFM"),
@Authorization(value = "Admin", type = "ROLE_ADMIN")
}
)
@ApiResponses(
value = {
@ApiResponse(code = 400, message = "NiFi was unable to complete the request because it was invalid. The request should not be retried without modification."),
@ApiResponse(code = 401, message = "Client could not be authenticated."),
@ApiResponse(code = 403, message = "Client is not authorized to make this request."),
@ApiResponse(code = 404, message = "The specified resource could not be found."),
@ApiResponse(code = 409, message = "The request was valid but NiFi was not in the appropriate state to process it. Retrying the same request later may be successful.")
}
)
public Response getProcessor(
@ApiParam(
value = "If the client id is not specified, new one will be generated. This value (whether specified or generated) is included in the response.",
required = false
)
@QueryParam(CLIENT_ID) @DefaultValue(StringUtils.EMPTY) ClientIdParameter clientId,
@ApiParam(
value = "The processor id.",
required = true
)
@PathParam("id") String id) {
if (!properties.isClusterManager()) {
final ProcessorDTO dto = serviceFacade.getProcessor(id);
// create the revision
RevisionDTO revision = new RevisionDTO();
revision.setClientId(clientId.getClientId());
// create entity
final ProcessorEntity entity = new ProcessorEntity();
entity.setProcessor(dto);
entity.setRevision(revision);
// generate the response
return generateOkResponse(entity).build();
}
throw new IllegalClusterResourceRequestException("Only a node can process the request.");
}
/**
* Updates the processors annotation data.
*
* @param httpServletRequest request
* @param version The revision is used to verify the client is working with the latest version of the flow.
* @param clientId Optional client id. If the client id is not specified, a new one will be generated. This value (whether specified or generated) is included in the response.
* @param processorId The id of the processor.
* @param annotationData The annotation data to set.
* @return A processorEntity.
*/
@PUT
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
@Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
@Path("/processors/{id}")
// TODO - @PreAuthorize("hasAnyRole('ROLE_DFM')")
public Response updateProcessor(
@Context HttpServletRequest httpServletRequest,
@FormParam(VERSION) LongParameter version,
@FormParam(CLIENT_ID) @DefaultValue(StringUtils.EMPTY) ClientIdParameter clientId,
@PathParam("id") String processorId,
@FormParam("annotationData") String annotationData) {
if (!properties.isClusterManager()) {
// create the processor configuration with the given annotation data
ProcessorConfigDTO configDto = new ProcessorConfigDTO();
configDto.setAnnotationData(annotationData);
// create the processor dto
ProcessorDTO processorDto = new ProcessorDTO();
processorDto.setId(processorId);
processorDto.setConfig(configDto);
// create the revision
RevisionDTO revision = new RevisionDTO();
revision.setClientId(clientId.getClientId());
if (version != null) {
revision.setVersion(version.getLong());
}
// create the processor entity
ProcessorEntity processorEntity = new ProcessorEntity();
processorEntity.setRevision(revision);
processorEntity.setProcessor(processorDto);
return updateProcessor(httpServletRequest, processorId, processorEntity);
}
throw new IllegalClusterResourceRequestException("Only a node can process the request.");
}
/**
* Updates the processors annotation data.
*
* @param httpServletRequest request
* @param processorId The id of the processor.
* @param processorEntity A processorEntity.
* @return A processorEntity.
*/
@PUT
@Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
@Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
@Path("/processors/{id}")
// TODO - @PreAuthorize("hasAnyRole('ROLE_DFM')")
@ApiOperation(
value = "Updates processor annotation data",
response = ProcessorEntity.class,
authorizations = {
@Authorization(value = "Read Only", type = "ROLE_MONITOR"),
@Authorization(value = "DFM", type = "ROLE_DFM"),
@Authorization(value = "Admin", type = "ROLE_ADMIN")
}
)
@ApiResponses(
value = {
@ApiResponse(code = 400, message = "NiFi was unable to complete the request because it was invalid. The request should not be retried without modification."),
@ApiResponse(code = 401, message = "Client could not be authenticated."),
@ApiResponse(code = 403, message = "Client is not authorized to make this request."),
@ApiResponse(code = 404, message = "The specified resource could not be found."),
@ApiResponse(code = 409, message = "The request was valid but NiFi was not in the appropriate state to process it. Retrying the same request later may be successful.")
}
)
public Response updateProcessor(
@Context HttpServletRequest httpServletRequest,
@ApiParam(
value = "The processor id.",
required = true
)
@PathParam("id") final String processorId,
@ApiParam(
value = "The processor configuration details. The only configuration that will be honored at this endpoint is the processor annontation data.",
required = true
)
final ProcessorEntity processorEntity) {
if (!properties.isClusterManager()) {
if (processorEntity == null || processorEntity.getProcessor() == null) {
throw new IllegalArgumentException("Processor details must be specified.");
}
if (processorEntity.getRevision() == null) {
throw new IllegalArgumentException("Revision must be specified.");
}
// ensure the same id is being used
ProcessorDTO requestProcessorDTO = processorEntity.getProcessor();
if (!processorId.equals(requestProcessorDTO.getId())) {
throw new IllegalArgumentException(String.format("The processor id (%s) in the request body does "
+ "not equal the processor id of the requested resource (%s).", requestProcessorDTO.getId(), processorId));
}
// get the processor configuration
ProcessorConfigDTO config = requestProcessorDTO.getConfig();
if (config == null) {
throw new IllegalArgumentException("Processor configuration must be specified.");
}
// handle expects request (usually from the cluster manager)
final String expects = httpServletRequest.getHeader(WebClusterManager.NCM_EXPECTS_HTTP_HEADER);
if (expects != null) {
serviceFacade.verifyUpdateProcessor(requestProcessorDTO);
return generateContinueResponse().build();
}
// update the processor
final RevisionDTO revision = processorEntity.getRevision();
final ConfigurationSnapshot<ProcessorDTO> controllerResponse = serviceFacade.setProcessorAnnotationData(
new Revision(revision.getVersion(), revision.getClientId()), processorId, config.getAnnotationData());
// get the processor dto
final ProcessorDTO responseProcessorDTO = controllerResponse.getConfiguration();
// update the revision
RevisionDTO updatedRevision = new RevisionDTO();
updatedRevision.setClientId(revision.getClientId());
updatedRevision.setVersion(controllerResponse.getVersion());
// generate the response entity
final ProcessorEntity entity = new ProcessorEntity();
entity.setRevision(updatedRevision);
entity.setProcessor(responseProcessorDTO);
return generateOkResponse(entity).build();
}
throw new IllegalClusterResourceRequestException("Only a node can process the request.");
}
// setters
public void setServiceFacade(NiFiServiceFacade serviceFacade) {
this.serviceFacade = serviceFacade;

View File

@ -25,9 +25,9 @@ import com.wordnik.swagger.annotations.Authorization;
import org.apache.commons.lang3.StringUtils;
import org.apache.nifi.cluster.manager.impl.WebClusterManager;
import org.apache.nifi.util.NiFiProperties;
import org.apache.nifi.web.ConfigurationSnapshot;
import org.apache.nifi.web.NiFiServiceFacade;
import org.apache.nifi.web.Revision;
import org.apache.nifi.web.UpdateResult;
import org.apache.nifi.web.api.dto.ConnectionDTO;
import org.apache.nifi.web.api.dto.FlowFileSummaryDTO;
import org.apache.nifi.web.api.dto.ListingRequestDTO;
@ -69,6 +69,32 @@ public class ConnectionResource extends ApplicationResource {
private WebClusterManager clusterManager;
private NiFiProperties properties;
/**
* Populate the URIs for the specified connections.
*
* @param connectionEntities connections
* @return dtos
*/
public Set<ConnectionEntity> populateRemainingConnectionEntitiesContent(Set<ConnectionEntity> connectionEntities) {
for (ConnectionEntity connectionEntity : connectionEntities) {
populateRemainingConnectionEntityContent(connectionEntity);
}
return connectionEntities;
}
/**
* Populate the URIs for the specified connection.
*
* @param connectionEntity connection
* @return dto
*/
public ConnectionEntity populateRemainingConnectionEntityContent(ConnectionEntity connectionEntity) {
if (connectionEntity.getComponent() != null) {
populateRemainingConnectionContent(connectionEntity.getComponent());
}
return connectionEntity;
}
/**
* Populate the URIs for the specified connections.
*
@ -129,7 +155,6 @@ public class ConnectionResource extends ApplicationResource {
/**
* Retrieves the specified connection.
*
* @param clientId Optional client id. If the client id is not specified, a new one will be generated. This value (whether specified or generated) is included in the response.
* @param id The id of the connection.
* @return A connectionEntity.
*/
@ -157,11 +182,6 @@ public class ConnectionResource extends ApplicationResource {
}
)
public Response getConnection(
@ApiParam(
value = "If the client id is not specified, new one will be generated. This value (whether specified or generated) is included in the response.",
required = false
)
@QueryParam(CLIENT_ID) @DefaultValue(StringUtils.EMPTY) ClientIdParameter clientId,
@ApiParam(
value = "The connection id.",
required = true
@ -174,16 +194,8 @@ public class ConnectionResource extends ApplicationResource {
}
// get the specified relationship
ConnectionDTO connection = serviceFacade.getConnection(id);
// create the revision
RevisionDTO revision = new RevisionDTO();
revision.setClientId(clientId.getClientId());
// create the response entity
ConnectionEntity entity = new ConnectionEntity();
entity.setRevision(revision);
entity.setConnection(populateRemainingConnectionContent(connection));
ConnectionEntity entity = serviceFacade.getConnection(id);
populateRemainingConnectionEntityContent(entity);
// generate the response
return clusterContext(generateOkResponse(entity)).build();
@ -230,7 +242,7 @@ public class ConnectionResource extends ApplicationResource {
required = true
) ConnectionEntity connectionEntity) {
if (connectionEntity == null || connectionEntity.getConnection() == null) {
if (connectionEntity == null || connectionEntity.getComponent() == null) {
throw new IllegalArgumentException("Connection details must be specified.");
}
@ -239,7 +251,7 @@ public class ConnectionResource extends ApplicationResource {
}
// ensure the ids are the same
final ConnectionDTO connection = connectionEntity.getConnection();
final ConnectionDTO connection = connectionEntity.getComponent();
if (!id.equals(connection.getId())) {
throw new IllegalArgumentException(String.format("The connection id "
+ "(%s) in the request body does not equal the connection id of the "
@ -265,26 +277,14 @@ public class ConnectionResource extends ApplicationResource {
// update the relationship target
final RevisionDTO revision = connectionEntity.getRevision();
final ConfigurationSnapshot<ConnectionDTO> controllerResponse = serviceFacade.updateConnection(
new Revision(revision.getVersion(), revision.getClientId()), connection);
final UpdateResult<ConnectionEntity> updateResult = serviceFacade.updateConnection(new Revision(revision.getVersion(), revision.getClientId()), connection);
// get the updated revision
final RevisionDTO updatedRevision = new RevisionDTO();
updatedRevision.setClientId(revision.getClientId());
updatedRevision.setVersion(controllerResponse.getVersion());
// marshall the target and add the source processor
final ConnectionDTO connectionDTO = controllerResponse.getConfiguration();
populateRemainingConnectionContent(connectionDTO);
// create the response entity
ConnectionEntity entity = new ConnectionEntity();
entity.setRevision(updatedRevision);
entity.setConnection(connectionDTO);
final ConnectionEntity entity = updateResult.getResult();
populateRemainingConnectionEntityContent(entity);
// generate the response
if (controllerResponse.isNew()) {
return clusterContext(generateCreatedResponse(URI.create(connectionDTO.getUri()), entity)).build();
if (updateResult.isNew()) {
return clusterContext(generateCreatedResponse(URI.create(entity.getUri()), entity)).build();
} else {
return clusterContext(generateOkResponse(entity)).build();
}
@ -357,16 +357,7 @@ public class ConnectionResource extends ApplicationResource {
}
// delete the connection
final ConfigurationSnapshot<Void> controllerResponse = serviceFacade.deleteConnection(new Revision(clientVersion, clientId.getClientId()), id);
// create the revision
final RevisionDTO updatedRevision = new RevisionDTO();
updatedRevision.setClientId(clientId.getClientId());
updatedRevision.setVersion(controllerResponse.getVersion());
// create the response entity
final ConnectionEntity entity = new ConnectionEntity();
entity.setRevision(updatedRevision);
final ConnectionEntity entity = serviceFacade.deleteConnection(new Revision(clientVersion, clientId.getClientId()), id);
// generate the response
return clusterContext(generateOkResponse(entity)).build();

View File

@ -24,6 +24,7 @@ import com.wordnik.swagger.annotations.ApiResponse;
import com.wordnik.swagger.annotations.ApiResponses;
import com.wordnik.swagger.annotations.Authorization;
import org.apache.commons.lang3.StringUtils;
import org.apache.nifi.authorization.user.NiFiUserUtils;
import org.apache.nifi.cluster.context.ClusterContext;
import org.apache.nifi.cluster.context.ClusterContextThreadLocal;
import org.apache.nifi.cluster.manager.NodeResponse;
@ -31,7 +32,7 @@ import org.apache.nifi.cluster.manager.exception.UnknownNodeException;
import org.apache.nifi.cluster.manager.impl.WebClusterManager;
import org.apache.nifi.cluster.node.Node;
import org.apache.nifi.cluster.protocol.NodeIdentifier;
import org.apache.nifi.user.NiFiUser;
import org.apache.nifi.authorization.user.NiFiUser;
import org.apache.nifi.util.NiFiProperties;
import org.apache.nifi.web.ConfigurationSnapshot;
import org.apache.nifi.web.NiFiServiceFacade;
@ -50,7 +51,6 @@ import org.apache.nifi.web.api.entity.ProcessGroupEntity;
import org.apache.nifi.web.api.entity.ReportingTaskEntity;
import org.apache.nifi.web.api.entity.ReportingTasksEntity;
import org.apache.nifi.web.api.request.ClientIdParameter;
import org.apache.nifi.web.security.user.NiFiUserUtils;
import org.apache.nifi.web.util.Availability;
import javax.servlet.http.HttpServletRequest;

View File

@ -152,9 +152,6 @@ public class ControllerServiceResource extends ApplicationResource {
/**
* Retrieves the specified controller service.
*
* @param clientId Optional client id. If the client id is not specified, a
* new one will be generated. This value (whether specified or generated) is
* included in the response.
* @param availability Whether the controller service is available on the
* NCM only (ncm) or on the nodes only (node). If this instance is not
* clustered all services should use the node availability.
@ -185,11 +182,6 @@ public class ControllerServiceResource extends ApplicationResource {
}
)
public Response getControllerService(
@ApiParam(
value = "If the client id is not specified, new one will be generated. This value (whether specified or generated) is included in the response.",
required = false
)
@QueryParam(CLIENT_ID) @DefaultValue(StringUtils.EMPTY) ClientIdParameter clientId,
@ApiParam(
value = "Whether the controller service is available on the NCM or nodes. If the NiFi is standalone the availability should be NODE.",
allowableValues = "NCM, NODE",
@ -212,13 +204,8 @@ public class ControllerServiceResource extends ApplicationResource {
// get the controller service
final ControllerServiceDTO controllerService = serviceFacade.getControllerService(id);
// create the revision
final RevisionDTO revision = new RevisionDTO();
revision.setClientId(clientId.getClientId());
// create the response entity
final ControllerServiceEntity entity = new ControllerServiceEntity();
entity.setRevision(revision);
entity.setControllerService(populateRemainingControllerServiceContent(availability, controllerService));
return clusterContext(generateOkResponse(entity)).build();
@ -227,9 +214,6 @@ public class ControllerServiceResource extends ApplicationResource {
/**
* Returns the descriptor for the specified property.
*
* @param clientId Optional client id. If the client id is not specified, a
* new one will be generated. This value (whether specified or generated) is
* included in the response.
* @param availability avail
* @param id The id of the controller service.
* @param propertyName The property
@ -259,11 +243,6 @@ public class ControllerServiceResource extends ApplicationResource {
}
)
public Response getPropertyDescriptor(
@ApiParam(
value = "If the client id is not specified, new one will be generated. This value (whether specified or generated) is included in the response.",
required = false
)
@QueryParam(CLIENT_ID) @DefaultValue(StringUtils.EMPTY) ClientIdParameter clientId,
@ApiParam(
value = "Whether the controller service is available on the NCM or nodes. If the NiFi is standalone the availability should be NODE.",
allowableValues = "NCM, NODE",
@ -296,13 +275,8 @@ public class ControllerServiceResource extends ApplicationResource {
// get the property descriptor
final PropertyDescriptorDTO descriptor = serviceFacade.getControllerServicePropertyDescriptor(id, propertyName);
// create the revision
final RevisionDTO revision = new RevisionDTO();
revision.setClientId(clientId.getClientId());
// generate the response entity
final PropertyDescriptorEntity entity = new PropertyDescriptorEntity();
entity.setRevision(revision);
entity.setPropertyDescriptor(descriptor);
// generate the response
@ -312,7 +286,6 @@ public class ControllerServiceResource extends ApplicationResource {
/**
* Gets the state for a controller service.
*
* @param clientId Optional client id. If the client id is not specified, a new one will be generated. This value (whether specified or generated) is included in the response.
* @param availability Whether the controller service is available on the
* NCM only (ncm) or on the nodes only (node). If this instance is not
* clustered all services should use the node availability.
@ -341,11 +314,6 @@ public class ControllerServiceResource extends ApplicationResource {
}
)
public Response getState(
@ApiParam(
value = "If the client id is not specified, new one will be generated. This value (whether specified or generated) is included in the response.",
required = false
)
@QueryParam(CLIENT_ID) @DefaultValue(StringUtils.EMPTY) ClientIdParameter clientId,
@ApiParam(
value = "Whether the controller service is available on the NCM or nodes. If the NiFi is standalone the availability should be NODE.",
allowableValues = "NCM, NODE",
@ -368,13 +336,8 @@ public class ControllerServiceResource extends ApplicationResource {
// get the component state
final ComponentStateDTO state = serviceFacade.getControllerServiceState(id);
// create the revision
final RevisionDTO revision = new RevisionDTO();
revision.setClientId(clientId.getClientId());
// generate the response entity
final ComponentStateEntity entity = new ComponentStateEntity();
entity.setRevision(revision);
entity.setComponentState(state);
// generate the response
@ -465,9 +428,6 @@ public class ControllerServiceResource extends ApplicationResource {
/**
* Retrieves the references of the specified controller service.
*
* @param clientId Optional client id. If the client id is not specified, a
* new one will be generated. This value (whether specified or generated) is
* included in the response.
* @param availability Whether the controller service is available on the
* NCM only (ncm) or on the nodes only (node). If this instance is not
* clustered all services should use the node availability.
@ -498,11 +458,6 @@ public class ControllerServiceResource extends ApplicationResource {
}
)
public Response getControllerServiceReferences(
@ApiParam(
value = "If the client id is not specified, new one will be generated. This value (whether specified or generated) is included in the response.",
required = false
)
@QueryParam(CLIENT_ID) @DefaultValue(StringUtils.EMPTY) ClientIdParameter clientId,
@ApiParam(
value = "Whether the controller service is available on the NCM or nodes. If the NiFi is standalone the availability should be NODE.",
allowableValues = "NCM, NODE",
@ -525,13 +480,8 @@ public class ControllerServiceResource extends ApplicationResource {
// get the controller service
final Set<ControllerServiceReferencingComponentDTO> controllerServiceReferences = serviceFacade.getControllerServiceReferencingComponents(id);
// create the revision
final RevisionDTO revision = new RevisionDTO();
revision.setClientId(clientId.getClientId());
// create the response entity
final ControllerServiceReferencingComponentsEntity entity = new ControllerServiceReferencingComponentsEntity();
entity.setRevision(revision);
entity.setControllerServiceReferencingComponents(controllerServiceReferences);
return clusterContext(generateOkResponse(entity)).build();

View File

@ -24,20 +24,32 @@ import com.wordnik.swagger.annotations.ApiResponse;
import com.wordnik.swagger.annotations.ApiResponses;
import com.wordnik.swagger.annotations.Authorization;
import org.apache.commons.lang3.StringUtils;
import org.apache.nifi.authorization.AccessDeniedException;
import org.apache.nifi.authorization.AuthorizationRequest;
import org.apache.nifi.authorization.AuthorizationResult;
import org.apache.nifi.authorization.AuthorizationResult.Result;
import org.apache.nifi.authorization.Authorizer;
import org.apache.nifi.authorization.RequestAction;
import org.apache.nifi.authorization.resource.ResourceFactory;
import org.apache.nifi.authorization.user.NiFiUser;
import org.apache.nifi.authorization.user.NiFiUserUtils;
import org.apache.nifi.cluster.manager.NodeResponse;
import org.apache.nifi.cluster.manager.exception.UnknownNodeException;
import org.apache.nifi.cluster.manager.impl.WebClusterManager;
import org.apache.nifi.cluster.node.Node;
import org.apache.nifi.cluster.protocol.NodeIdentifier;
import org.apache.nifi.user.NiFiUser;
import org.apache.nifi.util.NiFiProperties;
import org.apache.nifi.web.ConfigurationSnapshot;
import org.apache.nifi.web.NiFiServiceFacade;
import org.apache.nifi.web.api.dto.AboutDTO;
import org.apache.nifi.web.api.dto.BannerDTO;
import org.apache.nifi.web.api.dto.BulletinBoardDTO;
import org.apache.nifi.web.api.dto.BulletinQueryDTO;
import org.apache.nifi.web.api.dto.ControllerConfigurationDTO;
import org.apache.nifi.web.api.dto.ProcessGroupDTO;
import org.apache.nifi.web.api.dto.RevisionDTO;
import org.apache.nifi.web.api.dto.flow.FlowDTO;
import org.apache.nifi.web.api.dto.flow.ProcessGroupFlowDTO;
import org.apache.nifi.web.api.dto.search.SearchResultsDTO;
import org.apache.nifi.web.api.dto.status.ConnectionStatusDTO;
import org.apache.nifi.web.api.dto.status.ControllerStatusDTO;
@ -58,6 +70,8 @@ import org.apache.nifi.web.api.entity.Entity;
import org.apache.nifi.web.api.entity.IdentityEntity;
import org.apache.nifi.web.api.entity.PortStatusEntity;
import org.apache.nifi.web.api.entity.PrioritizerTypesEntity;
import org.apache.nifi.web.api.entity.ProcessGroupEntity;
import org.apache.nifi.web.api.entity.ProcessGroupFlowEntity;
import org.apache.nifi.web.api.entity.ProcessGroupStatusEntity;
import org.apache.nifi.web.api.entity.ProcessorStatusEntity;
import org.apache.nifi.web.api.entity.ProcessorTypesEntity;
@ -69,7 +83,6 @@ import org.apache.nifi.web.api.request.BulletinBoardPatternParameter;
import org.apache.nifi.web.api.request.ClientIdParameter;
import org.apache.nifi.web.api.request.IntegerParameter;
import org.apache.nifi.web.api.request.LongParameter;
import org.apache.nifi.web.security.user.NiFiUserUtils;
import javax.ws.rs.Consumes;
import javax.ws.rs.DefaultValue;
@ -92,7 +105,7 @@ import java.util.Set;
@Path("/flow")
@Api(
value = "/flow",
description = "Endpoint for accessing the flow structure and component statuses."
description = "Endpoint for accessing the flow structure and component status."
)
public class FlowResource extends ApplicationResource {
@ -101,10 +114,164 @@ public class FlowResource extends ApplicationResource {
private NiFiServiceFacade serviceFacade;
private WebClusterManager clusterManager;
private NiFiProperties properties;
private Authorizer authorizer;
@Context
private ResourceContext resourceContext;
private ProcessorResource processorResource;
private InputPortResource inputPortResource;
private OutputPortResource outputPortResource;
private FunnelResource funnelResource;
private LabelResource labelResource;
private RemoteProcessGroupResource remoteProcessGroupResource;
private ConnectionResource connectionResource;
private TemplateResource templateResource;
private ProcessGroupResource processGroupResource;
private ControllerServiceResource controllerServiceResource;
/**
* Populates the remaining fields in the specified process group.
*
* @param flow group
* @return group dto
*/
private ProcessGroupFlowDTO populateRemainingFlowContent(ProcessGroupFlowDTO flow) {
FlowDTO flowStructure = flow.getFlow();
// populate the remaining fields for the processors, connections, process group refs, remote process groups, and labels if appropriate
if (flowStructure != null) {
populateRemainingFlowStructure(flowStructure);
}
// set the process group uri
flow.setUri(generateResourceUri("flow", "process-groups", flow.getId()));
return flow;
}
/**
* Populates the remaining content of the specified snippet.
*/
private FlowDTO populateRemainingFlowStructure(FlowDTO flowStructure) {
processorResource.populateRemainingProcessorEntitiesContent(flowStructure.getProcessors());
connectionResource.populateRemainingConnectionEntitiesContent(flowStructure.getConnections());
inputPortResource.populateRemainingInputPortEntitiesContent(flowStructure.getInputPorts());
outputPortResource.populateRemainingOutputPortEntitiesContent(flowStructure.getOutputPorts());
remoteProcessGroupResource.populateRemainingRemoteProcessGroupEntitiesContent(flowStructure.getRemoteProcessGroups());
funnelResource.populateRemainingFunnelEntitiesContent(flowStructure.getFunnels());
labelResource.populateRemainingLabelEntitiesContent(flowStructure.getLabels());
processGroupResource.populateRemainingProcessGroupEntitiesContent(flowStructure.getProcessGroups());
// go through each process group child and populate its uri
for (final ProcessGroupEntity processGroupEntity : flowStructure.getProcessGroups()) {
final ProcessGroupDTO processGroup = processGroupEntity.getComponent();
if (processGroup != null) {
processGroup.setContents(null);
}
}
return flowStructure;
}
private void authorizeFlow() {
final NiFiUser user = NiFiUserUtils.getNiFiUser();
final AuthorizationRequest request = new AuthorizationRequest.Builder()
.resource(ResourceFactory.getFlowResource())
.identity(user.getIdentity())
.anonymous(user.isAnonymous())
.accessAttempt(true)
.action(RequestAction.READ)
.build();
final AuthorizationResult result = authorizer.authorize(request);
if (!Result.Approved.equals(result.getResult())) {
final String message = StringUtils.isNotBlank(result.getExplanation()) ? result.getExplanation() : "Access is denied";
throw new AccessDeniedException(message);
}
}
// ----
// flow
// ----
/**
* Retrieves the contents of the specified group.
*
* @param clientId Optional client id. If the client id is not specified, a new one will be generated. This value (whether specified or generated) is included in the response.
* @param recursive Optional recursive flag that defaults to false. If set to true, all descendent groups and their content will be included if the verbose flag is also set to true.
* @param groupId The id of the process group.
* @return A processGroupEntity.
*/
@GET
@Consumes(MediaType.WILDCARD)
@Produces(MediaType.APPLICATION_JSON)
@Path("process-groups/{id}")
// TODO - @PreAuthorize("hasAnyRole('ROLE_MONITOR', 'ROLE_DFM', 'ROLE_ADMIN')")
@ApiOperation(
value = "Gets a process group",
response = ProcessGroupEntity.class,
authorizations = {
@Authorization(value = "Read Only", type = "ROLE_MONITOR"),
@Authorization(value = "Data Flow Manager", type = "ROLE_DFM"),
@Authorization(value = "Administrator", type = "ROLE_ADMIN")
}
)
@ApiResponses(
value = {
@ApiResponse(code = 400, message = "NiFi was unable to complete the request because it was invalid. The request should not be retried without modification."),
@ApiResponse(code = 401, message = "Client could not be authenticated."),
@ApiResponse(code = 403, message = "Client is not authorized to make this request."),
@ApiResponse(code = 404, message = "The specified resource could not be found."),
@ApiResponse(code = 409, message = "The request was valid but NiFi was not in the appropriate state to process it. Retrying the same request later may be successful.")
}
)
public Response getFlow(
@ApiParam(
value = "If the client id is not specified, new one will be generated. This value (whether specified or generated) is included in the response.",
required = false
)
@QueryParam(CLIENT_ID) @DefaultValue(StringUtils.EMPTY) ClientIdParameter clientId,
@ApiParam(
value = "The process group id.",
required = false
)
@PathParam("id") String groupId,
@ApiParam(
value = "Whether the response should contain all encapsulated components or just the immediate children.",
required = false
)
@QueryParam("recursive") @DefaultValue(RECURSIVE) Boolean recursive) {
authorizeFlow();
// replicate if cluster manager
if (properties.isClusterManager()) {
return clusterManager.applyRequest(HttpMethod.GET, getAbsolutePath(), getRequestParameters(true), getHeaders()).getResponse();
}
// get this process group contents
final ConfigurationSnapshot<ProcessGroupFlowDTO> controllerResponse = serviceFacade.getProcessGroupFlow(groupId, recursive);
final ProcessGroupFlowDTO flow = controllerResponse.getConfiguration();
// create the revision
final RevisionDTO revision = new RevisionDTO();
revision.setClientId(clientId.getClientId());
revision.setVersion(controllerResponse.getVersion());
// create the response entity
final ProcessGroupFlowEntity processGroupEntity = new ProcessGroupFlowEntity();
processGroupEntity.setRevision(revision);
processGroupEntity.setProcessGroupFlow(populateRemainingFlowContent(flow));
return clusterContext(generateOkResponse(processGroupEntity)).build();
}
// ------
// search
// ------
/**
* Performs a search request in this flow.
*
@ -134,6 +301,8 @@ public class FlowResource extends ApplicationResource {
}
)
public Response searchFlow(@QueryParam("q") @DefaultValue(StringUtils.EMPTY) String value) {
authorizeFlow();
// replicate if cluster manager
if (properties.isClusterManager()) {
return clusterManager.applyRequest(HttpMethod.GET, getAbsolutePath(), getRequestParameters(true), getHeaders()).getResponse();
@ -186,6 +355,8 @@ public class FlowResource extends ApplicationResource {
}
)
public Response getRevision() {
authorizeFlow();
// create the current revision
final RevisionDTO revision = serviceFacade.getRevision();
@ -232,6 +403,8 @@ public class FlowResource extends ApplicationResource {
)
@QueryParam(CLIENT_ID) @DefaultValue(StringUtils.EMPTY) ClientIdParameter clientId) {
authorizeFlow();
if (properties.isClusterManager()) {
return clusterManager.applyRequest(HttpMethod.GET, getAbsolutePath(), getRequestParameters(true), getHeaders()).getResponse();
}
@ -327,6 +500,8 @@ public class FlowResource extends ApplicationResource {
)
@QueryParam(CLIENT_ID) @DefaultValue(StringUtils.EMPTY) ClientIdParameter clientId) {
authorizeFlow();
// get the banner from the properties - will come from the NCM when clustered
final String bannerText = properties.getBannerText();
@ -383,6 +558,8 @@ public class FlowResource extends ApplicationResource {
)
@QueryParam(CLIENT_ID) @DefaultValue(StringUtils.EMPTY) ClientIdParameter clientId) {
authorizeFlow();
// replicate if cluster manager
if (properties.isClusterManager()) {
return clusterManager.applyRequest(HttpMethod.GET, getAbsolutePath(), getRequestParameters(true), getHeaders()).getResponse();
@ -442,6 +619,8 @@ public class FlowResource extends ApplicationResource {
)
@QueryParam("serviceType") String serviceType) {
authorizeFlow();
// replicate if cluster manager
if (properties.isClusterManager()) {
return clusterManager.applyRequest(HttpMethod.GET, getAbsolutePath(), getRequestParameters(true), getHeaders()).getResponse();
@ -495,6 +674,8 @@ public class FlowResource extends ApplicationResource {
)
@QueryParam(CLIENT_ID) @DefaultValue(StringUtils.EMPTY) ClientIdParameter clientId) {
authorizeFlow();
// replicate if cluster manager
if (properties.isClusterManager()) {
return clusterManager.applyRequest(HttpMethod.GET, getAbsolutePath(), getRequestParameters(true), getHeaders()).getResponse();
@ -548,6 +729,8 @@ public class FlowResource extends ApplicationResource {
)
@QueryParam(CLIENT_ID) @DefaultValue(StringUtils.EMPTY) ClientIdParameter clientId) {
authorizeFlow();
// replicate if cluster manager
if (properties.isClusterManager()) {
return clusterManager.applyRequest(HttpMethod.GET, getAbsolutePath(), getRequestParameters(true), getHeaders()).getResponse();
@ -601,6 +784,8 @@ public class FlowResource extends ApplicationResource {
)
@QueryParam(CLIENT_ID) @DefaultValue(StringUtils.EMPTY) ClientIdParameter clientId) {
authorizeFlow();
// replicate if cluster manager
if (properties.isClusterManager()) {
return clusterManager.applyRequest(HttpMethod.GET, getAbsolutePath(), getRequestParameters(true), getHeaders()).getResponse();
@ -708,6 +893,8 @@ public class FlowResource extends ApplicationResource {
)
@QueryParam("limit") IntegerParameter limit) {
authorizeFlow();
// replicate if cluster manager
if (properties.isClusterManager()) {
return clusterManager.applyRequest(HttpMethod.GET, getAbsolutePath(), getRequestParameters(true), getHeaders()).getResponse();
@ -807,6 +994,8 @@ public class FlowResource extends ApplicationResource {
)
@PathParam("id") String id) {
authorizeFlow();
// ensure a valid request
if (Boolean.TRUE.equals(nodewise) && clusterNodeId != null) {
throw new IllegalArgumentException("Nodewise requests cannot be directed at a specific node.");
@ -907,6 +1096,8 @@ public class FlowResource extends ApplicationResource {
)
@PathParam("id") String id) {
authorizeFlow();
// ensure a valid request
if (Boolean.TRUE.equals(nodewise) && clusterNodeId != null) {
throw new IllegalArgumentException("Nodewise requests cannot be directed at a specific node.");
@ -1007,6 +1198,8 @@ public class FlowResource extends ApplicationResource {
)
@PathParam("id") String id) {
authorizeFlow();
// ensure a valid request
if (Boolean.TRUE.equals(nodewise) && clusterNodeId != null) {
throw new IllegalArgumentException("Nodewise requests cannot be directed at a specific node.");
@ -1107,6 +1300,8 @@ public class FlowResource extends ApplicationResource {
)
@PathParam("id") String id) {
authorizeFlow();
// ensure a valid request
if (Boolean.TRUE.equals(nodewise) && clusterNodeId != null) {
throw new IllegalArgumentException("Nodewise requests cannot be directed at a specific node.");
@ -1216,6 +1411,8 @@ public class FlowResource extends ApplicationResource {
)
@PathParam("id") String groupId) {
authorizeFlow();
// ensure a valid request
if (Boolean.TRUE.equals(nodewise) && clusterNodeId != null) {
throw new IllegalArgumentException("Nodewise requests cannot be directed at a specific node.");
@ -1337,6 +1534,8 @@ public class FlowResource extends ApplicationResource {
)
@PathParam("id") String id) {
authorizeFlow();
// ensure a valid request
if (Boolean.TRUE.equals(nodewise) && clusterNodeId != null) {
throw new IllegalArgumentException("Nodewise requests cannot be directed at a specific node.");
@ -1431,6 +1630,8 @@ public class FlowResource extends ApplicationResource {
)
@PathParam("id") String id) {
authorizeFlow();
// replicate if cluster manager
if (properties.isClusterManager()) {
return clusterManager.applyRequest(HttpMethod.GET, getAbsolutePath(), getRequestParameters(true), getHeaders()).getResponse();
@ -1490,6 +1691,8 @@ public class FlowResource extends ApplicationResource {
)
@PathParam("id") String groupId) {
authorizeFlow();
// replicate if cluster manager
if (properties.isClusterManager()) {
return clusterManager.applyRequest(HttpMethod.GET, getAbsolutePath(), getRequestParameters(true), getHeaders()).getResponse();
@ -1553,6 +1756,8 @@ public class FlowResource extends ApplicationResource {
)
@PathParam("id") String id) {
authorizeFlow();
// replicate if cluster manager
if (properties.isClusterManager()) {
return clusterManager.applyRequest(HttpMethod.GET, getAbsolutePath(), getRequestParameters(true), getHeaders()).getResponse();
@ -1616,6 +1821,8 @@ public class FlowResource extends ApplicationResource {
)
@PathParam("id") String id) {
authorizeFlow();
// replicate if cluster manager
if (properties.isClusterManager()) {
return clusterManager.applyRequest(HttpMethod.GET, getAbsolutePath(), getRequestParameters(true), getHeaders()).getResponse();
@ -1646,6 +1853,50 @@ public class FlowResource extends ApplicationResource {
this.clusterManager = clusterManager;
}
public void setProcessorResource(ProcessorResource processorResource) {
this.processorResource = processorResource;
}
public void setInputPortResource(InputPortResource inputPortResource) {
this.inputPortResource = inputPortResource;
}
public void setOutputPortResource(OutputPortResource outputPortResource) {
this.outputPortResource = outputPortResource;
}
public void setFunnelResource(FunnelResource funnelResource) {
this.funnelResource = funnelResource;
}
public void setLabelResource(LabelResource labelResource) {
this.labelResource = labelResource;
}
public void setRemoteProcessGroupResource(RemoteProcessGroupResource remoteProcessGroupResource) {
this.remoteProcessGroupResource = remoteProcessGroupResource;
}
public void setConnectionResource(ConnectionResource connectionResource) {
this.connectionResource = connectionResource;
}
public void setTemplateResource(TemplateResource templateResource) {
this.templateResource = templateResource;
}
public void setProcessGroupResource(ProcessGroupResource processGroupResource) {
this.processGroupResource = processGroupResource;
}
public void setControllerServiceResource(ControllerServiceResource controllerServiceResource) {
this.controllerServiceResource = controllerServiceResource;
}
public void setAuthorizer(Authorizer authorizer) {
this.authorizer = authorizer;
}
public void setProperties(NiFiProperties properties) {
this.properties = properties;
}

View File

@ -25,9 +25,9 @@ import com.wordnik.swagger.annotations.Authorization;
import org.apache.commons.lang3.StringUtils;
import org.apache.nifi.cluster.manager.impl.WebClusterManager;
import org.apache.nifi.util.NiFiProperties;
import org.apache.nifi.web.ConfigurationSnapshot;
import org.apache.nifi.web.NiFiServiceFacade;
import org.apache.nifi.web.Revision;
import org.apache.nifi.web.UpdateResult;
import org.apache.nifi.web.api.dto.FunnelDTO;
import org.apache.nifi.web.api.dto.RevisionDTO;
import org.apache.nifi.web.api.entity.FunnelEntity;
@ -71,6 +71,32 @@ public class FunnelResource extends ApplicationResource {
private WebClusterManager clusterManager;
private NiFiProperties properties;
/**
* Populates the uri for the specified funnels.
*
* @param funnelEntities funnels
* @return funnels
*/
public Set<FunnelEntity> populateRemainingFunnelEntitiesContent(Set<FunnelEntity> funnelEntities) {
for (FunnelEntity funnelEntity : funnelEntities) {
populateRemainingFunnelEntityContent(funnelEntity);
}
return funnelEntities;
}
/**
* Populates the uri for the specified funnel.
*
* @param funnelEntity funnel
* @return funnel
*/
public FunnelEntity populateRemainingFunnelEntityContent(FunnelEntity funnelEntity) {
if (funnelEntity.getComponent() != null) {
populateRemainingFunnelContent(funnelEntity.getComponent());
}
return funnelEntity;
}
/**
* Populates the uri for the specified funnels.
*
@ -96,9 +122,6 @@ public class FunnelResource extends ApplicationResource {
/**
* Retrieves the specified funnel.
*
* @param clientId Optional client id. If the client id is not specified, a
* new one will be generated. This value (whether specified or generated) is
* included in the response.
* @param id The id of the funnel to retrieve
* @return A funnelEntity.
*/
@ -126,11 +149,6 @@ public class FunnelResource extends ApplicationResource {
}
)
public Response getFunnel(
@ApiParam(
value = "If the client id is not specified, new one will be generated. This value (whether specified or generated) is included in the response.",
required = false
)
@QueryParam(CLIENT_ID) @DefaultValue(StringUtils.EMPTY) ClientIdParameter clientId,
@ApiParam(
value = "The funnel id.",
required = true
@ -143,16 +161,8 @@ public class FunnelResource extends ApplicationResource {
}
// get the funnel
final FunnelDTO funnel = serviceFacade.getFunnel(id);
// create the revision
final RevisionDTO revision = new RevisionDTO();
revision.setClientId(clientId.getClientId());
// create the response entity
final FunnelEntity entity = new FunnelEntity();
entity.setRevision(revision);
entity.setFunnel(populateRemainingFunnelContent(funnel));
final FunnelEntity entity = serviceFacade.getFunnel(id);
populateRemainingFunnelEntityContent(entity);
return clusterContext(generateOkResponse(entity)).build();
}
@ -198,7 +208,7 @@ public class FunnelResource extends ApplicationResource {
required = true
) FunnelEntity funnelEntity) {
if (funnelEntity == null || funnelEntity.getFunnel() == null) {
if (funnelEntity == null || funnelEntity.getComponent() == null) {
throw new IllegalArgumentException("Funnel details must be specified.");
}
@ -207,7 +217,7 @@ public class FunnelResource extends ApplicationResource {
}
// ensure the ids are the same
final FunnelDTO requestFunnelDTO = funnelEntity.getFunnel();
final FunnelDTO requestFunnelDTO = funnelEntity.getComponent();
if (!id.equals(requestFunnelDTO.getId())) {
throw new IllegalArgumentException(String.format("The funnel id (%s) in the request body does not equal the "
+ "funnel id of the requested resource (%s).", requestFunnelDTO.getId(), id));
@ -231,25 +241,15 @@ public class FunnelResource extends ApplicationResource {
// update the funnel
final RevisionDTO revision = funnelEntity.getRevision();
final ConfigurationSnapshot<FunnelDTO> controllerResponse = serviceFacade.updateFunnel(
final UpdateResult<FunnelEntity> updateResult = serviceFacade.updateFunnel(
new Revision(revision.getVersion(), revision.getClientId()), requestFunnelDTO);
// get the results
final FunnelDTO responseFunnelDTO = controllerResponse.getConfiguration();
populateRemainingFunnelContent(responseFunnelDTO);
final FunnelEntity entity = updateResult.getResult();
populateRemainingFunnelEntityContent(entity);
// get the updated revision
final RevisionDTO updatedRevision = new RevisionDTO();
updatedRevision.setClientId(revision.getClientId());
updatedRevision.setVersion(controllerResponse.getVersion());
// build the response entity
final FunnelEntity entity = new FunnelEntity();
entity.setRevision(updatedRevision);
entity.setFunnel(responseFunnelDTO);
if (controllerResponse.isNew()) {
return clusterContext(generateCreatedResponse(URI.create(responseFunnelDTO.getUri()), entity)).build();
if (updateResult.isNew()) {
return clusterContext(generateCreatedResponse(URI.create(entity.getComponent().getUri()), entity)).build();
} else {
return clusterContext(generateOkResponse(entity)).build();
}
@ -325,17 +325,7 @@ public class FunnelResource extends ApplicationResource {
}
// delete the specified funnel
final ConfigurationSnapshot<Void> controllerResponse = serviceFacade.deleteFunnel(new Revision(clientVersion, clientId.getClientId()), id);
// get the updated revision
final RevisionDTO revision = new RevisionDTO();
revision.setClientId(clientId.getClientId());
revision.setVersion(controllerResponse.getVersion());
// build the response entity
final FunnelEntity entity = new FunnelEntity();
entity.setRevision(revision);
final FunnelEntity entity = serviceFacade.deleteFunnel(new Revision(clientVersion, clientId.getClientId()), id);
return clusterContext(generateOkResponse(entity)).build();
}

Some files were not shown because too many files have changed in this diff Show More