http://git-wip-us.apache.org/repos/asf/nifi/blob/6baea8cc/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/StandardNiFiContentAccess.java ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/StandardNiFiContentAccess.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/StandardNiFiContentAccess.java index 8e647ed..79973fe 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/StandardNiFiContentAccess.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/StandardNiFiContentAccess.java @@ -16,9 +16,6 @@ */ package org.apache.nifi.web; -import com.sun.jersey.api.client.ClientResponse; -import com.sun.jersey.api.client.ClientResponse.Status; -import com.sun.jersey.core.util.MultivaluedMapImpl; import org.apache.commons.lang3.StringUtils; import org.apache.nifi.authorization.AccessDeniedException; import org.apache.nifi.cluster.coordination.ClusterCoordinator; @@ -31,7 +28,9 @@ import org.apache.nifi.controller.repository.claim.ContentDirection; import org.apache.nifi.util.NiFiProperties; import javax.ws.rs.HttpMethod; +import javax.ws.rs.core.MultivaluedHashMap; import javax.ws.rs.core.MultivaluedMap; +import javax.ws.rs.core.Response; import java.net.URI; import java.net.URISyntaxException; import java.util.Collections; @@ -72,7 +71,7 @@ public class StandardNiFiContentAccess implements ContentAccess { } // set the request parameters - final MultivaluedMap<String, String> parameters = new MultivaluedMapImpl(); + final MultivaluedMap<String, String> parameters = new MultivaluedHashMap(); parameters.add(CLIENT_ID_PARAM, request.getClientId()); // set the headers @@ -100,17 +99,17 @@ public class StandardNiFiContentAccess implements ContentAccess { throw new IllegalClusterStateException("Interrupted while waiting for a response from node"); } - final ClientResponse clientResponse = nodeResponse.getClientResponse(); - final MultivaluedMap<String, String> responseHeaders = clientResponse.getHeaders(); + final Response clientResponse = nodeResponse.getClientResponse(); + final MultivaluedMap<String, String> responseHeaders = clientResponse.getStringHeaders(); // ensure an appropriate response - if (Status.NOT_FOUND.getStatusCode() == clientResponse.getStatusInfo().getStatusCode()) { - throw new ResourceNotFoundException(clientResponse.getEntity(String.class)); - } else if (Status.FORBIDDEN.getStatusCode() == clientResponse.getStatusInfo().getStatusCode() - || Status.UNAUTHORIZED.getStatusCode() == clientResponse.getStatusInfo().getStatusCode()) { - throw new AccessDeniedException(clientResponse.getEntity(String.class)); - } else if (Status.OK.getStatusCode() != clientResponse.getStatusInfo().getStatusCode()) { - throw new IllegalStateException(clientResponse.getEntity(String.class)); + if (Response.Status.NOT_FOUND.getStatusCode() == clientResponse.getStatusInfo().getStatusCode()) { + throw new ResourceNotFoundException(clientResponse.readEntity(String.class)); + } else if (Response.Status.FORBIDDEN.getStatusCode() == clientResponse.getStatusInfo().getStatusCode() + || Response.Status.UNAUTHORIZED.getStatusCode() == clientResponse.getStatusInfo().getStatusCode()) { + throw new AccessDeniedException(clientResponse.readEntity(String.class)); + } else if (Response.Status.OK.getStatusCode() != clientResponse.getStatusInfo().getStatusCode()) { + throw new IllegalStateException(clientResponse.readEntity(String.class)); } // get the file name
http://git-wip-us.apache.org/repos/asf/nifi/blob/6baea8cc/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/StandardNiFiWebConfigurationContext.java ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/StandardNiFiWebConfigurationContext.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/StandardNiFiWebConfigurationContext.java index 9a8827a..d8789c2 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/StandardNiFiWebConfigurationContext.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/StandardNiFiWebConfigurationContext.java @@ -16,7 +16,6 @@ */ package org.apache.nifi.web; -import com.sun.jersey.core.util.MultivaluedMapImpl; import org.apache.commons.lang3.StringUtils; import org.apache.nifi.action.Action; import org.apache.nifi.action.Component; @@ -60,6 +59,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import javax.ws.rs.HttpMethod; +import javax.ws.rs.core.MultivaluedHashMap; import javax.ws.rs.core.MultivaluedMap; import javax.ws.rs.core.Response; import java.io.UnsupportedEncodingException; @@ -335,7 +335,7 @@ public class StandardNiFiWebConfigurationContext implements NiFiWebConfiguration } // set the request parameters - final MultivaluedMap<String, String> parameters = new MultivaluedMapImpl(); + final MultivaluedMap<String, String> parameters = new MultivaluedHashMap(); // replicate request NodeResponse nodeResponse; @@ -351,7 +351,7 @@ public class StandardNiFiWebConfigurationContext implements NiFiWebConfiguration // return processor ProcessorEntity entity = (ProcessorEntity) nodeResponse.getUpdatedEntity(); if (entity == null) { - entity = nodeResponse.getClientResponse().getEntity(ProcessorEntity.class); + entity = nodeResponse.getClientResponse().readEntity(ProcessorEntity.class); } processor = entity.getComponent(); } else { @@ -420,7 +420,7 @@ public class StandardNiFiWebConfigurationContext implements NiFiWebConfiguration // return processor ProcessorEntity entity = (ProcessorEntity) nodeResponse.getUpdatedEntity(); if (entity == null) { - entity = nodeResponse.getClientResponse().getEntity(ProcessorEntity.class); + entity = nodeResponse.getClientResponse().readEntity(ProcessorEntity.class); } processor = entity.getComponent(); } else { @@ -528,7 +528,7 @@ public class StandardNiFiWebConfigurationContext implements NiFiWebConfiguration } // set the request parameters - final MultivaluedMap<String, String> parameters = new MultivaluedMapImpl(); + final MultivaluedMap<String, String> parameters = new MultivaluedHashMap(); // replicate request NodeResponse nodeResponse; @@ -544,7 +544,7 @@ public class StandardNiFiWebConfigurationContext implements NiFiWebConfiguration // return controller service ControllerServiceEntity entity = (ControllerServiceEntity) nodeResponse.getUpdatedEntity(); if (entity == null) { - entity = nodeResponse.getClientResponse().getEntity(ControllerServiceEntity.class); + entity = nodeResponse.getClientResponse().readEntity(ControllerServiceEntity.class); } controllerService = entity.getComponent(); } @@ -635,7 +635,7 @@ public class StandardNiFiWebConfigurationContext implements NiFiWebConfiguration // return controller service ControllerServiceEntity entity = (ControllerServiceEntity) nodeResponse.getUpdatedEntity(); if (entity == null) { - entity = nodeResponse.getClientResponse().getEntity(ControllerServiceEntity.class); + entity = nodeResponse.getClientResponse().readEntity(ControllerServiceEntity.class); } controllerService = entity.getComponent(); } @@ -693,7 +693,7 @@ public class StandardNiFiWebConfigurationContext implements NiFiWebConfiguration } // set the request parameters - final MultivaluedMap<String, String> parameters = new MultivaluedMapImpl(); + final MultivaluedMap<String, String> parameters = new MultivaluedHashMap(); // replicate request NodeResponse nodeResponse; @@ -709,7 +709,7 @@ public class StandardNiFiWebConfigurationContext implements NiFiWebConfiguration // return reporting task ReportingTaskEntity entity = (ReportingTaskEntity) nodeResponse.getUpdatedEntity(); if (entity == null) { - entity = nodeResponse.getClientResponse().getEntity(ReportingTaskEntity.class); + entity = nodeResponse.getClientResponse().readEntity(ReportingTaskEntity.class); } reportingTask = entity.getComponent(); } @@ -801,7 +801,7 @@ public class StandardNiFiWebConfigurationContext implements NiFiWebConfiguration // return reporting task ReportingTaskEntity entity = (ReportingTaskEntity) nodeResponse.getUpdatedEntity(); if (entity == null) { - entity = nodeResponse.getClientResponse().getEntity(ReportingTaskEntity.class); + entity = nodeResponse.getClientResponse().readEntity(ReportingTaskEntity.class); } reportingTask = entity.getComponent(); } http://git-wip-us.apache.org/repos/asf/nifi/blob/6baea8cc/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/ApplicationResource.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/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 b4d5ce4..c1f2226 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 @@ -18,10 +18,6 @@ package org.apache.nifi.web.api; import com.google.common.cache.Cache; import com.google.common.cache.CacheBuilder; -import com.sun.jersey.api.core.HttpContext; -import com.sun.jersey.api.representation.Form; -import com.sun.jersey.core.util.MultivaluedMapImpl; -import com.sun.jersey.server.impl.model.method.dispatch.FormDispatchProvider; import org.apache.commons.lang3.StringUtils; import org.apache.nifi.authorization.AuthorizableLookup; import org.apache.nifi.authorization.AuthorizeAccess; @@ -66,6 +62,7 @@ import javax.servlet.http.HttpServletResponse; import javax.ws.rs.core.CacheControl; 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.ResponseBuilder; @@ -123,9 +120,6 @@ public abstract class ApplicationResource { @Context private UriInfo uriInfo; - @Context - private HttpContext httpContext; - protected NiFiProperties properties; private RequestReplicator requestReplicator; private ClusterCoordinator clusterCoordinator; @@ -300,22 +294,16 @@ public abstract class ApplicationResource { } protected MultivaluedMap<String, String> getRequestParameters() { - final MultivaluedMap<String, String> entity = new MultivaluedMapImpl(); - - // get the form that jersey processed and use it if it exists (only exist for requests with a body and application form urlencoded - final Form form = (Form) httpContext.getProperties().get(FormDispatchProvider.FORM_PROPERTY); - if (form == null) { - for (final Map.Entry<String, String[]> entry : httpServletRequest.getParameterMap().entrySet()) { - if (entry.getValue() == null) { - entity.add(entry.getKey(), null); - } else { - for (final String aValue : entry.getValue()) { - entity.add(entry.getKey(), aValue); - } + final MultivaluedMap<String, String> entity = new MultivaluedHashMap(); + + for (final Map.Entry<String, String[]> entry : httpServletRequest.getParameterMap().entrySet()) { + if (entry.getValue() == null) { + entity.add(entry.getKey(), null); + } else { + for (final String aValue : entry.getValue()) { + entity.add(entry.getKey(), aValue); } } - } else { - entity.putAll(form); } return entity; http://git-wip-us.apache.org/repos/asf/nifi/blob/6baea8cc/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/ControllerResource.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/ControllerResource.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/ControllerResource.java index 23ac3cd..b213755 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/ControllerResource.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/ControllerResource.java @@ -16,7 +16,6 @@ */ package org.apache.nifi.web.api; -import com.sun.jersey.api.core.ResourceContext; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; @@ -82,9 +81,6 @@ public class ControllerResource extends ApplicationResource { private ReportingTaskResource reportingTaskResource; private ControllerServiceResource controllerServiceResource; - @Context - private ResourceContext resourceContext; - /** * Authorizes access to the flow. */ http://git-wip-us.apache.org/repos/asf/nifi/blob/6baea8cc/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/CountersResource.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/CountersResource.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/CountersResource.java index 028e6a1..0b258f5 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/CountersResource.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/CountersResource.java @@ -16,7 +16,6 @@ */ package org.apache.nifi.web.api; -import com.sun.jersey.api.core.ResourceContext; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; @@ -62,9 +61,6 @@ import javax.ws.rs.core.Response; ) public class CountersResource extends ApplicationResource { - @Context - private ResourceContext resourceContext; - private NiFiServiceFacade serviceFacade; private Authorizer authorizer; http://git-wip-us.apache.org/repos/asf/nifi/blob/6baea8cc/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/FlowResource.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/FlowResource.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/FlowResource.java index 378e381..c9aea4f 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/FlowResource.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/FlowResource.java @@ -16,7 +16,6 @@ */ package org.apache.nifi.web.api; -import com.sun.jersey.api.core.ResourceContext; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; @@ -139,9 +138,6 @@ public class FlowResource extends ApplicationResource { private NiFiServiceFacade serviceFacade; private Authorizer authorizer; - @Context - private ResourceContext resourceContext; - private ProcessorResource processorResource; private InputPortResource inputPortResource; private OutputPortResource outputPortResource; @@ -154,6 +150,10 @@ public class FlowResource extends ApplicationResource { private ControllerServiceResource controllerServiceResource; private ReportingTaskResource reportingTaskResource; + public FlowResource() { + super(); + } + /** * Populates the remaining fields in the specified process group. * http://git-wip-us.apache.org/repos/asf/nifi/blob/6baea8cc/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/ProcessGroupResource.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/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 de1f15b..7ff7885 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,9 +16,6 @@ */ package org.apache.nifi.web.api; -import com.sun.jersey.api.core.ResourceContext; -import com.sun.jersey.core.util.MultivaluedMapImpl; -import com.sun.jersey.multipart.FormDataParam; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; @@ -100,6 +97,7 @@ import org.apache.nifi.web.api.request.ClientIdParameter; import org.apache.nifi.web.api.request.LongParameter; import org.apache.nifi.web.security.token.NiFiAuthenticationToken; import org.apache.nifi.web.util.Pause; +import org.glassfish.jersey.media.multipart.FormDataParam; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.security.core.Authentication; @@ -119,6 +117,7 @@ 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; @@ -166,9 +165,6 @@ public class ProcessGroupResource extends ApplicationResource { private static final Logger logger = LoggerFactory.getLogger(ProcessGroupResource.class); - @Context - private ResourceContext resourceContext; - private NiFiServiceFacade serviceFacade; private Authorizer authorizer; @@ -826,7 +822,7 @@ public class ProcessGroupResource extends ApplicationResource { } final Map<String, String> headers = new HashMap<>(); - final MultivaluedMap<String, String> requestEntity = new MultivaluedMapImpl(); + final MultivaluedMap<String, String> requestEntity = new MultivaluedHashMap(); boolean continuePolling = true; while (continuePolling) { @@ -983,7 +979,7 @@ public class ProcessGroupResource extends ApplicationResource { } final Map<String, String> headers = new HashMap<>(); - final MultivaluedMap<String, String> requestEntity = new MultivaluedMapImpl(); + final MultivaluedMap<String, String> requestEntity = new MultivaluedHashMap(); boolean continuePolling = true; while (continuePolling) { @@ -1416,7 +1412,7 @@ public class ProcessGroupResource extends ApplicationResource { private <T> T getResponseEntity(final NodeResponse nodeResponse, final Class<T> clazz) { T entity = (T) nodeResponse.getUpdatedEntity(); if (entity == null) { - entity = nodeResponse.getClientResponse().getEntity(clazz); + entity = nodeResponse.getClientResponse().readEntity(clazz); } return entity; } http://git-wip-us.apache.org/repos/asf/nifi/blob/6baea8cc/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/config/JsonMappingExceptionMapper.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/JsonMappingExceptionMapper.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/config/JsonMappingExceptionMapper.java deleted file mode 100644 index 8845214..0000000 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/config/JsonMappingExceptionMapper.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * 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.config; - -import javax.ws.rs.core.Response; -import javax.ws.rs.ext.ExceptionMapper; -import javax.ws.rs.ext.Provider; -import org.apache.nifi.util.StringUtils; -import org.codehaus.jackson.map.JsonMappingException; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * Maps invalid revision exceptions into client responses. - */ -@Provider -public class JsonMappingExceptionMapper implements ExceptionMapper<JsonMappingException> { - - private static final Logger logger = LoggerFactory.getLogger(JsonMappingExceptionMapper.class); - - @Override - public Response toResponse(JsonMappingException ex) { - // log the error - logger.info(String.format("%s. Returning %s response.", ex, Response.Status.BAD_REQUEST)); - - if (logger.isDebugEnabled()) { - logger.debug(StringUtils.EMPTY, ex); - } - - return Response.status(Response.Status.BAD_REQUEST).entity("Message body is malformed. Unable to map into expected format.").type("text/plain").build(); - } -} http://git-wip-us.apache.org/repos/asf/nifi/blob/6baea8cc/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/config/JsonParseExceptionMapper.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/JsonParseExceptionMapper.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/config/JsonParseExceptionMapper.java deleted file mode 100644 index 3c38f23..0000000 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/config/JsonParseExceptionMapper.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * 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.config; - -import javax.ws.rs.core.Response; -import javax.ws.rs.ext.ExceptionMapper; -import javax.ws.rs.ext.Provider; -import org.apache.nifi.util.StringUtils; -import org.codehaus.jackson.JsonParseException; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * Maps invalid revision exceptions into client responses. - */ -@Provider -public class JsonParseExceptionMapper implements ExceptionMapper<JsonParseException> { - - private static final Logger logger = LoggerFactory.getLogger(JsonMappingExceptionMapper.class); - - @Override - public Response toResponse(JsonParseException ex) { - // log the error - logger.info(String.format("%s. Returning %s response.", ex, Response.Status.BAD_REQUEST)); - - if (logger.isDebugEnabled()) { - logger.debug(StringUtils.EMPTY, ex); - } - - return Response.status(Response.Status.BAD_REQUEST).entity("Unable to parse body as JSON.").type("text/plain").build(); - } -} http://git-wip-us.apache.org/repos/asf/nifi/blob/6baea8cc/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/config/NotFoundExceptionMapper.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/NotFoundExceptionMapper.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/config/NotFoundExceptionMapper.java index 512391f..a3b583d 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/config/NotFoundExceptionMapper.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/config/NotFoundExceptionMapper.java @@ -16,15 +16,16 @@ */ package org.apache.nifi.web.api.config; -import com.sun.jersey.api.NotFoundException; -import com.sun.jersey.api.Responses; -import javax.ws.rs.core.Response; -import javax.ws.rs.ext.ExceptionMapper; -import javax.ws.rs.ext.Provider; import org.apache.nifi.util.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import javax.ws.rs.NotFoundException; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.Response.Status; +import javax.ws.rs.ext.ExceptionMapper; +import javax.ws.rs.ext.Provider; + /** * Maps not found exceptions into client responses. */ @@ -36,13 +37,13 @@ public class NotFoundExceptionMapper implements ExceptionMapper<NotFoundExceptio @Override public Response toResponse(NotFoundException exception) { // log the error - logger.info(String.format("%s. Returning %s response.", exception, Response.Status.NOT_FOUND)); + logger.info(String.format("%s. Returning %s response.", exception, Status.NOT_FOUND)); if (logger.isDebugEnabled()) { logger.debug(StringUtils.EMPTY, exception); } - return Responses.notFound().entity("The specified resource could not be found.").type("text/plain").build(); + return Response.status(Status.NOT_FOUND).entity("The specified resource could not be found.").type("text/plain").build(); } } http://git-wip-us.apache.org/repos/asf/nifi/blob/6baea8cc/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/config/ResourceNotFoundExceptionMapper.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/ResourceNotFoundExceptionMapper.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/config/ResourceNotFoundExceptionMapper.java index 1ea6596..bdf0b1e 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/config/ResourceNotFoundExceptionMapper.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/config/ResourceNotFoundExceptionMapper.java @@ -16,15 +16,16 @@ */ package org.apache.nifi.web.api.config; -import com.sun.jersey.api.Responses; -import javax.ws.rs.core.Response; -import javax.ws.rs.ext.ExceptionMapper; -import javax.ws.rs.ext.Provider; import org.apache.nifi.util.StringUtils; import org.apache.nifi.web.ResourceNotFoundException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.Response.Status; +import javax.ws.rs.ext.ExceptionMapper; +import javax.ws.rs.ext.Provider; + /** * Maps resource not found exceptions into client responses. */ @@ -42,7 +43,7 @@ public class ResourceNotFoundExceptionMapper implements ExceptionMapper<Resource logger.debug(StringUtils.EMPTY, exception); } - return Responses.notFound().entity(exception.getMessage()).type("text/plain").build(); + return Response.status(Status.NOT_FOUND).entity(exception.getMessage()).type("text/plain").build(); } } http://git-wip-us.apache.org/repos/asf/nifi/blob/6baea8cc/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/filter/RedirectResourceFilter.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/filter/RedirectResourceFilter.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/filter/RedirectResourceFilter.java index 51271aa..c17df15 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/filter/RedirectResourceFilter.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/filter/RedirectResourceFilter.java @@ -17,13 +17,13 @@ package org.apache.nifi.web.api.filter; -import com.sun.jersey.spi.container.ContainerRequest; -import com.sun.jersey.spi.container.ContainerRequestFilter; import org.apache.nifi.web.api.SiteToSiteResource; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import javax.ws.rs.container.ContainerRequestContext; +import javax.ws.rs.container.ContainerRequestFilter; import javax.ws.rs.core.UriBuilder; +import javax.ws.rs.core.UriInfo; +import java.io.IOException; import java.net.URI; /** @@ -31,26 +31,23 @@ import java.net.URI; */ public class RedirectResourceFilter implements ContainerRequestFilter { - private static final Logger logger = LoggerFactory.getLogger(RedirectResourceFilter.class); - /** * This method checks path of the incoming request, and * redirects following URIs: * <li>/controller -> SiteToSiteResource - * @param containerRequest request to be modified - * @return modified request + * @param requestContext request to be modified */ @Override - public ContainerRequest filter(ContainerRequest containerRequest) { + public void filter(ContainerRequestContext requestContext) throws IOException { + final UriInfo uriInfo = requestContext.getUriInfo(); - if(containerRequest.getPath().equals("controller")){ - UriBuilder builder = UriBuilder.fromUri(containerRequest.getBaseUri()) + if (uriInfo.getPath().equals("controller")){ + UriBuilder builder = UriBuilder.fromUri(uriInfo.getBaseUri()) .path(SiteToSiteResource.class) - .replaceQuery(containerRequest.getRequestUri().getRawQuery()); + .replaceQuery(uriInfo.getRequestUri().getRawQuery()); URI redirectTo = builder.build(); - containerRequest.setUris(containerRequest.getBaseUri(), redirectTo); + requestContext.setRequestUri(uriInfo.getBaseUri(), redirectTo); } - return containerRequest; } } http://git-wip-us.apache.org/repos/asf/nifi/blob/6baea8cc/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/util/ClientResponseUtils.java ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/util/ClientResponseUtils.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/util/ClientResponseUtils.java index 6a587aa..5f49bf8 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/util/ClientResponseUtils.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/util/ClientResponseUtils.java @@ -16,15 +16,17 @@ */ package org.apache.nifi.web.util; -import com.sun.jersey.api.client.ClientResponse; -import java.io.BufferedInputStream; -import java.io.IOException; -import org.apache.nifi.stream.io.NullOutputStream; -import org.apache.nifi.logging.NiFiLog; import org.apache.commons.io.IOUtils; +import org.apache.nifi.logging.NiFiLog; +import org.apache.nifi.stream.io.NullOutputStream; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import javax.ws.rs.core.Response; +import java.io.BufferedInputStream; +import java.io.IOException; +import java.io.InputStream; + /** * */ @@ -32,11 +34,11 @@ public class ClientResponseUtils { private static final Logger logger = new NiFiLog(LoggerFactory.getLogger(ClientResponseUtils.class)); - public static void drainClientResponse(final ClientResponse clientResponse) { - if (clientResponse != null) { + public static void drainClientResponse(final Response response) { + if (response != null) { BufferedInputStream bis = null; try { - bis = new BufferedInputStream(clientResponse.getEntityInputStream()); + bis = new BufferedInputStream(response.readEntity(InputStream.class)); IOUtils.copy(bis, new NullOutputStream()); } catch (final IOException ioe) { logger.info("Failed clearing out non-client response buffer due to: " + ioe, ioe); http://git-wip-us.apache.org/repos/asf/nifi/blob/6baea8cc/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 f79b7c8..7fc33cf 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 @@ -414,40 +414,6 @@ <constructor-arg ref="flowController" /> </bean> - <!-- configuration for jaxb serialization --> - <bean class="org.apache.nifi.web.util.ObjectMapperResolver" scope="singleton"/> - - <!-- exception mapping --> - <bean class="org.apache.nifi.web.api.config.AccessDeniedExceptionMapper" scope="singleton"/> - <bean class="org.apache.nifi.web.api.config.AuthorizationAccessExceptionMapper" scope="singleton"/> - <bean class="org.apache.nifi.web.api.config.InvalidAuthenticationExceptionMapper" scope="singleton"/> - <bean class="org.apache.nifi.web.api.config.AuthenticationCredentialsNotFoundExceptionMapper" scope="singleton"/> - <bean class="org.apache.nifi.web.api.config.AdministrationExceptionMapper" scope="singleton"/> - <bean class="org.apache.nifi.web.api.config.ClusterExceptionMapper" scope="singleton"/> - <bean class="org.apache.nifi.web.api.config.IllegalArgumentExceptionMapper" scope="singleton"/> - <bean class="org.apache.nifi.web.api.config.IllegalClusterResourceRequestExceptionMapper" scope="singleton"/> - <bean class="org.apache.nifi.web.api.config.IllegalClusterStateExceptionMapper" scope="singleton"/> - <bean class="org.apache.nifi.web.api.config.IllegalNodeDeletionExceptionMapper" scope="singleton"/> - <bean class="org.apache.nifi.web.api.config.IllegalNodeDisconnectionExceptionMapper" scope="singleton"/> - <bean class="org.apache.nifi.web.api.config.IllegalNodeReconnectionExceptionMapper" scope="singleton"/> - <bean class="org.apache.nifi.web.api.config.IllegalStateExceptionMapper" scope="singleton"/> - <bean class="org.apache.nifi.web.api.config.InvalidRevisionExceptionMapper" scope="singleton"/> - <bean class="org.apache.nifi.web.api.config.JsonMappingExceptionMapper" scope="singleton"/> - <bean class="org.apache.nifi.web.api.config.JsonParseExceptionMapper" scope="singleton"/> - <bean class="org.apache.nifi.web.api.config.MutableRequestExceptionMapper" scope="singleton"/> - <bean class="org.apache.nifi.web.api.config.NiFiCoreExceptionMapper" scope="singleton"/> - <bean class="org.apache.nifi.web.api.config.NoConnectedNodesExceptionMapper" scope="singleton"/> - <bean class="org.apache.nifi.web.api.config.NoClusterCoordinatorExceptionMapper" scope="singleton"/> - <bean class="org.apache.nifi.web.api.config.NoResponseFromNodesExceptionMapper" scope="singleton"/> - <bean class="org.apache.nifi.web.api.config.NodeDisconnectionExceptionMapper" scope="singleton"/> - <bean class="org.apache.nifi.web.api.config.NodeReconnectionExceptionMapper" scope="singleton"/> - <bean class="org.apache.nifi.web.api.config.ResourceNotFoundExceptionMapper" scope="singleton"/> - <bean class="org.apache.nifi.web.api.config.NotFoundExceptionMapper" scope="singleton"/> - <bean class="org.apache.nifi.web.api.config.UnknownNodeExceptionMapper" scope="singleton"/> - <bean class="org.apache.nifi.web.api.config.ValidationExceptionMapper" scope="singleton"/> - <bean class="org.apache.nifi.web.api.config.WebApplicationExceptionMapper" scope="singleton"/> - <bean class="org.apache.nifi.web.api.config.ThrowableMapper" scope="singleton"/> - <!-- enable aop --> <!-- By setting '-target-class' to 'true' Spring will use CGLIB for http://git-wip-us.apache.org/repos/asf/nifi/blob/6baea8cc/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/webapp/WEB-INF/web.xml ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/webapp/WEB-INF/web.xml b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/webapp/WEB-INF/web.xml index 6575abe..1887710 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/webapp/WEB-INF/web.xml +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/webapp/WEB-INF/web.xml @@ -21,7 +21,7 @@ </context-param> <context-param> <param-name>contextConfigLocation</param-name> - <param-value>org.apache.nifi.web</param-value> + <param-value>org.apache.nifi.web.NiFiWebApiConfiguration</param-value> </context-param> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> @@ -31,15 +31,12 @@ </listener> <servlet> <servlet-name>jerseySpring</servlet-name> - <servlet-class>com.sun.jersey.spi.spring.container.servlet.SpringServlet</servlet-class> + <servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class> <init-param> - <param-name>com.sun.jersey.api.json.POJOMappingFeature</param-name> - <param-value>true</param-value> - </init-param> - <init-param> - <param-name>com.sun.jersey.spi.container.ContainerRequestFilters</param-name> - <param-value>org.apache.nifi.web.api.filter.RedirectResourceFilter</param-value> + <param-name>javax.ws.rs.Application</param-name> + <param-value>org.apache.nifi.web.NiFiWebApiResourceConfig</param-value> </init-param> + <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>jerseySpring</servlet-name> http://git-wip-us.apache.org/repos/asf/nifi/blob/6baea8cc/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 ce8f18a..3856220 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 @@ -16,9 +16,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 org.apache.nifi.connectable.ConnectableType; import org.apache.nifi.integration.util.NiFiTestUser; import org.apache.nifi.integration.util.SourceTestProcessor; @@ -39,6 +36,8 @@ import org.apache.nifi.web.api.entity.ProcessGroupEntity; import org.apache.nifi.web.api.entity.ProcessorEntity; import org.junit.Ignore; +import javax.ws.rs.client.Client; +import javax.ws.rs.core.Response; import java.util.HashSet; import java.util.Set; @@ -70,18 +69,18 @@ public class NiFiWebApiTest { processorEntity.setComponent(processorDTO); // add the processor - ClientResponse response = user.testPost(baseUrl + "/process-groups/root/processors", processorEntity); + Response response = user.testPost(baseUrl + "/process-groups/root/processors", processorEntity); // ensure a successful response - if (Status.CREATED.getStatusCode() != response.getStatusInfo().getStatusCode()) { + if (Response.Status.CREATED.getStatusCode() != response.getStatusInfo().getStatusCode()) { // since it was unable to create the component attempt to extract an // error message from the response body - final String responseEntity = response.getEntity(String.class); + final String responseEntity = response.readEntity(String.class); throw new Exception("Unable to populate initial flow: " + responseEntity); } // get the processors id - processorEntity = response.getEntity(ProcessorEntity.class); + processorEntity = response.readEntity(ProcessorEntity.class); processorDTO = processorEntity.getComponent(); String localSelectionId = processorDTO.getId(); String localSelectionGroupId = processorDTO.getParentGroupId(); @@ -104,15 +103,15 @@ public class NiFiWebApiTest { response = user.testPost(baseUrl + "/process-groups/root/processors", processorEntity); // ensure a successful response - if (Status.CREATED.getStatusCode() != response.getStatusInfo().getStatusCode()) { + if (Response.Status.CREATED.getStatusCode() != response.getStatusInfo().getStatusCode()) { // since it was unable to create the component attempt to extract an // error message from the response body - final String responseEntity = response.getEntity(String.class); + final String responseEntity = response.readEntity(String.class); throw new Exception("Unable to populate initial flow: " + responseEntity); } // get the processors id - processorEntity = response.getEntity(ProcessorEntity.class); + processorEntity = response.readEntity(ProcessorEntity.class); processorDTO = processorEntity.getComponent(); String terminationId = processorDTO.getId(); String terminationGroupId = processorDTO.getParentGroupId(); @@ -150,10 +149,10 @@ public class NiFiWebApiTest { response = user.testPost(baseUrl + "/process-groups/root/connections", connectionEntity); // ensure a successful response - if (Status.CREATED.getStatusCode() != response.getStatusInfo().getStatusCode()) { + if (Response.Status.CREATED.getStatusCode() != response.getStatusInfo().getStatusCode()) { // since it was unable to create the component attempt to extract an // error message from the response body - final String responseEntity = response.getEntity(String.class); + final String responseEntity = response.readEntity(String.class); throw new Exception("Unable to populate initial flow: " + responseEntity); } @@ -174,10 +173,10 @@ public class NiFiWebApiTest { response = user.testPost(baseUrl + "/process-groups/root/labels", labelEntity); // ensure a successful response - if (Status.CREATED.getStatusCode() != response.getStatusInfo().getStatusCode()) { + if (Response.Status.CREATED.getStatusCode() != response.getStatusInfo().getStatusCode()) { // since it was unable to create the component attempt to extract an // error message from the response body - final String responseEntity = response.getEntity(String.class); + final String responseEntity = response.readEntity(String.class); throw new Exception("Unable to populate initial flow: " + responseEntity); } @@ -197,10 +196,10 @@ public class NiFiWebApiTest { response = user.testPost(baseUrl + "/process-groups/root/funnels", funnelEntity); // ensure a successful response - if (Status.CREATED.getStatusCode() != response.getStatusInfo().getStatusCode()) { + if (Response.Status.CREATED.getStatusCode() != response.getStatusInfo().getStatusCode()) { // since it was unable to create the component attempt to extract an // error message from the response body - final String responseEntity = response.getEntity(String.class); + final String responseEntity = response.readEntity(String.class); throw new Exception("Unable to populate initial flow: " + responseEntity); } @@ -221,10 +220,10 @@ public class NiFiWebApiTest { response = user.testPost(baseUrl + "/process-groups/root/process-groups", processGroupEntity); // ensure a successful response - if (Status.CREATED.getStatusCode() != response.getStatusInfo().getStatusCode()) { + if (Response.Status.CREATED.getStatusCode() != response.getStatusInfo().getStatusCode()) { // since it was unable to create the component attempt to extract an // error message from the response body - final String responseEntity = response.getEntity(String.class); + final String responseEntity = response.readEntity(String.class); throw new Exception("Unable to populate initial flow: " + responseEntity); } @@ -245,10 +244,10 @@ public class NiFiWebApiTest { response = user.testPost(baseUrl + "/process-groups/root/input-ports", inputPortEntity); // ensure a successful response - if (Status.CREATED.getStatusCode() != response.getStatusInfo().getStatusCode()) { + if (Response.Status.CREATED.getStatusCode() != response.getStatusInfo().getStatusCode()) { // since it was unable to create the component attempt to extract an // error message from the response body - final String responseEntity = response.getEntity(String.class); + final String responseEntity = response.readEntity(String.class); throw new Exception("Unable to populate initial flow: " + responseEntity); } @@ -269,10 +268,10 @@ public class NiFiWebApiTest { response = user.testPost(baseUrl + "/process-groups/root/output-ports", outputPortEntity); // ensure a successful response - if (Status.CREATED.getStatusCode() != response.getStatusInfo().getStatusCode()) { + if (Response.Status.CREATED.getStatusCode() != response.getStatusInfo().getStatusCode()) { // since it was unable to create the component attempt to extract an // error message from the response body - final String responseEntity = response.getEntity(String.class); + final String responseEntity = response.readEntity(String.class); throw new Exception("Unable to populate initial flow: " + responseEntity); } http://git-wip-us.apache.org/repos/asf/nifi/blob/6baea8cc/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/test/java/org/apache/nifi/integration/accesscontrol/AccessControlHelper.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/AccessControlHelper.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/test/java/org/apache/nifi/integration/accesscontrol/AccessControlHelper.java index b425856..a7293b2 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/test/java/org/apache/nifi/integration/accesscontrol/AccessControlHelper.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/test/java/org/apache/nifi/integration/accesscontrol/AccessControlHelper.java @@ -16,7 +16,6 @@ */ package org.apache.nifi.integration.accesscontrol; -import com.sun.jersey.api.client.ClientResponse; import org.apache.nifi.bundle.Bundle; import org.apache.nifi.integration.NiFiWebApiTest; import org.apache.nifi.integration.util.NiFiTestAuthorizer; @@ -27,6 +26,7 @@ import org.apache.nifi.nar.NarClassLoaders; import org.apache.nifi.nar.SystemBundle; import org.apache.nifi.util.NiFiProperties; +import javax.ws.rs.core.Response; import java.io.File; import static org.junit.Assert.assertEquals; @@ -109,7 +109,7 @@ public class AccessControlHelper { } public void testGenericGetUri(final String uri) throws Exception { - ClientResponse response; + Response response; // read response = getReadUser().testGet(uri); http://git-wip-us.apache.org/repos/asf/nifi/blob/6baea8cc/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/test/java/org/apache/nifi/integration/accesscontrol/ITAccessTokenEndpoint.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/ITAccessTokenEndpoint.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/test/java/org/apache/nifi/integration/accesscontrol/ITAccessTokenEndpoint.java index 8deffe7..aa8c154 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/test/java/org/apache/nifi/integration/accesscontrol/ITAccessTokenEndpoint.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/test/java/org/apache/nifi/integration/accesscontrol/ITAccessTokenEndpoint.java @@ -16,8 +16,6 @@ */ package org.apache.nifi.integration.accesscontrol; -import com.sun.jersey.api.client.Client; -import com.sun.jersey.api.client.ClientResponse; import org.apache.commons.io.FileUtils; import org.apache.nifi.bundle.Bundle; import org.apache.nifi.integration.util.NiFiTestServer; @@ -42,6 +40,8 @@ import org.junit.BeforeClass; import org.junit.Test; import javax.net.ssl.SSLContext; +import javax.ws.rs.client.Client; +import javax.ws.rs.core.Response; import java.io.File; import java.util.HashMap; import java.util.Map; @@ -107,13 +107,13 @@ public class ITAccessTokenEndpoint { public void testGetAccessConfig() throws Exception { String url = BASE_URL + "/access/config"; - ClientResponse response = TOKEN_USER.testGet(url); + Response response = TOKEN_USER.testGet(url); // ensure the request is successful Assert.assertEquals(200, response.getStatus()); // extract the process group - AccessConfigurationEntity accessConfigEntity = response.getEntity(AccessConfigurationEntity.class); + AccessConfigurationEntity accessConfigEntity = response.readEntity(AccessConfigurationEntity.class); // ensure there is content Assert.assertNotNull(accessConfigEntity); @@ -134,13 +134,13 @@ public class ITAccessTokenEndpoint { public void testCreateProcessorUsingToken() throws Exception { String url = BASE_URL + "/access/token"; - ClientResponse response = TOKEN_USER.testCreateToken(url, "user@nifi", "whatever"); + Response response = TOKEN_USER.testCreateToken(url, "user@nifi", "whatever"); // ensure the request is successful Assert.assertEquals(201, response.getStatus()); // get the token - String token = response.getEntity(String.class); + String token = response.readEntity(String.class); // attempt to create a processor with it createProcessor(token); @@ -169,13 +169,13 @@ public class ITAccessTokenEndpoint { entity.setComponent(processor); // perform the request - ClientResponse response = TOKEN_USER.testPostWithHeaders(url, entity, headers); + Response response = TOKEN_USER.testPostWithHeaders(url, entity, headers); // ensure the request is successful Assert.assertEquals(201, response.getStatus()); // get the entity body - entity = response.getEntity(ProcessorEntity.class); + entity = response.readEntity(ProcessorEntity.class); // verify creation processor = entity.getComponent(); @@ -194,7 +194,7 @@ public class ITAccessTokenEndpoint { public void testInvalidCredentials() throws Exception { String url = BASE_URL + "/access/token"; - ClientResponse response = TOKEN_USER.testCreateToken(url, "user@nifi", "not a real password"); + Response response = TOKEN_USER.testCreateToken(url, "user@nifi", "not a real password"); // ensure the request is successful Assert.assertEquals(400, response.getStatus()); @@ -209,7 +209,7 @@ public class ITAccessTokenEndpoint { public void testUnknownUser() throws Exception { String url = BASE_URL + "/access/token"; - ClientResponse response = TOKEN_USER.testCreateToken(url, "not a real user", "not a real password"); + Response response = TOKEN_USER.testCreateToken(url, "not a real user", "not a real password"); // ensure the request is successful Assert.assertEquals(400, response.getStatus()); @@ -225,12 +225,12 @@ public class ITAccessTokenEndpoint { String accessStatusUrl = BASE_URL + "/access"; String accessTokenUrl = BASE_URL + "/access/token"; - ClientResponse response = TOKEN_USER.testGet(accessStatusUrl); + Response response = TOKEN_USER.testGet(accessStatusUrl); // ensure the request is successful Assert.assertEquals(200, response.getStatus()); - AccessStatusEntity accessStatusEntity = response.getEntity(AccessStatusEntity.class); + AccessStatusEntity accessStatusEntity = response.readEntity(AccessStatusEntity.class); AccessStatusDTO accessStatus = accessStatusEntity.getAccessStatus(); // verify unknown @@ -242,7 +242,7 @@ public class ITAccessTokenEndpoint { Assert.assertEquals(201, response.getStatus()); // get the token - String token = response.getEntity(String.class); + String token = response.readEntity(String.class); // authorization header Map<String, String> headers = new HashMap<>(); @@ -254,7 +254,7 @@ public class ITAccessTokenEndpoint { // ensure the request is successful Assert.assertEquals(200, response.getStatus()); - accessStatusEntity = response.getEntity(AccessStatusEntity.class); + accessStatusEntity = response.readEntity(AccessStatusEntity.class); accessStatus = accessStatusEntity.getAccessStatus(); // verify unregistered http://git-wip-us.apache.org/repos/asf/nifi/blob/6baea8cc/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/test/java/org/apache/nifi/integration/accesscontrol/ITConnectionAccessControl.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/ITConnectionAccessControl.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/test/java/org/apache/nifi/integration/accesscontrol/ITConnectionAccessControl.java index bb2d4eb..e78a88e 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/test/java/org/apache/nifi/integration/accesscontrol/ITConnectionAccessControl.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/test/java/org/apache/nifi/integration/accesscontrol/ITConnectionAccessControl.java @@ -16,7 +16,6 @@ */ package org.apache.nifi.integration.accesscontrol; -import com.sun.jersey.api.client.ClientResponse; import org.apache.nifi.connectable.ConnectableType; import org.apache.nifi.integration.util.NiFiTestAuthorizer; import org.apache.nifi.integration.util.NiFiTestUser; @@ -31,6 +30,7 @@ import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; +import javax.ws.rs.core.Response; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; @@ -128,7 +128,7 @@ public class ITConnectionAccessControl { entity.getComponent().setName("Updated Name"); // perform the request - final ClientResponse response = updateConnection(helper.getReadUser(), entity); + final Response response = updateConnection(helper.getReadUser(), entity); // ensure forbidden response assertEquals(403, response.getStatus()); @@ -154,13 +154,13 @@ public class ITConnectionAccessControl { entity.getComponent().setName(updatedName); // perform the request - final ClientResponse response = updateConnection(helper.getReadWriteUser(), entity); + final Response response = updateConnection(helper.getReadWriteUser(), entity); // ensure successful response assertEquals(200, response.getStatus()); // get the response - final ConnectionEntity responseEntity = response.getEntity(ConnectionEntity.class); + final ConnectionEntity responseEntity = response.readEntity(ConnectionEntity.class); // verify assertEquals(READ_WRITE_CLIENT_ID, responseEntity.getRevision().getClientId()); @@ -185,13 +185,13 @@ public class ITConnectionAccessControl { entity.getComponent().setName(updatedName); // perform the request - final ClientResponse response = updateConnection(helper.getReadWriteUser(), entity); + final Response response = updateConnection(helper.getReadWriteUser(), entity); // ensure successful response assertEquals(200, response.getStatus()); // get the response - final ConnectionEntity responseEntity = response.getEntity(ConnectionEntity.class); + final ConnectionEntity responseEntity = response.readEntity(ConnectionEntity.class); // verify assertEquals(AccessControlHelper.READ_WRITE_CLIENT_ID, responseEntity.getRevision().getClientId()); @@ -229,13 +229,13 @@ public class ITConnectionAccessControl { requestEntity.setComponent(requestDto); // perform the request - final ClientResponse response = updateConnection(helper.getWriteUser(), requestEntity); + final Response response = updateConnection(helper.getWriteUser(), requestEntity); // ensure successful response assertEquals(200, response.getStatus()); // get the response - final ConnectionEntity responseEntity = response.getEntity(ConnectionEntity.class); + final ConnectionEntity responseEntity = response.readEntity(ConnectionEntity.class); // verify assertEquals(WRITE_CLIENT_ID, responseEntity.getRevision().getClientId()); @@ -272,7 +272,7 @@ public class ITConnectionAccessControl { requestEntity.setComponent(requestDto); // perform the request - final ClientResponse response = updateConnection(helper.getNoneUser(), requestEntity); + final Response response = updateConnection(helper.getNoneUser(), requestEntity); // ensure forbidden response assertEquals(403, response.getStatus()); @@ -322,13 +322,13 @@ public class ITConnectionAccessControl { final String url = helper.getBaseUrl() + "/flow/process-groups/root"; // get the connections - final ClientResponse response = user.testGet(url); + final Response response = user.testGet(url); // ensure the response was successful assertEquals(200, response.getStatus()); // unmarshal - final ProcessGroupFlowEntity flowEntity = response.getEntity(ProcessGroupFlowEntity.class); + final ProcessGroupFlowEntity flowEntity = response.readEntity(ProcessGroupFlowEntity.class); final FlowDTO flowDto = flowEntity.getProcessGroupFlow().getFlow(); final Set<ConnectionEntity> connections = flowDto.getConnections(); @@ -341,7 +341,7 @@ public class ITConnectionAccessControl { return connectionIter.next(); } - private ClientResponse updateConnection(final NiFiTestUser user, final ConnectionEntity entity) throws Exception { + private Response updateConnection(final NiFiTestUser user, final ConnectionEntity entity) throws Exception { final String url = helper.getBaseUrl() + "/connections/" + entity.getId(); // perform the request @@ -389,13 +389,13 @@ public class ITConnectionAccessControl { entity.setComponent(connection); // perform the request - ClientResponse response = helper.getReadWriteUser().testPost(url, entity); + Response response = helper.getReadWriteUser().testPost(url, entity); // ensure the request is successful assertEquals(201, response.getStatus()); // get the entity body - entity = response.getEntity(ConnectionEntity.class); + entity = response.readEntity(ConnectionEntity.class); // verify creation connection = entity.getComponent(); @@ -414,7 +414,7 @@ public class ITConnectionAccessControl { queryParams.put("clientId", clientId); // perform the request - ClientResponse response = user.testDelete(entity.getUri(), queryParams); + Response response = user.testDelete(entity.getUri(), queryParams); // ensure the request is failed with a forbidden status code assertEquals(responseCode, response.getStatus()); http://git-wip-us.apache.org/repos/asf/nifi/blob/6baea8cc/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/test/java/org/apache/nifi/integration/accesscontrol/ITCountersAccessControl.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/ITCountersAccessControl.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/test/java/org/apache/nifi/integration/accesscontrol/ITCountersAccessControl.java index 7d4ee10..db69ae9 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/test/java/org/apache/nifi/integration/accesscontrol/ITCountersAccessControl.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/test/java/org/apache/nifi/integration/accesscontrol/ITCountersAccessControl.java @@ -16,11 +16,11 @@ */ package org.apache.nifi.integration.accesscontrol; -import com.sun.jersey.api.client.ClientResponse; import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; +import javax.ws.rs.core.Response; import java.util.Collections; import static org.junit.Assert.assertEquals; @@ -58,7 +58,7 @@ public class ITCountersAccessControl { public void testUpdateCounters() throws Exception { final String counterUri = uri + "/my-counter"; - ClientResponse response; + Response response; // read response = helper.getReadUser().testPut(counterUri, Collections.emptyMap()); http://git-wip-us.apache.org/repos/asf/nifi/blob/6baea8cc/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/test/java/org/apache/nifi/integration/accesscontrol/ITFlowAccessControl.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/ITFlowAccessControl.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/test/java/org/apache/nifi/integration/accesscontrol/ITFlowAccessControl.java index 0deffef..7796ffe 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/test/java/org/apache/nifi/integration/accesscontrol/ITFlowAccessControl.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/test/java/org/apache/nifi/integration/accesscontrol/ITFlowAccessControl.java @@ -16,11 +16,12 @@ */ package org.apache.nifi.integration.accesscontrol; -import com.sun.jersey.api.client.ClientResponse; import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; +import javax.ws.rs.core.Response; + import static org.junit.Assert.assertEquals; /** @@ -185,7 +186,7 @@ public class ITFlowAccessControl { public void testGetAction() throws Exception { final String uri = helper.getBaseUrl() + "/flow/history/98766"; - ClientResponse response; + Response response; // the action does not exist... should return 404 @@ -220,7 +221,7 @@ public class ITFlowAccessControl { // will succeed due to controller level access // read - ClientResponse response = helper.getReadUser().testGet(uri); + Response response = helper.getReadUser().testGet(uri); assertEquals(200, response.getStatus()); // read/write @@ -239,7 +240,7 @@ public class ITFlowAccessControl { } public void testComponentSpecificGetUri(final String uri) throws Exception { - ClientResponse response; + Response response; // read response = helper.getReadUser().testGet(uri); http://git-wip-us.apache.org/repos/asf/nifi/blob/6baea8cc/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/test/java/org/apache/nifi/integration/accesscontrol/ITFunnelAccessControl.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/ITFunnelAccessControl.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/test/java/org/apache/nifi/integration/accesscontrol/ITFunnelAccessControl.java index 663ee48..a340ff0 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/test/java/org/apache/nifi/integration/accesscontrol/ITFunnelAccessControl.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/test/java/org/apache/nifi/integration/accesscontrol/ITFunnelAccessControl.java @@ -16,7 +16,6 @@ */ package org.apache.nifi.integration.accesscontrol; -import com.sun.jersey.api.client.ClientResponse; import org.apache.nifi.integration.util.NiFiTestUser; import org.apache.nifi.web.api.dto.FunnelDTO; import org.apache.nifi.web.api.dto.PositionDTO; @@ -28,6 +27,7 @@ import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; +import javax.ws.rs.core.Response; import java.util.HashMap; import java.util.Iterator; import java.util.Map; @@ -124,7 +124,7 @@ public class ITFunnelAccessControl { entity.getComponent().setPosition(new PositionDTO(0.0, 10.0)); // perform the request - final ClientResponse response = updateFunnel(helper.getReadUser(), entity); + final Response response = updateFunnel(helper.getReadUser(), entity); // ensure forbidden response assertEquals(403, response.getStatus()); @@ -150,13 +150,13 @@ public class ITFunnelAccessControl { entity.getComponent().setPosition(new PositionDTO(0.0, y)); // perform the request - final ClientResponse response = updateFunnel(helper.getReadWriteUser(), entity); + final Response response = updateFunnel(helper.getReadWriteUser(), entity); // ensure successful response assertEquals(200, response.getStatus()); // get the response - final FunnelEntity responseEntity = response.getEntity(FunnelEntity.class); + final FunnelEntity responseEntity = response.readEntity(FunnelEntity.class); // verify assertEquals(READ_WRITE_CLIENT_ID, responseEntity.getRevision().getClientId()); @@ -194,13 +194,13 @@ public class ITFunnelAccessControl { requestEntity.setComponent(requestDto); // perform the request - final ClientResponse response = updateFunnel(helper.getWriteUser(), requestEntity); + final Response response = updateFunnel(helper.getWriteUser(), requestEntity); // ensure successful response assertEquals(200, response.getStatus()); // get the response - final FunnelEntity responseEntity = response.getEntity(FunnelEntity.class); + final FunnelEntity responseEntity = response.readEntity(FunnelEntity.class); // verify assertEquals(WRITE_CLIENT_ID, responseEntity.getRevision().getClientId()); @@ -235,7 +235,7 @@ public class ITFunnelAccessControl { requestEntity.setComponent(requestDto); // perform the request - final ClientResponse response = updateFunnel(helper.getNoneUser(), requestEntity); + final Response response = updateFunnel(helper.getNoneUser(), requestEntity); // ensure forbidden response assertEquals(403, response.getStatus()); @@ -285,13 +285,13 @@ public class ITFunnelAccessControl { final String url = helper.getBaseUrl() + "/flow/process-groups/root"; // get the flow - final ClientResponse response = user.testGet(url); + final Response response = user.testGet(url); // ensure the response was successful assertEquals(200, response.getStatus()); // unmarshal - final ProcessGroupFlowEntity flowEntity = response.getEntity(ProcessGroupFlowEntity.class); + final ProcessGroupFlowEntity flowEntity = response.readEntity(ProcessGroupFlowEntity.class); final FlowDTO flowDto = flowEntity.getProcessGroupFlow().getFlow(); final Set<FunnelEntity> funnels = flowDto.getFunnels(); @@ -304,7 +304,7 @@ public class ITFunnelAccessControl { return funnelIter.next(); } - private ClientResponse updateFunnel(final NiFiTestUser user, final FunnelEntity entity) throws Exception { + private Response updateFunnel(final NiFiTestUser user, final FunnelEntity entity) throws Exception { final String url = helper.getBaseUrl() + "/funnels/" + entity.getId(); // perform the request @@ -328,13 +328,13 @@ public class ITFunnelAccessControl { entity.setComponent(funnel); // perform the request - ClientResponse response = helper.getReadWriteUser().testPost(url, entity); + Response response = helper.getReadWriteUser().testPost(url, entity); // ensure the request is successful assertEquals(201, response.getStatus()); // get the entity body - return response.getEntity(FunnelEntity.class); + return response.readEntity(FunnelEntity.class); } private void verifyDelete(final NiFiTestUser user, final String clientId, final int responseCode) throws Exception { @@ -346,7 +346,7 @@ public class ITFunnelAccessControl { queryParams.put("clientId", clientId); // perform the request - ClientResponse response = user.testDelete(entity.getUri(), queryParams); + Response response = user.testDelete(entity.getUri(), queryParams); // ensure the request is failed with a forbidden status code assertEquals(responseCode, response.getStatus()); http://git-wip-us.apache.org/repos/asf/nifi/blob/6baea8cc/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/test/java/org/apache/nifi/integration/accesscontrol/ITInputPortAccessControl.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/ITInputPortAccessControl.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/test/java/org/apache/nifi/integration/accesscontrol/ITInputPortAccessControl.java index 2cb2264..673428f 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/test/java/org/apache/nifi/integration/accesscontrol/ITInputPortAccessControl.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/test/java/org/apache/nifi/integration/accesscontrol/ITInputPortAccessControl.java @@ -16,7 +16,6 @@ */ package org.apache.nifi.integration.accesscontrol; -import com.sun.jersey.api.client.ClientResponse; import org.apache.nifi.integration.util.NiFiTestAuthorizer; import org.apache.nifi.integration.util.NiFiTestUser; import org.apache.nifi.web.api.dto.PortDTO; @@ -28,6 +27,7 @@ import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; +import javax.ws.rs.core.Response; import java.util.HashMap; import java.util.Iterator; import java.util.Map; @@ -125,7 +125,7 @@ public class ITInputPortAccessControl { entity.getComponent().setName("Updated Name" + count++); // perform the request - final ClientResponse response = updateInputPort(helper.getReadUser(), entity); + final Response response = updateInputPort(helper.getReadUser(), entity); // ensure forbidden response assertEquals(403, response.getStatus()); @@ -151,13 +151,13 @@ public class ITInputPortAccessControl { entity.getComponent().setName(updatedName); // perform the request - final ClientResponse response = updateInputPort(helper.getReadWriteUser(), entity); + final Response response = updateInputPort(helper.getReadWriteUser(), entity); // ensure successful response assertEquals(200, response.getStatus()); // get the response - final PortEntity responseEntity = response.getEntity(PortEntity.class); + final PortEntity responseEntity = response.readEntity(PortEntity.class); // verify assertEquals(READ_WRITE_CLIENT_ID, responseEntity.getRevision().getClientId()); @@ -182,13 +182,13 @@ public class ITInputPortAccessControl { entity.getComponent().setName(updatedName); // perform the request - final ClientResponse response = updateInputPort(helper.getReadWriteUser(), entity); + final Response response = updateInputPort(helper.getReadWriteUser(), entity); // ensure successful response assertEquals(200, response.getStatus()); // get the response - final PortEntity responseEntity = response.getEntity(PortEntity.class); + final PortEntity responseEntity = response.readEntity(PortEntity.class); // verify assertEquals(AccessControlHelper.READ_WRITE_CLIENT_ID, responseEntity.getRevision().getClientId()); @@ -226,13 +226,13 @@ public class ITInputPortAccessControl { requestEntity.setComponent(requestDto); // perform the request - final ClientResponse response = updateInputPort(helper.getWriteUser(), requestEntity); + final Response response = updateInputPort(helper.getWriteUser(), requestEntity); // ensure successful response assertEquals(200, response.getStatus()); // get the response - final PortEntity responseEntity = response.getEntity(PortEntity.class); + final PortEntity responseEntity = response.readEntity(PortEntity.class); // verify assertEquals(WRITE_CLIENT_ID, responseEntity.getRevision().getClientId()); @@ -269,7 +269,7 @@ public class ITInputPortAccessControl { requestEntity.setComponent(requestDto); // perform the request - final ClientResponse response = updateInputPort(helper.getNoneUser(), requestEntity); + final Response response = updateInputPort(helper.getNoneUser(), requestEntity); // ensure forbidden response assertEquals(403, response.getStatus()); @@ -319,13 +319,13 @@ public class ITInputPortAccessControl { final String url = helper.getBaseUrl() + "/flow/process-groups/root"; // get the input ports - final ClientResponse response = user.testGet(url); + final Response response = user.testGet(url); // ensure the response was successful assertEquals(200, response.getStatus()); // unmarshal - final ProcessGroupFlowEntity flowEntity = response.getEntity(ProcessGroupFlowEntity.class); + final ProcessGroupFlowEntity flowEntity = response.readEntity(ProcessGroupFlowEntity.class); final FlowDTO flowDto = flowEntity.getProcessGroupFlow().getFlow(); final Set<PortEntity> inputPorts = flowDto.getInputPorts(); @@ -338,7 +338,7 @@ public class ITInputPortAccessControl { return inputPortIter.next(); } - private ClientResponse updateInputPort(final NiFiTestUser user, final PortEntity entity) throws Exception { + private Response updateInputPort(final NiFiTestUser user, final PortEntity entity) throws Exception { final String url = helper.getBaseUrl() + "/input-ports/" + entity.getId(); // perform the request @@ -365,13 +365,13 @@ public class ITInputPortAccessControl { entity.setComponent(inputPort); // perform the request - ClientResponse response = helper.getReadWriteUser().testPost(url, entity); + Response response = helper.getReadWriteUser().testPost(url, entity); // ensure the request is successful assertEquals(201, response.getStatus()); // get the entity body - entity = response.getEntity(PortEntity.class); + entity = response.readEntity(PortEntity.class); // verify creation inputPort = entity.getComponent(); @@ -390,7 +390,7 @@ public class ITInputPortAccessControl { queryParams.put("clientId", clientId); // perform the request - ClientResponse response = user.testDelete(entity.getUri(), queryParams); + Response response = user.testDelete(entity.getUri(), queryParams); // ensure the request is failed with a forbidden status code assertEquals(responseCode, response.getStatus());
