Java Code Examples for javax.ws.rs.core.MediaType#TEXT_PLAIN

The following examples show how to use javax.ws.rs.core.MediaType#TEXT_PLAIN . 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: DelimitedRest.java    From mobi with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * Maps the data in an uploaded delimited document into RDF in the requested format
 * using a JSON-LD mapping string. The file must be present in the data/tmp/ directory.
 *
 * @param fileName the name of the delimited document in the data/tmp/ directory
 * @param jsonld a mapping in JSON-LD
 * @param format the RDF serialization to use if getting a preview
 * @param containsHeaders whether the delimited file has headers
 * @param separator the character the columns are separated by if it is a CSV
 * @return a Response with a JSON object containing the mapping file name and a
 *      string containing the converted data in the requested format
 */
@POST
@javax.ws.rs.Path("{documentName}/map-preview")
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Produces({MediaType.APPLICATION_JSON, MediaType.TEXT_PLAIN})
@RolesAllowed("user")
@ApiOperation("ETL an uploaded delimited document using mapping JSON-LD")
public Response etlFilePreview(@PathParam("documentName") String fileName,
                        @FormDataParam("jsonld") String jsonld,
                        @DefaultValue("jsonld") @QueryParam("format") String format,
                        @DefaultValue("true") @QueryParam("containsHeaders") boolean containsHeaders,
                        @DefaultValue(",") @QueryParam("separator") String separator) {
    checkStringParam(jsonld, "Must provide a JSON-LD string");

    // Convert the data
    Model data = etlFile(fileName, () -> jsonldToModel(jsonld, transformer), containsHeaders, separator, true);

    return Response.ok(groupedModelToString(data, format, transformer)).build();
}
 
Example 3
Source File: PlaygroundApi.java    From mercury with Apache License 2.0 5 votes vote down vote up
@GET
@Path("/{id}")
@Produces({MediaType.TEXT_PLAIN})
public String getSpecs(@PathParam("id") String id) throws AppException {
    if (!ready) {
        throw new AppException(503, "API playground not ready");
    }
    File f = new File(dir, id);
    if (!f.exists()) {
        throw new AppException(404, "File not found");
    }
    return Utility.getInstance().file2str(f);
}
 
Example 4
Source File: TestServlet.java    From quarkus with Apache License 2.0 5 votes vote down vote up
@GET
@Produces(MediaType.TEXT_PLAIN)
public List<String> getIDs() {
    ensureStart();
    log.info("Retrieving all IDs");
    return cache.keySet().stream().sorted().collect(Collectors.toList());
}
 
Example 5
Source File: MustacheResource.java    From camel-quarkus with Apache License 2.0 5 votes vote down vote up
@Path("/templateUriFromHeader")
@POST
@Consumes(MediaType.TEXT_PLAIN)
@Produces(MediaType.TEXT_PLAIN)
public String templateUriFromHeader(String message) {
    LOG.infof("Calling templateUriFromHeader with %s", message);
    return template.requestBodyAndHeader("mustache://template/simple.mustache?allowTemplateFromHeader=true", message,
            MustacheConstants.MUSTACHE_RESOURCE_URI,
            "/template/another.mustache", String.class);
}
 
Example 6
Source File: QuotedResource.java    From quarkus with Apache License 2.0 5 votes vote down vote up
@POST
@Produces(MediaType.TEXT_PLAIN)
@Transactional
public String create() {
    Group group = new Group();
    group.setId(1L);
    group.setName("group_name");
    em.merge(group);
    return "ok";
}
 
Example 7
Source File: ContextService.java    From semanticMDR with GNU General Public License v3.0 5 votes vote down vote up
@GET
@Path("/oc")
@Produces(MediaType.TEXT_PLAIN)
public Response getNumberOfObjectClasses(
		@CookieParam(AuthenticationService.SID) String sessionID,
		@PathParam("contextid") String contextID) {
	WebUtil.checkUserSession(sessionID);
	Repository repository = RepositoryManager.getInstance().getRepository();
	Context context = repository.getContext(contextID);

	int size = context.getNumberOfObjectClasses();
	return Response.ok(String.valueOf(size)).build();
}
 
Example 8
Source File: MonitorConsoleResource.java    From dyno with Apache License 2.0 5 votes vote down vote up
@Path("/topologies")
@GET
@Consumes(MediaType.TEXT_PLAIN)
@Produces(MediaType.TEXT_PLAIN)
public String getConnectionPoolNames() {
    return MonitorConsole.getInstance().getMonitorNames();
}
 
Example 9
Source File: ClustersResource.java    From incubator-myriad with Apache License 2.0 5 votes vote down vote up
@Timed
@PUT
@Path("/flexdown")
@Produces(MediaType.TEXT_PLAIN)
@Consumes(MediaType.APPLICATION_JSON)
public Response flexDown(FlexDownClusterRequest request) {
  Preconditions.checkNotNull(request, "request object cannot be null or empty");

  Integer instances = request.getInstances();
  String profile = request.getProfile();
  List<String> constraints = request.getConstraints();
  LOGGER.info("Received flex down request. Profile: {}, Instances: {}, Constraints: {}", profile, instances, constraints);

  Response.ResponseBuilder response = Response.status(Response.Status.ACCEPTED);
  boolean isValidRequest = validateProfile(profile, response);
  isValidRequest = isValidRequest && validateInstances(instances, response);
  isValidRequest = isValidRequest && validateConstraints(constraints, response);

  if (isValidRequest) {
    Integer numFlexedUp = this.getNumFlexedupNMs(profile);
    if (numFlexedUp < instances) {
      String message = String.format("Number of requested instances for flexdown is greater than the number of " +
          "Node Managers previously flexed up for profile '%s'. Requested: %d, Previously flexed Up: %d. " +
          "Only %d Node Managers will be flexed down.", profile, instances, numFlexedUp, numFlexedUp);
      response.entity(message);
      LOGGER.warn(message);
    }
  }

  Response returnResponse = response.build();
  if (returnResponse.getStatus() == Response.Status.ACCEPTED.getStatusCode()) {
    String constraint = constraints != null && !constraints.isEmpty() ? constraints.get(0) : null;
    this.myriadOperations.flexDownCluster(profileManager.get(profile), ConstraintFactory.createConstraint(constraint), instances);
  }
  return returnResponse;
}
 
Example 10
Source File: AccessResource.java    From nifi-registry with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a token for accessing the REST API using a custom identity provider configured using NiFi Registry extensions.
 *
 * @param httpServletRequest the servlet request
 * @return A JWT (string)
 */
@GET
@Consumes(MediaType.WILDCARD)
@Produces(MediaType.TEXT_PLAIN)
@Path("/token/identity-provider/usage")
@ApiOperation(
        value = "Get identity provider usage",
        notes = "Provides a description of how the currently configured identity provider expects credentials to be passed to POST /access/token/identity-provider",
        response = String.class
)
@ApiResponses({
        @ApiResponse(code = 400, message = HttpStatusMessages.MESSAGE_400),
        @ApiResponse(code = 409, message = HttpStatusMessages.MESSAGE_409 + " The NiFi Registry may not be configured to support login with customized credentials."),
        @ApiResponse(code = 500, message = HttpStatusMessages.MESSAGE_500) })
public Response getIdentityProviderUsageInstructions(@Context HttpServletRequest httpServletRequest) {

    // if not configuration for login, don't consider credentials
    if (identityProvider == null) {
        throw new IllegalStateException("Custom login not supported by this NiFi Registry");
    }

    Class ipClazz = identityProvider.getClass();
    String identityProviderName = StringUtils.isNotEmpty(ipClazz.getSimpleName()) ? ipClazz.getSimpleName() : ipClazz.getName();

    try {
        String usageInstructions = "Usage Instructions for '" + identityProviderName + "': ";
        usageInstructions += identityProvider.getUsageInstructions().getText();
        return generateOkResponse(usageInstructions).build();

    } catch (Exception e) {
        // If, for any reason, this identity provider does not support getUsageInstructions(), e.g., returns null or throws NotImplementedException.
        return Response.status(Response.Status.NOT_IMPLEMENTED)
                .entity("The currently configured identity provider, '" + identityProvider.getClass().getName() + "' does not provide usage instructions.")
                .build();
    }

}
 
Example 11
Source File: TokenSecuredResourceV1.java    From quarkus-quickstarts with Apache License 2.0 5 votes vote down vote up
@GET()
@Path("permit-all")
@PermitAll
@Produces(MediaType.TEXT_PLAIN)
public String hello(@Context SecurityContext ctx) {
    Principal caller = ctx.getUserPrincipal();
    String name = caller == null ? "anonymous" : caller.getName();
    boolean hasJWT = jwt.getClaimNames() != null;
    String helloReply = String.format("hello + %s, isSecure: %s, authScheme: %s, hasJWT: %s", name, ctx.isSecure(),
            ctx.getAuthenticationScheme(), hasJWT);
    return helloReply;
}
 
Example 12
Source File: Endpoint.java    From Hands-On-Cloud-Native-Applications-with-Java-and-Quarkus with MIT License 5 votes vote down vote up
@GET
@Path("/count")
@Produces(MediaType.TEXT_PLAIN)
public String oneTimeEvnt() {


    scheduler.startTimer(300, () -> event());
    return "started!";
}
 
Example 13
Source File: IRestBotEngine.java    From EDDI with Apache License 2.0 5 votes vote down vote up
@GET
@Path("/{environment}/{botId}/undo/{conversationId}")
@Produces(MediaType.TEXT_PLAIN)
@ApiOperation(value = "Is UNDO available?")
Boolean isUndoAvailable(@PathParam("environment") Deployment.Environment environment,
                        @PathParam("botId") String botId,
                        @PathParam("conversationId") String conversationId);
 
Example 14
Source File: RestService.java    From peer-os with Apache License 2.0 4 votes vote down vote up
@POST
@Path( "{environmentId}/containers/{containerId}/export/{name}/{version}/{private}" )
@Produces( { MediaType.TEXT_PLAIN } )
Response createTemplate( @PathParam( "environmentId" ) String environmentId,
                         @PathParam( "containerId" ) String containerId, @PathParam( "name" ) String templateName,
                         @PathParam( "version" ) String version, @PathParam( "private" ) boolean privateTemplate );
 
Example 15
Source File: HelloResource.java    From quarkus with Apache License 2.0 4 votes vote down vote up
@GET
@Path("/nameAndVersion")
@Produces(MediaType.TEXT_PLAIN)
public String nameAndVersion() {
    return applicationName + "/" +  applicationVersion;
}
 
Example 16
Source File: ReactiveGreetingResource.java    From quarkus-quickstarts with Apache License 2.0 4 votes vote down vote up
@GET
@Produces(MediaType.TEXT_PLAIN)
public String hello() {
    return "hello";
}
 
Example 17
Source File: CountResource.java    From quarkus with Apache License 2.0 4 votes vote down vote up
@GET
@Produces(MediaType.TEXT_PLAIN)
public String getCount() {
    return "count:" + counter.get();
}
 
Example 18
Source File: TestResource1.java    From tajo with Apache License 2.0 4 votes vote down vote up
@GET
@Produces(MediaType.TEXT_PLAIN)
public String getApplicationName() {
  return outputMessage;
}
 
Example 19
Source File: ExampleResource.java    From quarkus with Apache License 2.0 4 votes vote down vote up
@GET
@Produces(MediaType.TEXT_PLAIN)
public String hello() {
    return "hello";
}
 
Example 20
Source File: HelloResource.java    From quarkus with Apache License 2.0 4 votes vote down vote up
@GET
@Path("/greeting")
@Produces(MediaType.TEXT_PLAIN)
public String greeting() {
    return greeting;
}