You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nifi.apache.org by ma...@apache.org on 2016/04/15 22:04:05 UTC
[13/22] nifi git commit: NIFI-1551: - Removing the AuthorityProvider.
- Refactoring REST API in preparation for introduction of the Authorizer. -
Updating UI accordingly. - Removing unneeded properties from nifi.properties.
- Addressing comments from PR.
http://git-wip-us.apache.org/repos/asf/nifi/blob/153f63ef/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/ConnectionResource.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/ConnectionResource.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/ConnectionResource.java
index 712233f..fd4a81c 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/ConnectionResource.java
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/ConnectionResource.java
@@ -16,7 +16,6 @@
*/
package org.apache.nifi.web.api;
-import com.wordnik.swagger.annotations.Api;
import com.wordnik.swagger.annotations.ApiOperation;
import com.wordnik.swagger.annotations.ApiParam;
import com.wordnik.swagger.annotations.ApiResponse;
@@ -36,34 +35,27 @@ import org.apache.nifi.web.ConfigurationSnapshot;
import org.apache.nifi.web.DownloadableContent;
import org.apache.nifi.web.NiFiServiceFacade;
import org.apache.nifi.web.Revision;
-import org.apache.nifi.web.api.dto.ConnectableDTO;
import org.apache.nifi.web.api.dto.ConnectionDTO;
import org.apache.nifi.web.api.dto.DropRequestDTO;
import org.apache.nifi.web.api.dto.FlowFileDTO;
import org.apache.nifi.web.api.dto.FlowFileSummaryDTO;
import org.apache.nifi.web.api.dto.ListingRequestDTO;
-import org.apache.nifi.web.api.dto.PositionDTO;
import org.apache.nifi.web.api.dto.RevisionDTO;
import org.apache.nifi.web.api.dto.status.ConnectionStatusDTO;
import org.apache.nifi.web.api.dto.status.StatusHistoryDTO;
import org.apache.nifi.web.api.entity.ConnectionEntity;
import org.apache.nifi.web.api.entity.ConnectionStatusEntity;
-import org.apache.nifi.web.api.entity.ConnectionsEntity;
import org.apache.nifi.web.api.entity.DropRequestEntity;
import org.apache.nifi.web.api.entity.FlowFileEntity;
import org.apache.nifi.web.api.entity.ListingRequestEntity;
import org.apache.nifi.web.api.entity.StatusHistoryEntity;
import org.apache.nifi.web.api.request.ClientIdParameter;
-import org.apache.nifi.web.api.request.ConnectableTypeParameter;
-import org.apache.nifi.web.api.request.IntegerParameter;
import org.apache.nifi.web.api.request.LongParameter;
-import org.springframework.security.access.prepost.PreAuthorize;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.DefaultValue;
-import javax.ws.rs.FormParam;
import javax.ws.rs.GET;
import javax.ws.rs.HttpMethod;
import javax.ws.rs.POST;
@@ -75,7 +67,6 @@ import javax.ws.rs.QueryParam;
import javax.ws.rs.WebApplicationException;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.Status;
import javax.ws.rs.core.StreamingOutput;
@@ -83,12 +74,9 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URI;
-import java.net.URISyntaxException;
import java.nio.charset.StandardCharsets;
-import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
-import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
@@ -96,13 +84,12 @@ import java.util.UUID;
/**
* RESTful endpoint for managing a Connection.
*/
-@Api(hidden = true)
+@Path("connections")
public class ConnectionResource extends ApplicationResource {
private NiFiServiceFacade serviceFacade;
private WebClusterManager clusterManager;
private NiFiProperties properties;
- private String groupId;
/**
* Populate the URIs for the specified connections.
@@ -123,9 +110,9 @@ public class ConnectionResource extends ApplicationResource {
* @param connection connection
* @return dto
*/
- private ConnectionDTO populateRemainingConnectionContent(ConnectionDTO connection) {
+ public ConnectionDTO populateRemainingConnectionContent(ConnectionDTO connection) {
// populate the remaining properties
- connection.setUri(generateResourceUri("controller", "process-groups", groupId, "connections", connection.getId()));
+ connection.setUri(generateResourceUri("connections", connection.getId()));
return connection;
}
@@ -138,7 +125,7 @@ public class ConnectionResource extends ApplicationResource {
*/
public ListingRequestDTO populateRemainingFlowFileListingContent(final String connectionId, final ListingRequestDTO flowFileListing) {
// uri of the listing
- flowFileListing.setUri(generateResourceUri("controller", "process-groups", groupId, "connections", connectionId, "listing-requests", flowFileListing.getId()));
+ flowFileListing.setUri(generateResourceUri("connections", connectionId, "listing-requests", flowFileListing.getId()));
// uri of each flowfile
if (flowFileListing.getFlowFileSummaries() != null) {
@@ -156,69 +143,12 @@ public class ConnectionResource extends ApplicationResource {
* @param flowFile the flowfile
* @return the dto
*/
- private FlowFileSummaryDTO populateRemainingFlowFileContent(final String connectionId, final FlowFileSummaryDTO flowFile) {
- flowFile.setUri(generateResourceUri("controller", "process-groups", groupId, "connections", connectionId, "flowfiles", flowFile.getUuid()));
+ public FlowFileSummaryDTO populateRemainingFlowFileContent(final String connectionId, final FlowFileSummaryDTO flowFile) {
+ flowFile.setUri(generateResourceUri("connections", connectionId, "flowfiles", flowFile.getUuid()));
return flowFile;
}
/**
- * Gets all the connections.
- *
- * @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.
- * @return A connectionsEntity.
- */
- @GET
- @Consumes(MediaType.WILDCARD)
- @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
- @Path("") // necessary due to bug in swagger
- @PreAuthorize("hasAnyRole('ROLE_MONITOR', 'ROLE_DFM', 'ROLE_ADMIN')")
- @ApiOperation(
- value = "Gets all connections",
- response = ConnectionsEntity.class,
- authorizations = {
- @Authorization(value = "Read Only", type = "ROLE_MONITOR"),
- @Authorization(value = "Data Flow Manager", type = "ROLE_DFM"),
- @Authorization(value = "Administrator", type = "ROLE_ADMIN")
- }
- )
- @ApiResponses(
- value = {
- @ApiResponse(code = 400, message = "NiFi was unable to complete the request because it was invalid. The request should not be retried without modification."),
- @ApiResponse(code = 401, message = "Client could not be authenticated."),
- @ApiResponse(code = 403, message = "Client is not authorized to make this request."),
- @ApiResponse(code = 404, message = "The specified resource could not be found."),
- @ApiResponse(code = 409, message = "The request was valid but NiFi was not in the appropriate state to process it. Retrying the same request later may be successful.")
- }
- )
- public Response getConnections(
- @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) {
-
- // replicate if cluster manager
- if (properties.isClusterManager()) {
- return clusterManager.applyRequest(HttpMethod.GET, getAbsolutePath(), getRequestParameters(true), getHeaders()).getResponse();
- }
-
- // all of the relationships for the specified source processor
- Set<ConnectionDTO> connections = serviceFacade.getConnections(groupId);
-
- // create the revision
- RevisionDTO revision = new RevisionDTO();
- revision.setClientId(clientId.getClientId());
-
- // create the client response entity
- ConnectionsEntity entity = new ConnectionsEntity();
- entity.setRevision(revision);
- entity.setConnections(populateRemainingConnectionsContent(connections));
-
- // generate the response
- return clusterContext(generateOkResponse(entity)).build();
- }
-
- /**
* Retrieves the specified connection.
*
* @param clientId Optional client id. If the client id is not specified, a new one will be generated. This value (whether specified or generated) is included in the response.
@@ -227,9 +157,9 @@ public class ConnectionResource extends ApplicationResource {
*/
@GET
@Consumes(MediaType.WILDCARD)
- @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
+ @Produces(MediaType.APPLICATION_JSON)
@Path("/{id}")
- @PreAuthorize("hasAnyRole('ROLE_MONITOR', 'ROLE_DFM', 'ROLE_ADMIN')")
+ // TODO - @PreAuthorize("hasAnyRole('ROLE_MONITOR', 'ROLE_DFM', 'ROLE_ADMIN')")
@ApiOperation(
value = "Gets a connection",
response = ConnectionEntity.class,
@@ -266,7 +196,7 @@ public class ConnectionResource extends ApplicationResource {
}
// get the specified relationship
- ConnectionDTO connection = serviceFacade.getConnection(groupId, id);
+ ConnectionDTO connection = serviceFacade.getConnection(id);
// create the revision
RevisionDTO revision = new RevisionDTO();
@@ -290,9 +220,9 @@ public class ConnectionResource extends ApplicationResource {
*/
@GET
@Consumes(MediaType.WILDCARD)
- @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
+ @Produces(MediaType.APPLICATION_JSON)
@Path("/{id}/status")
- @PreAuthorize("hasAnyRole('ROLE_MONITOR', 'ROLE_DFM', 'ROLE_ADMIN')")
+ // TODO - @PreAuthorize("hasAnyRole('ROLE_MONITOR', 'ROLE_DFM', 'ROLE_ADMIN')")
@ApiOperation(
value = "Gets status for a connection",
response = ConnectionStatusEntity.class,
@@ -366,7 +296,7 @@ public class ConnectionResource extends ApplicationResource {
}
// get the specified connection status
- final ConnectionStatusDTO connectionStatus = serviceFacade.getConnectionStatus(groupId, id);
+ final ConnectionStatusDTO connectionStatus = serviceFacade.getConnectionStatus(id);
// create the revision
final RevisionDTO revision = new RevisionDTO();
@@ -390,9 +320,9 @@ public class ConnectionResource extends ApplicationResource {
*/
@GET
@Consumes(MediaType.WILDCARD)
- @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
+ @Produces(MediaType.APPLICATION_JSON)
@Path("/{id}/status/history")
- @PreAuthorize("hasAnyRole('ROLE_MONITOR', 'ROLE_DFM', 'ROLE_ADMIN')")
+ // TODO - @PreAuthorize("hasAnyRole('ROLE_MONITOR', 'ROLE_DFM', 'ROLE_ADMIN')")
@ApiOperation(
value = "Gets the status history for a connection",
response = StatusHistoryEntity.class,
@@ -429,7 +359,7 @@ public class ConnectionResource extends ApplicationResource {
}
// get the specified processor status history
- final StatusHistoryDTO connectionStatusHistory = serviceFacade.getConnectionStatusHistory(groupId, id);
+ final StatusHistoryDTO connectionStatusHistory = serviceFacade.getConnectionStatusHistory(id);
// create the revision
final RevisionDTO revision = new RevisionDTO();
@@ -445,415 +375,6 @@ public class ConnectionResource extends ApplicationResource {
}
/**
- * Creates a connection.
- *
- * @param httpServletRequest request
- * @param version The revision is used to verify the client is working with the latest version of the flow.
- * @param clientId Optional client id. If the client id is not specified, a new one will be generated. This value (whether specified or generated) is included in the response.
- * @param name The name of the connection.
- * @param sourceId The id of the source connectable.
- * @param sourceGroupId The parent group id for the source.
- * @param sourceType The type of the source connectable.
- * @param bends Array of bend points in string form ["x,y", "x,y", "x,y"]
- * @param relationships Array of relationships.
- * @param flowFileExpiration The flow file expiration in minutes
- * @param backPressureObjectThreshold The object count for when to apply back pressure.
- * @param backPressureDataSizeThreshold The object size for when to apply back pressure.
- * @param prioritizers Array of prioritizer types. These types should refer to one of the types in the GET /controller/prioritizers response. If this parameter is not specified no change will be
- * made. If this parameter appears with no value (empty string), it will be treated as an empty array.
- * @param destinationId The id of the destination connectable.
- * @param destinationGroupId The parent group id for the destination.
- * @param destinationType The type of the destination connectable.
- * @param formParams params
- * @return A connectionEntity.
- */
- @POST
- @Consumes(MediaType.APPLICATION_FORM_URLENCODED)
- @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
- @Path("") // necessary due to bug in swagger
- @PreAuthorize("hasRole('ROLE_DFM')")
- public Response createConnection(
- @Context HttpServletRequest httpServletRequest,
- @FormParam(VERSION) LongParameter version,
- @FormParam(CLIENT_ID) @DefaultValue(StringUtils.EMPTY) ClientIdParameter clientId,
- @FormParam("name") String name,
- @FormParam("sourceId") String sourceId,
- @FormParam("sourceGroupId") String sourceGroupId,
- @FormParam("sourceType") ConnectableTypeParameter sourceType,
- @FormParam("relationships[]") Set<String> relationships,
- @FormParam("bends[]") List<String> bends,
- @FormParam("flowFileExpiration") String flowFileExpiration,
- @FormParam("backPressureObjectThreshold") LongParameter backPressureObjectThreshold,
- @FormParam("backPressureDataSizeThreshold") String backPressureDataSizeThreshold,
- @FormParam("prioritizers[]") List<String> prioritizers,
- @FormParam("destinationId") String destinationId,
- @FormParam("destinationGroupId") String destinationGroupId,
- @FormParam("destinationType") ConnectableTypeParameter destinationType,
- MultivaluedMap<String, String> formParams) {
-
- if (sourceId == null || sourceGroupId == null || destinationId == null || destinationGroupId == null) {
- throw new IllegalArgumentException("The source and destination (and parent groups) must be specified.");
- }
-
- // ensure the source and destination type has been specified
- if (sourceType == null || destinationType == null) {
- throw new IllegalArgumentException("The source and destination type must be specified.");
- }
-
- // create the source dto
- final ConnectableDTO source = new ConnectableDTO();
- source.setId(sourceId);
- source.setType(sourceType.getConnectableType().name());
- source.setGroupId(sourceGroupId);
-
- // create the destination dto
- final ConnectableDTO destination = new ConnectableDTO();
- destination.setId(destinationId);
- destination.setType(destinationType.getConnectableType().name());
- destination.setGroupId(destinationGroupId);
-
- // create the connection dto
- final ConnectionDTO connectionDTO = new ConnectionDTO();
- connectionDTO.setName(name);
- connectionDTO.setSource(source);
- connectionDTO.setDestination(destination);
-
- // only set the relationships when applicable
- if (!relationships.isEmpty() || formParams.containsKey("relationships[]")) {
- connectionDTO.setSelectedRelationships(relationships);
- }
-
- connectionDTO.setFlowFileExpiration(flowFileExpiration);
- connectionDTO.setBackPressureDataSizeThreshold(backPressureDataSizeThreshold);
-
- if (backPressureObjectThreshold != null) {
- connectionDTO.setBackPressureObjectThreshold(backPressureObjectThreshold.getLong());
- }
-
- // handle the bends when applicable
- if (!bends.isEmpty() || formParams.containsKey("bends[]")) {
- final List<PositionDTO> bendPoints = new ArrayList<>(bends.size());
- for (final String bend : bends) {
- final String[] coordinate = bend.split(",");
-
- // ensure the appropriate number of tokens
- if (coordinate.length != 2) {
- throw new IllegalArgumentException("Bend points should be an array where each entry is in the form 'x,y'");
- }
-
- // convert the coordinate
- final Double x;
- final Double y;
- try {
- x = Double.parseDouble(coordinate[0].trim());
- y = Double.parseDouble(coordinate[1].trim());
- } catch (final NumberFormatException nfe) {
- throw new IllegalArgumentException("Bend points should be an array where each entry is in the form 'x,y'");
- }
-
- // add the bend point
- bendPoints.add(new PositionDTO(x, y));
- }
-
- // set the bend points
- connectionDTO.setBends(bendPoints);
- }
-
- // create prioritizer list
- final List<String> prioritizerTypes = new ArrayList<>(prioritizers.size());
-
- // add each prioritizer specified
- for (String rawPrioritizer : prioritizers) {
- // when prioritizers[] is specified in the request with no value, it creates an array
- // with a single element (empty string). an empty array is created when prioritizers[]
- // is not found in the request
- if (StringUtils.isNotBlank(rawPrioritizer)) {
- prioritizerTypes.add(rawPrioritizer);
- }
- }
-
- // only set the prioritizers when appropriate
- if (!prioritizerTypes.isEmpty() || formParams.containsKey("prioritizers[]")) {
- connectionDTO.setPrioritizers(prioritizerTypes);
- }
-
- // create the revision
- final RevisionDTO revision = new RevisionDTO();
- revision.setClientId(clientId.getClientId());
-
- if (version != null) {
- revision.setVersion(version.getLong());
- }
-
- // create the connection entity
- final ConnectionEntity entity = new ConnectionEntity();
- entity.setRevision(revision);
- entity.setConnection(connectionDTO);
-
- // create the relationship target
- return createConnection(httpServletRequest, entity);
- }
-
- /**
- * Creates a new connection.
- *
- * @param httpServletRequest request
- * @param connectionEntity A connectionEntity.
- * @return A connectionEntity.
- */
- @POST
- @Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
- @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
- @Path("") // necessary due to bug in swagger
- @PreAuthorize("hasRole('ROLE_DFM')")
- @ApiOperation(
- value = "Creates a connection",
- response = ConnectionEntity.class,
- authorizations = {
- @Authorization(value = "Data Flow Manager", type = "ROLE_DFM")
- }
- )
- @ApiResponses(
- value = {
- @ApiResponse(code = 400, message = "NiFi was unable to complete the request because it was invalid. The request should not be retried without modification."),
- @ApiResponse(code = 401, message = "Client could not be authenticated."),
- @ApiResponse(code = 403, message = "Client is not authorized to make this request."),
- @ApiResponse(code = 404, message = "The specified resource could not be found."),
- @ApiResponse(code = 409, message = "The request was valid but NiFi was not in the appropriate state to process it. Retrying the same request later may be successful.")
- }
- )
- public Response createConnection(
- @Context HttpServletRequest httpServletRequest,
- @ApiParam(
- value = "The connection configuration details.",
- required = true
- ) ConnectionEntity connectionEntity) {
-
- if (connectionEntity == null || connectionEntity.getConnection() == null) {
- throw new IllegalArgumentException("Connection details must be specified.");
- }
-
- if (connectionEntity.getConnection().getId() != null) {
- throw new IllegalArgumentException("Connection ID cannot be specified.");
- }
-
- if (connectionEntity.getRevision() == null) {
- throw new IllegalArgumentException("Revision must be specified.");
- }
-
- // if cluster manager, convert POST to PUT (to maintain same ID across nodes) and replicate
- if (properties.isClusterManager()) {
-
- // create ID for resource
- final String id = UUID.randomUUID().toString();
-
- // set ID for resource
- connectionEntity.getConnection().setId(id);
-
- // convert POST request to PUT request to force entity ID to be the same across nodes
- URI putUri = null;
- try {
- putUri = new URI(getAbsolutePath().toString() + "/" + id);
- } catch (final URISyntaxException e) {
- throw new WebApplicationException(e);
- }
-
- // change content type to JSON for serializing entity
- final Map<String, String> headersToOverride = new HashMap<>();
- headersToOverride.put("content-type", MediaType.APPLICATION_JSON);
-
- // replicate put request
- return clusterManager.applyRequest(HttpMethod.PUT, putUri, updateClientId(connectionEntity), getHeaders(headersToOverride)).getResponse();
- }
-
- // get the connection
- final ConnectionDTO connection = connectionEntity.getConnection();
-
- // handle expects request (usually from the cluster manager)
- final String expects = httpServletRequest.getHeader(WebClusterManager.NCM_EXPECTS_HTTP_HEADER);
- if (expects != null) {
- serviceFacade.verifyCreateConnection(groupId, connection);
- return generateContinueResponse().build();
- }
-
- // create the new relationship target
- final RevisionDTO revision = connectionEntity.getRevision();
- final ConfigurationSnapshot<ConnectionDTO> controllerResponse = serviceFacade.createConnection(
- new Revision(revision.getVersion(), revision.getClientId()), groupId, connection);
- ConnectionDTO connectionDTO = controllerResponse.getConfiguration();
-
- // marshall the target and add the source processor
- populateRemainingConnectionContent(connectionDTO);
-
- // get the updated revision
- final RevisionDTO updatedRevision = new RevisionDTO();
- updatedRevision.setClientId(revision.getClientId());
- updatedRevision.setVersion(controllerResponse.getVersion());
-
- // create the response entity
- ConnectionEntity entity = new ConnectionEntity();
- entity.setRevision(updatedRevision);
- entity.setConnection(connectionDTO);
-
- // extract the href and build the response
- String href = connectionDTO.getUri();
-
- return clusterContext(generateCreatedResponse(URI.create(href), entity)).build();
- }
-
- /**
- * Updates the specified relationship target.
- *
- * @param httpServletRequest request
- * @param version The revision is used to verify the client is working with the latest version of the flow.
- * @param clientId Optional client id. If the client id is not specified, a new one will be generated. This value (whether specified or generated) is included in the response.
- * @param connectionId The id of the source processor.
- * @param name The name of the connection.
- * @param relationships Array of relationships.
- * @param bends Array of bend points in string form ["x,y", "x,y", "x,y"]
- * @param labelIndex The control point index for the connection label
- * @param zIndex The zIndex for this connection
- * @param flowFileExpiration The flow file expiration in minutes
- * @param backPressureObjectThreshold The object count for when to apply back pressure.
- * @param backPressureDataSizeThreshold The object size for when to apply back pressure.
- * @param prioritizers Array of prioritizer types. These types should refer to one of the types in the GET /controller/prioritizers response. If this parameter is not specified no change will be
- * made. If this parameter appears with no value (empty string), it will be treated as an empty array.
- * @param destinationId The id of the destination connectable.
- * @param destinationGroupId The group id of the destination.
- * @param destinationType The type of the destination type.
- * @param formParams params
- * @return A connectionEntity.
- */
- @PUT
- @Consumes(MediaType.APPLICATION_FORM_URLENCODED)
- @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
- @Path("/{id}")
- @PreAuthorize("hasRole('ROLE_DFM')")
- public Response updateConnection(
- @Context HttpServletRequest httpServletRequest,
- @FormParam(VERSION) LongParameter version,
- @FormParam(CLIENT_ID) @DefaultValue(StringUtils.EMPTY) ClientIdParameter clientId,
- @PathParam("id") String connectionId,
- @FormParam("name") String name,
- @FormParam("relationships[]") Set<String> relationships,
- @FormParam("bends[]") List<String> bends,
- @FormParam("labelIndex") IntegerParameter labelIndex,
- @FormParam("zIndex") LongParameter zIndex,
- @FormParam("flowFileExpiration") String flowFileExpiration,
- @FormParam("backPressureObjectThreshold") LongParameter backPressureObjectThreshold,
- @FormParam("backPressureDataSizeThreshold") String backPressureDataSizeThreshold,
- @FormParam("prioritizers[]") List<String> prioritizers,
- @FormParam("destinationId") String destinationId,
- @FormParam("destinationGroupId") String destinationGroupId,
- @FormParam("destinationType") ConnectableTypeParameter destinationType,
- MultivaluedMap<String, String> formParams) {
-
- // create the target connectable if necessary
- ConnectableDTO destination = null;
- if (destinationId != null) {
- if (destinationGroupId == null) {
- throw new IllegalArgumentException("The destination group must be specified.");
- }
-
- if (destinationType == null) {
- throw new IllegalArgumentException("The destination type must be specified.");
- }
-
- destination = new ConnectableDTO();
- destination.setId(destinationId);
- destination.setType(destinationType.getConnectableType().name());
- destination.setGroupId(destinationGroupId);
- }
-
- // create the relationship target dto
- final ConnectionDTO connectionDTO = new ConnectionDTO();
- connectionDTO.setId(connectionId);
- connectionDTO.setName(name);
- connectionDTO.setDestination(destination);
- if (labelIndex != null) {
- connectionDTO.setLabelIndex(labelIndex.getInteger());
- }
- if (zIndex != null) {
- connectionDTO.setzIndex(zIndex.getLong());
- }
-
- // handle the bends when applicable
- if (!bends.isEmpty() || formParams.containsKey("bends[]")) {
- final List<PositionDTO> bendPoints = new ArrayList<>(bends.size());
- for (final String bend : bends) {
- final String[] coordinate = bend.split(",");
-
- // ensure the appropriate number of tokens
- if (coordinate.length != 2) {
- throw new IllegalArgumentException("Bend points should be an array where each entry is in the form 'x,y'");
- }
-
- // convert the coordinate
- final Double x;
- final Double y;
- try {
- x = Double.parseDouble(coordinate[0].trim());
- y = Double.parseDouble(coordinate[1].trim());
- } catch (final NumberFormatException nfe) {
- throw new IllegalArgumentException("Bend points should be an array where each entry is in the form 'x,y'");
- }
-
- // add the bend point
- bendPoints.add(new PositionDTO(x, y));
- }
-
- // set the bend points
- connectionDTO.setBends(bendPoints);
- }
-
- // only set the relationships when applicable
- if (!relationships.isEmpty() || formParams.containsKey("relationships[]")) {
- connectionDTO.setSelectedRelationships(relationships);
- }
-
- connectionDTO.setFlowFileExpiration(flowFileExpiration);
- connectionDTO.setBackPressureDataSizeThreshold(backPressureDataSizeThreshold);
-
- if (backPressureObjectThreshold != null) {
- connectionDTO.setBackPressureObjectThreshold(backPressureObjectThreshold.getLong());
- }
-
- // create prioritizer list
- final List<String> prioritizerTypes = new ArrayList<>(prioritizers.size());
-
- // add each prioritizer specified
- for (final String rawPrioritizer : prioritizers) {
- // when prioritizers[] is specified in the request with no value, it creates an array
- // with a single element (empty string). an empty array is created when prioritizers[]
- // is not found in the request
- if (StringUtils.isNotBlank(rawPrioritizer)) {
- prioritizerTypes.add(rawPrioritizer);
- }
- }
-
- // only set the prioritizers when appropriate
- if (!prioritizerTypes.isEmpty() || formParams.containsKey("prioritizers[]")) {
- connectionDTO.setPrioritizers(prioritizerTypes);
- }
-
- // create the revision
- final RevisionDTO revision = new RevisionDTO();
- revision.setClientId(clientId.getClientId());
-
- if (version != null) {
- revision.setVersion(version.getLong());
- }
-
- // create the connection entity
- final ConnectionEntity entity = new ConnectionEntity();
- entity.setRevision(revision);
- entity.setConnection(connectionDTO);
-
- // update the relationship target
- return updateConnection(httpServletRequest, connectionId, entity);
- }
-
- /**
* Updates the specified connection.
*
* @param httpServletRequest request
@@ -862,10 +383,10 @@ public class ConnectionResource extends ApplicationResource {
* @return A connectionEntity.
*/
@PUT
- @Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
- @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
@Path("/{id}")
- @PreAuthorize("hasRole('ROLE_DFM')")
+ // TODO - @PreAuthorize("hasRole('ROLE_DFM')")
@ApiOperation(
value = "Updates a connection",
response = ConnectionEntity.class,
@@ -923,14 +444,14 @@ public class ConnectionResource extends ApplicationResource {
// handle expects request (usually from the cluster manager)
final String expects = httpServletRequest.getHeader(WebClusterManager.NCM_EXPECTS_HTTP_HEADER);
if (expects != null) {
- serviceFacade.verifyUpdateConnection(groupId, connection);
+ serviceFacade.verifyUpdateConnection(connection);
return generateContinueResponse().build();
}
// update the relationship target
final RevisionDTO revision = connectionEntity.getRevision();
final ConfigurationSnapshot<ConnectionDTO> controllerResponse = serviceFacade.updateConnection(
- new Revision(revision.getVersion(), revision.getClientId()), groupId, connection);
+ new Revision(revision.getVersion(), revision.getClientId()), connection);
// get the updated revision
final RevisionDTO updatedRevision = new RevisionDTO();
@@ -965,9 +486,9 @@ public class ConnectionResource extends ApplicationResource {
*/
@DELETE
@Consumes(MediaType.WILDCARD)
- @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
+ @Produces(MediaType.APPLICATION_JSON)
@Path("/{id}")
- @PreAuthorize("hasRole('ROLE_DFM')")
+ // TODO - @PreAuthorize("hasRole('ROLE_DFM')")
@ApiOperation(
value = "Deletes a connection",
response = ConnectionEntity.class,
@@ -1010,7 +531,7 @@ public class ConnectionResource extends ApplicationResource {
// handle expects request (usually from the cluster manager)
final String expects = httpServletRequest.getHeader(WebClusterManager.NCM_EXPECTS_HTTP_HEADER);
if (expects != null) {
- serviceFacade.verifyDeleteConnection(groupId, id);
+ serviceFacade.verifyDeleteConnection(id);
return generateContinueResponse().build();
}
@@ -1021,7 +542,7 @@ public class ConnectionResource extends ApplicationResource {
}
// delete the connection
- final ConfigurationSnapshot<Void> controllerResponse = serviceFacade.deleteConnection(new Revision(clientVersion, clientId.getClientId()), groupId, id);
+ final ConfigurationSnapshot<Void> controllerResponse = serviceFacade.deleteConnection(new Revision(clientVersion, clientId.getClientId()), id);
// create the revision
final RevisionDTO updatedRevision = new RevisionDTO();
@@ -1047,9 +568,9 @@ public class ConnectionResource extends ApplicationResource {
*/
@GET
@Consumes(MediaType.WILDCARD)
- @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
+ @Produces(MediaType.APPLICATION_JSON)
@Path("/{connection-id}/flowfiles/{flowfile-uuid}")
- @PreAuthorize("hasRole('ROLE_DFM')")
+ // TODO - @PreAuthorize("hasRole('ROLE_DFM')")
@ApiOperation(
value = "Gets a FlowFile from a Connection.",
authorizations = {
@@ -1108,7 +629,7 @@ public class ConnectionResource extends ApplicationResource {
}
// get the flowfile
- final FlowFileDTO flowfileDto = serviceFacade.getFlowFile(groupId, connectionId, flowFileUuid);
+ final FlowFileDTO flowfileDto = serviceFacade.getFlowFile(connectionId, flowFileUuid);
populateRemainingFlowFileContent(connectionId, flowfileDto);
// create the revision
@@ -1136,7 +657,7 @@ public class ConnectionResource extends ApplicationResource {
@Consumes(MediaType.WILDCARD)
@Produces(MediaType.WILDCARD)
@Path("/{connection-id}/flowfiles/{flowfile-uuid}/content")
- @PreAuthorize("hasRole('ROLE_DFM')")
+ // TODO - @PreAuthorize("hasRole('ROLE_DFM')")
@ApiOperation(
value = "Gets the content for a FlowFile in a Connection.",
authorizations = {
@@ -1195,10 +716,10 @@ public class ConnectionResource extends ApplicationResource {
}
// get the uri of the request
- final String uri = generateResourceUri("controller", "process-groups", groupId, "connections", connectionId, "flowfiles", flowFileUuid, "content");
+ final String uri = generateResourceUri("connections", connectionId, "flowfiles", flowFileUuid, "content");
// get an input stream to the content
- final DownloadableContent content = serviceFacade.getContent(groupId, connectionId, flowFileUuid, uri);
+ final DownloadableContent content = serviceFacade.getContent(connectionId, flowFileUuid, uri);
// generate a streaming response
final StreamingOutput response = new StreamingOutput() {
@@ -1224,73 +745,17 @@ public class ConnectionResource extends ApplicationResource {
}
/**
- * Drops the flowfiles in the queue of the specified connection. This endpoint is DEPRECATED. Please use
- * POST /nifi-api/controller/process-groups/{process-group-id}/connections/{connection-id}/drop-requests instead.
- *
- * @param httpServletRequest request
- * @param clientId Optional client id. If the client id is not specified, a new one will be generated. This value (whether specified or generated) is included in the response.
- * @param id The id of the connection
- * @return A dropRequestEntity
- */
- @DELETE
- @Consumes(MediaType.WILDCARD)
- @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
- @Path("/{connection-id}/contents")
- @PreAuthorize("hasRole('ROLE_DFM')")
- @ApiOperation(
- value = "Drops the contents of the queue in this connection.",
- notes = "This endpoint is DEPRECATED. Please use POST /nifi-api/controller/process-groups/{process-group-id}/connections/{connection-id}/drop-requests instead.",
- response = DropRequestEntity.class,
- authorizations = {
- @Authorization(value = "Data Flow Manager", type = "ROLE_DFM")
- }
- )
- @ApiResponses(
- value = {
- @ApiResponse(code = 202, message = "The request has been accepted. A HTTP response header will contain the URI where the response can be polled."),
- @ApiResponse(code = 400, message = "NiFi was unable to complete the request because it was invalid. The request should not be retried without modification."),
- @ApiResponse(code = 401, message = "Client could not be authenticated."),
- @ApiResponse(code = 403, message = "Client is not authorized to make this request."),
- @ApiResponse(code = 404, message = "The specified resource could not be found."),
- @ApiResponse(code = 409, message = "The request was valid but NiFi was not in the appropriate state to process it. Retrying the same request later may be successful.")
- }
- )
- @Deprecated
- public Response dropQueueContents(
- @Context HttpServletRequest httpServletRequest,
- @ApiParam(
- value = "If the client id is not specified, new one will be generated. This value (whether specified or generated) is included in the response.",
- required = false
- )
- @QueryParam(CLIENT_ID) @DefaultValue(StringUtils.EMPTY) ClientIdParameter clientId,
- @ApiParam(
- value = "The connection id.",
- required = true
- )
- @PathParam("connection-id") String id) {
-
- // replicate if cluster manager
- if (properties.isClusterManager()) {
- return clusterManager.applyRequest(HttpMethod.DELETE, getAbsolutePath(), getRequestParameters(true), getHeaders()).getResponse();
- }
-
- // defer to the new endpoint that references /drop-requests in the URI
- return createDropRequest(httpServletRequest, clientId, id);
- }
-
- /**
* Creates a request to list the flowfiles in the queue of the specified connection.
*
* @param httpServletRequest request
- * @param clientId Optional client id. If the client id is not specified, a new one will be generated. This value (whether specified or generated) is included in the response.
* @param id The id of the connection
* @return A listRequestEntity
*/
@POST
- @Consumes(MediaType.APPLICATION_FORM_URLENCODED)
- @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
+ @Consumes(MediaType.WILDCARD)
+ @Produces(MediaType.APPLICATION_JSON)
@Path("/{connection-id}/listing-requests")
- @PreAuthorize("hasRole('ROLE_DFM')")
+ // TODO - @PreAuthorize("hasRole('ROLE_DFM')")
@ApiOperation(
value = "Lists the contents of the queue in this connection.",
response = ListingRequestEntity.class,
@@ -1311,11 +776,6 @@ public class ConnectionResource extends ApplicationResource {
public Response createFlowFileListing(
@Context HttpServletRequest httpServletRequest,
@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
- )
- @FormParam(CLIENT_ID) @DefaultValue(StringUtils.EMPTY) ClientIdParameter clientId,
- @ApiParam(
value = "The connection id.",
required = true
)
@@ -1329,7 +789,7 @@ public class ConnectionResource extends ApplicationResource {
// handle expects request (usually from the cluster manager)
final String expects = httpServletRequest.getHeader(WebClusterManager.NCM_EXPECTS_HTTP_HEADER);
if (expects != null) {
- serviceFacade.verifyListQueue(groupId, id);
+ serviceFacade.verifyListQueue(id);
return generateContinueResponse().build();
}
@@ -1343,12 +803,11 @@ public class ConnectionResource extends ApplicationResource {
}
// submit the listing request
- final ListingRequestDTO listingRequest = serviceFacade.createFlowFileListingRequest(groupId, id, listingRequestId);
+ final ListingRequestDTO listingRequest = serviceFacade.createFlowFileListingRequest(id, listingRequestId);
populateRemainingFlowFileListingContent(id, listingRequest);
// create the revision
final RevisionDTO revision = new RevisionDTO();
- revision.setClientId(clientId.getClientId());
// create the response entity
final ListingRequestEntity entity = new ListingRequestEntity();
@@ -1370,9 +829,9 @@ public class ConnectionResource extends ApplicationResource {
*/
@GET
@Consumes(MediaType.WILDCARD)
- @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
+ @Produces(MediaType.APPLICATION_JSON)
@Path("/{connection-id}/listing-requests/{listing-request-id}")
- @PreAuthorize("hasRole('ROLE_DFM')")
+ // TODO - @PreAuthorize("hasRole('ROLE_DFM')")
@ApiOperation(
value = "Gets the current status of a listing request for the specified connection.",
response = ListingRequestEntity.class,
@@ -1412,7 +871,7 @@ public class ConnectionResource extends ApplicationResource {
}
// get the listing request
- final ListingRequestDTO listingRequest = serviceFacade.getFlowFileListingRequest(groupId, connectionId, listingRequestId);
+ final ListingRequestDTO listingRequest = serviceFacade.getFlowFileListingRequest(connectionId, listingRequestId);
populateRemainingFlowFileListingContent(connectionId, listingRequest);
// create the revision
@@ -1438,8 +897,9 @@ public class ConnectionResource extends ApplicationResource {
*/
@DELETE
@Consumes(MediaType.WILDCARD)
- @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
+ @Produces(MediaType.APPLICATION_JSON)
@Path("/{connection-id}/listing-requests/{listing-request-id}")
+ // TODO - @PreAuthorize("hasRole('ROLE_DFM')")
@ApiOperation(
value = "Cancels and/or removes a request to list the contents of this connection.",
response = DropRequestEntity.class,
@@ -1486,7 +946,7 @@ public class ConnectionResource extends ApplicationResource {
}
// delete the listing request
- final ListingRequestDTO listingRequest = serviceFacade.deleteFlowFileListingRequest(groupId, connectionId, listingRequestId);
+ final ListingRequestDTO listingRequest = serviceFacade.deleteFlowFileListingRequest(connectionId, listingRequestId);
// prune the results as they were already received when the listing completed
listingRequest.setFlowFileSummaries(null);
@@ -1510,15 +970,14 @@ public class ConnectionResource extends ApplicationResource {
* Creates a request to delete the flowfiles in the queue of the specified connection.
*
* @param httpServletRequest request
- * @param clientId Optional client id. If the client id is not specified, a new one will be generated. This value (whether specified or generated) is included in the response.
* @param id The id of the connection
* @return A dropRequestEntity
*/
@POST
- @Consumes(MediaType.APPLICATION_FORM_URLENCODED)
- @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
+ @Consumes(MediaType.WILDCARD)
+ @Produces(MediaType.APPLICATION_JSON)
@Path("/{connection-id}/drop-requests")
- @PreAuthorize("hasRole('ROLE_DFM')")
+ // TODO - @PreAuthorize("hasRole('ROLE_DFM')")
@ApiOperation(
value = "Creates a request to drop the contents of the queue in this connection.",
response = DropRequestEntity.class,
@@ -1539,11 +998,6 @@ public class ConnectionResource extends ApplicationResource {
public Response createDropRequest(
@Context HttpServletRequest httpServletRequest,
@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
- )
- @FormParam(CLIENT_ID) @DefaultValue(StringUtils.EMPTY) ClientIdParameter clientId,
- @ApiParam(
value = "The connection id.",
required = true
)
@@ -1570,12 +1024,11 @@ public class ConnectionResource extends ApplicationResource {
}
// submit the drop request
- final DropRequestDTO dropRequest = serviceFacade.createFlowFileDropRequest(groupId, id, dropRequestId);
- dropRequest.setUri(generateResourceUri("controller", "process-groups", groupId, "connections", id, "drop-requests", dropRequest.getId()));
+ final DropRequestDTO dropRequest = serviceFacade.createFlowFileDropRequest(id, dropRequestId);
+ dropRequest.setUri(generateResourceUri("connections", id, "drop-requests", dropRequest.getId()));
// create the revision
final RevisionDTO revision = new RevisionDTO();
- revision.setClientId(clientId.getClientId());
// create the response entity
final DropRequestEntity entity = new DropRequestEntity();
@@ -1597,9 +1050,9 @@ public class ConnectionResource extends ApplicationResource {
*/
@GET
@Consumes(MediaType.WILDCARD)
- @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
+ @Produces(MediaType.APPLICATION_JSON)
@Path("/{connection-id}/drop-requests/{drop-request-id}")
- @PreAuthorize("hasRole('ROLE_DFM')")
+ // TODO - @PreAuthorize("hasRole('ROLE_DFM')")
@ApiOperation(
value = "Gets the current status of a drop request for the specified connection.",
response = DropRequestEntity.class,
@@ -1639,8 +1092,8 @@ public class ConnectionResource extends ApplicationResource {
}
// get the drop request
- final DropRequestDTO dropRequest = serviceFacade.getFlowFileDropRequest(groupId, connectionId, dropRequestId);
- dropRequest.setUri(generateResourceUri("controller", "process-groups", groupId, "connections", connectionId, "drop-requests", dropRequestId));
+ final DropRequestDTO dropRequest = serviceFacade.getFlowFileDropRequest(connectionId, dropRequestId);
+ dropRequest.setUri(generateResourceUri("connections", connectionId, "drop-requests", dropRequestId));
// create the revision
final RevisionDTO revision = new RevisionDTO();
@@ -1665,9 +1118,9 @@ public class ConnectionResource extends ApplicationResource {
*/
@DELETE
@Consumes(MediaType.WILDCARD)
- @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
+ @Produces(MediaType.APPLICATION_JSON)
@Path("/{connection-id}/drop-requests/{drop-request-id}")
- @PreAuthorize("hasRole('ROLE_DFM')")
+ // TODO - @PreAuthorize("hasRole('ROLE_DFM')")
@ApiOperation(
value = "Cancels and/or removes a request to drop the contents of this connection.",
response = DropRequestEntity.class,
@@ -1714,8 +1167,8 @@ public class ConnectionResource extends ApplicationResource {
}
// delete the drop request
- final DropRequestDTO dropRequest = serviceFacade.deleteFlowFileDropRequest(groupId, connectionId, dropRequestId);
- dropRequest.setUri(generateResourceUri("controller", "process-groups", groupId, "connections", connectionId, "drop-requests", dropRequestId));
+ final DropRequestDTO dropRequest = serviceFacade.deleteFlowFileDropRequest(connectionId, dropRequestId);
+ dropRequest.setUri(generateResourceUri("connections", connectionId, "drop-requests", dropRequestId));
// create the revision
final RevisionDTO revision = new RevisionDTO();
@@ -1734,10 +1187,6 @@ public class ConnectionResource extends ApplicationResource {
this.serviceFacade = serviceFacade;
}
- public void setGroupId(String groupId) {
- this.groupId = groupId;
- }
-
public void setClusterManager(WebClusterManager clusterManager) {
this.clusterManager = clusterManager;
}
http://git-wip-us.apache.org/repos/asf/nifi/blob/153f63ef/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 a3d0dc1..a3fdc12 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
@@ -64,7 +64,6 @@ import org.apache.nifi.web.api.request.ClientIdParameter;
import org.apache.nifi.web.api.request.IntegerParameter;
import org.apache.nifi.web.api.request.LongParameter;
import org.apache.nifi.web.security.user.NiFiUserUtils;
-import org.springframework.security.access.prepost.PreAuthorize;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.Consumes;
@@ -84,6 +83,7 @@ import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import java.net.URI;
+import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
@@ -121,62 +121,6 @@ public class ControllerResource extends ApplicationResource {
}
/**
- * Locates the User sub-resource.
- *
- * @return the User sub-resource
- */
- @Path("/users")
- @ApiOperation(
- value = "Gets the user resource",
- response = UserResource.class
- )
- public UserResource getUserResource() {
- return resourceContext.getResource(UserResource.class);
- }
-
- /**
- * Locates the User sub-resource.
- *
- * @return the User sub-resource
- */
- @Path("/user-groups")
- @ApiOperation(
- value = "Gets the user group resource",
- response = UserGroupResource.class
- )
- public UserGroupResource getUserGroupResource() {
- return resourceContext.getResource(UserGroupResource.class);
- }
-
- /**
- * Locates the History sub-resource.
- *
- * @return the History sub-resource
- */
- @Path("/history")
- @ApiOperation(
- value = "Gets the history resource",
- response = HistoryResource.class
- )
- public HistoryResource getHistoryResource() {
- return resourceContext.getResource(HistoryResource.class);
- }
-
- /**
- * Locates the History sub-resource.
- *
- * @return the History sub-resource
- */
- @Path("/bulletin-board")
- @ApiOperation(
- value = "Gets the bulletin board resource",
- response = BulletinBoardResource.class
- )
- public BulletinBoardResource getBulletinBoardResource() {
- return resourceContext.getResource(BulletinBoardResource.class);
- }
-
- /**
* Locates the Template sub-resource.
*
* @return the Template sub-resource
@@ -205,63 +149,12 @@ public class ControllerResource extends ApplicationResource {
}
/**
- * Locates the Controller Services sub-resource.
- *
- * @return the Controller Services sub-resource
- */
- @Path("/controller-services")
- @ApiOperation(
- value = "Gets the controller service resource",
- response = ControllerServiceResource.class
- )
- public ControllerServiceResource getControllerServiceResource() {
- return resourceContext.getResource(ControllerServiceResource.class);
- }
-
- /**
- * Locates the Reporting Tasks sub-resource.
- *
- * @return the Reporting Tasks sub-resource
- */
- @Path("/reporting-tasks")
- @ApiOperation(
- value = "Gets the reporting task resource",
- response = ReportingTaskResource.class
- )
- public ReportingTaskResource getReportingTaskResource() {
- return resourceContext.getResource(ReportingTaskResource.class);
- }
-
- /**
- * Locates the Group sub-resource.
- *
- * @param groupId The process group id
- * @return the Group sub-resource
- */
- @Path("/process-groups/{process-group-id}")
- @ApiOperation(
- value = "Gets the process group resource",
- response = ProcessGroupResource.class
- )
- public ProcessGroupResource getGroupResource(
- @ApiParam(
- value = "The id of the process group that is the parent of the requested resource(s). If the desired process group is "
- + "the root group an alias 'root' may be used as the process-group-id.",
- required = true
- )
- @PathParam("process-group-id") String groupId) {
- ProcessGroupResource groupResource = resourceContext.getResource(ProcessGroupResource.class);
- groupResource.setGroupId(groupId);
- return groupResource;
- }
-
- /**
* Returns a 200 OK response to indicate this is a valid controller endpoint.
*
* @return An OK response with an empty entity body.
*/
@HEAD
- @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
+ @Produces(MediaType.APPLICATION_JSON)
public Response getControllerHead() {
if (properties.isClusterManager()) {
throw new IllegalClusterResourceRequestException("A cluster manager cannot process the request.");
@@ -279,7 +172,7 @@ public class ControllerResource extends ApplicationResource {
@GET
@Consumes(MediaType.WILDCARD)
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
- @PreAuthorize("hasRole('ROLE_NIFI')")
+ // TODO - @PreAuthorize("hasRole('ROLE_NIFI')")
@ApiOperation(
value = "Returns the details about this NiFi necessary to communicate via site to site",
response = ControllerEntity.class,
@@ -330,7 +223,7 @@ public class ControllerResource extends ApplicationResource {
@Consumes(MediaType.WILDCARD)
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
@Path("/search-results")
- @PreAuthorize("hasAnyRole('ROLE_MONITOR', 'ROLE_DFM', 'ROLE_ADMIN')")
+ // TODO - @PreAuthorize("hasAnyRole('ROLE_MONITOR', 'ROLE_DFM', 'ROLE_ADMIN')")
@ApiOperation(
value = "Performs a search against this NiFi using the specified search term",
response = SearchResultsEntity.class,
@@ -380,7 +273,7 @@ public class ControllerResource extends ApplicationResource {
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
@Path("/archive")
- @PreAuthorize("hasRole('ROLE_DFM')")
+ // TODO - @PreAuthorize("hasRole('ROLE_DFM')")
@ApiOperation(
value = "Creates a new archive of this NiFi flow configuration",
notes = "This POST operation returns a URI that is not representative of the thing "
@@ -457,7 +350,7 @@ public class ControllerResource extends ApplicationResource {
@Consumes(MediaType.WILDCARD)
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
@Path("/revision")
- @PreAuthorize("hasAnyRole('ROLE_MONITOR', 'ROLE_DFM', 'ROLE_ADMIN')")
+ // TODO - @PreAuthorize("hasAnyRole('ROLE_MONITOR', 'ROLE_DFM', 'ROLE_ADMIN')")
@ApiOperation(
value = "Gets the current revision of this NiFi",
notes = "NiFi employs an optimistic locking strategy where the client must include a revision in their request when "
@@ -505,7 +398,7 @@ public class ControllerResource extends ApplicationResource {
@Consumes(MediaType.WILDCARD)
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
@Path("/status")
- @PreAuthorize("hasAnyRole('ROLE_MONITOR', 'ROLE_DFM', 'ROLE_ADMIN')")
+ // TODO - @PreAuthorize("hasAnyRole('ROLE_MONITOR', 'ROLE_DFM', 'ROLE_ADMIN')")
@ApiOperation(
value = "Gets the current status of this NiFi",
response = Entity.class,
@@ -559,7 +452,7 @@ public class ControllerResource extends ApplicationResource {
@Consumes(MediaType.WILDCARD)
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
@Path("/counters")
- @PreAuthorize("hasAnyRole('ROLE_MONITOR', 'ROLE_DFM', 'ROLE_ADMIN')")
+ // TODO - @PreAuthorize("hasAnyRole('ROLE_MONITOR', 'ROLE_DFM', 'ROLE_ADMIN')")
@ApiOperation(
value = "Gets the current counters for this NiFi",
response = Entity.class,
@@ -654,7 +547,7 @@ public class ControllerResource extends ApplicationResource {
@Consumes(MediaType.WILDCARD)
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
@Path("/counters/{id}")
- @PreAuthorize("hasRole('ROLE_DFM')")
+ // TODO - @PreAuthorize("hasRole('ROLE_DFM')")
@ApiOperation(
value = "Updates the specified counter. This will reset the counter value to 0",
response = CounterEntity.class,
@@ -717,7 +610,7 @@ public class ControllerResource extends ApplicationResource {
@Consumes(MediaType.WILDCARD)
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
@Path("/config")
- @PreAuthorize("hasAnyRole('ROLE_MONITOR', 'ROLE_DFM', 'ROLE_ADMIN', 'ROLE_NIFI')")
+ // TODO - @PreAuthorize("hasAnyRole('ROLE_MONITOR', 'ROLE_DFM', 'ROLE_ADMIN', 'ROLE_NIFI')")
@ApiOperation(
value = "Retrieves the configuration for this NiFi",
response = ControllerConfigurationEntity.class,
@@ -780,7 +673,7 @@ public class ControllerResource extends ApplicationResource {
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
@Path("/config")
- @PreAuthorize("hasRole('ROLE_DFM')")
+ // TODO - @PreAuthorize("hasRole('ROLE_DFM')")
public Response updateControllerConfig(
@Context HttpServletRequest httpServletRequest,
@FormParam(VERSION) LongParameter version,
@@ -831,7 +724,7 @@ public class ControllerResource extends ApplicationResource {
@Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
@Path("/config")
- @PreAuthorize("hasRole('ROLE_DFM')")
+ // TODO - @PreAuthorize("hasRole('ROLE_DFM')")
@ApiOperation(
value = "Retrieves the configuration for this NiFi",
response = ControllerConfigurationEntity.class,
@@ -932,7 +825,7 @@ public class ControllerResource extends ApplicationResource {
// create the response entity
IdentityEntity entity = new IdentityEntity();
entity.setRevision(revision);
- entity.setUserId(user.getId());
+ entity.setUserId(user.getIdentity());
entity.setIdentity(user.getUserName());
// generate the response
@@ -949,7 +842,7 @@ public class ControllerResource extends ApplicationResource {
@Consumes(MediaType.WILDCARD)
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
@Path("/authorities")
- @PreAuthorize("hasAnyRole('ROLE_MONITOR', 'ROLE_DFM', 'ROLE_ADMIN', 'ROLE_PROXY', 'ROLE_NIFI', 'ROLE_PROVENANCE')")
+ // TODO - @PreAuthorize("hasAnyRole('ROLE_MONITOR', 'ROLE_DFM', 'ROLE_ADMIN', 'ROLE_PROXY', 'ROLE_NIFI', 'ROLE_PROVENANCE')")
@ApiOperation(
value = "Retrieves the user details, including the authorities, about the user making the request",
response = AuthorityEntity.class,
@@ -990,8 +883,8 @@ public class ControllerResource extends ApplicationResource {
// create the response entity
AuthorityEntity entity = new AuthorityEntity();
entity.setRevision(revision);
- entity.setUserId(user.getId());
- entity.setAuthorities(NiFiUserUtils.getAuthorities());
+ entity.setUserId(user.getIdentity());
+ entity.setAuthorities(new HashSet<>(Arrays.asList("ROLE_MONITOR", "ROLE_DFM", "ROLE_ADMIN", "ROLE_PROXY", "ROLE_NIFI", "ROLE_PROVENANCE")));
// generate the response
return clusterContext(generateOkResponse(entity)).build();
@@ -1007,7 +900,7 @@ public class ControllerResource extends ApplicationResource {
@Consumes(MediaType.WILDCARD)
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
@Path("/banners")
- @PreAuthorize("hasAnyRole('ROLE_MONITOR', 'ROLE_DFM', 'ROLE_ADMIN')")
+ // TODO - @PreAuthorize("hasAnyRole('ROLE_MONITOR', 'ROLE_DFM', 'ROLE_ADMIN')")
@ApiOperation(
value = "Retrieves the banners for this NiFi",
response = BannerEntity.class,
@@ -1063,7 +956,7 @@ public class ControllerResource extends ApplicationResource {
@Consumes(MediaType.WILDCARD)
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
@Path("/processor-types")
- @PreAuthorize("hasAnyRole('ROLE_MONITOR', 'ROLE_DFM', 'ROLE_ADMIN')")
+ // TODO - @PreAuthorize("hasAnyRole('ROLE_MONITOR', 'ROLE_DFM', 'ROLE_ADMIN')")
@ApiOperation(
value = "Retrieves the types of processors that this NiFi supports",
response = ProcessorTypesEntity.class,
@@ -1117,7 +1010,7 @@ public class ControllerResource extends ApplicationResource {
@Consumes(MediaType.WILDCARD)
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
@Path("/controller-service-types")
- @PreAuthorize("hasAnyRole('ROLE_MONITOR', 'ROLE_DFM', 'ROLE_ADMIN')")
+ // TODO - @PreAuthorize("hasAnyRole('ROLE_MONITOR', 'ROLE_DFM', 'ROLE_ADMIN')")
@ApiOperation(
value = "Retrieves the types of controller services that this NiFi supports",
response = ControllerServiceTypesEntity.class,
@@ -1175,7 +1068,7 @@ public class ControllerResource extends ApplicationResource {
@Consumes(MediaType.WILDCARD)
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
@Path("/reporting-task-types")
- @PreAuthorize("hasAnyRole('ROLE_MONITOR', 'ROLE_DFM', 'ROLE_ADMIN')")
+ // TODO - @PreAuthorize("hasAnyRole('ROLE_MONITOR', 'ROLE_DFM', 'ROLE_ADMIN')")
@ApiOperation(
value = "Retrieves the types of reporting tasks that this NiFi supports",
response = ReportingTaskTypesEntity.class,
@@ -1228,7 +1121,7 @@ public class ControllerResource extends ApplicationResource {
@Consumes(MediaType.WILDCARD)
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
@Path("/prioritizers")
- @PreAuthorize("hasAnyRole('ROLE_MONITOR', 'ROLE_DFM', 'ROLE_ADMIN')")
+ // TODO - @PreAuthorize("hasAnyRole('ROLE_MONITOR', 'ROLE_DFM', 'ROLE_ADMIN')")
@ApiOperation(
value = "Retrieves the types of prioritizers that this NiFi supports",
response = PrioritizerTypesEntity.class,
@@ -1281,7 +1174,7 @@ public class ControllerResource extends ApplicationResource {
@Consumes(MediaType.WILDCARD)
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
@Path("/about")
- @PreAuthorize("hasAnyRole('ROLE_MONITOR', 'ROLE_DFM', 'ROLE_ADMIN')")
+ // TODO - @PreAuthorize("hasAnyRole('ROLE_MONITOR', 'ROLE_DFM', 'ROLE_ADMIN')")
@ApiOperation(
value = "Retrieves details about this NiFi to put in the About dialog",
response = AboutEntity.class,