From fd18eeb84e976c7ac77a92ee5e36764697e63abb Mon Sep 17 00:00:00 2001 From: Matt Gilman Date: Wed, 3 Jan 2018 10:46:04 -0500 Subject: [PATCH] NIFI-4436: - Code clean up. - Backing out incomplete fix for variable registry two phase commit to address in separate JIRA. --- .../api/dto/ControllerConfigurationDTO.java | 1 - .../web/api/dto/FlowConfigurationDTO.java | 1 - .../api/entity/CreateActiveRequestEntity.java | 2 +- .../StartVersionControlRequestEntity.java | 2 +- .../web/api/entity/VersionedFlowEntity.java | 2 +- .../entity/VersionedFlowSnapshotEntity.java | 2 +- .../VersionedFlowSnapshotMetadataEntity.java | 2 +- .../nifi/web/api/ApplicationResource.java | 16 ----- .../nifi/web/api/ProcessGroupResource.java | 66 +++++++++---------- 9 files changed, 37 insertions(+), 57 deletions(-) diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/ControllerConfigurationDTO.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/ControllerConfigurationDTO.java index 597d700d5b..61b037ffa9 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/ControllerConfigurationDTO.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/ControllerConfigurationDTO.java @@ -28,7 +28,6 @@ public class ControllerConfigurationDTO { private Integer maxTimerDrivenThreadCount; private Integer maxEventDrivenThreadCount; - private String registryUrl; /** * @return maximum number of timer driven threads this NiFi has available diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/FlowConfigurationDTO.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/FlowConfigurationDTO.java index d7a0c8327d..657d760468 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/FlowConfigurationDTO.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/FlowConfigurationDTO.java @@ -127,5 +127,4 @@ public class FlowConfigurationDTO { public void setTimeOffset(Integer timeOffset) { this.timeOffset = timeOffset; } - } diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/CreateActiveRequestEntity.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/CreateActiveRequestEntity.java index 63a07a2287..8074e00dec 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/CreateActiveRequestEntity.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/CreateActiveRequestEntity.java @@ -21,7 +21,7 @@ import io.swagger.annotations.ApiModelProperty; import javax.xml.bind.annotation.XmlRootElement; -@XmlRootElement(name = "createActiveRequest") +@XmlRootElement(name = "createActiveRequestEntity") public class CreateActiveRequestEntity extends Entity { private String processGroupId; diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/StartVersionControlRequestEntity.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/StartVersionControlRequestEntity.java index 08761407ed..b5b943de1e 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/StartVersionControlRequestEntity.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/StartVersionControlRequestEntity.java @@ -23,7 +23,7 @@ import org.apache.nifi.web.api.dto.VersionedFlowDTO; import javax.xml.bind.annotation.XmlRootElement; -@XmlRootElement(name = "versionedFlow") +@XmlRootElement(name = "startVersionControlRequestEntity") public class StartVersionControlRequestEntity extends Entity { private VersionedFlowDTO versionedFlow; private RevisionDTO processGroupRevision; diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/VersionedFlowEntity.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/VersionedFlowEntity.java index 4a43826f3c..26772ad7c3 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/VersionedFlowEntity.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/VersionedFlowEntity.java @@ -22,7 +22,7 @@ import org.apache.nifi.web.api.dto.VersionedFlowDTO; import javax.xml.bind.annotation.XmlRootElement; -@XmlRootElement(name = "versionedFlow") +@XmlRootElement(name = "versionedFlowEntity") public class VersionedFlowEntity extends Entity { private VersionedFlowDTO versionedFlow; diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/VersionedFlowSnapshotEntity.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/VersionedFlowSnapshotEntity.java index 2faf791d94..8929fa7a11 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/VersionedFlowSnapshotEntity.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/VersionedFlowSnapshotEntity.java @@ -23,7 +23,7 @@ import org.apache.nifi.web.api.dto.RevisionDTO; import javax.xml.bind.annotation.XmlRootElement; -@XmlRootElement(name = "versionedFlowSnapshot") +@XmlRootElement(name = "versionedFlowSnapshotEntity") public class VersionedFlowSnapshotEntity extends Entity { private VersionedFlowSnapshot versionedFlowSnapshot; private RevisionDTO processGroupRevision; diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/VersionedFlowSnapshotMetadataEntity.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/VersionedFlowSnapshotMetadataEntity.java index 29b57cc559..face25ce91 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/VersionedFlowSnapshotMetadataEntity.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/VersionedFlowSnapshotMetadataEntity.java @@ -22,7 +22,7 @@ import org.apache.nifi.registry.flow.VersionedFlowSnapshotMetadata; import javax.xml.bind.annotation.XmlRootElement; -@XmlRootElement(name = "versionedFlowSnapshotMetadata") +@XmlRootElement(name = "versionedFlowSnapshotMetadataEntity") public class VersionedFlowSnapshotMetadataEntity extends Entity { private VersionedFlowSnapshotMetadata versionedFlowSnapshotMetadata; private String registryId; diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/ApplicationResource.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/ApplicationResource.java index 531823a911..7e19d9821d 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/ApplicationResource.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/ApplicationResource.java @@ -37,7 +37,6 @@ import org.apache.nifi.cluster.manager.exception.IllegalClusterStateException; import org.apache.nifi.cluster.manager.exception.UnknownNodeException; import org.apache.nifi.cluster.protocol.NodeIdentifier; import org.apache.nifi.controller.FlowController; -import org.apache.nifi.framework.security.util.SslContextFactory; import org.apache.nifi.remote.HttpRemoteSiteListener; import org.apache.nifi.remote.VersionNegotiator; import org.apache.nifi.remote.exception.BadRequestException; @@ -46,7 +45,6 @@ import org.apache.nifi.remote.exception.NotAuthorizedException; import org.apache.nifi.remote.protocol.ResponseCode; import org.apache.nifi.remote.protocol.http.HttpHeaders; import org.apache.nifi.util.ComponentIdGenerator; -import org.apache.nifi.util.FormatUtils; import org.apache.nifi.util.NiFiProperties; import org.apache.nifi.web.NiFiServiceFacade; import org.apache.nifi.web.Revision; @@ -57,14 +55,11 @@ import org.apache.nifi.web.api.entity.TransactionResultEntity; import org.apache.nifi.web.security.ProxiedEntitiesUtils; import org.apache.nifi.web.security.util.CacheKey; import org.apache.nifi.web.util.WebUtils; -import org.glassfish.jersey.client.ClientConfig; -import org.glassfish.jersey.client.ClientProperties; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import javax.ws.rs.client.Client; import javax.ws.rs.core.CacheControl; import javax.ws.rs.core.Context; import javax.ws.rs.core.MediaType; @@ -227,17 +222,6 @@ public abstract class ApplicationResource { return Optional.of(idGenerationSeed); } - protected Client createJerseyClient() { - final NiFiProperties properties = getProperties(); - final ClientConfig clientConfig = new ClientConfig(); - final int connectionTimeout = (int) FormatUtils.getTimeDuration(properties.getClusterNodeConnectionTimeout(), TimeUnit.MILLISECONDS); - final int readTimeout = (int) FormatUtils.getTimeDuration(properties.getClusterNodeReadTimeout(), TimeUnit.MILLISECONDS); - clientConfig.property(ClientProperties.READ_TIMEOUT, readTimeout); - clientConfig.property(ClientProperties.CONNECT_TIMEOUT, connectionTimeout); - clientConfig.property(ClientProperties.FOLLOW_REDIRECTS, Boolean.TRUE); - return WebUtils.createClient(clientConfig, SslContextFactory.createSslContext(properties)); - } - /** * Generates an Ok response with no content. * diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/ProcessGroupResource.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/ProcessGroupResource.java index a2c16ed70a..96e1e08d3b 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/ProcessGroupResource.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/ProcessGroupResource.java @@ -16,32 +16,12 @@ */ package org.apache.nifi.web.api; -import javax.servlet.http.HttpServletRequest; -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.DefaultValue; -import javax.ws.rs.GET; -import javax.ws.rs.HttpMethod; -import javax.ws.rs.POST; -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; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.MultivaluedHashMap; -import javax.ws.rs.core.MultivaluedMap; -import javax.ws.rs.core.Response; -import javax.ws.rs.core.Response.Status; -import javax.ws.rs.core.UriBuilder; -import javax.ws.rs.core.UriInfo; -import javax.xml.bind.JAXBContext; -import javax.xml.bind.JAXBElement; -import javax.xml.bind.JAXBException; -import javax.xml.bind.Unmarshaller; -import javax.xml.stream.XMLStreamReader; - +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import io.swagger.annotations.ApiResponse; +import io.swagger.annotations.ApiResponses; +import io.swagger.annotations.Authorization; import org.apache.commons.lang3.StringUtils; import org.apache.nifi.authorization.AuthorizableLookup; import org.apache.nifi.authorization.AuthorizeAccess; @@ -132,6 +112,31 @@ import org.slf4j.LoggerFactory; import org.springframework.security.core.Authentication; import org.springframework.security.core.context.SecurityContextHolder; +import javax.servlet.http.HttpServletRequest; +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.DefaultValue; +import javax.ws.rs.GET; +import javax.ws.rs.HttpMethod; +import javax.ws.rs.POST; +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; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.MultivaluedHashMap; +import javax.ws.rs.core.MultivaluedMap; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.Response.Status; +import javax.ws.rs.core.UriBuilder; +import javax.ws.rs.core.UriInfo; +import javax.xml.bind.JAXBContext; +import javax.xml.bind.JAXBElement; +import javax.xml.bind.JAXBException; +import javax.xml.bind.Unmarshaller; +import javax.xml.stream.XMLStreamReader; import java.io.IOException; import java.io.InputStream; import java.net.URI; @@ -157,13 +162,6 @@ import java.util.function.Consumer; import java.util.function.Function; import java.util.stream.Collectors; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import io.swagger.annotations.ApiParam; -import io.swagger.annotations.ApiResponse; -import io.swagger.annotations.ApiResponses; -import io.swagger.annotations.Authorization; - /** * RESTful endpoint for managing a Group. */ @@ -622,7 +620,7 @@ public class ProcessGroupResource extends ApplicationResource { final VariableRegistryDTO requestRegistryDto = requestVariableRegistryEntity.getVariableRegistry(); if (!groupId.equals(requestRegistryDto.getProcessGroupId())) { throw new IllegalArgumentException(String.format("The process group id (%s) in the request body does " - + "not equal the process group id of the requested resource (%s).", requestRegistryDto.getProcessGroupId(), groupId)); + + "not equal the process group id of the requested resource (%s).", registryDto.getProcessGroupId(), groupId)); } if (isReplicateRequest()) {