Search in sources :

Example 1 with ActionEntity

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();
}
Also used : Action(org.apache.nifi.update.attributes.Action) WebApplicationException(javax.ws.rs.WebApplicationException) UpdateAttributeModelFactory(org.apache.nifi.update.attributes.UpdateAttributeModelFactory) UriBuilder(javax.ws.rs.core.UriBuilder) ResponseBuilder(javax.ws.rs.core.Response.ResponseBuilder) ActionEntity(org.apache.nifi.update.attributes.entity.ActionEntity) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Produces(javax.ws.rs.Produces)

Aggregations

POST (javax.ws.rs.POST)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1 WebApplicationException (javax.ws.rs.WebApplicationException)1 ResponseBuilder (javax.ws.rs.core.Response.ResponseBuilder)1 UriBuilder (javax.ws.rs.core.UriBuilder)1 Action (org.apache.nifi.update.attributes.Action)1 UpdateAttributeModelFactory (org.apache.nifi.update.attributes.UpdateAttributeModelFactory)1 ActionEntity (org.apache.nifi.update.attributes.entity.ActionEntity)1