http://git-wip-us.apache.org/repos/asf/nifi/blob/ff98d823/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/RemoteProcessGroupResource.java ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/RemoteProcessGroupResource.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/RemoteProcessGroupResource.java index d1999d9..64fe273 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/RemoteProcessGroupResource.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/RemoteProcessGroupResource.java @@ -28,6 +28,7 @@ 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.RemoteProcessGroupDTO; import org.apache.nifi.web.api.dto.RemoteProcessGroupPortDTO; import org.apache.nifi.web.api.dto.RevisionDTO; @@ -74,6 +75,32 @@ public class RemoteProcessGroupResource extends ApplicationResource { /** * Populates the remaining content for each remote process group. The uri must be generated and the remote process groups name must be retrieved. * + * @param remoteProcessGroupEntities groups + * @return dtos + */ + public Set<RemoteProcessGroupEntity> populateRemainingRemoteProcessGroupEntitiesContent(Set<RemoteProcessGroupEntity> remoteProcessGroupEntities) { + for (RemoteProcessGroupEntity remoteProcessEntities : remoteProcessGroupEntities) { + populateRemainingRemoteProcessGroupEntityContent(remoteProcessEntities); + } + return remoteProcessGroupEntities; + } + + /** + * Populates the remaining content for each remote process group. The uri must be generated and the remote process groups name must be retrieved. + * + * @param remoteProcessGroupEntity groups + * @return dtos + */ + public RemoteProcessGroupEntity populateRemainingRemoteProcessGroupEntityContent(RemoteProcessGroupEntity remoteProcessGroupEntity) { + if (remoteProcessGroupEntity.getComponent() != null) { + populateRemainingRemoteProcessGroupContent(remoteProcessGroupEntity.getComponent()); + } + return remoteProcessGroupEntity; + } + + /** + * Populates the remaining content for each remote process group. The uri must be generated and the remote process groups name must be retrieved. + * * @param remoteProcessGroups groups * @return dtos */ @@ -100,7 +127,6 @@ public class RemoteProcessGroupResource extends ApplicationResource { /** * Retrieves the specified remote process 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 verbose Optional verbose flag that defaults to false. If the verbose flag is set to true remote group contents (ports) will be included. * @param id The id of the remote process group to retrieve * @return A remoteProcessGroupEntity. @@ -130,11 +156,6 @@ public class RemoteProcessGroupResource extends ApplicationResource { ) public Response getRemoteProcessGroup( @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 to include any encapulated ports or just details about the remote process group.", required = false ) @@ -150,23 +171,17 @@ public class RemoteProcessGroupResource extends ApplicationResource { return clusterManager.applyRequest(HttpMethod.GET, getAbsolutePath(), getRequestParameters(true), getHeaders()).getResponse(); } - // get the label - final RemoteProcessGroupDTO remoteProcessGroup = serviceFacade.getRemoteProcessGroup(id); + // get the remote process group + final RemoteProcessGroupEntity entity = serviceFacade.getRemoteProcessGroup(id); + populateRemainingRemoteProcessGroupEntityContent(entity); // prune the response as necessary if (!verbose) { - remoteProcessGroup.setContents(null); + if (entity.getComponent() != null) { + entity.getComponent().setContents(null); + } } - // create the revision - final RevisionDTO revision = new RevisionDTO(); - revision.setClientId(clientId.getClientId()); - - // create the response entity - final RemoteProcessGroupEntity entity = new RemoteProcessGroupEntity(); - entity.setRevision(revision); - entity.setRemoteProcessGroup(populateRemainingRemoteProcessGroupContent(remoteProcessGroup)); - return clusterContext(generateOkResponse(entity)).build(); } @@ -236,18 +251,7 @@ public class RemoteProcessGroupResource extends ApplicationResource { clientVersion = version.getLong(); } - final ConfigurationSnapshot<Void> controllerResponse = serviceFacade.deleteRemoteProcessGroup(new Revision(clientVersion, clientId.getClientId()), id); - - // get the updated revision - final RevisionDTO revision = new RevisionDTO(); - revision.setClientId(clientId.getClientId()); - revision.setVersion(controllerResponse.getVersion()); - - // create the response entity - final RemoteProcessGroupEntity entity = new RemoteProcessGroupEntity(); - entity.setRevision(revision); - - // create the response + final RemoteProcessGroupEntity entity = serviceFacade.deleteRemoteProcessGroup(new Revision(clientVersion, clientId.getClientId()), id); return clusterContext(generateOkResponse(entity)).build(); } @@ -463,7 +467,7 @@ public class RemoteProcessGroupResource extends ApplicationResource { @PathParam("id") String id, RemoteProcessGroupEntity remoteProcessGroupEntity) { - if (remoteProcessGroupEntity == null || remoteProcessGroupEntity.getRemoteProcessGroup() == null) { + if (remoteProcessGroupEntity == null || remoteProcessGroupEntity.getComponent() == null) { throw new IllegalArgumentException("Remote process group details must be specified."); } @@ -472,7 +476,7 @@ public class RemoteProcessGroupResource extends ApplicationResource { } // ensure the ids are the same - final RemoteProcessGroupDTO requestRemoteProcessGroup = remoteProcessGroupEntity.getRemoteProcessGroup(); + final RemoteProcessGroupDTO requestRemoteProcessGroup = remoteProcessGroupEntity.getComponent(); if (!id.equals(requestRemoteProcessGroup.getId())) { throw new IllegalArgumentException(String.format("The remote process group id (%s) in the request body does not equal the " + "remote process group id of the requested resource (%s).", requestRemoteProcessGroup.getId(), id)); @@ -530,24 +534,14 @@ public class RemoteProcessGroupResource extends ApplicationResource { // update the specified remote process group final RevisionDTO revision = remoteProcessGroupEntity.getRevision(); - final ConfigurationSnapshot<RemoteProcessGroupDTO> controllerResponse + final UpdateResult<RemoteProcessGroupEntity> updateResult = serviceFacade.updateRemoteProcessGroup(new Revision(revision.getVersion(), revision.getClientId()), requestRemoteProcessGroup); - final RemoteProcessGroupDTO responseRemoteProcessGroup = controllerResponse.getConfiguration(); - populateRemainingRemoteProcessGroupContent(responseRemoteProcessGroup); - - // get the updated revision - final RevisionDTO updatedRevision = new RevisionDTO(); - updatedRevision.setClientId(revision.getClientId()); - updatedRevision.setVersion(controllerResponse.getVersion()); - - // build the response entity - final RemoteProcessGroupEntity entity = new RemoteProcessGroupEntity(); - entity.setRevision(updatedRevision); - entity.setRemoteProcessGroup(responseRemoteProcessGroup); + final RemoteProcessGroupEntity entity = updateResult.getResult(); + populateRemainingRemoteProcessGroupEntityContent(entity); - if (controllerResponse.isNew()) { - return clusterContext(generateCreatedResponse(URI.create(responseRemoteProcessGroup.getUri()), entity)).build(); + if (updateResult.isNew()) { + return clusterContext(generateCreatedResponse(URI.create(entity.getComponent().getUri()), entity)).build(); } else { return clusterContext(generateOkResponse(entity)).build(); }
http://git-wip-us.apache.org/repos/asf/nifi/blob/ff98d823/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/TemplateResource.java ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/TemplateResource.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/TemplateResource.java index 5657fff..ceb9455 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/TemplateResource.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/TemplateResource.java @@ -89,9 +89,6 @@ public class TemplateResource extends ApplicationResource { /** * Retrieves the specified template. * - * @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 template to retrieve * @return A templateEntity. */ @@ -120,11 +117,6 @@ public class TemplateResource extends ApplicationResource { ) public Response exportTemplate( @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 template id.", required = true ) http://git-wip-us.apache.org/repos/asf/nifi/blob/ff98d823/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/config/AccessDeniedExceptionMapper.java ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/config/AccessDeniedExceptionMapper.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/config/AccessDeniedExceptionMapper.java index 5d50e70..3af22c9 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/config/AccessDeniedExceptionMapper.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/config/AccessDeniedExceptionMapper.java @@ -19,12 +19,13 @@ package org.apache.nifi.web.api.config; import javax.ws.rs.core.Response; import javax.ws.rs.ext.ExceptionMapper; import javax.ws.rs.ext.Provider; -import org.apache.nifi.web.security.user.NiFiUserUtils; -import org.apache.nifi.user.NiFiUser; + +import org.apache.nifi.authorization.AccessDeniedException; +import org.apache.nifi.authorization.user.NiFiUser; import org.apache.commons.lang3.StringUtils; +import org.apache.nifi.authorization.user.NiFiUserUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.springframework.security.access.AccessDeniedException; /** * Maps access denied exceptions into a client response. http://git-wip-us.apache.org/repos/asf/nifi/blob/ff98d823/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/dto/DtoFactory.java ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/dto/DtoFactory.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/dto/DtoFactory.java index 79e1d55..afcf86a 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/dto/DtoFactory.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/dto/DtoFactory.java @@ -34,7 +34,10 @@ import org.apache.nifi.action.details.PurgeDetails; import org.apache.nifi.annotation.behavior.Stateful; import org.apache.nifi.annotation.documentation.CapabilityDescription; import org.apache.nifi.annotation.documentation.Tags; +import org.apache.nifi.authorization.Authorizer; +import org.apache.nifi.authorization.RequestAction; import org.apache.nifi.authorization.Resource; +import org.apache.nifi.authorization.resource.Authorizable; import org.apache.nifi.cluster.coordination.heartbeat.NodeHeartbeat; import org.apache.nifi.cluster.event.Event; import org.apache.nifi.cluster.manager.StatusMerger; @@ -113,6 +116,9 @@ import org.apache.nifi.web.api.dto.action.details.ConfigureDetailsDTO; import org.apache.nifi.web.api.dto.action.details.ConnectDetailsDTO; import org.apache.nifi.web.api.dto.action.details.MoveDetailsDTO; import org.apache.nifi.web.api.dto.action.details.PurgeDetailsDTO; +import org.apache.nifi.web.api.dto.flow.FlowBreadcrumbDTO; +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.lineage.LineageDTO; import org.apache.nifi.web.api.dto.provenance.lineage.LineageRequestDTO; import org.apache.nifi.web.api.dto.provenance.lineage.LineageRequestDTO.LineageRequestType; @@ -163,6 +169,8 @@ public final class DtoFactory { }; private ControllerServiceLookup controllerServiceLookup; + private EntityFactory entityFactory; + private Authorizer authorizer; /** * Creates an ActionDTO for the specified Action. @@ -537,6 +545,7 @@ public final class DtoFactory { if (connection == null) { return null; } + final ConnectionDTO dto = new ConnectionDTO(); dto.setId(connection.getIdentifier()); @@ -652,6 +661,9 @@ public final class DtoFactory { if (funnel == null) { return null; } + if (!funnel.isAuthorized(authorizer, RequestAction.READ)) { + return null; + } final FunnelDTO dto = new FunnelDTO(); dto.setId(funnel.getIdentifier()); @@ -1385,27 +1397,34 @@ public final class DtoFactory { } /** - * Creates a ProcessGroupDTO from the specified parent ProcessGroup. + * Creates a FlowBreadcrumbDTO from the specified parent ProcessGroup. * * @param parentGroup group * @return dto */ - private ProcessGroupDTO createParentProcessGroupDto(final ProcessGroup parentGroup) { + private FlowBreadcrumbDTO createBreadcrumbDto(final ProcessGroup parentGroup) { if (parentGroup == null) { return null; } - final ProcessGroupDTO dto = new ProcessGroupDTO(); + final FlowBreadcrumbDTO dto = new FlowBreadcrumbDTO(); dto.setId(parentGroup.getIdentifier()); dto.setName(parentGroup.getName()); if (parentGroup.getParent() != null) { - dto.setParent(createParentProcessGroupDto(parentGroup.getParent())); + dto.setParentBreadcrumb(createBreadcrumbDto(parentGroup.getParent())); } return dto; } + public AccessPolicyDTO createAccessPolicyDto(final Authorizable authorizable) { + final AccessPolicyDTO dto = new AccessPolicyDTO(); + dto.setCanRead(authorizable.isAuthorized(authorizer, RequestAction.READ)); + dto.setCanWrite(authorizable.isAuthorized(authorizer, RequestAction.WRITE)); + return dto; + } + /** * Creates a ProcessGroupDTO from the specified ProcessGroup. * @@ -1416,6 +1435,125 @@ public final class DtoFactory { return createProcessGroupDto(group, false); } + public ProcessGroupFlowDTO createProcessGroupFlowDto(final ProcessGroup group, final boolean recurse) { + final ProcessGroupFlowDTO dto = new ProcessGroupFlowDTO(); + dto.setId(group.getIdentifier()); + dto.setBreadcrumb(createBreadcrumbDto(group)); + dto.setFlow(createFlowDto(group)); + + final ProcessGroup parent = group.getParent(); + if (parent != null) { + dto.setParentGroupId(parent.getIdentifier()); + } + + return dto; + } + + public FlowDTO createFlowDto(final ProcessGroup group, final FlowSnippetDTO snippet) { + if (snippet == null) { + return null; + } + + final FlowDTO flow = new FlowDTO(); + + for (final ConnectionDTO connection : snippet.getConnections()) { + final AccessPolicyDTO accessPolicy = createAccessPolicyDto(group.getConnection(connection.getId())); + flow.getConnections().add(entityFactory.createConnectionEntity(connection, null, accessPolicy)); + } + + for (final ControllerServiceDTO controllerService : snippet.getControllerServices()) { + flow.getControllerServices().add(entityFactory.createControllerServiceEntity(controllerService, null, null)); + } + + for (final FunnelDTO funnel : snippet.getFunnels()) { + final AccessPolicyDTO accessPolicy = createAccessPolicyDto(group.getFunnel(funnel.getId())); + flow.getFunnels().add(entityFactory.createFunnelEntity(funnel, null, accessPolicy)); + } + + for (final PortDTO inputPort : snippet.getInputPorts()) { + final AccessPolicyDTO accessPolicy = createAccessPolicyDto(group.getInputPort(inputPort.getId())); + flow.getInputPorts().add(entityFactory.createPortEntity(inputPort, null, accessPolicy)); + } + + for (final PortDTO outputPort : snippet.getOutputPorts()) { + final AccessPolicyDTO accessPolicy = createAccessPolicyDto(group.getOutputPort(outputPort.getId())); + flow.getOutputPorts().add(entityFactory.createPortEntity(outputPort, null, accessPolicy)); + } + + for (final LabelDTO label : snippet.getLabels()) { + final AccessPolicyDTO accessPolicy = createAccessPolicyDto(group.getLabel(label.getId())); + flow.getLabels().add(entityFactory.createLabelEntity(label, null, accessPolicy)); + } + + for (final ProcessGroupDTO processGroup : snippet.getProcessGroups()) { + // clear the contents as we only return a single level/group at a time + processGroup.setContents(null); + + final AccessPolicyDTO accessPolicy = createAccessPolicyDto(group.getProcessGroup(processGroup.getId())); + flow.getProcessGroups().add(entityFactory.createProcessGroupEntity(processGroup, null, accessPolicy)); + } + + for (final ProcessorDTO processor : snippet.getProcessors()) { + final AccessPolicyDTO accessPolicy = createAccessPolicyDto(group.getProcessor(processor.getId())); + flow.getProcessors().add(entityFactory.createProcessorEntity(processor, null, accessPolicy)); + } + + for (final RemoteProcessGroupDTO remoteProcessGroup : snippet.getRemoteProcessGroups()) { + final AccessPolicyDTO accessPolicy = createAccessPolicyDto(group.getRemoteProcessGroup(remoteProcessGroup.getId())); + flow.getRemoteProcessGroups().add(entityFactory.createRemoteProcessGroupEntity(remoteProcessGroup, null, accessPolicy)); + } + + return flow; + } + + public FlowDTO createFlowDto(final ProcessGroup group) { + final FlowDTO dto = new FlowDTO(); + + for (final ProcessorNode procNode : group.getProcessors()) { + final AccessPolicyDTO accessPolicy = createAccessPolicyDto(procNode); + dto.getProcessors().add(entityFactory.createProcessorEntity(createProcessorDto(procNode), null, accessPolicy)); + } + + for (final Connection connNode : group.getConnections()) { + final AccessPolicyDTO accessPolicy = createAccessPolicyDto(connNode); + dto.getConnections().add(entityFactory.createConnectionEntity(createConnectionDto(connNode), null, accessPolicy)); + } + + for (final Label label : group.getLabels()) { + final AccessPolicyDTO accessPolicy = createAccessPolicyDto(label); + dto.getLabels().add(entityFactory.createLabelEntity(createLabelDto(label), null, accessPolicy)); + } + + for (final Funnel funnel : group.getFunnels()) { + final AccessPolicyDTO accessPolicy = createAccessPolicyDto(funnel); + dto.getFunnels().add(entityFactory.createFunnelEntity(createFunnelDto(funnel), null, accessPolicy)); + } + + for (final ProcessGroup childGroup : group.getProcessGroups()) { + final AccessPolicyDTO accessPolicy = createAccessPolicyDto(childGroup); + dto.getProcessGroups().add(entityFactory.createProcessGroupEntity(createProcessGroupDto(childGroup), null, accessPolicy)); + } + + for (final RemoteProcessGroup rpg : group.getRemoteProcessGroups()) { + final AccessPolicyDTO accessPolicy = createAccessPolicyDto(rpg); + dto.getRemoteProcessGroups().add(entityFactory.createRemoteProcessGroupEntity(createRemoteProcessGroupDto(rpg), null, accessPolicy)); + } + + for (final Port inputPort : group.getInputPorts()) { + final AccessPolicyDTO accessPolicy = createAccessPolicyDto(inputPort); + dto.getInputPorts().add(entityFactory.createPortEntity(createPortDto(inputPort), null, accessPolicy)); + } + + for (final Port outputPort : group.getOutputPorts()) { + final AccessPolicyDTO accessPolicy = createAccessPolicyDto(outputPort); + dto.getOutputPorts().add(entityFactory.createPortEntity(createPortDto(outputPort), null, accessPolicy)); + } + + // TODO - controller services once they are accessible from the group + + return dto; + } + /** * Creates a ProcessGroupDTO from the specified ProcessGroup. * @@ -1449,7 +1587,6 @@ public final class DtoFactory { ProcessGroup parentGroup = group.getParent(); if (parentGroup != null) { dto.setParentGroupId(parentGroup.getIdentifier()); - dto.setParent(createParentProcessGroupDto(parentGroup)); } final ProcessGroupCounts counts = group.getCounts(); @@ -1480,7 +1617,6 @@ public final class DtoFactory { final FlowSnippetDTO dto = new FlowSnippetDTO(); for (final ProcessorNode procNode : group.getProcessors()) { - // authorization check dto.getProcessors().add(createProcessorDto(procNode)); } @@ -2121,7 +2257,6 @@ public final class DtoFactory { copy.setPosition(original.getPosition()); copy.setWidth(original.getWidth()); copy.setHeight(original.getHeight()); - copy.setUri(original.getUri()); return copy; } @@ -2139,7 +2274,6 @@ public final class DtoFactory { copy.setReferencingComponents(copy(original.getReferencingComponents())); copy.setState(original.getState()); copy.setType(original.getType()); - copy.setUri(original.getUri()); copy.setValidationErrors(copy(original.getValidationErrors())); return copy; } @@ -2149,7 +2283,6 @@ public final class DtoFactory { copy.setId(original.getId()); copy.setParentGroupId(original.getParentGroupId()); copy.setPosition(original.getPosition()); - copy.setUri(original.getUri()); return copy; } @@ -2198,7 +2331,6 @@ public final class DtoFactory { copy.setState(original.getState()); copy.setStyle(copy(original.getStyle())); copy.setType(original.getType()); - copy.setUri(original.getUri()); copy.setSupportsParallelProcessing(original.getSupportsParallelProcessing()); copy.setSupportsEventDriven(original.getSupportsEventDriven()); copy.setValidationErrors(copy(original.getValidationErrors())); @@ -2242,7 +2374,6 @@ public final class DtoFactory { copy.setBackPressureDataSizeThreshold(original.getBackPressureDataSizeThreshold()); copy.setPrioritizers(copy(original.getPrioritizers())); copy.setSource(original.getSource()); - copy.setUri(original.getUri()); copy.setzIndex(original.getzIndex()); copy.setLabelIndex(original.getLabelIndex()); copy.setBends(copy(original.getBends())); @@ -2271,7 +2402,6 @@ public final class DtoFactory { copy.setName(original.getName()); copy.setComments(original.getComments()); copy.setParentGroupId(original.getParentGroupId()); - copy.setUri(original.getUri()); copy.setState(original.getState()); copy.setType(original.getType()); copy.setTransmitting(original.isTransmitting()); @@ -2300,14 +2430,12 @@ public final class DtoFactory { public ProcessGroupDTO copy(final ProcessGroupDTO original, final boolean deep) { final ProcessGroupDTO copy = new ProcessGroupDTO(); copy.setComments(original.getComments()); - copy.setContents(copy(original.getContents(), deep)); copy.setPosition(original.getPosition()); copy.setId(original.getId()); copy.setInputPortCount(original.getInputPortCount()); copy.setInvalidCount(original.getInvalidCount()); copy.setName(original.getName()); copy.setOutputPortCount(original.getOutputPortCount()); - copy.setParent(original.getParent()); copy.setParentGroupId(original.getParentGroupId()); copy.setRunning(original.isRunning()); @@ -2316,7 +2444,6 @@ public final class DtoFactory { copy.setDisabledCount(original.getDisabledCount()); copy.setActiveRemotePortCount(original.getActiveRemotePortCount()); copy.setInactiveRemotePortCount(original.getInactiveRemotePortCount()); - copy.setUri(original.getUri()); return copy; } @@ -2356,7 +2483,6 @@ public final class DtoFactory { copy.setInactiveRemoteOutputPortCount(original.getInactiveRemoteOutputPortCount()); copy.setParentGroupId(original.getParentGroupId()); copy.setTargetUri(original.getTargetUri()); - copy.setUri(original.getUri()); copy.setContents(copyContents); @@ -2545,6 +2671,12 @@ public final class DtoFactory { return revisionDTO; } + public RevisionDTO createRevisionDTO(final Long version, final String clientId) { + final RevisionDTO dto = new RevisionDTO(); + dto.setVersion(version); + dto.setClientId(clientId); + return dto; + } public NodeDTO createNodeDTO(Node node, NodeHeartbeat nodeHeartbeat, List<Event> events, boolean primary) { final NodeDTO nodeDto = new NodeDTO(); @@ -2599,4 +2731,11 @@ public final class DtoFactory { this.controllerServiceLookup = lookup; } + public void setAuthorizer(Authorizer authorizer) { + this.authorizer = authorizer; + } + + public void setEntityFactory(EntityFactory entityFactory) { + this.entityFactory = entityFactory; + } } http://git-wip-us.apache.org/repos/asf/nifi/blob/ff98d823/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/dto/EntityFactory.java ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/dto/EntityFactory.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/dto/EntityFactory.java new file mode 100644 index 0000000..0d46d94 --- /dev/null +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/dto/EntityFactory.java @@ -0,0 +1,155 @@ +/* + * 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 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; + +public final class EntityFactory { + + public ProcessorEntity createProcessorEntity(final ProcessorDTO dto, final RevisionDTO revision, final AccessPolicyDTO accessPolicy) { + final ProcessorEntity entity = new ProcessorEntity(); + entity.setRevision(revision); + if (dto != null) { + entity.setAccessPolicy(accessPolicy); + entity.setId(dto.getId()); + entity.setPosition(dto.getPosition()); + if (accessPolicy != null && accessPolicy.getCanRead()) { + entity.setComponent(dto); + } + } + return entity; + } + + public PortEntity createPortEntity(final PortDTO dto, final RevisionDTO revision, final AccessPolicyDTO accessPolicy) { + final PortEntity entity = new PortEntity(); + entity.setRevision(revision); + if (dto != null) { + entity.setAccessPolicy(accessPolicy); + entity.setId(dto.getId()); + entity.setPosition(dto.getPosition()); + entity.setPortType(dto.getType()); + if (accessPolicy != null && accessPolicy.getCanRead()) { + entity.setComponent(dto); + } + } + return entity; + } + + public ProcessGroupEntity createProcessGroupEntity(final ProcessGroupDTO dto, final RevisionDTO revision, final AccessPolicyDTO accessPolicy) { + final ProcessGroupEntity entity = new ProcessGroupEntity(); + entity.setRevision(revision); + if (dto != null) { + entity.setAccessPolicy(accessPolicy); + entity.setId(dto.getId()); + entity.setPosition(dto.getPosition()); + if (accessPolicy != null && accessPolicy.getCanRead()) { + entity.setComponent(dto); + } + } + return entity; + } + + public LabelEntity createLabelEntity(final LabelDTO dto, final RevisionDTO revision, final AccessPolicyDTO accessPolicy) { + final LabelEntity entity = new LabelEntity(); + entity.setRevision(revision); + if (dto != null) { + entity.setAccessPolicy(accessPolicy); + entity.setId(dto.getId()); + entity.setPosition(dto.getPosition()); + + final DimensionsDTO dimensions = new DimensionsDTO(); + dimensions.setHeight(dto.getHeight()); + dimensions.setWidth(dto.getWidth()); + entity.setDimensions(dimensions); + + if (accessPolicy != null && accessPolicy.getCanRead()) { + entity.setComponent(dto); + } + } + return entity; + } + + public FunnelEntity createFunnelEntity(final FunnelDTO dto, final RevisionDTO revision, final AccessPolicyDTO accessPolicy) { + final FunnelEntity entity = new FunnelEntity(); + entity.setRevision(revision); + if (dto != null) { + entity.setAccessPolicy(accessPolicy); + entity.setId(dto.getId()); + entity.setPosition(dto.getPosition()); + if (accessPolicy != null && accessPolicy.getCanRead()) { + entity.setComponent(dto); + } + } + return entity; + } + + public ConnectionEntity createConnectionEntity(final ConnectionDTO dto, final RevisionDTO revision, final AccessPolicyDTO accessPolicy) { + final ConnectionEntity entity = new ConnectionEntity(); + entity.setRevision(revision); + if (dto != null) { + entity.setAccessPolicy(accessPolicy); + entity.setId(dto.getId()); + entity.setPosition(dto.getPosition()); + entity.setBends(dto.getBends()); + entity.setLabelIndex(dto.getLabelIndex()); + entity.setSourceId(dto.getSource().getId()); + entity.setSourceGroupId(dto.getSource().getGroupId()); + entity.setDestinationId(dto.getDestination().getId()); + entity.setDestinationGroupId(dto.getDestination().getGroupId()); + if (accessPolicy != null && accessPolicy.getCanRead()) { + entity.setComponent(dto); + } + } + return entity; + } + + public ControllerServiceEntity createControllerServiceEntity(final ControllerServiceDTO dto, final RevisionDTO revision, final AccessPolicyDTO accessPolicy) { + final ControllerServiceEntity entity = new ControllerServiceEntity(); + entity.setRevision(revision); + if (dto != null) { + entity.setAccessPolicy(accessPolicy); + entity.setId(dto.getId()); + entity.setPosition(dto.getPosition()); + if (accessPolicy != null && accessPolicy.getCanRead()) { + entity.setControllerService(dto); + } + } + return entity; + } + + public RemoteProcessGroupEntity createRemoteProcessGroupEntity(final RemoteProcessGroupDTO dto, final RevisionDTO revision, final AccessPolicyDTO accessPolicy) { + final RemoteProcessGroupEntity entity = new RemoteProcessGroupEntity(); + entity.setRevision(revision); + if (dto != null) { + entity.setAccessPolicy(accessPolicy); + entity.setId(dto.getId()); + entity.setPosition(dto.getPosition()); + if (accessPolicy != null && accessPolicy.getCanRead()) { + entity.setComponent(dto); + } + } + return entity; + } + +} http://git-wip-us.apache.org/repos/asf/nifi/blob/ff98d823/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/controller/ControllerFacade.java ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/controller/ControllerFacade.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/controller/ControllerFacade.java index e8686a3..40e2ee8 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/controller/ControllerFacade.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/controller/ControllerFacade.java @@ -21,8 +21,11 @@ import org.apache.commons.lang3.ClassUtils; import org.apache.commons.lang3.StringUtils; import org.apache.nifi.admin.service.KeyService; 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.authorization.user.NiFiUser; +import org.apache.nifi.authorization.user.NiFiUserUtils; import org.apache.nifi.cluster.protocol.NodeIdentifier; import org.apache.nifi.components.PropertyDescriptor; import org.apache.nifi.connectable.Connectable; @@ -79,7 +82,6 @@ import org.apache.nifi.search.SearchContext; import org.apache.nifi.search.SearchResult; import org.apache.nifi.search.Searchable; import org.apache.nifi.services.FlowService; -import org.apache.nifi.user.NiFiUser; import org.apache.nifi.util.FormatUtils; import org.apache.nifi.util.NiFiProperties; import org.apache.nifi.web.DownloadableContent; @@ -108,7 +110,6 @@ 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.security.ProxiedEntitiesUtils; -import org.apache.nifi.web.security.user.NiFiUserUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -132,7 +133,7 @@ import java.util.TimeZone; import java.util.TreeSet; import java.util.concurrent.TimeUnit; -public class ControllerFacade { +public class ControllerFacade implements Authorizable { private static final Logger logger = LoggerFactory.getLogger(ControllerFacade.class); @@ -177,6 +178,16 @@ public class ControllerFacade { flowController.setName(name); } + @Override + public Authorizable getParentAuthorizable() { + return null; + } + + @Override + public Resource getResource() { + return ResourceFactory.getControllerResource(); + } + /** * Sets the comments of this controller. * http://git-wip-us.apache.org/repos/asf/nifi/blob/ff98d823/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/dao/TemplateDAO.java ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/dao/TemplateDAO.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/dao/TemplateDAO.java index 014a607..13fe66d 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/dao/TemplateDAO.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/dao/TemplateDAO.java @@ -16,11 +16,12 @@ */ package org.apache.nifi.web.dao; -import java.util.Set; import org.apache.nifi.controller.Template; import org.apache.nifi.web.api.dto.FlowSnippetDTO; import org.apache.nifi.web.api.dto.TemplateDTO; +import java.util.Set; + public interface TemplateDAO { /** http://git-wip-us.apache.org/repos/asf/nifi/blob/ff98d823/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/dao/impl/StandardConnectionDAO.java ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/dao/impl/StandardConnectionDAO.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/dao/impl/StandardConnectionDAO.java index 29bd9b3..8a6bc3e 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/dao/impl/StandardConnectionDAO.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/dao/impl/StandardConnectionDAO.java @@ -16,7 +16,10 @@ */ package org.apache.nifi.web.dao.impl; -import org.apache.nifi.admin.service.KeyService; +import org.apache.nifi.authorization.Authorizer; +import org.apache.nifi.authorization.RequestAction; +import org.apache.nifi.authorization.user.NiFiUser; +import org.apache.nifi.authorization.user.NiFiUserUtils; import org.apache.nifi.connectable.Connectable; import org.apache.nifi.connectable.ConnectableType; import org.apache.nifi.connectable.Connection; @@ -34,7 +37,6 @@ import org.apache.nifi.groups.ProcessGroup; import org.apache.nifi.groups.RemoteProcessGroup; import org.apache.nifi.processor.Relationship; import org.apache.nifi.remote.RemoteGroupPort; -import org.apache.nifi.user.NiFiUser; import org.apache.nifi.util.FormatUtils; import org.apache.nifi.web.DownloadableContent; import org.apache.nifi.web.ResourceNotFoundException; @@ -43,7 +45,6 @@ import org.apache.nifi.web.api.dto.ConnectionDTO; import org.apache.nifi.web.api.dto.PositionDTO; import org.apache.nifi.web.dao.ConnectionDAO; import org.apache.nifi.web.security.ProxiedEntitiesUtils; -import org.apache.nifi.web.security.user.NiFiUserUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -63,7 +64,7 @@ public class StandardConnectionDAO extends ComponentDAO implements ConnectionDAO private static final Logger logger = LoggerFactory.getLogger(StandardConnectionDAO.class); private FlowController flowController; - private KeyService keyService; + private Authorizer authorizer; private Connection locateConnection(final String connectionId) { final ProcessGroup rootGroup = flowController.getGroup(flowController.getRootGroupId()); @@ -292,6 +293,9 @@ public class StandardConnectionDAO extends ComponentDAO implements ConnectionDAO source = sourceGroup.getConnectable(sourceConnectableDTO.getId()); } + // ensure the user has write access to the source component + source.authorize(authorizer, RequestAction.WRITE); + // find the destination final Connectable destination; if (ConnectableType.REMOTE_INPUT_PORT.name().equals(destinationConnectableDTO.getType())) { @@ -315,6 +319,9 @@ public class StandardConnectionDAO extends ComponentDAO implements ConnectionDAO destination = destinationGroup.getConnectable(destinationConnectableDTO.getId()); } + // ensure the user has write access to the source component + destination.authorize(authorizer, RequestAction.WRITE); + // determine the relationships final Set<String> relationships = new HashSet<>(); if (isNotNull(connectionDTO.getSelectedRelationships())) { @@ -612,7 +619,7 @@ public class StandardConnectionDAO extends ComponentDAO implements ConnectionDAO this.flowController = flowController; } - public void setKeyService(KeyService keyService) { - this.keyService = keyService; + public void setAuthorizer(Authorizer authorizer) { + this.authorizer = authorizer; } } http://git-wip-us.apache.org/repos/asf/nifi/blob/ff98d823/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/filter/RequestLogger.java ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/filter/RequestLogger.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/filter/RequestLogger.java index 9f63611..bb30a1e 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/filter/RequestLogger.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/filter/RequestLogger.java @@ -26,9 +26,9 @@ import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; import javax.servlet.http.HttpServletRequest; +import org.apache.nifi.authorization.user.NiFiUserUtils; import org.apache.nifi.logging.NiFiLog; -import org.apache.nifi.web.security.user.NiFiUserUtils; -import org.apache.nifi.user.NiFiUser; +import org.apache.nifi.authorization.user.NiFiUser; import org.slf4j.Logger; import org.slf4j.LoggerFactory; http://git-wip-us.apache.org/repos/asf/nifi/blob/ff98d823/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/resources/nifi-web-api-context.xml ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/resources/nifi-web-api-context.xml b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/resources/nifi-web-api-context.xml index 0f79369..9f13a23 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/resources/nifi-web-api-context.xml +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/resources/nifi-web-api-context.xml @@ -49,9 +49,14 @@ <property name="clusterManager" ref="clusterManager"/> </bean> + <!-- entity factory --> + <bean id="entityFactory" class="org.apache.nifi.web.api.dto.EntityFactory"></bean> + <!-- dto factory --> <bean id="dtoFactory" class="org.apache.nifi.web.api.dto.DtoFactory"> <property name="controllerServiceLookup" ref="controllerServiceProvider" /> + <property name="entityFactory" ref="entityFactory"/> + <property name="authorizer" ref="authorizer"/> </bean> <!-- snippet utils --> @@ -81,7 +86,7 @@ </bean> <bean id="connectionDAO" class="org.apache.nifi.web.dao.impl.StandardConnectionDAO"> <property name="flowController" ref="flowController"/> - <property name="keyService" ref="keyService"/> + <property name="authorizer" ref="authorizer"/> </bean> <bean id="processorDAO" class="org.apache.nifi.web.dao.impl.StandardProcessorDAO"> <property name="flowController" ref="flowController"/> @@ -115,6 +120,7 @@ </bean> <bean id="serviceFacade" class="org.apache.nifi.web.StandardNiFiServiceFacade"> <property name="properties" ref="nifiProperties"/> + <property name="authorizer" ref="authorizer"/> <property name="controllerFacade" ref="controllerFacade"/> <property name="processorDAO" ref="processorDAO"/> <property name="inputPortDAO" ref="inputPortDAO"/> @@ -133,6 +139,7 @@ <property name="snippetUtils" ref="snippetUtils"/> <property name="optimisticLockingManager" ref="webOptimisticLockingManager"/> <property name="dtoFactory" ref="dtoFactory"/> + <property name="entityFactory" ref="entityFactory"/> <property name="clusterManager" ref="clusterManager"/> </bean> @@ -158,8 +165,19 @@ <!-- rest endpoints --> <bean id="flowResource" class="org.apache.nifi.web.api.FlowResource" scope="singleton"> <property name="serviceFacade" ref="serviceFacade"/> + <property name="authorizer" ref="authorizer"/> <property name="properties" ref="nifiProperties"/> <property name="clusterManager" ref="clusterManager"/> + <property name="processorResource" ref="processorResource"/> + <property name="inputPortResource" ref="inputPortResource"/> + <property name="outputPortResource" ref="outputPortResource"/> + <property name="funnelResource" ref="funnelResource"/> + <property name="labelResource" ref="labelResource"/> + <property name="remoteProcessGroupResource" ref="remoteProcessGroupResource"/> + <property name="connectionResource" ref="connectionResource"/> + <property name="templateResource" ref="templateResource"/> + <property name="controllerServiceResource" ref="controllerServiceResource"/> + <property name="processGroupResource" ref="processGroupResource"/> </bean> <bean id="resourceResource" class="org.apache.nifi.web.api.ResourceResource" scope="singleton"> <property name="serviceFacade" ref="serviceFacade"/> http://git-wip-us.apache.org/repos/asf/nifi/blob/ff98d823/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/test/java/org/apache/nifi/integration/NiFiWebApiTest.java ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/test/java/org/apache/nifi/integration/NiFiWebApiTest.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/test/java/org/apache/nifi/integration/NiFiWebApiTest.java index dbe158a..eecc28a 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/test/java/org/apache/nifi/integration/NiFiWebApiTest.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/test/java/org/apache/nifi/integration/NiFiWebApiTest.java @@ -19,8 +19,6 @@ package org.apache.nifi.integration; import com.sun.jersey.api.client.Client; import com.sun.jersey.api.client.ClientResponse; import com.sun.jersey.api.client.ClientResponse.Status; -import java.util.HashSet; -import java.util.Set; import org.apache.nifi.connectable.ConnectableType; import org.apache.nifi.integration.accesscontrol.DfmAccessControlTest; import org.apache.nifi.integration.util.NiFiTestUser; @@ -34,13 +32,15 @@ import org.apache.nifi.web.api.dto.ProcessGroupDTO; import org.apache.nifi.web.api.dto.ProcessorDTO; import org.apache.nifi.web.api.dto.RevisionDTO; import org.apache.nifi.web.api.entity.ConnectionEntity; -import org.apache.nifi.web.api.entity.InputPortEntity; import org.apache.nifi.web.api.entity.LabelEntity; -import org.apache.nifi.web.api.entity.OutputPortEntity; +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.junit.Ignore; +import java.util.HashSet; +import java.util.Set; + /** * */ @@ -66,7 +66,7 @@ public class NiFiWebApiTest { // create the local selection processor entity ProcessorEntity processorEntity = new ProcessorEntity(); processorEntity.setRevision(revision); - processorEntity.setProcessor(processorDTO); + processorEntity.setComponent(processorDTO); // add the processor ClientResponse response = dfm.testPost(baseUrl + "/controller/process-groups/root/processors", processorEntity); @@ -81,7 +81,7 @@ public class NiFiWebApiTest { // get the processors id processorEntity = response.getEntity(ProcessorEntity.class); - processorDTO = processorEntity.getProcessor(); + processorDTO = processorEntity.getComponent(); String localSelectionId = processorDTO.getId(); // ----------------------------------------------- @@ -95,7 +95,7 @@ public class NiFiWebApiTest { // create the termination processor entity processorEntity = new ProcessorEntity(); processorEntity.setRevision(revision); - processorEntity.setProcessor(processorDTO); + processorEntity.setComponent(processorDTO); // add the processor response = dfm.testPost(baseUrl + "/controller/process-groups/root/processors", processorEntity); @@ -110,7 +110,7 @@ public class NiFiWebApiTest { // get the processors id processorEntity = response.getEntity(ProcessorEntity.class); - processorDTO = processorEntity.getProcessor(); + processorDTO = processorEntity.getComponent(); String terminationId = processorDTO.getId(); // ----------------------------------------------- @@ -137,7 +137,7 @@ public class NiFiWebApiTest { // create the connection entity ConnectionEntity connectionEntity = new ConnectionEntity(); connectionEntity.setRevision(revision); - connectionEntity.setConnection(connectionDTO); + connectionEntity.setComponent(connectionDTO); // add the processor response = dfm.testPost(baseUrl + "/controller/process-groups/root/connections", connectionEntity); @@ -160,7 +160,7 @@ public class NiFiWebApiTest { // create the label entity LabelEntity labelEntity = new LabelEntity(); labelEntity.setRevision(revision); - labelEntity.setLabel(labelDTO); + labelEntity.setComponent(labelDTO); // add the label response = dfm.testPost(baseUrl + "/controller/process-groups/root/labels", labelEntity); @@ -183,7 +183,7 @@ public class NiFiWebApiTest { // create the process group entity ProcessGroupEntity processGroupEntity = new ProcessGroupEntity(); processGroupEntity.setRevision(revision); - processGroupEntity.setProcessGroup(processGroup); + processGroupEntity.setComponent(processGroup); // add the process group response = dfm.testPost(baseUrl + "/controller/process-groups/root/process-group-references", processGroupEntity); @@ -204,9 +204,9 @@ public class NiFiWebApiTest { inputPort.setName("input"); // create the input port entity - InputPortEntity inputPortEntity = new InputPortEntity(); + PortEntity inputPortEntity = new PortEntity(); inputPortEntity.setRevision(revision); - inputPortEntity.setInputPort(inputPort); + inputPortEntity.setComponent(inputPort); // add the input port response = dfm.testPost(baseUrl + "/controller/process-groups/root/input-ports", inputPortEntity); @@ -227,9 +227,9 @@ public class NiFiWebApiTest { outputPort.setName("output"); // create the process group entity - OutputPortEntity outputPortEntity = new OutputPortEntity(); + PortEntity outputPortEntity = new PortEntity(); outputPortEntity.setRevision(revision); - outputPortEntity.setOutputPort(outputPort); + outputPortEntity.setComponent(outputPort); // add the output port response = dfm.testPost(baseUrl + "/controller/process-groups/root/output-ports", outputPortEntity); http://git-wip-us.apache.org/repos/asf/nifi/blob/ff98d823/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/test/java/org/apache/nifi/integration/accesscontrol/AccessTokenEndpointTest.java ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/test/java/org/apache/nifi/integration/accesscontrol/AccessTokenEndpointTest.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/test/java/org/apache/nifi/integration/accesscontrol/AccessTokenEndpointTest.java index 5b96c6e..e43747d 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/test/java/org/apache/nifi/integration/accesscontrol/AccessTokenEndpointTest.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/test/java/org/apache/nifi/integration/accesscontrol/AccessTokenEndpointTest.java @@ -166,7 +166,7 @@ public class AccessTokenEndpointTest { // create the entity body ProcessorEntity entity = new ProcessorEntity(); entity.setRevision(revision); - entity.setProcessor(processor); + entity.setComponent(processor); // perform the request ClientResponse response = TOKEN_USER.testPostWithHeaders(url, entity, headers); @@ -178,7 +178,7 @@ public class AccessTokenEndpointTest { entity = response.getEntity(ProcessorEntity.class); // verify creation - processor = entity.getProcessor(); + processor = entity.getComponent(); Assert.assertEquals("Copy", processor.getName()); Assert.assertEquals("org.apache.nifi.integration.util.SourceTestProcessor", processor.getType()); http://git-wip-us.apache.org/repos/asf/nifi/blob/ff98d823/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/test/java/org/apache/nifi/integration/accesscontrol/AdminAccessControlTest.java ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/test/java/org/apache/nifi/integration/accesscontrol/AdminAccessControlTest.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/test/java/org/apache/nifi/integration/accesscontrol/AdminAccessControlTest.java index dd69954..12693b2 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/test/java/org/apache/nifi/integration/accesscontrol/AdminAccessControlTest.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/test/java/org/apache/nifi/integration/accesscontrol/AdminAccessControlTest.java @@ -17,9 +17,7 @@ package org.apache.nifi.integration.accesscontrol; import com.sun.jersey.api.client.ClientResponse; -import java.io.File; -import java.util.HashMap; -import java.util.Map; +import org.apache.commons.collections4.CollectionUtils; import org.apache.nifi.integration.NiFiWebApiTest; import org.apache.nifi.integration.util.NiFiTestServer; import org.apache.nifi.integration.util.NiFiTestUser; @@ -35,12 +33,11 @@ import org.apache.nifi.web.api.entity.BannerEntity; import org.apache.nifi.web.api.entity.ConnectionEntity; import org.apache.nifi.web.api.entity.ConnectionsEntity; import org.apache.nifi.web.api.entity.ControllerConfigurationEntity; -import org.apache.nifi.web.api.entity.InputPortEntity; import org.apache.nifi.web.api.entity.InputPortsEntity; import org.apache.nifi.web.api.entity.LabelEntity; import org.apache.nifi.web.api.entity.LabelsEntity; -import org.apache.nifi.web.api.entity.OutputPortEntity; import org.apache.nifi.web.api.entity.OutputPortsEntity; +import org.apache.nifi.web.api.entity.PortEntity; import org.apache.nifi.web.api.entity.PrioritizerTypesEntity; import org.apache.nifi.web.api.entity.ProcessGroupEntity; import org.apache.nifi.web.api.entity.ProcessGroupsEntity; @@ -49,13 +46,16 @@ import org.apache.nifi.web.api.entity.ProcessorTypesEntity; import org.apache.nifi.web.api.entity.ProcessorsEntity; import org.apache.nifi.web.api.entity.UserEntity; import org.apache.nifi.web.api.entity.UsersEntity; -import org.apache.commons.collections4.CollectionUtils; import org.junit.AfterClass; import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Ignore; import org.junit.Test; +import java.io.File; +import java.util.HashMap; +import java.util.Map; + /** * Access control test for the admin user. */ @@ -129,7 +129,7 @@ public class AdminAccessControlTest { Assert.assertNotNull(processGroupEntity); // extract the process group dto - ProcessGroupDTO processGroupDTO = processGroupEntity.getProcessGroup(); + ProcessGroupDTO processGroupDTO = processGroupEntity.getComponent(); FlowSnippetDTO processGroupContentsDTO = processGroupDTO.getContents(); // verify graph @@ -634,7 +634,7 @@ public class AdminAccessControlTest { revision.setVersion(NiFiTestUser.REVISION); // create the entity body - InputPortEntity entity = new InputPortEntity(); + PortEntity entity = new PortEntity(); entity.setRevision(revision); // perform the request @@ -659,7 +659,7 @@ public class AdminAccessControlTest { revision.setVersion(NiFiTestUser.REVISION); // create the entity body - InputPortEntity entity = new InputPortEntity(); + PortEntity entity = new PortEntity(); entity.setRevision(revision); // perform the request @@ -724,7 +724,7 @@ public class AdminAccessControlTest { revision.setVersion(NiFiTestUser.REVISION); // create the entity body - OutputPortEntity entity = new OutputPortEntity(); + PortEntity entity = new PortEntity(); entity.setRevision(revision); // perform the request @@ -749,7 +749,7 @@ public class AdminAccessControlTest { revision.setVersion(NiFiTestUser.REVISION); // create the entity body - OutputPortEntity entity = new OutputPortEntity(); + PortEntity entity = new PortEntity(); entity.setRevision(revision); // perform the request http://git-wip-us.apache.org/repos/asf/nifi/blob/ff98d823/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/test/java/org/apache/nifi/integration/accesscontrol/DfmAccessControlTest.java ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/test/java/org/apache/nifi/integration/accesscontrol/DfmAccessControlTest.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/test/java/org/apache/nifi/integration/accesscontrol/DfmAccessControlTest.java index 914cf60..ecbb374 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/test/java/org/apache/nifi/integration/accesscontrol/DfmAccessControlTest.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/test/java/org/apache/nifi/integration/accesscontrol/DfmAccessControlTest.java @@ -20,19 +20,6 @@ import com.sun.jersey.api.client.ClientResponse; import com.sun.jersey.multipart.BodyPart; import com.sun.jersey.multipart.FormDataBodyPart; import com.sun.jersey.multipart.FormDataMultiPart; -import java.io.File; -import java.nio.file.DirectoryStream; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.util.Collection; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.Map; -import java.util.Set; -import javax.ws.rs.core.MediaType; -import org.junit.Assert; import org.apache.nifi.connectable.ConnectableType; import org.apache.nifi.controller.ScheduledState; import org.apache.nifi.integration.NiFiWebApiTest; @@ -57,12 +44,11 @@ import org.apache.nifi.web.api.entity.BannerEntity; import org.apache.nifi.web.api.entity.ConnectionEntity; import org.apache.nifi.web.api.entity.ConnectionsEntity; import org.apache.nifi.web.api.entity.ControllerConfigurationEntity; -import org.apache.nifi.web.api.entity.InputPortEntity; import org.apache.nifi.web.api.entity.InputPortsEntity; import org.apache.nifi.web.api.entity.LabelEntity; import org.apache.nifi.web.api.entity.LabelsEntity; -import org.apache.nifi.web.api.entity.OutputPortEntity; import org.apache.nifi.web.api.entity.OutputPortsEntity; +import org.apache.nifi.web.api.entity.PortEntity; import org.apache.nifi.web.api.entity.PrioritizerTypesEntity; import org.apache.nifi.web.api.entity.ProcessGroupEntity; import org.apache.nifi.web.api.entity.ProcessGroupsEntity; @@ -71,10 +57,24 @@ import org.apache.nifi.web.api.entity.ProcessorTypesEntity; import org.apache.nifi.web.api.entity.ProcessorsEntity; import org.apache.nifi.web.api.entity.TemplateEntity; import org.junit.AfterClass; +import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Ignore; import org.junit.Test; +import javax.ws.rs.core.MediaType; +import java.io.File; +import java.nio.file.DirectoryStream; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.Collection; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.Map; +import java.util.Set; + /** * Access control test for the dfm user. */ @@ -159,7 +159,7 @@ public class DfmAccessControlTest { Assert.assertNotNull(processGroupEntity); // extract the process group dto - ProcessGroupDTO processGroupDTO = processGroupEntity.getProcessGroup(); + ProcessGroupDTO processGroupDTO = processGroupEntity.getComponent(); FlowSnippetDTO processGroupContentsDTO = processGroupDTO.getContents(); // verify graph @@ -371,7 +371,7 @@ public class DfmAccessControlTest { // create the entity body ProcessGroupEntity entity = new ProcessGroupEntity(); entity.setRevision(revision); - entity.setProcessGroup(processGroup); + entity.setComponent(processGroup); // perform the request ClientResponse response = DFM_USER.testPut(url + "/" + processGroup.getId(), entity); @@ -401,7 +401,7 @@ public class DfmAccessControlTest { // create the entity body ProcessGroupEntity entity = new ProcessGroupEntity(); entity.setRevision(revision); - entity.setProcessGroup(processGroup); + entity.setComponent(processGroup); // perform the request ClientResponse response = DFM_USER.testPut(url + "/" + processGroup.getId(), entity); @@ -411,8 +411,8 @@ public class DfmAccessControlTest { // get the result entity = response.getEntity(ProcessGroupEntity.class); - Assert.assertNotNull(entity.getProcessGroup()); - Assert.assertEquals("new group name", entity.getProcessGroup().getName()); + Assert.assertNotNull(entity.getComponent()); + Assert.assertEquals("new group name", entity.getComponent().getName()); } /** @@ -436,7 +436,7 @@ public class DfmAccessControlTest { // create the entity body ProcessorEntity entity = new ProcessorEntity(); entity.setRevision(revision); - entity.setProcessor(processor); + entity.setComponent(processor); // perform the request ClientResponse response = DFM_USER.testPut(url + "/" + processor.getId(), entity); @@ -466,7 +466,7 @@ public class DfmAccessControlTest { // create the entity body ProcessorEntity entity = new ProcessorEntity(); entity.setRevision(revision); - entity.setProcessor(processor); + entity.setComponent(processor); // perform the request ClientResponse response = DFM_USER.testPut(url + "/" + processor.getId(), entity); @@ -476,8 +476,8 @@ public class DfmAccessControlTest { // get the result entity = response.getEntity(ProcessorEntity.class); - Assert.assertNotNull(entity.getProcessor()); - Assert.assertEquals("new processor name", entity.getProcessor().getName()); + Assert.assertNotNull(entity.getComponent()); + Assert.assertEquals("new processor name", entity.getComponent().getName()); } /** @@ -501,7 +501,7 @@ public class DfmAccessControlTest { // create the entity body ConnectionEntity entity = new ConnectionEntity(); entity.setRevision(revision); - entity.setConnection(connection); + entity.setComponent(connection); // perform the request ClientResponse response = DFM_USER.testPut(url + "/" + connection.getId(), entity); @@ -531,7 +531,7 @@ public class DfmAccessControlTest { // create the entity body LabelEntity entity = new LabelEntity(); entity.setRevision(revision); - entity.setLabel(label); + entity.setComponent(label); // perform the request ClientResponse response = DFM_USER.testPut(url + "/" + label.getId(), entity); @@ -541,8 +541,8 @@ public class DfmAccessControlTest { // get the result entity = response.getEntity(LabelEntity.class); - Assert.assertNotNull(entity.getLabel()); - Assert.assertEquals("new label", entity.getLabel().getLabel()); + Assert.assertNotNull(entity.getComponent()); + Assert.assertEquals("new label", entity.getComponent().getLabel()); } /** @@ -564,9 +564,9 @@ public class DfmAccessControlTest { revision.setVersion(NiFiTestUser.REVISION); // create the entity body - InputPortEntity entity = new InputPortEntity(); + PortEntity entity = new PortEntity(); entity.setRevision(revision); - entity.setInputPort(inputPort); + entity.setComponent(inputPort); // perform the request ClientResponse response = DFM_USER.testPut(url + "/" + inputPort.getId(), entity); @@ -575,9 +575,9 @@ public class DfmAccessControlTest { Assert.assertEquals(200, response.getStatus()); // get the result - entity = response.getEntity(InputPortEntity.class); - Assert.assertNotNull(entity.getInputPort()); - Assert.assertEquals("new input port name", entity.getInputPort().getName()); + entity = response.getEntity(PortEntity.class); + Assert.assertNotNull(entity.getComponent()); + Assert.assertEquals("new input port name", entity.getComponent().getName()); } /** @@ -599,9 +599,9 @@ public class DfmAccessControlTest { revision.setVersion(NiFiTestUser.REVISION); // create the entity body - OutputPortEntity entity = new OutputPortEntity(); + PortEntity entity = new PortEntity(); entity.setRevision(revision); - entity.setOutputPort(outputPort); + entity.setComponent(outputPort); // perform the request ClientResponse response = DFM_USER.testPut(url + "/" + outputPort.getId(), entity); @@ -610,9 +610,9 @@ public class DfmAccessControlTest { Assert.assertEquals(200, response.getStatus()); // get the result - entity = response.getEntity(OutputPortEntity.class); - Assert.assertNotNull(entity.getOutputPort()); - Assert.assertEquals("new output port name", entity.getOutputPort().getName()); + entity = response.getEntity(PortEntity.class); + Assert.assertNotNull(entity.getComponent()); + Assert.assertEquals("new output port name", entity.getComponent().getName()); } // ---------------------------------------------- @@ -761,15 +761,15 @@ public class DfmAccessControlTest { // get the process group dtos ProcessGroupsEntity processGroupEntity = response.getEntity(ProcessGroupsEntity.class); - Collection<ProcessGroupDTO> processGroups = processGroupEntity.getProcessGroups(); + Collection<ProcessGroupEntity> processGroups = processGroupEntity.getProcessGroups(); // ensure the correct number of processor groups Assert.assertFalse(processGroups.isEmpty()); // use the first process group as the target - Iterator<ProcessGroupDTO> processorIter = processGroups.iterator(); + Iterator<ProcessGroupEntity> processorIter = processGroups.iterator(); Assert.assertTrue(processorIter.hasNext()); - return processorIter.next(); + return processorIter.next().getComponent(); } private ProcessorDTO getRandomProcessor() throws Exception { @@ -783,15 +783,15 @@ public class DfmAccessControlTest { // get the processor dtos ProcessorsEntity processorsEntity = response.getEntity(ProcessorsEntity.class); - Collection<ProcessorDTO> processors = processorsEntity.getProcessors(); + Collection<ProcessorEntity> processors = processorsEntity.getProcessors(); // ensure the correct number of processors Assert.assertFalse(processors.isEmpty()); // use the first processor as the target - Iterator<ProcessorDTO> processorIter = processors.iterator(); + Iterator<ProcessorEntity> processorIter = processors.iterator(); Assert.assertTrue(processorIter.hasNext()); - return processorIter.next(); + return processorIter.next().getComponent(); } private ConnectionDTO getRandomConnection() throws Exception { @@ -805,15 +805,15 @@ public class DfmAccessControlTest { // get the connection dtos ConnectionsEntity connectionEntity = response.getEntity(ConnectionsEntity.class); - Collection<ConnectionDTO> connections = connectionEntity.getConnections(); + Collection<ConnectionEntity> connections = connectionEntity.getConnections(); // ensure the correct number of connections Assert.assertFalse(connections.isEmpty()); // use the first connection as the target - Iterator<ConnectionDTO> connectionIter = connections.iterator(); + Iterator<ConnectionEntity> connectionIter = connections.iterator(); Assert.assertTrue(connectionIter.hasNext()); - return connectionIter.next(); + return connectionIter.next().getComponent(); } private LabelDTO getRandomLabel() throws Exception { @@ -827,15 +827,15 @@ public class DfmAccessControlTest { // get the label dtos LabelsEntity labelEntity = response.getEntity(LabelsEntity.class); - Collection<LabelDTO> labels = labelEntity.getLabels(); + Collection<LabelEntity> labels = labelEntity.getLabels(); // ensure the correct number of labels Assert.assertFalse(labels.isEmpty()); // use the first label as the target - Iterator<LabelDTO> labelIter = labels.iterator(); + Iterator<LabelEntity> labelIter = labels.iterator(); Assert.assertTrue(labelIter.hasNext()); - return labelIter.next(); + return labelIter.next().getComponent(); } private PortDTO getRandomInputPort() throws Exception { @@ -849,15 +849,15 @@ public class DfmAccessControlTest { // get the port dtos InputPortsEntity inputPortsEntity = response.getEntity(InputPortsEntity.class); - Collection<PortDTO> inputPorts = inputPortsEntity.getInputPorts(); + Collection<PortEntity> inputPorts = inputPortsEntity.getInputPorts(); // ensure the correct number of ports Assert.assertFalse(inputPorts.isEmpty()); // use the first port as the target - Iterator<PortDTO> inputPortsIter = inputPorts.iterator(); + Iterator<PortEntity> inputPortsIter = inputPorts.iterator(); Assert.assertTrue(inputPortsIter.hasNext()); - return inputPortsIter.next(); + return inputPortsIter.next().getComponent(); } private PortDTO getRandomOutputPort() throws Exception { @@ -871,15 +871,15 @@ public class DfmAccessControlTest { // get the port dtos OutputPortsEntity outputPortsEntity = response.getEntity(OutputPortsEntity.class); - Collection<PortDTO> outputPorts = outputPortsEntity.getOutputPorts(); + Collection<PortEntity> outputPorts = outputPortsEntity.getOutputPorts(); // ensure the correct number of ports Assert.assertFalse(outputPorts.isEmpty()); // use the first port as the target - Iterator<PortDTO> inputPortsIter = outputPorts.iterator(); + Iterator<PortEntity> inputPortsIter = outputPorts.iterator(); Assert.assertTrue(inputPortsIter.hasNext()); - return inputPortsIter.next(); + return inputPortsIter.next().getComponent(); } // ---------------------------------------------- @@ -900,7 +900,7 @@ public class DfmAccessControlTest { // create the entity body ProcessGroupEntity entity = new ProcessGroupEntity(); entity.setRevision(revision); - entity.setProcessGroup(processGroup); + entity.setComponent(processGroup); // perform the request ClientResponse response = DFM_USER.testPost(url, entity); @@ -912,7 +912,7 @@ public class DfmAccessControlTest { entity = response.getEntity(ProcessGroupEntity.class); // verify creation - processGroup = entity.getProcessGroup(); + processGroup = entity.getComponent(); Assert.assertEquals("Group1", processGroup.getName()); // get the process group @@ -932,9 +932,9 @@ public class DfmAccessControlTest { revision.setVersion(NiFiTestUser.REVISION); // create the entity body - InputPortEntity entity = new InputPortEntity(); + PortEntity entity = new PortEntity(); entity.setRevision(revision); - entity.setInputPort(portDTO); + entity.setComponent(portDTO); // perform the request ClientResponse response = DFM_USER.testPost(url, entity); @@ -943,10 +943,10 @@ public class DfmAccessControlTest { Assert.assertEquals(201, response.getStatus()); // get the entity body - entity = response.getEntity(InputPortEntity.class); + entity = response.getEntity(PortEntity.class); // verify creation - portDTO = entity.getInputPort(); + portDTO = entity.getComponent(); Assert.assertEquals("Input Port", portDTO.getName()); // get the process group @@ -966,9 +966,9 @@ public class DfmAccessControlTest { revision.setVersion(NiFiTestUser.REVISION); // create the entity body - OutputPortEntity entity = new OutputPortEntity(); + PortEntity entity = new PortEntity(); entity.setRevision(revision); - entity.setOutputPort(portDTO); + entity.setComponent(portDTO); // perform the request ClientResponse response = DFM_USER.testPost(url, entity); @@ -977,10 +977,10 @@ public class DfmAccessControlTest { Assert.assertEquals(201, response.getStatus()); // get the entity body - entity = response.getEntity(OutputPortEntity.class); + entity = response.getEntity(PortEntity.class); // verify creation - portDTO = entity.getOutputPort(); + portDTO = entity.getComponent(); Assert.assertEquals("Output Port", portDTO.getName()); // get the process group @@ -1003,7 +1003,7 @@ public class DfmAccessControlTest { // create the entity body ProcessorEntity entity = new ProcessorEntity(); entity.setRevision(revision); - entity.setProcessor(processor); + entity.setComponent(processor); // perform the request ClientResponse response = DFM_USER.testPost(url, entity); @@ -1015,7 +1015,7 @@ public class DfmAccessControlTest { entity = response.getEntity(ProcessorEntity.class); // verify creation - processor = entity.getProcessor(); + processor = entity.getComponent(); Assert.assertEquals("Copy", processor.getName()); Assert.assertEquals("org.apache.nifi.integration.util.SourceTestProcessor", processor.getType()); @@ -1054,7 +1054,7 @@ public class DfmAccessControlTest { // create the entity body ConnectionEntity entity = new ConnectionEntity(); entity.setRevision(revision); - entity.setConnection(connection); + entity.setComponent(connection); // perform the request ClientResponse response = DFM_USER.testPost(url, entity); @@ -1066,7 +1066,7 @@ public class DfmAccessControlTest { entity = response.getEntity(ConnectionEntity.class); // verify the results - connection = entity.getConnection(); + connection = entity.getComponent(); Assert.assertEquals(sourceId, connection.getSource().getId()); Assert.assertEquals(targetId, connection.getDestination().getId()); Assert.assertEquals(1, connection.getSelectedRelationships().size()); @@ -1091,7 +1091,7 @@ public class DfmAccessControlTest { // create the entity body LabelEntity entity = new LabelEntity(); entity.setRevision(revision); - entity.setLabel(label); + entity.setComponent(label); // perform the request ClientResponse response = DFM_USER.testPost(url, entity); @@ -1103,7 +1103,7 @@ public class DfmAccessControlTest { entity = response.getEntity(LabelEntity.class); // verify the results - label = entity.getLabel(); + label = entity.getComponent(); Assert.assertEquals("Label2", label.getLabel()); // get the label id http://git-wip-us.apache.org/repos/asf/nifi/blob/ff98d823/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/test/java/org/apache/nifi/integration/accesscontrol/ReadOnlyAccessControlTest.java ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/test/java/org/apache/nifi/integration/accesscontrol/ReadOnlyAccessControlTest.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/test/java/org/apache/nifi/integration/accesscontrol/ReadOnlyAccessControlTest.java index 2ed653a..98a8cd0 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/test/java/org/apache/nifi/integration/accesscontrol/ReadOnlyAccessControlTest.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/test/java/org/apache/nifi/integration/accesscontrol/ReadOnlyAccessControlTest.java @@ -17,9 +17,6 @@ package org.apache.nifi.integration.accesscontrol; import com.sun.jersey.api.client.ClientResponse; -import java.io.File; -import java.util.HashMap; -import java.util.Map; import org.apache.nifi.integration.NiFiWebApiTest; import org.apache.nifi.integration.util.NiFiTestServer; import org.apache.nifi.integration.util.NiFiTestUser; @@ -34,12 +31,11 @@ import org.apache.nifi.web.api.entity.BannerEntity; import org.apache.nifi.web.api.entity.ConnectionEntity; import org.apache.nifi.web.api.entity.ConnectionsEntity; import org.apache.nifi.web.api.entity.ControllerConfigurationEntity; -import org.apache.nifi.web.api.entity.InputPortEntity; import org.apache.nifi.web.api.entity.InputPortsEntity; import org.apache.nifi.web.api.entity.LabelEntity; import org.apache.nifi.web.api.entity.LabelsEntity; -import org.apache.nifi.web.api.entity.OutputPortEntity; import org.apache.nifi.web.api.entity.OutputPortsEntity; +import org.apache.nifi.web.api.entity.PortEntity; import org.apache.nifi.web.api.entity.PrioritizerTypesEntity; import org.apache.nifi.web.api.entity.ProcessGroupEntity; import org.apache.nifi.web.api.entity.ProcessGroupsEntity; @@ -52,6 +48,10 @@ import org.junit.BeforeClass; import org.junit.Ignore; import org.junit.Test; +import java.io.File; +import java.util.HashMap; +import java.util.Map; + /** * Access control test for a read only user. */ @@ -125,7 +125,7 @@ public class ReadOnlyAccessControlTest { Assert.assertNotNull(processGroupEntity); // extract the process group dto - ProcessGroupDTO processGroupDTO = processGroupEntity.getProcessGroup(); + ProcessGroupDTO processGroupDTO = processGroupEntity.getComponent(); FlowSnippetDTO processGroupContentsDTO = processGroupDTO.getContents(); // verify graph @@ -625,7 +625,7 @@ public class ReadOnlyAccessControlTest { revision.setVersion(NiFiTestUser.REVISION); // create the entity body - InputPortEntity entity = new InputPortEntity(); + PortEntity entity = new PortEntity(); entity.setRevision(revision); // perform the request @@ -650,7 +650,7 @@ public class ReadOnlyAccessControlTest { revision.setVersion(NiFiTestUser.REVISION); // create the entity body - InputPortEntity entity = new InputPortEntity(); + PortEntity entity = new PortEntity(); entity.setRevision(revision); // perform the request @@ -715,7 +715,7 @@ public class ReadOnlyAccessControlTest { revision.setVersion(NiFiTestUser.REVISION); // create the entity body - OutputPortEntity entity = new OutputPortEntity(); + PortEntity entity = new PortEntity(); entity.setRevision(revision); // perform the request @@ -740,7 +740,7 @@ public class ReadOnlyAccessControlTest { revision.setVersion(NiFiTestUser.REVISION); // create the entity body - OutputPortEntity entity = new OutputPortEntity(); + PortEntity entity = new PortEntity(); entity.setRevision(revision); // perform the request http://git-wip-us.apache.org/repos/asf/nifi/blob/ff98d823/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-content-viewer/pom.xml ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-content-viewer/pom.xml b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-content-viewer/pom.xml index 22b387c..9a7c69e 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-content-viewer/pom.xml +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-content-viewer/pom.xml @@ -42,6 +42,11 @@ <scope>provided</scope> </dependency> <dependency> + <groupId>org.apache.nifi</groupId> + <artifactId>nifi-framework-authorization</artifactId> + <scope>provided</scope> + </dependency> + <dependency> <groupId>org.apache.commons</groupId> <artifactId>commons-lang3</artifactId> <scope>provided</scope> http://git-wip-us.apache.org/repos/asf/nifi/blob/ff98d823/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-content-viewer/src/main/java/org/apache/nifi/web/ContentViewerController.java ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-content-viewer/src/main/java/org/apache/nifi/web/ContentViewerController.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-content-viewer/src/main/java/org/apache/nifi/web/ContentViewerController.java index 50ca101..00dc06f 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-content-viewer/src/main/java/org/apache/nifi/web/ContentViewerController.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-content-viewer/src/main/java/org/apache/nifi/web/ContentViewerController.java @@ -31,6 +31,7 @@ import javax.servlet.http.HttpServletResponse; import org.apache.commons.codec.binary.Base64; import org.apache.commons.io.IOUtils; import org.apache.commons.lang3.StringUtils; +import org.apache.nifi.authorization.AccessDeniedException; import org.apache.nifi.stream.io.StreamUtils; import org.apache.nifi.web.ViewableContent.DisplayMode; import org.apache.tika.detect.DefaultDetector; @@ -39,7 +40,6 @@ import org.apache.tika.metadata.Metadata; import org.apache.tika.mime.MediaType; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.springframework.security.access.AccessDeniedException; /** * Controller servlet for viewing content. This is responsible for generating
