本文整理汇总了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());
}
示例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();
}
}
示例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;
}
示例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();
}
示例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();
}
示例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);
}
示例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();
}
示例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);
示例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();
}
示例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;
}
}
示例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);
}
示例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();
}
示例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();
}
示例14: createGroup
@POST
@Consumes(MediaType.APPLICATION_JSON)
Response createGroup(final String aNewGroupName,
@BeanParam final AuthenticatedUser aUser);
示例15: update
/**
* 更新应用配置.
*
* @param appConfig 应用配置
*/
@PUT
@Consumes(MediaType.APPLICATION_JSON)
public void update(final CloudAppConfiguration appConfig) {
appConfigService.update(appConfig);
}