use of org.apache.nifi.update.attributes.entity.ActionEntity in project nifi by apache.
the class RuleResource method createAction.
@POST
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
@Path("/rules/actions")
public Response createAction(@Context final UriInfo uriInfo, final ActionEntity requestEntity) {
// generate a new id
final String uuid = UUID.randomUUID().toString();
final Action action;
try {
// create the condition object
final UpdateAttributeModelFactory factory = new UpdateAttributeModelFactory();
action = factory.createAction(requestEntity.getAction());
action.setId(uuid);
} catch (final IllegalArgumentException iae) {
throw new WebApplicationException(iae, badRequest(iae.getMessage()));
}
// build the response
final ActionEntity responseEntity = new ActionEntity();
responseEntity.setClientId(requestEntity.getClientId());
responseEntity.setProcessorId(requestEntity.getProcessorId());
responseEntity.setRevision(requestEntity.getRevision());
responseEntity.setAction(DtoFactory.createActionDTO(action));
// generate the response
final UriBuilder uriBuilder = uriInfo.getAbsolutePathBuilder();
final ResponseBuilder response = Response.created(uriBuilder.path(uuid).build()).entity(responseEntity);
return noCache(response).build();
}
Aggregations