NIFI-2694: - Addressing instances where phase one objects were being referenced instead of phase two objects. - Code clean up.

This closes #970.

Signed-off-by: Bryan Bende <bbende@apache.org>
This commit is contained in:
Matt Gilman 2016-08-30 10:07:09 -04:00 committed by Bryan Bende
parent 8556777bf6
commit ba19238757
No known key found for this signature in database
GPG Key ID: A0DDA9ED50711C39
4 changed files with 25 additions and 19 deletions

View File

@ -677,9 +677,9 @@ public class ControllerResource extends ApplicationResource {
authorizeController(RequestAction.WRITE);
},
null,
(endDateEtity) -> {
(endDateEntity) -> {
// purge the actions
serviceFacade.deleteActions(endDateEtity.getEndDate());
serviceFacade.deleteActions(endDateEntity.getEndDate());
// generate the response
return generateOkResponse(new HistoryEntity()).build();
@ -700,6 +700,7 @@ public class ControllerResource extends ApplicationResource {
}
// setters
public void setServiceFacade(final NiFiServiceFacade serviceFacade) {
this.serviceFacade = serviceFacade;
}

View File

@ -226,6 +226,9 @@ public class CountersResource extends ApplicationResource {
)
public Response updateCounter(
@Context final HttpServletRequest httpServletRequest,
@ApiParam(
value = "The id of the counter."
)
@PathParam("id") final String id) {
if (isReplicateRequest()) {
@ -244,7 +247,7 @@ public class CountersResource extends ApplicationResource {
null,
(componentEntity) -> {
// reset the specified counter
final CounterDTO counter = serviceFacade.updateCounter(requestComponentEntity.getId());
final CounterDTO counter = serviceFacade.updateCounter(componentEntity.getId());
// create the response entity
final CounterEntity entity = new CounterEntity();

View File

@ -173,7 +173,7 @@ public class LabelResource extends ApplicationResource {
)
@PathParam("id") final String id,
@ApiParam(
value = "The label configuraiton details.",
value = "The label configuration details.",
required = true
) final LabelEntity requestLabelEntity) {

View File

@ -387,10 +387,10 @@ public class ProcessGroupResource extends ApplicationResource {
// delete the process group
final ProcessGroupEntity entity = serviceFacade.deleteProcessGroup(revision, processGroupEntity.getId());
// create the response
return clusterContext(generateOkResponse(entity)).build();
}
);
// create the response
return clusterContext(generateOkResponse(entity)).build();
}
);
}
/**
@ -548,7 +548,7 @@ public class ProcessGroupResource extends ApplicationResource {
*
* @param httpServletRequest request
* @param groupId The group id
* @param processorEntity A processorEntity.
* @param requestProcessorEntity A processorEntity.
* @return A processorEntity.
*/
@POST
@ -582,17 +582,17 @@ public class ProcessGroupResource extends ApplicationResource {
@ApiParam(
value = "The processor configuration details.",
required = true
) final ProcessorEntity processorEntity) {
) final ProcessorEntity requestProcessorEntity) {
if (processorEntity == null || processorEntity.getComponent() == null) {
if (requestProcessorEntity == null || requestProcessorEntity.getComponent() == null) {
throw new IllegalArgumentException("Processor details must be specified.");
}
if (processorEntity.getRevision() == null || (processorEntity.getRevision().getVersion() == null || processorEntity.getRevision().getVersion() != 0)) {
if (requestProcessorEntity.getRevision() == null || (requestProcessorEntity.getRevision().getVersion() == null || requestProcessorEntity.getRevision().getVersion() != 0)) {
throw new IllegalArgumentException("A revision of 0 must be specified when creating a new Processor.");
}
final ProcessorDTO requestProcessor = processorEntity.getComponent();
final ProcessorDTO requestProcessor = requestProcessorEntity.getComponent();
if (requestProcessor.getId() != null) {
throw new IllegalArgumentException("Processor ID cannot be specified.");
}
@ -608,12 +608,12 @@ public class ProcessGroupResource extends ApplicationResource {
requestProcessor.setParentGroupId(groupId);
if (isReplicateRequest()) {
return replicate(HttpMethod.POST, processorEntity);
return replicate(HttpMethod.POST, requestProcessorEntity);
}
return withWriteLock(
serviceFacade,
processorEntity,
requestProcessorEntity,
lookup -> {
final Authorizable processGroup = lookup.getProcessGroup(groupId).getAuthorizable();
processGroup.authorize(authorizer, RequestAction.WRITE, NiFiUserUtils.getNiFiUser());
@ -625,13 +625,15 @@ public class ProcessGroupResource extends ApplicationResource {
}
},
null,
procEntity -> {
processorEntity -> {
final ProcessorDTO processor = processorEntity.getComponent();
// set the processor id as appropriate
requestProcessor.setId(generateUuid());
processor.setId(generateUuid());
// create the new processor
final Revision revision = getRevision(processorEntity, requestProcessor.getId());
final ProcessorEntity entity = serviceFacade.createProcessor(revision, groupId, requestProcessor);
final Revision revision = getRevision(processorEntity, processor.getId());
final ProcessorEntity entity = serviceFacade.createProcessor(revision, groupId, processor);
processorResource.populateRemainingProcessorEntityContent(entity);
// generate a 201 created response