javax.ws.rs.core.MediaType#TEXT_PLAIN源码实例Demo

下面列出了javax.ws.rs.core.MediaType#TEXT_PLAIN 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: mobi   文件: DelimitedRest.java
/**
 * 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();
}
 
源代码2 项目: mercury   文件: PlaygroundApi.java
@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);
}
 
源代码3 项目: quarkus   文件: TestServlet.java
@GET
@Produces(MediaType.TEXT_PLAIN)
public List<String> getIDs() {
    ensureStart();
    log.info("Retrieving all IDs");
    return cache.keySet().stream().sorted().collect(Collectors.toList());
}
 
源代码4 项目: quarkus   文件: QuotedResource.java
@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";
}
 
源代码5 项目: semanticMDR   文件: ContextService.java
@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();
}
 
源代码6 项目: dyno   文件: MonitorConsoleResource.java
@Path("/topologies")
@GET
@Consumes(MediaType.TEXT_PLAIN)
@Produces(MediaType.TEXT_PLAIN)
public String getConnectionPoolNames() {
    return MonitorConsole.getInstance().getMonitorNames();
}
 
源代码7 项目: nifi-registry   文件: AccessResource.java
/**
 * 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();
    }

}
 
@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;
}
 
@GET
@Path("/count")
@Produces(MediaType.TEXT_PLAIN)
public String oneTimeEvnt() {


    scheduler.startTimer(300, () -> event());
    return "started!";
}
 
源代码10 项目: camel-quarkus   文件: XmlResource.java
@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);
}
 
源代码11 项目: EDDI   文件: IRestBotEngine.java
@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);
 
源代码12 项目: incubator-myriad   文件: ClustersResource.java
@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;
}
 
源代码13 项目: camel-quarkus   文件: MustacheResource.java
@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);
}
 
源代码14 项目: quarkus   文件: HelloResource.java
@GET
@Path("/greeting")
@Produces(MediaType.TEXT_PLAIN)
public String greeting() {
    return greeting;
}
 
源代码15 项目: quarkus   文件: ExampleResource.java
@GET
@Produces(MediaType.TEXT_PLAIN)
public String hello() {
    return "hello";
}
 
源代码16 项目: tajo   文件: TestResource1.java
@GET
@Produces(MediaType.TEXT_PLAIN)
public String getApplicationName() {
  return outputMessage;
}
 
源代码17 项目: quarkus   文件: CountResource.java
@GET
@Produces(MediaType.TEXT_PLAIN)
public String getCount() {
    return "count:" + counter.get();
}
 
@GET
@Produces(MediaType.TEXT_PLAIN)
public String hello() {
    return "hello";
}
 
源代码19 项目: quarkus   文件: HelloResource.java
@GET
@Path("/nameAndVersion")
@Produces(MediaType.TEXT_PLAIN)
public String nameAndVersion() {
    return applicationName + "/" +  applicationVersion;
}
 
源代码20 项目: peer-os   文件: RestService.java
@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 );