当前位置: 首页>>代码示例>>Java>>正文


Java MediaType.APPLICATION_JSON属性代码示例

本文整理汇总了Java中javax.ws.rs.core.MediaType.APPLICATION_JSON属性的典型用法代码示例。如果您正苦于以下问题:Java MediaType.APPLICATION_JSON属性的具体用法?Java MediaType.APPLICATION_JSON怎么用?Java MediaType.APPLICATION_JSON使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在javax.ws.rs.core.MediaType的用法示例。


在下文中一共展示了MediaType.APPLICATION_JSON属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getProduct

@GET
@Path("/products/{id}")
@Produces(MediaType.APPLICATION_JSON)
public Response getProduct(@PathParam("id") Long id) {
	return getProductStore().get(id).map(p -> Response.ok(p).build())
			.orElse(Response.status(Status.NOT_FOUND).build());
}
 
开发者ID:holon-platform,项目名称:holon-examples,代码行数:7,代码来源:ProductEndpoint.java

示例2: updateFloatingIp

/**
 * Update FloatingIP.
 *
 * @param id    FloatingIP identifier
 * @param input JSON data describing FloatingIP
 * @return 200 OK
 */
@PUT
@Path("{id}")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response updateFloatingIp(@PathParam("id") String id, InputStream input) {
    checkNotNull(id);
    checkNotNull(input);

    try {
        ObjectMapper mapper = new ObjectMapper();
        ObjectNode floatingIpNode = (ObjectNode) mapper.readTree(input);

        OpenstackFloatingIP osFloatingIp =
                FLOATING_IP_CODEC.decode(floatingIpNode, this);

        OpenstackRoutingService routingService =
                getService(OpenstackRoutingService.class);

        routingService.updateFloatingIP(osFloatingIp);

        log.debug("REST API UPDATE floatingip called {}", id);

        return Response.status(Response.Status.OK).build();
    } catch (Exception e) {
        log.error("updateFloatingIp failed with {}", e.toString());

        return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(e.toString())
                .build();
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:37,代码来源:OpenstackFloatingIpWebResource.java

示例3: verifyInjectedCustomInteger

@GET
@Path("/verifyInjectedCustomInteger")
@Produces(MediaType.APPLICATION_JSON)
public JsonObject verifyInjectedCustomInteger(@QueryParam("value") Long value) {
    boolean pass = false;
    String msg;
    // iat
    Object test = customInteger.get();
    System.out.printf("+++ verifyInjectedCustomInteger, JsonNumber.class.CL: %s\n",
        JsonNumber.class.getClassLoader());
    System.out.printf("+++ customInteger.CL: %s\n",
        test.getClass().getClassLoader());
    Class[] ifaces = test.getClass().getInterfaces();
    for(Class iface : ifaces) {
        System.out.printf("%s: %s\n", iface, iface.getClassLoader());
    }
    JsonNumber customValue = JsonNumber.class.cast(test);
    if(customValue == null || customValue.isIntegral() == false) {
        msg = "customInteger value is null or not integral, FAIL";
    }
    else if(customValue.longValueExact() == value) {
        msg = "customInteger PASS";
        pass = true;
    }
    else {
        msg = String.format("customInteger: %d != %d", customValue, value);
    }
    JsonObject result = Json.createObjectBuilder()
        .add("pass", pass)
        .add("msg", msg)
        .build();
    return result;
}
 
开发者ID:eclipse,项目名称:microprofile-jwt-auth,代码行数:33,代码来源:ProviderInjectionEndpoint.java

示例4: getPolicy

/**
 * Get all segment routing policies.
 * Returns an array of segment routing policies.
 *
 * @return status of OK
 */
@GET
@Produces(MediaType.APPLICATION_JSON)
public Response getPolicy() {
    SegmentRoutingService srService = get(SegmentRoutingService.class);
    List<Policy> policies = srService.getPolicies();
    ObjectNode result = new ObjectMapper().createObjectNode();
    result.set("policy", new PolicyCodec().encode(policies, this));

    return ok(result.toString()).build();
}
 
开发者ID:shlee89,项目名称:athena,代码行数:16,代码来源:PolicyWebResource.java

示例5: getPostedPeople

@GET
@Produces({MediaType.APPLICATION_JSON})
@Path("/posted")
public Response getPostedPeople(@DefaultValue("1") @QueryParam("maxPeople") int maxPeople) {

    return Response.ok(POSTED_PEOPLE.subList(0, Math.min(maxPeople, POSTED_PEOPLE.size())))
            .build();
}
 
开发者ID:javaee-cool,项目名称:rest-basic-tutorial,代码行数:8,代码来源:PeopleResource.java

示例6: getStaffFiles

@GET
@Produces({ MediaType.APPLICATION_JSON })
@Path("staff")
public Page<FileOutVO> getStaffFiles(@Context UriInfo uriInfo)
		throws AuthenticationException, AuthorisationException, ServiceException {
	PSFUriPart psf;
	return new Page<FileOutVO>(WebUtil.getServiceLocator().getFileService().getFiles(auth, FileModule.STAFF_DOCUMENT, null, null, null, psf = new PSFUriPart(uriInfo)), psf);
}
 
开发者ID:phoenixctms,项目名称:ctsms,代码行数:8,代码来源:FileResource.java

示例7: find

@GET
@JSONP
@Path("/find")
@Produces({ MediaType.APPLICATION_JSON, TEXT_JAVASCRIPT })
public Response find() {
    final Map<String, List<String>> response = new HashMap<>();
    response.put("dashboards", Collections.emptyList());
    return Response.ok(response).build();
}
 
开发者ID:smoketurner,项目名称:graphiak,代码行数:9,代码来源:DashboardResource.java

示例8: getPaymentConfigDetail

@GET
@Path("/{id}")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@ApiOperation(value = "Get the PaymentConfig by primekey", response = PaymentConfigInputModel.class)
@ApiResponses(value = {
		@ApiResponse(code = HttpURLConnection.HTTP_OK, message = "Returns detail of PaymentConfig", response = PaymentConfigInputModel.class),
		@ApiResponse(code = HttpURLConnection.HTTP_FORBIDDEN, message = "Access denied", response = ExceptionModel.class),
		@ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = "Not found", response = ExceptionModel.class),
		@ApiResponse(code = HttpURLConnection.HTTP_INTERNAL_ERROR, message = "Internal error", response = ExceptionModel.class) })

public Response getPaymentConfigDetail(@Context HttpServletRequest request, @Context HttpHeaders header,
		@Context Company company, @Context Locale locale, @Context User user,
		@Context ServiceContext serviceContext, @PathParam("id") long id);
 
开发者ID:VietOpenCPS,项目名称:opencps-v2,代码行数:13,代码来源:PaymentConfigManagement.java

示例9: detail

/**
 * 查询作业详情.
 *
 * @param jobName 作业名称
 * @return 作业配置对象
 */
@GET
@Path("/jobs/{jobName}")
@Consumes(MediaType.APPLICATION_JSON)
public Response detail(@PathParam("jobName") final String jobName) {
    Optional<CloudJobConfiguration> jobConfig = configService.load(jobName);
    if (!jobConfig.isPresent()) {
        return Response.status(NOT_FOUND).build();
    }
    return Response.ok(jobConfig.get()).build();
}
 
开发者ID:elasticjob,项目名称:elastic-job-cloud,代码行数:16,代码来源:CloudJobRestfulApi.java

示例10: login

@GET
@Produces(MediaType.APPLICATION_JSON)
@Path("/login")
public String login() {
    if (sessionBean.isLogged() == true) {
        return "You are already logged in";
    } else {
        String url = loginClass.getAuthorizationURL();//send auth url
        sessionBean.setAuthorizationURL(url);
        return url;
    }
}
 
开发者ID:cipriancus,项目名称:FakeTwitterDetection,代码行数:12,代码来源:Login.java

示例11: getStaffList

@GET
@Produces({ MediaType.APPLICATION_JSON })
public Page<StaffOutVO> getStaffList(@Context UriInfo uriInfo)
		throws AuthenticationException, AuthorisationException, ServiceException {
	PSFUriPart psf;
	return new Page<StaffOutVO>(WebUtil.getServiceLocator().getStaffService()
			.getStaffList(auth, null, null, ResourceUtils.LIST_GRAPH_MAX_STAFF_INSTANCES, psf = new PSFUriPart(uriInfo)), psf);
}
 
开发者ID:phoenixctms,项目名称:ctsms,代码行数:8,代码来源:StaffResource.java

示例12: uploadCoreBackup

@POST
@Path("{serviceName}/getOfflinePendingChanges")
@Consumes({MediaType.MULTIPART_FORM_DATA})
@Produces({MediaType.APPLICATION_JSON})
public Response uploadCoreBackup(
        @PathParam("serviceName") String serviceName,
        @FormDataParam("file") InputStream zipByteArray,
        @FormDataParam("file") FormDataContentDisposition fileDisposition) throws IOException, SerializerException {
    return Response.ok(offlineModeService.calculateOfflinePendingChanges(serviceName, zipByteArray)).build();
}
 
开发者ID:Comcast,项目名称:redirector,代码行数:10,代码来源:OfflineRedirectorController.java

示例13: get

@GET
@Path("{" + PATH + ":.*}")
@Produces({MediaType.APPLICATION_JSON})
public Response get(
    @PathParam(PATH) @DefaultValue("UNKNOWN_" + PATH) final String path,
    @QueryParam(OP) @DefaultValue("UNKNOWN_" + OP) final String op
    ) throws IOException {
  LOG.info("get: " + PATH + "=" + path + ", " + OP + "=" + op);

  final Map<String, Object> m = new TreeMap<String, Object>();
  m.put(PATH, path);
  m.put(OP, op);
  final String js = JSON.toString(m);
  return Response.ok(js).type(MediaType.APPLICATION_JSON).build();
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:15,代码来源:JerseyResource.java

示例14: createGroup

@POST
@Consumes(MediaType.APPLICATION_JSON)
Response createGroup(final String aNewGroupName,
                     @BeanParam final AuthenticatedUser aUser);
 
开发者ID:cerner,项目名称:jwala,代码行数:4,代码来源:GroupServiceRest.java

示例15: update

/**
 * 更新应用配置.
 *
 * @param appConfig 应用配置
 */
@PUT
@Consumes(MediaType.APPLICATION_JSON)
public void update(final CloudAppConfiguration appConfig) {
    appConfigService.update(appConfig);
}
 
开发者ID:elasticjob,项目名称:elastic-job-cloud,代码行数:10,代码来源:CloudAppRestfulApi.java


注:本文中的javax.ws.rs.core.MediaType.APPLICATION_JSON属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。