javax.ws.rs.Consumes Java Examples

The following examples show how to use javax.ws.rs.Consumes. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: XmlResource.java    From camel-quarkus with Apache License 2.0 7 votes vote down vote up
@Path("/html-transform")
@POST
@Consumes(MediaType.TEXT_HTML)
@Produces(MediaType.TEXT_PLAIN)
public String htmlTransform(String html) {
    LOG.debugf("Parsing HTML %s", html);
    return producerTemplate.requestBody(
            XmlRouteBuilder.DIRECT_HTML_TRANSFORM,
            html,
            String.class);
}
 
Example #2
Source File: GoogleMailResource.java    From camel-quarkus with Apache License 2.0 6 votes vote down vote up
@Path("/create")
@POST
@Consumes(MediaType.TEXT_PLAIN)
@Produces(MediaType.TEXT_PLAIN)
public Response createMail(String message) throws Exception {
    Message email = createMessage(message);
    Map<String, Object> headers = new HashMap<>();
    headers.put("CamelGoogleMail.userId", USER_ID);
    headers.put("CamelGoogleMail.content", email);
    final Message response = producerTemplate.requestBodyAndHeaders("google-mail://messages/send", null, headers,
            Message.class);
    return Response
            .created(new URI("https://camel.apache.org/"))
            .entity(response.getId())
            .build();
}
 
Example #3
Source File: ApplicationResource.java    From hmdm-server with Apache License 2.0 6 votes vote down vote up
@ApiOperation(
        value = "Update application configurations",
        notes = "Updates the list of configurations using requested application"
)
@POST
@Path("/configurations")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response updateApplicationConfigurations(LinkConfigurationsToAppRequest request) {
    try {
        this.applicationDAO.updateApplicationConfigurations(request);

        return Response.OK();
    } catch (Exception e) {
        logger.error("Unexpected error when updating application configurations", e);
        return Response.INTERNAL_ERROR();
    }
}
 
Example #4
Source File: ExperimentRestApi.java    From submarine with Apache License 2.0 6 votes vote down vote up
@PATCH
@Path("/{id}")
@Consumes({RestConstants.MEDIA_TYPE_YAML, MediaType.APPLICATION_JSON})
@Operation(summary = "Update the experiment in the submarine server with spec",
        tags = {"experiment"},
        responses = {
                @ApiResponse(description = "successful operation", content = @Content(
                        schema = @Schema(implementation = JsonResponse.class))),
                @ApiResponse(responseCode = "404", description = "Experiment not found")})
public Response patchExperiment(@PathParam(RestConstants.ID) String id, ExperimentSpec spec) {
  try {
    Experiment experiment = experimentManager.patchExperiment(id, spec);
    return new JsonResponse.Builder<Experiment>(Response.Status.OK).success(true)
        .result(experiment).build();
  } catch (SubmarineRuntimeException e) {
    return parseExperimentServiceException(e);
  }
}
 
Example #5
Source File: ReactiveRestResourceTemplate.java    From kogito-runtimes with Apache License 2.0 6 votes vote down vote up
@POST()
@Path("/{id}")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public CompletionStage<$Type$Output> updateModel_$name$(@PathParam("id") String id, $Type$ resource) {
    return CompletableFuture.supplyAsync(() -> {
        return org.kie.kogito.services.uow.UnitOfWorkExecutor.executeInUnitOfWork(application.unitOfWorkManager(), () -> {
            ProcessInstance<$Type$> pi = process.instances()
                    .findById(id)
                    .orElse(null);
            if (pi == null) {
                return null;
            } else {
                pi.updateVariables(resource);
                return mapOutput(new $Type$Output(), pi.variables());
            }
        });
    });
}
 
Example #6
Source File: StramWebServices.java    From Bats with Apache License 2.0 6 votes vote down vote up
@POST // not supported by WebAppProxyServlet, can only be called directly
@Path(PATH_PHYSICAL_PLAN_OPERATORS + "/{operatorId:\\d+}/properties")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public JSONObject setPhysicalOperatorProperties(JSONObject request, @PathParam("operatorId") int operatorId)
{
  init();
  JSONObject response = new JSONObject();
  try {
    @SuppressWarnings("unchecked")
    Iterator<String> keys = request.keys();
    while (keys.hasNext()) {
      String key = keys.next();
      String val = request.isNull(key) ? null : request.getString(key);
      dagManager.setPhysicalOperatorProperty(operatorId, key, val);
    }
  } catch (JSONException ex) {
    LOG.warn("Got JSON Exception: ", ex);
  }
  return response;
}
 
Example #7
Source File: JiraResource.java    From camel-quarkus with Apache License 2.0 6 votes vote down vote up
@Path("/post")
@POST
@Consumes(MediaType.TEXT_PLAIN)
@Produces(MediaType.TEXT_PLAIN)
public Response post(@QueryParam("jiraUrl") String jiraUrl, String message) throws Exception {
    Map<String, Object> headers = new HashMap<>();
    headers.put(JiraConstants.ISSUE_PROJECT_KEY, projectKey);
    headers.put(JiraConstants.ISSUE_TYPE_NAME, "Task");
    headers.put(JiraConstants.ISSUE_SUMMARY, "Demo Bug");

    log.infof("Sending to jira: %s", message);

    Issue issue = producerTemplate.requestBodyAndHeaders("jira:addIssue?jiraUrl=" + jiraUrl, message, headers, Issue.class);

    log.infof("Created new issue: %s", issue.getKey());
    return Response
            .created(new URI("https://camel.apache.org/"))
            .entity(issue.getKey())
            .status(201)
            .build();
}
 
Example #8
Source File: UserResource.java    From hmdm-server with Apache License 2.0 6 votes vote down vote up
@ApiOperation(
        value = "Delete user",
        notes = "Deletes a user account referenced by the specified ID"
)
@DELETE
@Path("/other/{id}")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response deleteUser(@PathParam("id") @ApiParam("User ID") int id) {
    try {
        userDAO.deleteUser(id);
        return Response.OK();
    } catch (Exception e) {
        return Response.ERROR(e.getMessage());
    }
}
 
Example #9
Source File: TaskResource.java    From presto with Apache License 2.0 6 votes vote down vote up
@ResourceSecurity(INTERNAL_ONLY)
@POST
@Path("{taskId}")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response createOrUpdateTask(@PathParam("taskId") TaskId taskId, TaskUpdateRequest taskUpdateRequest, @Context UriInfo uriInfo)
{
    requireNonNull(taskUpdateRequest, "taskUpdateRequest is null");

    Session session = taskUpdateRequest.getSession().toSession(sessionPropertyManager, taskUpdateRequest.getExtraCredentials());
    TaskInfo taskInfo = taskManager.updateTask(session,
            taskId,
            taskUpdateRequest.getFragment(),
            taskUpdateRequest.getSources(),
            taskUpdateRequest.getOutputIds(),
            taskUpdateRequest.getTotalPartitions());

    if (shouldSummarize(uriInfo)) {
        taskInfo = taskInfo.summarize();
    }

    return Response.ok().entity(taskInfo).build();
}
 
Example #10
Source File: ApplicationResource.java    From hmdm-server with Apache License 2.0 6 votes vote down vote up
@ApiOperation(
        value = "Validate application package",
        notes = "Validate the application package ID for uniqueness",
        response = Application.class,
        responseContainer = "List"
)
@Path("/validatePkg")
@PUT
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response validateApplication(Application application) {
    try {
        final List<Application> otherApps = this.applicationDAO.getApplicationsForPackageID(application);
        return Response.OK(otherApps);
    } catch (Exception e) {
        logger.error("Failed to validate application", e);
        return Response.INTERNAL_ERROR();
    }
}
 
Example #11
Source File: GoogleSheetsResource.java    From camel-quarkus with Apache License 2.0 6 votes vote down vote up
@Path("/create")
@POST
@Consumes(MediaType.TEXT_PLAIN)
@Produces(MediaType.TEXT_PLAIN)
public Response createSheet(String title) throws Exception {
    SpreadsheetProperties sheetProperties = new SpreadsheetProperties();
    sheetProperties.setTitle(title);

    Spreadsheet sheet = new Spreadsheet();
    sheet.setProperties(sheetProperties);

    Spreadsheet response = producerTemplate.requestBody("google-sheets://spreadsheets/create?inBody=content", sheet,
            Spreadsheet.class);
    return Response
            .created(new URI("https://camel.apache.org/"))
            .entity(response.getSpreadsheetId())
            .build();
}
 
Example #12
Source File: GoogleSheetsResource.java    From camel-quarkus with Apache License 2.0 6 votes vote down vote up
@Path("/update")
@PATCH
@Consumes(MediaType.TEXT_PLAIN)
public Response updateSheet(@QueryParam("spreadsheetId") String spreadsheetId, String title) {
    BatchUpdateSpreadsheetRequest request = new BatchUpdateSpreadsheetRequest()
            .setIncludeSpreadsheetInResponse(true)
            .setRequests(Collections
                    .singletonList(new Request().setUpdateSpreadsheetProperties(new UpdateSpreadsheetPropertiesRequest()
                            .setProperties(new SpreadsheetProperties().setTitle(title))
                            .setFields("title"))));

    final Map<String, Object> headers = new HashMap<>();
    headers.put("CamelGoogleSheets.spreadsheetId", spreadsheetId);
    headers.put("CamelGoogleSheets.batchUpdateSpreadsheetRequest", request);
    producerTemplate.requestBodyAndHeaders("google-sheets://spreadsheets/batchUpdate", null, headers);
    return Response.ok().build();
}
 
Example #13
Source File: ReactiveRestResourceTemplate.java    From kogito-runtimes with Apache License 2.0 6 votes vote down vote up
@POST()
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)    
public CompletionStage<$Type$Output> createResource_$name$(@Context HttpHeaders httpHeaders, @QueryParam("businessKey") String businessKey, $Type$Input resource) {
    if (resource == null) {
        resource = new $Type$Input();
    }
    final $Type$Input value = resource;
    return CompletableFuture.supplyAsync(() -> {
        return org.kie.kogito.services.uow.UnitOfWorkExecutor.executeInUnitOfWork(application.unitOfWorkManager(), () -> {
            ProcessInstance<$Type$> pi = process.createInstance(businessKey, mapInput(value, new $Type$()));
            String startFromNode = httpHeaders.getHeaderString("X-KOGITO-StartFromNode");
            
            if (startFromNode != null) {
                pi.startFrom(startFromNode);
            } else {
            
                pi.start();
            }
            return getModel(pi);
        });
    });
}
 
Example #14
Source File: SoapResource.java    From camel-quarkus with Apache License 2.0 6 votes vote down vote up
@Path("/marshal/{soapVersion}")
@POST
@Consumes(MediaType.TEXT_PLAIN)
@Produces(MediaType.APPLICATION_XML)
public Response marshall(@PathParam("soapVersion") String soapVersion, String message) throws Exception {
    LOG.infof("Sending to soap: %s", message);
    GetCustomersByName request = new GetCustomersByName();
    request.setName(message);

    final String endpointUri = "direct:marshal" + (soapVersion.equals("1.2") ? "-soap12" : "");
    final String response = producerTemplate.requestBody(endpointUri, request, String.class);

    return Response
            .created(new URI("https://camel.apache.org/"))
            .entity(response)
            .build();
}
 
Example #15
Source File: RestResourceTemplate.java    From kogito-runtimes with Apache License 2.0 6 votes vote down vote up
@POST()
@Path("/{id}")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public $Type$Output updateModel_$name$(@PathParam("id") String id, $Type$ resource) {
    return org.kie.kogito.services.uow.UnitOfWorkExecutor.executeInUnitOfWork(application.unitOfWorkManager(), () -> {
        ProcessInstance<$Type$> pi = process.instances()
                .findById(id)
                .orElse(null);
        if (pi == null) {
            return null;
        } else {
            pi.updateVariables(resource);
            return mapOutput(new $Type$Output(), pi.variables());
        }
    });
}
 
Example #16
Source File: DeviceLogPluginSettingsResource.java    From hmdm-server with Apache License 2.0 6 votes vote down vote up
@ApiOperation(
        value = "Create or update plugin settings",
        notes = "Creates a new plugin settings record (if id is not provided) or updates existing one otherwise",
        authorizations = {@Authorization("Bearer Token")}
)
@PUT
@Path("/private")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response saveMainSettings(String settingsJSON) {
    try {
        ObjectMapper mapper = new ObjectMapper();
        DeviceLogPluginSettings settings = mapper.readValue(settingsJSON, this.settingsDAO.getSettingsClass());
        
        if (settings.getIdentifier() == null) {
            this.settingsDAO.insertPluginSettings(settings);
        } else {
            this.settingsDAO.updatePluginSettings(settings);
        }

        return Response.OK();
    } catch (Exception e) {
        log.error("Failed to create or update device log plugin settings", e);
        return Response.INTERNAL_ERROR();
    }
}
 
Example #17
Source File: ObjectsResource.java    From cantor with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@PUT
@Path("/{namespace}/{key}")
@Consumes({MediaType.APPLICATION_OCTET_STREAM, MediaType.APPLICATION_FORM_URLENCODED, MediaType.MULTIPART_FORM_DATA, MediaType.TEXT_PLAIN})
@Operation(summary = "Add or overwrite an object in a namespace")
@ApiResponses(value = {
    @ApiResponse(responseCode = "200", description = "Object was added or existing content was overwritten"),
    @ApiResponse(responseCode = "500", description = serverErrorMessage)
})
public Response store(@Parameter(description = "Namespace identifier") @PathParam("namespace") final String namespace,
                      @Parameter(description = "Key of the object") @PathParam("key") final String key,
                      @Parameter(description = "Content of the object") final byte[] bytes) throws IOException {
    logger.info("received request to store object with key '{}' in namespace {}", key, namespace);
    logger.debug("object bytes: {}", bytes);
    this.cantor.objects().store(namespace, key, bytes);
    return Response.ok().build();
}
 
Example #18
Source File: BindyResource.java    From camel-quarkus with Apache License 2.0 5 votes vote down vote up
@Path("/csvToJson")
@GET
@Consumes(MediaType.TEXT_PLAIN)
@Produces(MediaType.APPLICATION_JSON)
public CsvOrder csvToJson(final String csvOrder) {
    LOG.infof("Invoking  csvToJson: %s", csvOrder);
    return producerTemplate.requestBody("direct:csvToJson", csvOrder, CsvOrder.class);
}
 
Example #19
Source File: JoltResource.java    From camel-quarkus with Apache License 2.0 5 votes vote down vote up
@Path("/defaultr")
@PUT
@Consumes(MediaType.TEXT_PLAIN)
@Produces(MediaType.TEXT_PLAIN)
public String defaultr(String value) {
    LOG.infof("Calling defaultr with %s", value);
    Map<String, String> inbody = new HashMap<>();
    inbody.put("key", value);
    Map<?, ?> outBody = template.requestBody("jolt:defaultr.json?transformDsl=Defaultr", inbody, Map.class);
    return String.format("%s-%s+%s", outBody.get("a"), outBody.get("b"), outBody.get("key"));
}
 
Example #20
Source File: MusicRestService.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
@POST
@Path("/postjson")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public Response createMusicInJSONResponsePOST(
        Music music /*@PathParam("album") String album, @PathParam("singer") String singer*/) {

    musicService.setMusic(music);

    //String result = "Album Added in POST : " + music;
    return Response.status(201).entity(music).build();
    //return music.getAlbum();

}
 
Example #21
Source File: MustacheResource.java    From camel-quarkus with Apache License 2.0 5 votes vote down vote up
@Path("/templateFromClassPathResource")
@POST
@Consumes(MediaType.TEXT_PLAIN)
@Produces(MediaType.TEXT_PLAIN)
public String templateFromClassPathResource(String message) {
    LOG.infof("Calling templateFromClassPathResource with %s", message);
    return template.requestBodyAndHeader("mustache://template/simple.mustache", message, "header", "value", String.class);
}
 
Example #22
Source File: JoltResource.java    From camel-quarkus with Apache License 2.0 5 votes vote down vote up
@Path("/sample")
@PUT
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public String sample(String inputJson) {
    LOG.infof("Calling sample with %s", inputJson);
    Map<String, String> context = new HashMap<>();
    context.put("contextB", "bb");
    String joltEndpointUri = "jolt:sample-spec.json?inputType=JsonString&outputType=JsonString&allowTemplateFromHeader=true";
    return template.requestBodyAndHeader(joltEndpointUri, inputJson, JoltConstants.JOLT_CONTEXT, context, String.class);
}
 
Example #23
Source File: WebauthnService.java    From fido2 with GNU Lesser General Public License v2.1 5 votes vote down vote up
@POST
@Path("/" + Constants.RP_AUTHENTICATE_PATH)
@Consumes({MediaType.APPLICATION_JSON})
@Produces({MediaType.APPLICATION_JSON})
public Response authenticate(JsonObject input){
    try {
        HttpSession session = request.getSession(false);
        if (session == null) {
            WebauthnTutorialLogger.logp(Level.SEVERE, CLASSNAME, "authenticate", "WEBAUTHN-WS-ERR-1003", "");
            return generateResponse(Response.Status.FORBIDDEN, WebauthnTutorialLogger.getMessageProperty("WEBAUTHN-WS-ERR-1003"));
        }

        String username = (String) session.getAttribute(Constants.SESSION_USERNAME);
        if (doesAccountExists(username)) {
            String authresponse = SKFSClient.authenticate(username, getOrigin(), input);
            session.setAttribute("username", username);
            session.setAttribute("isAuthenticated", true);
            return generateResponse(Response.Status.OK, getResponseFromSKFSResponse(authresponse));
        } else {
            WebauthnTutorialLogger.logp(Level.SEVERE, CLASSNAME, "authenticate", "WEBAUTHN-WS-ERR-1002", username);
            return generateResponse(Response.Status.CONFLICT, WebauthnTutorialLogger.getMessageProperty("WEBAUTHN-WS-ERR-1002"));
        }
    } catch (Exception ex) {
        ex.printStackTrace();
        WebauthnTutorialLogger.logp(Level.SEVERE, CLASSNAME, "authenticate", "WEBAUTHN-WS-ERR-1000", ex.getLocalizedMessage());
        return generateResponse(Response.Status.INTERNAL_SERVER_ERROR,
                WebauthnTutorialLogger.getMessageProperty("WEBAUTHN-WS-ERR-1000"));
    }
}
 
Example #24
Source File: GrpcResource.java    From camel-quarkus with Apache License 2.0 5 votes vote down vote up
@Path("/producer")
@POST
@Consumes(MediaType.TEXT_PLAIN)
@Produces(MediaType.TEXT_PLAIN)
public String producer(String pingName, @QueryParam("pingId") int pingId) throws Exception {
    final PingRequest pingRequest = PingRequest.newBuilder()
            .setPingName(pingName)
            .setPingId(pingId)
            .build();
    final PongResponse response = producerTemplate.requestBody(
            "grpc://localhost:{{camel.grpc.test.server.port}}/org.apache.camel.quarkus.component.grpc.it.model.PingPong?method=pingSyncSync&synchronous=true",
            pingRequest, PongResponse.class);
    return response.getPongName();
}
 
Example #25
Source File: CafeResource.java    From jakartaee-azure with MIT License 5 votes vote down vote up
@POST
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public Response createCoffee(Coffee coffee) {
	try {
		coffee = this.cafeRepository.persistCoffee(coffee);
		return Response.created(URI.create("/" + coffee.getId())).build();
	} catch (PersistenceException e) {
		logger.log(Level.SEVERE, "Error creating coffee {0}: {1}.", new Object[] { coffee, e });
		throw new WebApplicationException(e, Response.Status.INTERNAL_SERVER_ERROR);
	}
}
 
Example #26
Source File: CallbackJobsServiceResource.java    From kogito-runtimes with Apache License 2.0 5 votes vote down vote up
@POST
@Path("{processId}/instances/{processInstanceId}/timers/{timerId}")
@Consumes(MediaType.APPLICATION_JSON)
public Response triggerTimer(@PathParam("processId") String processId, 
                                         @PathParam("processInstanceId") String processInstanceId, 
                                         @PathParam("timerId") String timerId,
                                         @QueryParam("limit") @DefaultValue("0") Integer limit) {
    if (processId == null || processInstanceId == null) {
        return Response.status(Status.BAD_REQUEST).entity("Process id and Process instance id must be given").build();
    }
    
    
    Process<?> process = processes.processById(processId);        
    if (process == null) {
        return Response.status(Status.NOT_FOUND).entity("Process with id " + processId + " not found").build();
    }

   return UnitOfWorkExecutor.executeInUnitOfWork(application.unitOfWorkManager(), () -> {
        Optional<? extends ProcessInstance<?>> processInstanceFound = process.instances().findById(processInstanceId);        
        if (processInstanceFound.isPresent()) {
            ProcessInstance<?> processInstance = processInstanceFound.get();
            String[] ids = timerId.split("_");
            processInstance.send(Sig.of("timerTriggered", TimerInstance.with(Long.parseLong(ids[1]), timerId, limit)));
        } else {
            return Response.status(Status.NOT_FOUND).entity("Process instance with id " + processInstanceId + " not found").build();
        }
        
        return Response.status(Status.OK).build();
    
    });


}
 
Example #27
Source File: WebauthnService.java    From fido2 with GNU Lesser General Public License v2.1 5 votes vote down vote up
@POST
@Path("/" + Constants.RP_PREGISTER_PATH)
@Consumes({MediaType.APPLICATION_JSON})
@Produces({MediaType.APPLICATION_JSON})
public Response preregister(JsonObject input){
    try{
        //Get user input + basic input checking
        String username = getValueFromInput(Constants.RP_JSON_KEY_USERNAME, input);
        String displayName = getValueFromInput(Constants.RP_JSON_KEY_DISPLAYNAME, input);

        //Verify User does not already exist
        if (!doesAccountExists(username)){
            String prereg = SKFSClient.preregister(username, displayName);
            HttpSession session = request.getSession(true);
            session.setAttribute(Constants.SESSION_USERNAME, username);
            session.setAttribute(Constants.SESSION_ISAUTHENTICATED, false);
            session.setMaxInactiveInterval(Constants.SESSION_TIMEOUT_VALUE);
            return generateResponse(Response.Status.OK, prereg);
        }
        else{
            //If the user already exists, throw an error
            WebauthnTutorialLogger.logp(Level.SEVERE, CLASSNAME, "preregister", "WEBAUTHN-WS-ERR-1001", username);
            return generateResponse(Response.Status.CONFLICT,
                    WebauthnTutorialLogger.getMessageProperty("WEBAUTHN-WS-ERR-1001"));
        }
    }
    catch(Exception ex){
        ex.printStackTrace();
        WebauthnTutorialLogger.logp(Level.SEVERE, CLASSNAME, "preregister", "WEBAUTHN-WS-ERR-1000", ex.getLocalizedMessage());
        return generateResponse(Response.Status.INTERNAL_SERVER_ERROR,
                WebauthnTutorialLogger.getMessageProperty("WEBAUTHN-WS-ERR-1000"));
    }
}
 
Example #28
Source File: HttpResource.java    From camel-quarkus with Apache License 2.0 5 votes vote down vote up
@Path("/netty-http/post")
@POST
@Consumes(MediaType.TEXT_PLAIN)
@Produces(MediaType.TEXT_PLAIN)
public String hettyHttpPost(@QueryParam("test-port") int port, String message) {
    return producerTemplate
            .to("netty-http://http://localhost:" + port + "/service/toUpper?bridgeEndpoint=true")
            .withBody(message)
            .withHeader(Exchange.CONTENT_TYPE, MediaType.TEXT_PLAIN)
            .withHeader(Exchange.HTTP_METHOD, "POST")
            .request(String.class);
}
 
Example #29
Source File: CamelResource.java    From camel-quarkus with Apache License 2.0 5 votes vote down vote up
@Path("/process-order")
@POST
@Consumes(MediaType.TEXT_PLAIN)
@Produces(MediaType.TEXT_PLAIN)
public String processOrder(String statement) {
    return template.requestBody("direct:process-order", statement, String.class);
}
 
Example #30
Source File: BindyResource.java    From camel-quarkus with Apache License 2.0 5 votes vote down vote up
@Path("/fixedLengthToJson")
@GET
@Consumes(MediaType.TEXT_PLAIN)
@Produces(MediaType.APPLICATION_JSON)
public FixedLengthOrder fixedLengthToJson(final String fixedLengthOrder) {
    LOG.infof("Invoking  fixedLengthToJson: %s", fixedLengthOrder);
    return producerTemplate.requestBody("direct:fixedLengthToJson", fixedLengthOrder, FixedLengthOrder.class);
}