You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nifi.apache.org by mc...@apache.org on 2016/05/17 14:33:54 UTC
[4/7] nifi git commit: NIFI-1554: - Introducing ControllerService and
ReportingTask authorization and revision. - Removing the revision where
appropriate. NIFI-1883 - Restoring referencing components automatically. -
This closes #448
http://git-wip-us.apache.org/repos/asf/nifi/blob/8bb56fca/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/NodeResource.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/NodeResource.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/NodeResource.java
index 6d19462..7993716 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/NodeResource.java
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/NodeResource.java
@@ -22,25 +22,19 @@ import com.wordnik.swagger.annotations.ApiParam;
import com.wordnik.swagger.annotations.ApiResponse;
import com.wordnik.swagger.annotations.ApiResponses;
import com.wordnik.swagger.annotations.Authorization;
-import org.apache.commons.lang3.StringUtils;
import org.apache.nifi.util.NiFiProperties;
import org.apache.nifi.web.IllegalClusterResourceRequestException;
import org.apache.nifi.web.NiFiServiceFacade;
import org.apache.nifi.web.api.dto.NodeDTO;
-import org.apache.nifi.web.api.dto.RevisionDTO;
import org.apache.nifi.web.api.entity.NodeEntity;
-import org.apache.nifi.web.api.request.ClientIdParameter;
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.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
-import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
@@ -56,13 +50,12 @@ public class NodeResource extends ApplicationResource {
/**
* Gets the contents of the specified node in this NiFi cluster.
*
- * @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 node id.
* @return A nodeEntity.
*/
@GET
@Consumes(MediaType.WILDCARD)
- @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
+ @Produces(MediaType.APPLICATION_JSON)
@Path("/{id}")
// TODO - @PreAuthorize("hasAnyRole('ROLE_MONITOR', 'ROLE_DFM', 'ROLE_ADMIN')")
@ApiOperation(
@@ -85,11 +78,6 @@ public class NodeResource extends ApplicationResource {
)
public Response getNode(
@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 node id.",
required = true
)
@@ -100,13 +88,8 @@ public class NodeResource extends ApplicationResource {
// get the specified relationship
final NodeDTO dto = serviceFacade.getNode(id);
- // create the revision
- final RevisionDTO revision = new RevisionDTO();
- revision.setClientId(clientId.getClientId());
-
// create the response entity
final NodeEntity entity = new NodeEntity();
- entity.setRevision(revision);
entity.setNode(dto);
// generate the response
@@ -117,45 +100,6 @@ public class NodeResource extends ApplicationResource {
throw new IllegalClusterResourceRequestException("Only a cluster manager can process the request.");
}
-
- /**
- * Updates the contents of the specified node in this NiFi cluster.
- *
- * @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 node.
- * @param status The status of the node.
- * @param primary Whether the node should be make primary.
- * @return A nodeEntity
- */
- @PUT
- @Consumes(MediaType.APPLICATION_FORM_URLENCODED)
- @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
- @Path("/{id}")
- // TODO - @PreAuthorize("hasAnyRole('ROLE_ADMIN')")
- public Response updateNode(@QueryParam(CLIENT_ID) @DefaultValue(StringUtils.EMPTY) ClientIdParameter clientId,
- @PathParam("id") String id,
- @FormParam("status") String status,
- @FormParam("primary") Boolean primary) {
-
- // create the node dto
- final NodeDTO nodeDTO = new NodeDTO();
- nodeDTO.setNodeId(id);
- nodeDTO.setStatus(status);
- nodeDTO.setPrimary(primary);
-
- // create the revision
- final RevisionDTO revision = new RevisionDTO();
- revision.setClientId(clientId.getClientId());
-
- // create the node entity
- final NodeEntity nodeEntity = new NodeEntity();
- nodeEntity.setRevision(revision);
- nodeEntity.setNode(nodeDTO);
-
- // update the node
- return updateNode(id, nodeEntity);
- }
-
/**
* Updates the contents of the specified node in this NiFi cluster.
*
@@ -164,8 +108,8 @@ public class NodeResource extends ApplicationResource {
* @return A nodeEntity
*/
@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}")
// TODO - @PreAuthorize("hasAnyRole('ROLE_ADMIN')")
@ApiOperation(
@@ -212,17 +156,8 @@ public class NodeResource extends ApplicationResource {
// update the node
final NodeDTO node = serviceFacade.updateNode(requestNodeDTO);
- // create the revision
- final RevisionDTO revision = new RevisionDTO();
- if (nodeEntity.getRevision() == null) {
- revision.setClientId(new ClientIdParameter().getClientId());
- } else {
- revision.setClientId(nodeEntity.getRevision().getClientId());
- }
-
// create the response entity
NodeEntity entity = new NodeEntity();
- entity.setRevision(revision);
entity.setNode(node);
// generate the response
@@ -235,13 +170,12 @@ public class NodeResource extends ApplicationResource {
/**
* Removes the specified from this NiFi cluster.
*
- * @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 node
* @return A nodeEntity
*/
@DELETE
@Consumes(MediaType.WILDCARD)
- @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
+ @Produces(MediaType.APPLICATION_JSON)
@Path("/{id}")
// TODO - @PreAuthorize("hasAnyRole('ROLE_ADMIN')")
@ApiOperation(
@@ -262,11 +196,6 @@ public class NodeResource extends ApplicationResource {
)
public Response deleteNode(
@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 node id.",
required = true
)
@@ -276,13 +205,8 @@ public class NodeResource extends ApplicationResource {
serviceFacade.deleteNode(id);
- // create the revision
- final RevisionDTO revision = new RevisionDTO();
- revision.setClientId(clientId.getClientId());
-
// create the response entity
final NodeEntity entity = new NodeEntity();
- entity.setRevision(revision);
// generate the response
return generateOkResponse(entity).build();
http://git-wip-us.apache.org/repos/asf/nifi/blob/8bb56fca/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/OutputPortResource.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/OutputPortResource.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/OutputPortResource.java
index 584ecc9..eb18b79 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/OutputPortResource.java
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/OutputPortResource.java
@@ -231,7 +231,7 @@ public class OutputPortResource extends ApplicationResource {
headersToOverride.put("content-type", MediaType.APPLICATION_JSON);
// replicate the request
- return clusterManager.applyRequest(HttpMethod.PUT, getAbsolutePath(), updateClientId(portEntity), getHeaders(headersToOverride)).getResponse();
+ return clusterManager.applyRequest(HttpMethod.PUT, getAbsolutePath(), portEntity, getHeaders(headersToOverride)).getResponse();
}
// handle expects request (usually from the cluster manager)
http://git-wip-us.apache.org/repos/asf/nifi/blob/8bb56fca/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 955d0bb..41f09d4 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
@@ -33,17 +33,14 @@ import org.apache.nifi.web.NiFiServiceFacade;
import org.apache.nifi.web.Revision;
import org.apache.nifi.web.UpdateResult;
import org.apache.nifi.web.api.dto.ConnectionDTO;
-import org.apache.nifi.web.api.dto.ControllerServiceDTO;
import org.apache.nifi.web.api.dto.ProcessGroupDTO;
import org.apache.nifi.web.api.dto.RemoteProcessGroupDTO;
-import org.apache.nifi.web.api.dto.RevisionDTO;
import org.apache.nifi.web.api.dto.SnippetDTO;
import org.apache.nifi.web.api.dto.TemplateDTO;
import org.apache.nifi.web.api.dto.flow.FlowDTO;
import org.apache.nifi.web.api.entity.ConnectionEntity;
import org.apache.nifi.web.api.entity.ConnectionsEntity;
import org.apache.nifi.web.api.entity.ControllerServiceEntity;
-import org.apache.nifi.web.api.entity.ControllerServicesEntity;
import org.apache.nifi.web.api.entity.CopySnippetRequestEntity;
import org.apache.nifi.web.api.entity.CreateTemplateRequestEntity;
import org.apache.nifi.web.api.entity.FlowEntity;
@@ -67,7 +64,6 @@ import org.apache.nifi.web.api.entity.TemplateEntity;
import org.apache.nifi.web.api.entity.TemplatesEntity;
import org.apache.nifi.web.api.request.ClientIdParameter;
import org.apache.nifi.web.api.request.LongParameter;
-import org.apache.nifi.web.util.Availability;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -96,7 +92,6 @@ import java.io.InputStream;
import java.net.URI;
import java.net.URISyntaxException;
import java.nio.charset.StandardCharsets;
-import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
@@ -341,7 +336,7 @@ public class ProcessGroupResource extends ApplicationResource {
}
if (properties.isClusterManager()) {
- return clusterManager.applyRequest(HttpMethod.PUT, getAbsolutePath(), updateClientId(processGroupEntity), getHeaders()).getResponse();
+ return clusterManager.applyRequest(HttpMethod.PUT, getAbsolutePath(), processGroupEntity, getHeaders()).getResponse();
}
// handle expects request (usually from the cluster manager)
@@ -495,7 +490,7 @@ public class ProcessGroupResource extends ApplicationResource {
processGroupEntity.getComponent().setParentGroupId(groupId);
if (properties.isClusterManager()) {
- return clusterManager.applyRequest(HttpMethod.POST, getAbsolutePath(), updateClientId(processGroupEntity), getHeaders()).getResponse();
+ return clusterManager.applyRequest(HttpMethod.POST, getAbsolutePath(), processGroupEntity, getHeaders()).getResponse();
}
// handle expects request (usually from the cluster manager)
@@ -644,7 +639,7 @@ public class ProcessGroupResource extends ApplicationResource {
processorEntity.getComponent().setParentGroupId(groupId);
if (properties.isClusterManager()) {
- return clusterManager.applyRequest(HttpMethod.POST, getAbsolutePath(), updateClientId(processorEntity), getHeaders()).getResponse();
+ return clusterManager.applyRequest(HttpMethod.POST, getAbsolutePath(), processorEntity, getHeaders()).getResponse();
}
// handle expects request (usually from the cluster manager)
@@ -782,7 +777,7 @@ public class ProcessGroupResource extends ApplicationResource {
portEntity.getComponent().setParentGroupId(groupId);
if (properties.isClusterManager()) {
- return clusterManager.applyRequest(HttpMethod.POST, getAbsolutePath(), updateClientId(portEntity), getHeaders()).getResponse();
+ return clusterManager.applyRequest(HttpMethod.POST, getAbsolutePath(), portEntity, getHeaders()).getResponse();
}
// handle expects request (usually from the cluster manager)
@@ -917,7 +912,7 @@ public class ProcessGroupResource extends ApplicationResource {
portEntity.getComponent().setParentGroupId(groupId);
if (properties.isClusterManager()) {
- return clusterManager.applyRequest(HttpMethod.POST, getAbsolutePath(), updateClientId(portEntity), getHeaders()).getResponse();
+ return clusterManager.applyRequest(HttpMethod.POST, getAbsolutePath(), portEntity, getHeaders()).getResponse();
}
// handle expects request (usually from the cluster manager)
@@ -1053,7 +1048,7 @@ public class ProcessGroupResource extends ApplicationResource {
funnelEntity.getComponent().setParentGroupId(groupId);
if (properties.isClusterManager()) {
- return clusterManager.applyRequest(HttpMethod.POST, getAbsolutePath(), updateClientId(funnelEntity), getHeaders()).getResponse();
+ return clusterManager.applyRequest(HttpMethod.POST, getAbsolutePath(), funnelEntity, getHeaders()).getResponse();
}
// handle expects request (usually from the cluster manager)
@@ -1189,7 +1184,7 @@ public class ProcessGroupResource extends ApplicationResource {
labelEntity.getComponent().setParentGroupId(groupId);
if (properties.isClusterManager()) {
- return clusterManager.applyRequest(HttpMethod.POST, getAbsolutePath(), updateClientId(labelEntity), getHeaders()).getResponse();
+ return clusterManager.applyRequest(HttpMethod.POST, getAbsolutePath(), labelEntity, getHeaders()).getResponse();
}
// handle expects request (usually from the cluster manager)
@@ -1331,7 +1326,7 @@ public class ProcessGroupResource extends ApplicationResource {
requestProcessGroupDTO.setParentGroupId(groupId);
if (properties.isClusterManager()) {
- return clusterManager.applyRequest(HttpMethod.POST, getAbsolutePath(), updateClientId(remoteProcessGroupEntity), getHeaders()).getResponse();
+ return clusterManager.applyRequest(HttpMethod.POST, getAbsolutePath(), remoteProcessGroupEntity, getHeaders()).getResponse();
}
// handle expects request (usually from the cluster manager)
@@ -1507,7 +1502,7 @@ public class ProcessGroupResource extends ApplicationResource {
connectionEntity.getComponent().setParentGroupId(groupId);
if (properties.isClusterManager()) {
- return clusterManager.applyRequest(HttpMethod.POST, getAbsolutePath(), updateClientId(connectionEntity), getHeaders()).getResponse();
+ return clusterManager.applyRequest(HttpMethod.POST, getAbsolutePath(), connectionEntity, getHeaders()).getResponse();
}
// get the connection
@@ -1655,7 +1650,7 @@ public class ProcessGroupResource extends ApplicationResource {
snippetEntity.getSnippet().setParentGroupId(groupId);
if (properties.isClusterManager()) {
- return clusterManager.applyRequest(HttpMethod.POST, getAbsolutePath(), updateClientId(snippetEntity), getHeaders()).getResponse();
+ return clusterManager.applyRequest(HttpMethod.POST, getAbsolutePath(), snippetEntity, getHeaders()).getResponse();
}
// handle expects request (usually from the cluster manager)
@@ -1797,7 +1792,7 @@ public class ProcessGroupResource extends ApplicationResource {
// replicate if cluster manager
if (properties.isClusterManager()) {
- return clusterManager.applyRequest(HttpMethod.PUT, getAbsolutePath(), updateClientId(snippetEntity), getHeaders()).getResponse();
+ return clusterManager.applyRequest(HttpMethod.PUT, getAbsolutePath(), snippetEntity, getHeaders()).getResponse();
}
// handle expects request (usually from the cluster manager)
@@ -1962,7 +1957,7 @@ public class ProcessGroupResource extends ApplicationResource {
// replicate if cluster manager
if (properties.isClusterManager()) {
- return clusterManager.applyRequest(HttpMethod.POST, getAbsolutePath(), updateClientId(copySnippetEntity), getHeaders()).getResponse();
+ return clusterManager.applyRequest(HttpMethod.POST, getAbsolutePath(), copySnippetEntity, getHeaders()).getResponse();
}
// handle expects request (usually from the cluster manager)
@@ -1983,7 +1978,6 @@ public class ProcessGroupResource extends ApplicationResource {
childGroupEntity.getComponent().setContents(null);
}
-
// create the response entity
populateRemainingSnippetContent(flow);
@@ -2046,7 +2040,7 @@ public class ProcessGroupResource extends ApplicationResource {
// replicate if cluster manager
if (properties.isClusterManager()) {
- return clusterManager.applyRequest(HttpMethod.POST, getAbsolutePath(), updateClientId(instantiateTemplateRequestEntity), getHeaders()).getResponse();
+ return clusterManager.applyRequest(HttpMethod.POST, getAbsolutePath(), instantiateTemplateRequestEntity, getHeaders()).getResponse();
}
// handle expects request (usually from the cluster manager)
@@ -2066,7 +2060,6 @@ public class ProcessGroupResource extends ApplicationResource {
childGroupEntity.getComponent().setContents(null);
}
-
// create the response entity
populateRemainingSnippetContent(flowSnippet);
@@ -2120,12 +2113,8 @@ public class ProcessGroupResource extends ApplicationResource {
// get all the templates
final Set<TemplateDTO> templates = templateResource.populateRemainingTemplatesContent(serviceFacade.getTemplates());
- // create the revision
- final RevisionDTO revision = new RevisionDTO();
-
// create the response entity
final TemplatesEntity entity = new TemplatesEntity();
- entity.setRevision(revision);
entity.setTemplates(templates);
entity.setGenerated(new Date());
@@ -2177,7 +2166,7 @@ public class ProcessGroupResource extends ApplicationResource {
// replicate if cluster manager
if (properties.isClusterManager()) {
- return clusterManager.applyRequest(HttpMethod.POST, getAbsolutePath(), updateClientId(createTemplateRequestEntity), getHeaders()).getResponse();
+ return clusterManager.applyRequest(HttpMethod.POST, getAbsolutePath(), createTemplateRequestEntity, getHeaders()).getResponse();
}
// handle expects request (usually from the cluster manager)
@@ -2187,18 +2176,12 @@ public class ProcessGroupResource extends ApplicationResource {
}
// create the template and generate the json
- final RevisionDTO revisionDTO = createTemplateRequestEntity.getRevision();
final TemplateDTO template = serviceFacade.createTemplate(createTemplateRequestEntity.getName(), createTemplateRequestEntity.getDescription(),
createTemplateRequestEntity.getSnippetId(), groupId);
templateResource.populateRemainingTemplateContent(template);
- // create the revision
- final RevisionDTO revision = new RevisionDTO();
- revision.setClientId(revisionDTO.getClientId());
-
// build the response entity
final TemplateEntity entity = new TemplateEntity();
- entity.setRevision(revision);
entity.setTemplate(template);
// build the response
@@ -2252,13 +2235,8 @@ public class ProcessGroupResource extends ApplicationResource {
return Response.status(Response.Status.OK).entity(responseXml).type("application/xml").build();
}
- // create the revision
- final RevisionDTO revision = new RevisionDTO();
- revision.setClientId(clientId.getClientId());
-
// build the response entity
TemplateEntity entity = new TemplateEntity();
- entity.setRevision(revision);
entity.setTemplate(template);
// replicate if cluster manager
@@ -2276,7 +2254,7 @@ public class ProcessGroupResource extends ApplicationResource {
headersToOverride.put("content-type", MediaType.APPLICATION_XML);
// replicate the request
- return clusterManager.applyRequest(HttpMethod.POST, importUri, updateClientId(entity), getHeaders(headersToOverride)).getResponse();
+ return clusterManager.applyRequest(HttpMethod.POST, importUri, entity, getHeaders(headersToOverride)).getResponse();
}
// otherwise import the template locally
@@ -2306,7 +2284,7 @@ public class ProcessGroupResource extends ApplicationResource {
// replicate if cluster manager
if (properties.isClusterManager()) {
- return clusterManager.applyRequest(HttpMethod.POST, getAbsolutePath(), updateClientId(templateEntity), getHeaders()).getResponse();
+ return clusterManager.applyRequest(HttpMethod.POST, getAbsolutePath(), templateEntity, getHeaders()).getResponse();
}
// handle expects request (usually from the cluster manager)
@@ -2325,17 +2303,8 @@ public class ProcessGroupResource extends ApplicationResource {
final TemplateDTO template = serviceFacade.importTemplate(templateEntity.getTemplate(), groupId);
templateResource.populateRemainingTemplateContent(template);
- // create the revision
- final RevisionDTO revision = new RevisionDTO();
- if (templateEntity.getRevision() == null) {
- revision.setClientId(new ClientIdParameter().getClientId());
- } else {
- revision.setClientId(templateEntity.getRevision().getClientId());
- }
-
// build the response entity
TemplateEntity entity = new TemplateEntity();
- entity.setRevision(revision);
entity.setTemplate(template);
// build the response
@@ -2360,16 +2329,13 @@ public class ProcessGroupResource extends ApplicationResource {
* Creates a new Controller Service.
*
* @param httpServletRequest request
- * @param availability Whether the controller service is available on the
- * NCM only (ncm) or on the nodes only (node). If this instance is not
- * clustered all services should use the node availability.
* @param controllerServiceEntity A controllerServiceEntity.
* @return A controllerServiceEntity.
*/
@POST
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
- @Path("{id}/controller-services/{availability}")
+ @Path("{id}/controller-services")
// TODO - @PreAuthorize("hasRole('ROLE_DFM')")
@ApiOperation(
value = "Creates a new controller service",
@@ -2394,41 +2360,30 @@ public class ProcessGroupResource extends ApplicationResource {
)
@PathParam("id") String groupId,
@ApiParam(
- value = "Whether the controller service is available on the NCM or nodes. If the NiFi is standalone the availability should be NODE.",
- allowableValues = "NCM, NODE",
- required = true
- )
- @PathParam("availability") String availability,
- @ApiParam(
value = "The controller service configuration details.",
required = true
) ControllerServiceEntity controllerServiceEntity) {
- final Availability avail = controllerServiceResource.parseAvailability(availability);
-
- if (controllerServiceEntity == null || controllerServiceEntity.getControllerService() == null) {
+ if (controllerServiceEntity == null || controllerServiceEntity.getComponent() == null) {
throw new IllegalArgumentException("Controller service details must be specified.");
}
- if (controllerServiceEntity.getControllerService().getId() != null) {
+ if (controllerServiceEntity.getComponent().getId() != null) {
throw new IllegalArgumentException("Controller service ID cannot be specified.");
}
- if (StringUtils.isBlank(controllerServiceEntity.getControllerService().getType())) {
+ if (StringUtils.isBlank(controllerServiceEntity.getComponent().getType())) {
throw new IllegalArgumentException("The type of controller service to create must be specified.");
}
- if (controllerServiceEntity.getControllerService().getParentGroupId() != null && !groupId.equals(controllerServiceEntity.getControllerService().getParentGroupId())) {
+ if (controllerServiceEntity.getComponent().getParentGroupId() != null && !groupId.equals(controllerServiceEntity.getComponent().getParentGroupId())) {
throw new IllegalArgumentException(String.format("If specified, the parent process group id %s must be the same as specified in the URI %s",
- controllerServiceEntity.getControllerService().getParentGroupId(), groupId));
+ controllerServiceEntity.getComponent().getParentGroupId(), groupId));
}
- controllerServiceEntity.getControllerService().setParentGroupId(groupId);
-
- // get the revision
- final RevisionDTO revision = controllerServiceEntity.getRevision();
+ controllerServiceEntity.getComponent().setParentGroupId(groupId);
if (properties.isClusterManager()) {
- return clusterManager.applyRequest(HttpMethod.POST, getAbsolutePath(), updateClientId(controllerServiceEntity), getHeaders()).getResponse();
+ return clusterManager.applyRequest(HttpMethod.POST, getAbsolutePath(), controllerServiceEntity, getHeaders()).getResponse();
}
// handle expects request (usually from the cluster manager)
@@ -2440,90 +2395,17 @@ public class ProcessGroupResource extends ApplicationResource {
// set the processor id as appropriate
final ClusterContext clusterContext = ClusterContextThreadLocal.getContext();
if (clusterContext != null) {
- controllerServiceEntity.getControllerService().setId(UUID.nameUUIDFromBytes(clusterContext.getIdGenerationSeed().getBytes(StandardCharsets.UTF_8)).toString());
+ controllerServiceEntity.getComponent().setId(UUID.nameUUIDFromBytes(clusterContext.getIdGenerationSeed().getBytes(StandardCharsets.UTF_8)).toString());
} else {
- controllerServiceEntity.getControllerService().setId(UUID.randomUUID().toString());
+ controllerServiceEntity.getComponent().setId(UUID.randomUUID().toString());
}
// create the controller service and generate the json
- final ControllerServiceEntity entity = serviceFacade.createControllerService(
- new Revision(revision.getVersion(), revision.getClientId()), groupId, controllerServiceEntity.getControllerService());
-
- // build the response entity
- controllerServiceResource.populateRemainingControllerServiceContent(availability, entity.getControllerService());
+ final ControllerServiceEntity entity = serviceFacade.createControllerService(groupId, controllerServiceEntity.getComponent());
+ controllerServiceResource.populateRemainingControllerServiceContent(entity.getComponent());
// build the response
- return clusterContext(generateCreatedResponse(URI.create(entity.getControllerService().getUri()), entity)).build();
- }
-
- /**
- * Retrieves all the of controller services in this NiFi.
- *
- * @param availability Whether the controller service is available on the
- * NCM only (ncm) or on the nodes only (node). If this instance is not
- * clustered all services should use the node availability.
- * @return A controllerServicesEntity.
- */
- @GET
- @Consumes(MediaType.WILDCARD)
- @Produces(MediaType.APPLICATION_JSON)
- @Path("{id}/controller-services/{availability}")
- // TODO - @PreAuthorize("hasAnyRole('ROLE_MONITOR', 'ROLE_DFM', 'ROLE_ADMIN')")
- @ApiOperation(
- value = "Gets all controller services",
- response = ControllerServicesEntity.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 = 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 getControllerServices(
- @ApiParam(
- value = "The process group id.",
- required = true
- )
- @PathParam("id") String groupId,
- @ApiParam(
- value = "Whether the controller service is available on the NCM or nodes. If the NiFi is standalone the availability should be NODE.",
- allowableValues = "NCM, NODE",
- required = true
- )
- @PathParam("availability") String availability) {
-
- final Availability avail = controllerServiceResource.parseAvailability(availability);
-
- // replicate if cluster manager
- if (properties.isClusterManager() && Availability.NODE.equals(avail)) {
- return clusterManager.applyRequest(HttpMethod.GET, getAbsolutePath(), getRequestParameters(true), getHeaders()).getResponse();
- } else if (properties.isClusterManager()) {
- // create the response entity
- final ControllerServicesEntity entity = new ControllerServicesEntity();
- entity.setControllerServices(Collections.emptySet());
- return clusterContext(generateOkResponse(entity)).build();
- }
-
- // get all the controller services
- final Set<ControllerServiceDTO> controllerServices = controllerServiceResource.populateRemainingControllerServicesContent(availability, serviceFacade.getControllerServices(groupId));
-
- // create the revision
- final RevisionDTO revision = new RevisionDTO();
-
- // create the response entity
- final ControllerServicesEntity entity = new ControllerServicesEntity();
- entity.setRevision(revision);
- entity.setControllerServices(controllerServices);
-
- // generate the response
- return clusterContext(generateOkResponse(entity)).build();
+ return clusterContext(generateCreatedResponse(URI.create(entity.getComponent().getUri()), entity)).build();
}
// setters
http://git-wip-us.apache.org/repos/asf/nifi/blob/8bb56fca/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/ProcessorResource.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/ProcessorResource.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/ProcessorResource.java
index 6356a18..4178774 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/ProcessorResource.java
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/ProcessorResource.java
@@ -30,7 +30,6 @@ import org.apache.nifi.scheduling.SchedulingStrategy;
import org.apache.nifi.ui.extension.UiExtension;
import org.apache.nifi.ui.extension.UiExtensionMapping;
import org.apache.nifi.util.NiFiProperties;
-import org.apache.nifi.web.ConfigurationSnapshot;
import org.apache.nifi.web.NiFiServiceFacade;
import org.apache.nifi.web.Revision;
import org.apache.nifi.web.UiExtensionType;
@@ -39,9 +38,7 @@ import org.apache.nifi.web.api.dto.ComponentStateDTO;
import org.apache.nifi.web.api.dto.ProcessorConfigDTO;
import org.apache.nifi.web.api.dto.ProcessorDTO;
import org.apache.nifi.web.api.dto.PropertyDescriptorDTO;
-import org.apache.nifi.web.api.dto.RevisionDTO;
import org.apache.nifi.web.api.entity.ComponentStateEntity;
-import org.apache.nifi.web.api.entity.Entity;
import org.apache.nifi.web.api.entity.ProcessorEntity;
import org.apache.nifi.web.api.entity.PropertyDescriptorEntity;
import org.apache.nifi.web.api.request.ClientIdParameter;
@@ -364,7 +361,7 @@ public class ProcessorResource extends ApplicationResource {
value = "The revision used to verify the client is working with the latest version of the flow.",
required = true
)
- Entity revisionEntity,
+ ComponentStateEntity revisionEntity,
@ApiParam(
value = "The processor id.",
required = true
@@ -372,7 +369,7 @@ public class ProcessorResource extends ApplicationResource {
@PathParam("id") String id) {
// ensure the revision was specified
- if (revisionEntity == null || revisionEntity.getRevision() == null) {
+ if (revisionEntity == null) {
throw new IllegalArgumentException("Revision must be specified.");
}
@@ -382,28 +379,16 @@ public class ProcessorResource extends ApplicationResource {
}
// handle expects request (usually from the cluster manager)
- final Revision revision = getRevision(revisionEntity.getRevision(), id);
- final boolean validationPhase = isValidationPhase(httpServletRequest);
- if (validationPhase || !isTwoPhaseRequest(httpServletRequest)) {
- serviceFacade.claimRevision(revision);
- }
-
- if (validationPhase) {
+ if (isValidationPhase(httpServletRequest)) {
serviceFacade.verifyCanClearProcessorState(id);
return generateContinueResponse().build();
}
// get the component state
- final ConfigurationSnapshot<Void> snapshot = serviceFacade.clearProcessorState(revision, id);
-
- // create the revision
- final RevisionDTO responseRevision = new RevisionDTO();
- responseRevision.setClientId(revision.getClientId());
- responseRevision.setVersion(snapshot.getVersion());
+ serviceFacade.clearProcessorState(id);
// generate the response entity
final ComponentStateEntity entity = new ComponentStateEntity();
- entity.setRevision(responseRevision);
// generate the response
return clusterContext(generateOkResponse(entity)).build();
@@ -478,7 +463,7 @@ public class ProcessorResource extends ApplicationResource {
}
// replicate the request
- return clusterManager.applyRequest(HttpMethod.PUT, getAbsolutePath(), updateClientId(processorEntity), getHeaders()).getResponse();
+ return clusterManager.applyRequest(HttpMethod.PUT, getAbsolutePath(), processorEntity, getHeaders()).getResponse();
}
// handle expects request (usually from the cluster manager)
http://git-wip-us.apache.org/repos/asf/nifi/blob/8bb56fca/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/ProvenanceResource.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/ProvenanceResource.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/ProvenanceResource.java
index bc9bcc8..f0e3a25 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/ProvenanceResource.java
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/ProvenanceResource.java
@@ -22,7 +22,6 @@ import com.wordnik.swagger.annotations.ApiParam;
import com.wordnik.swagger.annotations.ApiResponse;
import com.wordnik.swagger.annotations.ApiResponses;
import com.wordnik.swagger.annotations.Authorization;
-import org.apache.commons.lang3.StringUtils;
import org.apache.nifi.cluster.context.ClusterContext;
import org.apache.nifi.cluster.context.ClusterContextThreadLocal;
import org.apache.nifi.cluster.manager.exception.UnknownNodeException;
@@ -34,7 +33,6 @@ import org.apache.nifi.stream.io.StreamUtils;
import org.apache.nifi.util.NiFiProperties;
import org.apache.nifi.web.DownloadableContent;
import org.apache.nifi.web.NiFiServiceFacade;
-import org.apache.nifi.web.api.dto.RevisionDTO;
import org.apache.nifi.web.api.dto.provenance.ProvenanceDTO;
import org.apache.nifi.web.api.dto.provenance.ProvenanceEventDTO;
import org.apache.nifi.web.api.dto.provenance.ProvenanceOptionsDTO;
@@ -45,7 +43,6 @@ import org.apache.nifi.web.api.entity.ProvenanceEntity;
import org.apache.nifi.web.api.entity.ProvenanceEventEntity;
import org.apache.nifi.web.api.entity.ProvenanceOptionsEntity;
import org.apache.nifi.web.api.entity.SubmitReplayRequestEntity;
-import org.apache.nifi.web.api.request.ClientIdParameter;
import org.apache.nifi.web.api.request.LongParameter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -53,7 +50,6 @@ import org.slf4j.LoggerFactory;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
-import javax.ws.rs.DefaultValue;
import javax.ws.rs.GET;
import javax.ws.rs.HttpMethod;
import javax.ws.rs.POST;
@@ -113,7 +109,6 @@ public class ProvenanceResource extends ApplicationResource {
/**
* Gets the provenance search options for this NiFi.
*
- * @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 provenanceOptionsEntity
*/
@GET
@@ -136,12 +131,7 @@ public class ProvenanceResource extends ApplicationResource {
@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 getSearchOptions(
- @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) {
+ public Response getSearchOptions() {
// replicate if cluster manager
if (properties.isClusterManager()) {
@@ -151,14 +141,9 @@ public class ProvenanceResource extends ApplicationResource {
// get provenance search options
final ProvenanceOptionsDTO searchOptions = serviceFacade.getProvenanceSearchOptions();
- // create a revision to return
- final RevisionDTO revision = new RevisionDTO();
- revision.setClientId(clientId.getClientId());
-
// create the response entity
final ProvenanceOptionsEntity entity = new ProvenanceOptionsEntity();
entity.setProvenanceOptions(searchOptions);
- entity.setRevision(revision);
// generate the response
return clusterContext(noCache(Response.ok(entity))).build();
@@ -231,17 +216,11 @@ public class ProvenanceResource extends ApplicationResource {
}
// submit the provenance replay request
- final RevisionDTO requestRevision = replayRequestEntity.getRevision();
final ProvenanceEventDTO event = serviceFacade.submitReplay(replayRequestEntity.getEventId());
- // create a revision to return
- final RevisionDTO revision = new RevisionDTO();
- revision.setClientId(requestRevision.getClientId());
-
// create a response entity
final ProvenanceEventEntity entity = new ProvenanceEventEntity();
entity.setProvenanceEvent(event);
- entity.setRevision(revision);
// generate the response
URI uri = URI.create(generateResourceUri("provenance", "events", event.getId()));
@@ -251,7 +230,6 @@ public class ProvenanceResource extends ApplicationResource {
/**
* Gets the content for the input of the specified event.
*
- * @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 clusterNodeId The id of the node within the cluster this content is on. Required if clustered.
* @param id The id of the provenance event associated with this content.
* @return The content stream
@@ -278,11 +256,6 @@ public class ProvenanceResource extends ApplicationResource {
)
public Response getInputContent(
@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 id of the node where the content exists if clustered.",
required = false
)
@@ -350,7 +323,6 @@ public class ProvenanceResource extends ApplicationResource {
/**
* Gets the content for the output of the specified event.
*
- * @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 clusterNodeId The id of the node within the cluster this content is on. Required if clustered.
* @param id The id of the provenance event associated with this content.
* @return The content stream
@@ -377,11 +349,6 @@ public class ProvenanceResource extends ApplicationResource {
)
public Response getOutputContent(
@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 id of the node where the content exists if clustered.",
required = false
)
@@ -505,7 +472,7 @@ public class ProvenanceResource extends ApplicationResource {
// determine where this request should be sent
if (provenanceDto.getClusterNodeId() == null) {
// replicate to all nodes
- return clusterManager.applyRequest(HttpMethod.POST, getAbsolutePath(), updateClientId(provenanceEntity), getHeaders(headersToOverride)).getResponse();
+ return clusterManager.applyRequest(HttpMethod.POST, getAbsolutePath(), provenanceEntity, getHeaders(headersToOverride)).getResponse();
} else {
// get the target node and ensure it exists
final Node targetNode = clusterManager.getNode(provenanceDto.getClusterNodeId());
@@ -517,7 +484,7 @@ public class ProvenanceResource extends ApplicationResource {
targetNodes.add(targetNode.getNodeId());
// send to every node
- return clusterManager.applyRequest(HttpMethod.POST, getAbsolutePath(), updateClientId(provenanceEntity), getHeaders(headersToOverride), targetNodes).getResponse();
+ return clusterManager.applyRequest(HttpMethod.POST, getAbsolutePath(), provenanceEntity, getHeaders(headersToOverride), targetNodes).getResponse();
}
}
@@ -544,18 +511,9 @@ public class ProvenanceResource extends ApplicationResource {
dto.setClusterNodeId(provenanceDto.getClusterNodeId());
populateRemainingProvenanceContent(dto);
- // create the revision
- final RevisionDTO revision = new RevisionDTO();
- if (provenanceEntity.getRevision() == null) {
- revision.setClientId(new ClientIdParameter().getClientId());
- } else {
- revision.setClientId(provenanceEntity.getRevision().getClientId());
- }
-
// create the response entity
final ProvenanceEntity entity = new ProvenanceEntity();
entity.setProvenance(dto);
- entity.setRevision(revision);
// generate the response
return clusterContext(generateCreatedResponse(URI.create(dto.getUri()), entity)).build();
@@ -564,7 +522,6 @@ public class ProvenanceResource extends ApplicationResource {
/**
* Gets the provenance with the specified id.
*
- * @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 provenance
* @param clusterNodeId The id of node in the cluster to search. This is optional and only relevant when clustered. If clustered and it is not specified the entire cluster is searched.
* @return A provenanceEntity
@@ -592,11 +549,6 @@ public class ProvenanceResource extends ApplicationResource {
)
public Response getProvenance(
@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 id of the node where this query exists if clustered.",
required = false
)
@@ -633,14 +585,9 @@ public class ProvenanceResource extends ApplicationResource {
dto.setClusterNodeId(clusterNodeId);
populateRemainingProvenanceContent(dto);
- // create a revision to return
- final RevisionDTO revision = new RevisionDTO();
- revision.setClientId(clientId.getClientId());
-
// create the response entity
final ProvenanceEntity entity = new ProvenanceEntity();
entity.setProvenance(dto);
- entity.setRevision(revision);
// generate the response
return clusterContext(generateOkResponse(entity)).build();
@@ -650,7 +597,6 @@ public class ProvenanceResource extends ApplicationResource {
* Deletes the provenance with the specified id.
*
* @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 provenance
* @param clusterNodeId The id of node in the cluster to search. This is optional and only relevant when clustered. If clustered and it is not specified the entire cluster is searched.
* @return A provenanceEntity
@@ -679,11 +625,6 @@ public class ProvenanceResource extends ApplicationResource {
public Response deleteProvenance(
@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 id of the node where this query exists if clustered.",
required = false
)
@@ -724,13 +665,8 @@ public class ProvenanceResource extends ApplicationResource {
// delete the provenance
serviceFacade.deleteProvenance(id);
- // create a revision to return
- final RevisionDTO revision = new RevisionDTO();
- revision.setClientId(clientId.getClientId());
-
// create the response entity
final ProvenanceEntity entity = new ProvenanceEntity();
- entity.setRevision(revision);
// generate the response
return clusterContext(generateOkResponse(entity)).build();
@@ -739,7 +675,6 @@ public class ProvenanceResource extends ApplicationResource {
/**
* Gets the details for a provenance event.
*
- * @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 event
* @param clusterNodeId The id of node in the cluster that the event/flowfile originated from. This is only required when clustered.
* @return A provenanceEventEntity
@@ -767,11 +702,6 @@ public class ProvenanceResource extends ApplicationResource {
)
public Response getProvenanceEvent(
@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 id of the node where this event exists if clustered.",
required = false
)
@@ -810,17 +740,9 @@ public class ProvenanceResource extends ApplicationResource {
// get the provenance event
final ProvenanceEventDTO event = serviceFacade.getProvenanceEvent(id.getLong());
- // event clusterNodeId is set in the NCM where the request is replicated. it is not set
- // here because we also need the clusterNodeAddress (address:apiPort) that is unknown
- // at ths point.
- // create a revision to return
- final RevisionDTO revision = new RevisionDTO();
- revision.setClientId(clientId.getClientId());
-
// create a response entity
final ProvenanceEventEntity entity = new ProvenanceEventEntity();
entity.setProvenanceEvent(event);
- entity.setRevision(revision);
// generate the response
return clusterContext(generateOkResponse(entity)).build();
@@ -921,7 +843,7 @@ public class ProvenanceResource extends ApplicationResource {
headersToOverride.put("content-type", MediaType.APPLICATION_JSON);
// send to every node
- return clusterManager.applyRequest(HttpMethod.POST, getAbsolutePath(), updateClientId(lineageEntity), getHeaders(headersToOverride), targetNodes).getResponse();
+ return clusterManager.applyRequest(HttpMethod.POST, getAbsolutePath(), lineageEntity, getHeaders(headersToOverride), targetNodes).getResponse();
}
// handle expects request (usually from the cluster manager)
@@ -935,18 +857,9 @@ public class ProvenanceResource extends ApplicationResource {
dto.setClusterNodeId(lineageDto.getClusterNodeId());
populateRemainingLineageContent(dto);
- // create the revision
- final RevisionDTO revision = new RevisionDTO();
- if (lineageEntity.getRevision() == null) {
- revision.setClientId(new ClientIdParameter().getClientId());
- } else {
- revision.setClientId(lineageEntity.getRevision().getClientId());
- }
-
// create a response entity
final LineageEntity entity = new LineageEntity();
entity.setLineage(dto);
- entity.setRevision(revision);
// generate the response
return clusterContext(generateOkResponse(entity)).build();
@@ -955,7 +868,6 @@ public class ProvenanceResource extends ApplicationResource {
/**
* Gets the lineage with the specified id.
*
- * @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 clusterNodeId The id of node in the cluster that the event/flowfile originated from. This is only required when clustered.
* @param id The id of the lineage
* @return A lineageEntity
@@ -983,11 +895,6 @@ public class ProvenanceResource extends ApplicationResource {
)
public Response getLineage(
@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 id of the node where this query exists if clustered.",
required = false
)
@@ -1022,14 +929,9 @@ public class ProvenanceResource extends ApplicationResource {
dto.setClusterNodeId(clusterNodeId);
populateRemainingLineageContent(dto);
- // create a revision to return
- final RevisionDTO revision = new RevisionDTO();
- revision.setClientId(clientId.getClientId());
-
// create the response entity
final LineageEntity entity = new LineageEntity();
entity.setLineage(dto);
- entity.setRevision(revision);
// generate the response
return clusterContext(generateOkResponse(entity)).build();
@@ -1039,7 +941,6 @@ public class ProvenanceResource extends ApplicationResource {
* Deletes the lineage with the specified id.
*
* @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 clusterNodeId The id of node in the cluster that the event/flowfile originated from. This is only required when clustered.
* @param id The id of the lineage
* @return A lineageEntity
@@ -1068,11 +969,6 @@ public class ProvenanceResource extends ApplicationResource {
public Response deleteLineage(
@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 id of the node where this query exists if clustered.",
required = false
)
@@ -1111,13 +1007,8 @@ public class ProvenanceResource extends ApplicationResource {
// delete the lineage
serviceFacade.deleteLineage(id);
- // create a revision to return
- final RevisionDTO revision = new RevisionDTO();
- revision.setClientId(clientId.getClientId());
-
// create the response entity
final LineageEntity entity = new LineageEntity();
- entity.setRevision(revision);
// generate the response
return clusterContext(generateOkResponse(entity)).build();
http://git-wip-us.apache.org/repos/asf/nifi/blob/8bb56fca/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/RemoteProcessGroupResource.java
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/RemoteProcessGroupResource.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/RemoteProcessGroupResource.java
index 489cc1d..96183ea 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/RemoteProcessGroupResource.java
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/RemoteProcessGroupResource.java
@@ -313,7 +313,7 @@ public class RemoteProcessGroupResource extends ApplicationResource {
headersToOverride.put("content-type", MediaType.APPLICATION_JSON);
// replicate the request
- return clusterManager.applyRequest(HttpMethod.PUT, getAbsolutePath(), updateClientId(remoteProcessGroupPortEntity), getHeaders(headersToOverride)).getResponse();
+ return clusterManager.applyRequest(HttpMethod.PUT, getAbsolutePath(), remoteProcessGroupPortEntity, getHeaders(headersToOverride)).getResponse();
}
// handle expects request (usually from the cluster manager)
@@ -401,7 +401,7 @@ public class RemoteProcessGroupResource extends ApplicationResource {
headersToOverride.put("content-type", MediaType.APPLICATION_JSON);
// replicate the request
- return clusterManager.applyRequest(HttpMethod.PUT, getAbsolutePath(), updateClientId(remoteProcessGroupPortEntity), getHeaders(headersToOverride)).getResponse();
+ return clusterManager.applyRequest(HttpMethod.PUT, getAbsolutePath(), remoteProcessGroupPortEntity, getHeaders(headersToOverride)).getResponse();
}
// handle expects request (usually from the cluster manager)
@@ -486,7 +486,7 @@ public class RemoteProcessGroupResource extends ApplicationResource {
headersToOverride.put("content-type", MediaType.APPLICATION_JSON);
// replicate the request
- return clusterManager.applyRequest(HttpMethod.PUT, getAbsolutePath(), updateClientId(remoteProcessGroupEntity), getHeaders(headersToOverride)).getResponse();
+ return clusterManager.applyRequest(HttpMethod.PUT, getAbsolutePath(), remoteProcessGroupEntity, getHeaders(headersToOverride)).getResponse();
}
// handle expects request (usually from the cluster manager)
http://git-wip-us.apache.org/repos/asf/nifi/blob/8bb56fca/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/ReportingTaskResource.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/ReportingTaskResource.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/ReportingTaskResource.java
index b627964..bd17643 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/ReportingTaskResource.java
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/ReportingTaskResource.java
@@ -27,7 +27,6 @@ import org.apache.nifi.cluster.manager.impl.WebClusterManager;
import org.apache.nifi.ui.extension.UiExtension;
import org.apache.nifi.ui.extension.UiExtensionMapping;
import org.apache.nifi.util.NiFiProperties;
-import org.apache.nifi.web.ConfigurationSnapshot;
import org.apache.nifi.web.NiFiServiceFacade;
import org.apache.nifi.web.Revision;
import org.apache.nifi.web.UiExtensionType;
@@ -35,14 +34,11 @@ import org.apache.nifi.web.UpdateResult;
import org.apache.nifi.web.api.dto.ComponentStateDTO;
import org.apache.nifi.web.api.dto.PropertyDescriptorDTO;
import org.apache.nifi.web.api.dto.ReportingTaskDTO;
-import org.apache.nifi.web.api.dto.RevisionDTO;
import org.apache.nifi.web.api.entity.ComponentStateEntity;
-import org.apache.nifi.web.api.entity.Entity;
import org.apache.nifi.web.api.entity.PropertyDescriptorEntity;
import org.apache.nifi.web.api.entity.ReportingTaskEntity;
import org.apache.nifi.web.api.request.ClientIdParameter;
import org.apache.nifi.web.api.request.LongParameter;
-import org.apache.nifi.web.util.Availability;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
@@ -82,14 +78,42 @@ public class ReportingTaskResource extends ApplicationResource {
private ServletContext servletContext;
/**
+ * Populate the uri's for the specified reporting tasks.
+ *
+ * @param reportingTaskEntities reporting tasks
+ * @return dtos
+ */
+ public Set<ReportingTaskEntity> populateRemainingReportingTaskEntitiesContent(final Set<ReportingTaskEntity> reportingTaskEntities) {
+ for (ReportingTaskEntity reportingTaskEntity : reportingTaskEntities) {
+ if (reportingTaskEntity.getComponent() != null) {
+ populateRemainingReportingTaskEntityContent(reportingTaskEntity);
+ }
+ }
+ return reportingTaskEntities;
+ }
+
+ /**
+ * Populate the uri's for the specified reporting task.
+ *
+ * @param reportingTaskEntity reporting task
+ * @return dtos
+ */
+ public ReportingTaskEntity populateRemainingReportingTaskEntityContent(final ReportingTaskEntity reportingTaskEntity) {
+ if (reportingTaskEntity.getComponent() != null) {
+ populateRemainingReportingTaskContent(reportingTaskEntity.getComponent());
+ }
+ return reportingTaskEntity;
+ }
+
+ /**
* Populates the uri for the specified reporting task.
*
* @param reportingTasks tasks
* @return tasks
*/
- public Set<ReportingTaskDTO> populateRemainingReportingTasksContent(final String availability, final Set<ReportingTaskDTO> reportingTasks) {
+ public Set<ReportingTaskDTO> populateRemainingReportingTasksContent(final Set<ReportingTaskDTO> reportingTasks) {
for (ReportingTaskDTO reportingTask : reportingTasks) {
- populateRemainingReportingTaskContent(availability, reportingTask);
+ populateRemainingReportingTaskContent(reportingTask);
}
return reportingTasks;
}
@@ -97,10 +121,9 @@ public class ReportingTaskResource extends ApplicationResource {
/**
* Populates the uri for the specified reporting task.
*/
- public ReportingTaskDTO populateRemainingReportingTaskContent(final String availability, final ReportingTaskDTO reportingTask) {
+ public ReportingTaskDTO populateRemainingReportingTaskContent(final ReportingTaskDTO reportingTask) {
// populate the reporting task href
- reportingTask.setUri(generateResourceUri("reporting-tasks", availability, reportingTask.getId()));
- reportingTask.setAvailability(availability);
+ reportingTask.setUri(generateResourceUri("reporting-tasks", reportingTask.getId()));
// see if this processor has any ui extensions
final UiExtensionMapping uiExtensionMapping = (UiExtensionMapping) servletContext.getAttribute("nifi-ui-extensions");
@@ -117,41 +140,18 @@ public class ReportingTaskResource extends ApplicationResource {
}
/**
- * Parses the availability and ensure that the specified availability makes
- * sense for the given NiFi instance.
- */
- public Availability parseAvailability(final String availability) {
- final Availability avail;
- try {
- avail = Availability.valueOf(availability.toUpperCase());
- } catch (IllegalArgumentException iae) {
- throw new IllegalArgumentException(String.format("Availability: Value must be one of [%s]", StringUtils.join(Availability.values(), ", ")));
- }
-
- // ensure this nifi is an NCM is specifying NCM availability
- if (!properties.isClusterManager() && Availability.NCM.equals(avail)) {
- throw new IllegalArgumentException("Availability of NCM is only applicable when the NiFi instance is the cluster manager.");
- }
-
- return avail;
- }
-
- /**
* Retrieves the specified reporting task.
*
* @param clientId Optional client id. If the client id is not specified, a
* new one will be generated. This value (whether specified or generated) is
* included in the response.
- * @param availability Whether the reporting task is available on the NCM
- * only (ncm) or on the nodes only (node). If this instance is not clustered
- * all tasks should use the node availability.
* @param id The id of the reporting task to retrieve
* @return A reportingTaskEntity.
*/
@GET
@Consumes(MediaType.WILDCARD)
@Produces(MediaType.APPLICATION_JSON)
- @Path("{availability}/{id}")
+ @Path("{id}")
// TODO - @PreAuthorize("hasAnyRole('ROLE_MONITOR', 'ROLE_DFM', 'ROLE_ADMIN')")
@ApiOperation(
value = "Gets a reporting task",
@@ -178,37 +178,21 @@ public class ReportingTaskResource extends ApplicationResource {
)
@QueryParam(CLIENT_ID) @DefaultValue(StringUtils.EMPTY) ClientIdParameter clientId,
@ApiParam(
- value = "Whether the reporting task is available on the NCM or nodes. If the NiFi is standalone the availability should be NODE.",
- allowableValues = "NCM, NODE",
- required = true
- )
- @PathParam("availability") String availability,
- @ApiParam(
value = "The reporting task id.",
required = true
)
@PathParam("id") String id) {
- final Availability avail = parseAvailability(availability);
-
// replicate if cluster manager
- if (properties.isClusterManager() && Availability.NODE.equals(avail)) {
+ if (properties.isClusterManager()) {
return clusterManager.applyRequest(HttpMethod.GET, getAbsolutePath(), getRequestParameters(true), getHeaders()).getResponse();
}
// get the reporting task
- final ReportingTaskDTO reportingTask = serviceFacade.getReportingTask(id);
-
- // create the revision
- final RevisionDTO revision = new RevisionDTO();
- revision.setClientId(clientId.getClientId());
-
- // create the response entity
- final ReportingTaskEntity entity = new ReportingTaskEntity();
- entity.setRevision(revision);
- entity.setReportingTask(populateRemainingReportingTaskContent(availability, reportingTask));
+ final ReportingTaskEntity reportingTask = serviceFacade.getReportingTask(id);
+ populateRemainingReportingTaskEntityContent(reportingTask);
- return clusterContext(generateOkResponse(entity)).build();
+ return clusterContext(generateOkResponse(reportingTask)).build();
}
/**
@@ -217,7 +201,6 @@ public class ReportingTaskResource extends ApplicationResource {
* @param clientId Optional client id. If the client id is not specified, a
* new one will be generated. This value (whether specified or generated) is
* included in the response.
- * @param availability availability
* @param id The id of the reporting task.
* @param propertyName The property
* @return a propertyDescriptorEntity
@@ -225,7 +208,7 @@ public class ReportingTaskResource extends ApplicationResource {
@GET
@Consumes(MediaType.WILDCARD)
@Produces(MediaType.APPLICATION_JSON)
- @Path("{availability}/{id}/descriptors")
+ @Path("{id}/descriptors")
// TODO - @PreAuthorize("hasAnyRole('ROLE_MONITOR', 'ROLE_DFM', 'ROLE_ADMIN')")
@ApiOperation(
value = "Gets a reporting task property descriptor",
@@ -252,12 +235,6 @@ public class ReportingTaskResource extends ApplicationResource {
)
@QueryParam(CLIENT_ID) @DefaultValue(StringUtils.EMPTY) ClientIdParameter clientId,
@ApiParam(
- value = "Whether the reporting task is available on the NCM or nodes. If the NiFi is standalone the availability should be NODE.",
- allowableValues = "NCM, NODE",
- required = true
- )
- @PathParam("availability") String availability,
- @ApiParam(
value = "The reporting task id.",
required = true
)
@@ -268,28 +245,21 @@ public class ReportingTaskResource extends ApplicationResource {
)
@QueryParam("propertyName") String propertyName) {
- final Availability avail = parseAvailability(availability);
-
// ensure the property name is specified
if (propertyName == null) {
throw new IllegalArgumentException("The property name must be specified.");
}
// replicate if cluster manager and task is on node
- if (properties.isClusterManager() && Availability.NODE.equals(avail)) {
+ if (properties.isClusterManager()) {
return clusterManager.applyRequest(HttpMethod.GET, getAbsolutePath(), getRequestParameters(true), getHeaders()).getResponse();
}
// get the property descriptor
final PropertyDescriptorDTO descriptor = serviceFacade.getReportingTaskPropertyDescriptor(id, propertyName);
- // create the revision
- final RevisionDTO revision = new RevisionDTO();
- revision.setClientId(clientId.getClientId());
-
// generate the response entity
final PropertyDescriptorEntity entity = new PropertyDescriptorEntity();
- entity.setRevision(revision);
entity.setPropertyDescriptor(descriptor);
// generate the response
@@ -299,17 +269,13 @@ public class ReportingTaskResource extends ApplicationResource {
/**
* Gets the state for a reporting task.
*
- * @param clientId Optional client id. If the client id is not specified, a new one will be generated. This value (whether specified or generated) is included in the response.
- * @param availability Whether the reporting task is available on the
- * NCM only (ncm) or on the nodes only (node). If this instance is not
- * clustered all services should use the node availability.
* @param id The id of the reporting task
* @return a componentStateEntity
*/
@GET
@Consumes(MediaType.WILDCARD)
@Produces(MediaType.APPLICATION_JSON)
- @Path("{availability}/{id}/state")
+ @Path("{id}/state")
// TODO - @PreAuthorize("hasAnyRole('ROLE_DFM')")
@ApiOperation(
value = "Gets the state for a reporting task",
@@ -329,39 +295,21 @@ public class ReportingTaskResource extends ApplicationResource {
)
public Response getState(
@ApiParam(
- value = "If the client id is not specified, new one will be generated. This value (whether specified or generated) is included in the response.",
- required = false
- )
- @QueryParam(CLIENT_ID) @DefaultValue(StringUtils.EMPTY) ClientIdParameter clientId,
- @ApiParam(
- value = "Whether the reporting task is available on the NCM or nodes. If the NiFi is standalone the availability should be NODE.",
- allowableValues = "NCM, NODE",
- required = true
- )
- @PathParam("availability") String availability,
- @ApiParam(
value = "The reporting task id.",
required = true
)
@PathParam("id") String id) {
- final Availability avail = parseAvailability(availability);
-
// replicate if cluster manager
- if (properties.isClusterManager() && Availability.NODE.equals(avail)) {
+ if (properties.isClusterManager()) {
return clusterManager.applyRequest(HttpMethod.GET, getAbsolutePath(), getRequestParameters(true), getHeaders()).getResponse();
}
// get the component state
final ComponentStateDTO state = serviceFacade.getReportingTaskState(id);
- // create the revision
- final RevisionDTO revision = new RevisionDTO();
- revision.setClientId(clientId.getClientId());
-
// generate the response entity
final ComponentStateEntity entity = new ComponentStateEntity();
- entity.setRevision(revision);
entity.setComponentState(state);
// generate the response
@@ -372,16 +320,13 @@ public class ReportingTaskResource extends ApplicationResource {
* Clears the state for a reporting task.
*
* @param revisionEntity The revision is used to verify the client is working with the latest version of the flow.
- * @param availability Whether the reporting task is available on the
- * NCM only (ncm) or on the nodes only (node). If this instance is not
- * clustered all services should use the node availability.
* @param id The id of the reporting task
* @return a componentStateEntity
*/
@POST
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
- @Path("{availability}/{id}/state/clear-requests")
+ @Path("{id}/state/clear-requests")
// TODO - @PreAuthorize("hasAnyRole('ROLE_DFM')")
@ApiOperation(
value = "Clears the state for a reporting task",
@@ -404,49 +349,29 @@ public class ReportingTaskResource extends ApplicationResource {
@ApiParam(
value = "The revision used to verify the client is working with the latest version of the flow.",
required = true
- )
- Entity revisionEntity,
- @ApiParam(
- value = "Whether the reporting task is available on the NCM or nodes. If the NiFi is standalone the availability should be NODE.",
- allowableValues = "NCM, NODE",
- required = true
- )
- @PathParam("availability") String availability,
+ ) ComponentStateEntity revisionEntity,
@ApiParam(
value = "The reporting task id.",
required = true
)
@PathParam("id") String id) {
- final Availability avail = parseAvailability(availability);
-
// replicate if cluster manager
- if (properties.isClusterManager() && Availability.NODE.equals(avail)) {
+ if (properties.isClusterManager()) {
return clusterManager.applyRequest(HttpMethod.POST, getAbsolutePath(), getRequestParameters(true), getHeaders()).getResponse();
}
// handle expects request (usually from the cluster manager)
- final Revision revision = getRevision(revisionEntity.getRevision(), id);
- final boolean validationPhase = isValidationPhase(httpServletRequest);
- if (validationPhase || !isTwoPhaseRequest(httpServletRequest)) {
- serviceFacade.claimRevision(revision);
- }
- if (validationPhase) {
+ if (isValidationPhase(httpServletRequest)) {
serviceFacade.verifyCanClearReportingTaskState(id);
return generateContinueResponse().build();
}
// get the component state
- final ConfigurationSnapshot<Void> snapshot = serviceFacade.clearReportingTaskState(revision, id);
-
- // create the revision
- final RevisionDTO responseRevision = new RevisionDTO();
- responseRevision.setClientId(revision.getClientId());
- responseRevision.setVersion(snapshot.getVersion());
+ serviceFacade.clearReportingTaskState(id);
// generate the response entity
final ComponentStateEntity entity = new ComponentStateEntity();
- entity.setRevision(responseRevision);
// generate the response
return clusterContext(generateOkResponse(entity)).build();
@@ -456,9 +381,6 @@ public class ReportingTaskResource extends ApplicationResource {
* Updates the specified a Reporting Task.
*
* @param httpServletRequest request
- * @param availability Whether the reporting task is available on the NCM
- * only (ncm) or on the nodes only (node). If this instance is not clustered
- * all tasks should use the node availability.
* @param id The id of the reporting task to update.
* @param reportingTaskEntity A reportingTaskEntity.
* @return A reportingTaskEntity.
@@ -466,7 +388,7 @@ public class ReportingTaskResource extends ApplicationResource {
@PUT
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
- @Path("{availability}/{id}")
+ @Path("{id}")
// TODO - @PreAuthorize("hasRole('ROLE_DFM')")
@ApiOperation(
value = "Updates a reporting task",
@@ -487,12 +409,6 @@ public class ReportingTaskResource extends ApplicationResource {
public Response updateReportingTask(
@Context HttpServletRequest httpServletRequest,
@ApiParam(
- value = "Whether the reporting task is available on the NCM or nodes. If the NiFi is standalone the availability should be NODE.",
- allowableValues = "NCM, NODE",
- required = true
- )
- @PathParam("availability") String availability,
- @ApiParam(
value = "The reporting task id.",
required = true
)
@@ -502,9 +418,7 @@ public class ReportingTaskResource extends ApplicationResource {
required = true
) ReportingTaskEntity reportingTaskEntity) {
- final Availability avail = parseAvailability(availability);
-
- if (reportingTaskEntity == null || reportingTaskEntity.getReportingTask() == null) {
+ if (reportingTaskEntity == null || reportingTaskEntity.getComponent() == null) {
throw new IllegalArgumentException("Reporting task details must be specified.");
}
@@ -513,15 +427,15 @@ public class ReportingTaskResource extends ApplicationResource {
}
// ensure the ids are the same
- final ReportingTaskDTO requestReportingTaskDTO = reportingTaskEntity.getReportingTask();
+ final ReportingTaskDTO requestReportingTaskDTO = reportingTaskEntity.getComponent();
if (!id.equals(requestReportingTaskDTO.getId())) {
throw new IllegalArgumentException(String.format("The reporting task id (%s) in the request body does not equal the "
+ "reporting task id of the requested resource (%s).", requestReportingTaskDTO.getId(), id));
}
// replicate if cluster manager
- if (properties.isClusterManager() && Availability.NODE.equals(avail)) {
- return clusterManager.applyRequest(HttpMethod.PUT, getAbsolutePath(), updateClientId(reportingTaskEntity), getHeaders()).getResponse();
+ if (properties.isClusterManager()) {
+ return clusterManager.applyRequest(HttpMethod.PUT, getAbsolutePath(), reportingTaskEntity, getHeaders()).getResponse();
}
// handle expects request (usually from the cluster manager)
@@ -540,12 +454,10 @@ public class ReportingTaskResource extends ApplicationResource {
// get the results
final ReportingTaskEntity entity = controllerResponse.getResult();
-
- // build the response entity
- populateRemainingReportingTaskContent(availability, entity.getReportingTask());
+ populateRemainingReportingTaskEntityContent(entity);
if (controllerResponse.isNew()) {
- return clusterContext(generateCreatedResponse(URI.create(entity.getReportingTask().getUri()), entity)).build();
+ return clusterContext(generateCreatedResponse(URI.create(entity.getComponent().getUri()), entity)).build();
} else {
return clusterContext(generateOkResponse(entity)).build();
}
@@ -560,16 +472,13 @@ public class ReportingTaskResource extends ApplicationResource {
* @param clientId Optional client id. If the client id is not specified, a
* new one will be generated. This value (whether specified or generated) is
* included in the response.
- * @param availability Whether the reporting task is available on the NCM
- * only (ncm) or on the nodes only (node). If this instance is not clustered
- * all tasks should use the node availability.
* @param id The id of the reporting task to remove.
* @return A entity containing the client id and an updated revision.
*/
@DELETE
@Consumes(MediaType.WILDCARD)
@Produces(MediaType.APPLICATION_JSON)
- @Path("{availability}/{id}")
+ @Path("{id}")
// TODO - @PreAuthorize("hasRole('ROLE_DFM')")
@ApiOperation(
value = "Deletes a reporting task",
@@ -600,21 +509,13 @@ public class ReportingTaskResource extends ApplicationResource {
)
@QueryParam(CLIENT_ID) @DefaultValue(StringUtils.EMPTY) ClientIdParameter clientId,
@ApiParam(
- value = "Whether the reporting task is available on the NCM or nodes. If the NiFi is standalone the availability should be NODE.",
- allowableValues = "NCM, NODE",
- required = true
- )
- @PathParam("availability") String availability,
- @ApiParam(
value = "The reporting task id.",
required = true
)
@PathParam("id") String id) {
- final Availability avail = parseAvailability(availability);
-
// replicate if cluster manager
- if (properties.isClusterManager() && Availability.NODE.equals(avail)) {
+ if (properties.isClusterManager()) {
return clusterManager.applyRequest(HttpMethod.DELETE, getAbsolutePath(), getRequestParameters(true), getHeaders()).getResponse();
}
http://git-wip-us.apache.org/repos/asf/nifi/blob/8bb56fca/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/ResourceResource.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/ResourceResource.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/ResourceResource.java
index ccdfda7..b30d084 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/ResourceResource.java
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/ResourceResource.java
@@ -18,26 +18,20 @@ 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;
import com.wordnik.swagger.annotations.ApiResponses;
import com.wordnik.swagger.annotations.Authorization;
-import org.apache.commons.lang3.StringUtils;
import org.apache.nifi.cluster.manager.impl.WebClusterManager;
import org.apache.nifi.util.NiFiProperties;
import org.apache.nifi.web.NiFiServiceFacade;
import org.apache.nifi.web.api.dto.ResourceDTO;
-import org.apache.nifi.web.api.dto.RevisionDTO;
import org.apache.nifi.web.api.entity.ResourcesEntity;
-import org.apache.nifi.web.api.request.ClientIdParameter;
import javax.ws.rs.Consumes;
-import javax.ws.rs.DefaultValue;
import javax.ws.rs.GET;
import javax.ws.rs.HttpMethod;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
-import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import java.util.List;
@@ -59,9 +53,6 @@ public class ResourceResource extends ApplicationResource {
/**
* Gets the available resources that support access/authorization policies.
*
- * @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 resourcesEntity.
*/
@GET
@@ -82,12 +73,7 @@ public class ResourceResource extends ApplicationResource {
@ApiResponse(code = 401, message = "Client could not be authenticated."),
@ApiResponse(code = 403, message = "Client is not authorized to make this request."),}
)
- public Response getResources(
- @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) {
+ public Response getResources() {
// replicate if the cluster manager
if (properties.isClusterManager()) {
@@ -97,13 +83,8 @@ public class ResourceResource extends ApplicationResource {
// TODO - if unsecure, return no resources?
final List<ResourceDTO> resources = serviceFacade.getResources();
- // create the revision
- final RevisionDTO revision = new RevisionDTO();
- revision.setClientId(clientId.getClientId());
-
// create the response
final ResourcesEntity entity = new ResourcesEntity();
- entity.setRevision(revision);
entity.setResources(resources);
// generate the response