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


Java Consumes类代码示例

本文整理汇总了Java中javax.ws.rs.Consumes的典型用法代码示例。如果您正苦于以下问题:Java Consumes类的具体用法?Java Consumes怎么用?Java Consumes使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: save

import javax.ws.rs.Consumes; //导入依赖的package包/类
@Consumes(MediaType.APPLICATION_JSON)
@Path("/{projectName}/statuses/{commit}")
   @POST
   public Response save(@PathParam("projectName") String projectName, @PathParam("commit") String commit, 
   		Map<String, String> commitStatus, @Context UriInfo uriInfo) {

	Project project = getProject(projectName);
   	if (!SecurityUtils.canWrite(project))
   		throw new UnauthorizedException();
   	
   	String state = commitStatus.get("state").toUpperCase();
   	if (state.equals("PENDING"))
   		state = "RUNNING";
   	Verification verification = new Verification(Verification.Status.valueOf(state), 
   			new Date(), commitStatus.get("description"), commitStatus.get("target_url"));
   	String context = commitStatus.get("context");
   	if (context == null)
   		context = "default";
   	verificationManager.saveVerification(project, commit, context, verification);
   	UriBuilder uriBuilder = uriInfo.getAbsolutePathBuilder();
   	uriBuilder.path(context);
   	commitStatus.put("id", "1");
   	
   	return Response.created(uriBuilder.build()).entity(commitStatus).type(RestConstants.JSON_UTF8).build();
   }
 
开发者ID:jmfgdev,项目名称:gitplex-mit,代码行数:26,代码来源:CommitStatusResource.java

示例2: make

import javax.ws.rs.Consumes; //导入依赖的package包/类
@POST
@Path("/meeting")
@Produces(APPLICATION_JSON)
@Consumes(APPLICATION_JSON)
public Reservation make(Reservation reservation) {
	if (reservation.getId() != null)
		throw new BadRequestException(MessageFormat.format(ERROR_RESERVATION_IS_EXISTS_FMT, reservation.getId()));
	Set<Reservation> alreadyMadeReservations = reservationDao.getReservations(
			reservation.getVenue(), 
			reservation.getDate(), 
			reservation.getStartTime(),
			reservation.getDuration());
	if (alreadyMadeReservations != null && !alreadyMadeReservations.isEmpty())
		throw new BadRequestException(MessageFormat.format(ERROR_RESERVATION_CONFLICT_FMT, reservation.getVenue()));
	
	return reservationDao.createNew(reservation);
}
 
开发者ID:samolisov,项目名称:bluemix-liberty-microprofile-demo,代码行数:18,代码来源:MeetingBookingService.java

示例3: requestInvoice

import javax.ws.rs.Consumes; //导入依赖的package包/类
@POST
@Path(LRAOperationAPI.REQUEST)
@Produces(MediaType.TEXT_PLAIN)
@Consumes(MediaType.APPLICATION_JSON)
@LRA(value = LRA.Type.REQUIRED)
public Response requestInvoice(@HeaderParam(LRAClient.LRA_HTTP_HEADER) String lraUri, OrderInfo orderInfo) {
	String lraId = LRAClient.getLRAId(lraUri);
	log.info("processing request for LRA " + lraId);

	invoiceService.computeInvoice(lraId, orderInfo);

	//stub for compensation scenario
	if ("failInvoice".equals(orderInfo.getProduct().getProductId())) {
		return Response
				.status(Response.Status.BAD_REQUEST)
				.entity("Invoice for order " + orderInfo.getOrderId() + " failure")
				.build();
	}

	return Response
			.ok()
			.entity(String.format("Invoice for order %s processed", orderInfo.getOrderId()))
			.build();
}
 
开发者ID:xstefank,项目名称:lra-service,代码行数:25,代码来源:InvoiceEndpoint.java

示例4: updateFlowClassifier

import javax.ws.rs.Consumes; //导入依赖的package包/类
/**
 * Update details of a flow classifier.
 *
 * @param id
 *            flow classifier id
 * @param stream
 *            InputStream
 * @return 200 OK, 404 if given identifier does not exist
 */
@PUT
@Path("{flow_id}")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public Response updateFlowClassifier(@PathParam("flow_id") String id, final InputStream stream) {
    try {

        JsonNode jsonTree = mapper().readTree(stream);
        JsonNode flow = jsonTree.get("flow_classifier");
        FlowClassifier flowClassifier = codec(FlowClassifier.class).decode((ObjectNode) flow, this);
        Boolean result = nullIsNotFound(get(FlowClassifierService.class).updateFlowClassifier(flowClassifier),
                                        FLOW_CLASSIFIER_NOT_FOUND);
        return Response.status(OK).entity(result.toString()).build();
    } catch (IOException e) {
        log.error("Update flow classifier failed because of exception {}.", e.toString());
        throw new IllegalArgumentException(e);
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:28,代码来源:FlowClassifierWebResource.java

示例5: saveUser

import javax.ws.rs.Consumes; //导入依赖的package包/类
@POST
@Consumes("application/x-www-form-urlencoded")
@Produces("application/json")
@Path("/save")
public Object saveUser(@FormParam("userName") String userName,@FormParam("userPass") String userPass){
	String jsonData = "";
	User u = new User();
	u.setUserName(userName);
	u.setUserPass(userPass);
	try {
		userService.save(u);
	} catch (Exception e) {
		//-- 统一在过滤器中添加跨域访问的header信息,所以这里就不添加了
		jsonData = JsonUtil.toJsonByProperty("addUser","failure");
		return Response.ok(jsonData).status(HttpServletResponse.SC_INTERNAL_SERVER_ERROR ).build();
	}
	jsonData = JsonUtil.toJsonByProperty("id", u.getId());
	return Response.ok(jsonData).status(HttpServletResponse.SC_OK).build();
}
 
开发者ID:ranji1221,项目名称:clemon,代码行数:20,代码来源:UserResource.java

示例6: getFileTemplatesOfServiceInfo

import javax.ws.rs.Consumes; //导入依赖的package包/类
@GET
@Path("/{id}/filetemplates")
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON, MediaType.APPLICATION_FORM_URLENCODED })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@ApiOperation(value = "Get FileTemplate list of ServiceInfo by its id)", response = FileTemplateResultsModel.class)
@ApiResponses(value = {
		@ApiResponse(code = HttpURLConnection.HTTP_OK, message = "Returns the list of FileTemplate of ServiceInfo", response = FileTemplateResultsModel.class),
		@ApiResponse(code = HttpURLConnection.HTTP_UNAUTHORIZED, message = "Unauthorized", response = ExceptionModel.class),
		@ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = "Not found", response = ExceptionModel.class),
		@ApiResponse(code = HttpURLConnection.HTTP_FORBIDDEN, message = "Access denied", response = ExceptionModel.class) })
public Response getFileTemplatesOfServiceInfo(@Context HttpServletRequest request, @Context HttpHeaders header,
		@Context Company company, @Context Locale locale, @Context User user,
		@Context ServiceContext serviceContext,
		@ApiParam(value = "id of ServiceInfo that need to be get the list of FileTemplates", required = true) @PathParam("id") String id);
 
开发者ID:VietOpenCPS,项目名称:opencps-v2,代码行数:15,代码来源:ServiceInfoManagement.java

示例7: cancel

import javax.ws.rs.Consumes; //导入依赖的package包/类
@DELETE
@Path("/tcc/{txid}")
@Consumes("application/tcc")
   @ApiOperation(
   		code = 204,
   		response = String.class,
           value = "Rollback a given composite transaction",
           notes = "See https://www.atomikos.com/Blog/TransactionManagementAPIForRESTTCC",
           consumes = "application/tcc"
       )
public void cancel(
		@ApiParam(value = "Id of the composite transaction to rollback", required = true) @PathParam("txid") String txid
		){
	LOG.info("Trying to rollback transaction [{}]", txid);
	
	getCompositeTransactionParticipantService().cancel(txid);
	
	LOG.info("Transaction [{}] rolled back", txid);
}
 
开发者ID:jotorren,项目名称:microservices-transactions-tcc,代码行数:20,代码来源:CompositeTransactionParticipantController.java

示例8: updateFile

import javax.ws.rs.Consumes; //导入依赖的package包/类
@PUT
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Produces({ MediaType.APPLICATION_JSON })
public FileOutVO updateFile(@FormDataParam("json") FormDataBodyPart json,
		@FormDataParam("data") FormDataBodyPart content,
		@FormDataParam("data") FormDataContentDisposition contentDisposition,
		@FormDataParam("data") final InputStream input) throws AuthenticationException, AuthorisationException, ServiceException {
	// in.setId(fileId);
	json.setMediaType(MediaType.APPLICATION_JSON_TYPE);
	FileInVO in = json.getValueAs(FileInVO.class);
	FileStreamInVO stream = new FileStreamInVO();
	stream.setStream(input);
	stream.setMimeType(content.getMediaType().toString()); // .getType());
	stream.setSize(contentDisposition.getSize());
	stream.setFileName(contentDisposition.getFileName());
	return WebUtil.getServiceLocator().getFileService().updateFile(auth, in, stream);
}
 
开发者ID:phoenixctms,项目名称:ctsms,代码行数:18,代码来源:FileResource.java

示例9: createPorts

import javax.ws.rs.Consumes; //导入依赖的package包/类
@POST
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response createPorts(InputStream input) {
    try {
        ObjectMapper mapper = new ObjectMapper();
        ObjectNode portNode = (ObjectNode) mapper.readTree(input);

        OpenstackPort openstackPort = PORT_CODEC.decode(portNode, this);
        OpenstackSwitchingService switchingService =
                getService(OpenstackSwitchingService.class);
        switchingService.createPorts(openstackPort);

        log.debug("REST API ports is called with {}", portNode.toString());
        return Response.status(Response.Status.OK).build();

    } catch (Exception e) {
        log.error("Creates Port failed because of exception {}",
                e.toString());
        return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(e.toString())
                .build();
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:24,代码来源:OpenstackPortWebResource.java

示例10: update

import javax.ws.rs.Consumes; //导入依赖的package包/类
@PUT
@Path(value = "/{id}")
@Consumes("application/json")
public void update(@NotNull @PathParam("id") String id, @NotNull @Valid OAuthApp app) {
    final Connector connector = dataMgr.fetch(Connector.class, id);
    if (connector == null) {
        throw new WebApplicationException(Response.Status.NOT_FOUND);
    }

    final Connector updated = new Connector.Builder().createFrom(connector)
        .putOrRemoveConfiguredPropertyTaggedWith(Credentials.CLIENT_ID_TAG, app.clientId)
        .putOrRemoveConfiguredPropertyTaggedWith(Credentials.CLIENT_SECRET_TAG, app.clientSecret)
        .build();

    dataMgr.update(updated);
}
 
开发者ID:syndesisio,项目名称:syndesis,代码行数:17,代码来源:OAuthAppHandler.java

示例11: updateRegion

import javax.ws.rs.Consumes; //导入依赖的package包/类
/**
 * Updates the specified region using the supplied JSON input stream.
 *
 * @param regionId region identifier
 * @param stream region JSON stream
 * @return status of the request - UPDATED if the JSON is correct,
 * BAD_REQUEST if the JSON is invalid
 * @onos.rsModel RegionPost
 */
@PUT
@Path("{regionId}")
@Consumes(MediaType.APPLICATION_JSON)
public Response updateRegion(@PathParam("regionId") String regionId,
                             InputStream stream) {
    try {
        ObjectNode jsonTree = (ObjectNode) mapper().readTree(stream);
        JsonNode specifiedRegionId = jsonTree.get("id");

        if (specifiedRegionId != null &&
                !specifiedRegionId.asText().equals(regionId)) {
            throw new IllegalArgumentException(REGION_INVALID);
        }

        final Region region = codec(Region.class).decode(jsonTree, this);
        regionAdminService.updateRegion(region.id(),
                            region.name(), region.type(), region.masters());
    } catch (IOException e) {
        throw new IllegalArgumentException(e);
    }

    return Response.ok().build();
}
 
开发者ID:shlee89,项目名称:athena,代码行数:33,代码来源:RegionsWebResource.java

示例12: addRegistrationByRegistrationId

import javax.ws.rs.Consumes; //导入依赖的package包/类
@POST
@Path("/registrations/{id}/logs")
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@ApiOperation(value = "addRegistrationByRegistrationId)", response = RegistrationLogModel.class)
@ApiResponses(value = {
		@ApiResponse(code = HttpURLConnection.HTTP_OK, message = "Returns the RegistrationgModel was updated", response = RegistrationResultsModel.class),
		@ApiResponse(code = HttpURLConnection.HTTP_UNAUTHORIZED, message = "Unauthorized", response = ExceptionModel.class),
		@ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = "Not found", response = ExceptionModel.class),
		@ApiResponse(code = HttpURLConnection.HTTP_FORBIDDEN, message = "Access denied", response = ExceptionModel.class) })
public Response addRegistrationByRegistrationId(@Context HttpServletRequest request, @Context HttpHeaders header,
		@Context Company company, @Context Locale locale, @Context User user,
		@Context ServiceContext serviceContext,
		@ApiParam(value = "id of registration", required = true) @PathParam("id") long id,
		@ApiParam(value = "Metadata of RegistrationLog") @Multipart("author") String author,
		@ApiParam(value = "Metadata of RegistrationLog") @Multipart("payload") String payload,
		@ApiParam(value = "Metadata of RegistrationLog") @Multipart("content") String content);
 
开发者ID:VietOpenCPS,项目名称:opencps-v2,代码行数:18,代码来源:RegistrationLogManagement.java

示例13: format

import javax.ws.rs.Consumes; //导入依赖的package包/类
@ApiOperation(value = "Upload a private/public certificate zip file. ",
        notes = "Overwrites the entry marked &quot;internal&quot; in the truststore. "
        + "That is a private/public keypair used for secure connections by OSC. "
        + "The zip file should contain a  &quot;key.pem&quot; in PKCS8+PEM format (private key) and "
        + "certchain.pem or certchain.pkipath (the certificate chain). This results in the server restart ! ! !",
        response = BaseResponse.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "Successful operation"),
        @ApiResponse(code = 400, message = "In case of any error", response = ErrorCodeDto.class) })
@Path("/internalkeypair")
@POST
@Consumes(MediaType.APPLICATION_OCTET_STREAM)
public Response uploadKeypair(@Context HttpHeaders headers,
        @ApiParam(value = "The imported keypair zip file name",
        required = true) @PathParam("fileName") String fileName,
        @ApiParam(required = true) InputStream uploadedInputStream) {
    logger.info("Started uploading file " + fileName);
    this.userContext.setUser(OscAuthFilter.getUsername(headers));
    return this.apiUtil.getResponseForBaseRequest(this.replaceInternalKeypairServiceApi,
            new UploadRequest(fileName, uploadedInputStream));
}
 
开发者ID:opensecuritycontroller,项目名称:osc-core,代码行数:21,代码来源:ServerMgmtApis.java

示例14: updateEpaymentProfile

import javax.ws.rs.Consumes; //导入依赖的package包/类
@POST
@Path("/{id}/payments/{referenceUid}/epaymentprofile")
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON, MediaType.APPLICATION_FORM_URLENCODED })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@ApiOperation(value = "Add epaymentprofile", response = JSONObject.class)
@ApiResponses(value = {
		@ApiResponse(code = HttpURLConnection.HTTP_OK, message = "Returns epaymentprofile was update", response = JSONObject.class),
		@ApiResponse(code = HttpURLConnection.HTTP_UNAUTHORIZED, message = "Unauthorized", response = ExceptionModel.class),
		@ApiResponse(code = HttpURLConnection.HTTP_FORBIDDEN, message = "Access denied", response = ExceptionModel.class),
		@ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = "Not found", response = ExceptionModel.class) })
public Response updateEpaymentProfile(@Context HttpServletRequest request, @Context HttpHeaders header,
		@Context Company company, @Context Locale locale, @Context User user,
		@Context ServiceContext serviceContext,
		@ApiParam(value = "id of Payment", required = true) @PathParam("id") String id,
		@ApiParam (value = "referenceUid of Payment", required = true) @PathParam("referenceUid") String referenceUid,
		@BeanParam PaymentFileInputModel input);
 
开发者ID:VietOpenCPS,项目名称:opencps-v2,代码行数:17,代码来源:PaymentFileManagement.java

示例15: deleteFlow

import javax.ws.rs.Consumes; //导入依赖的package包/类
@DELETE
@Path("{flowId}")
@Consumes(MediaType.WILDCARD)
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(
        value = "Deletes a flow.",
        response = VersionedFlow.class
)
@ApiResponses({
        @ApiResponse(code = 401, message = HttpStatusMessages.MESSAGE_401),
        @ApiResponse(code = 403, message = HttpStatusMessages.MESSAGE_403),
        @ApiResponse(code = 404, message = HttpStatusMessages.MESSAGE_404),
        @ApiResponse(code = 409, message = HttpStatusMessages.MESSAGE_409) })
public Response deleteFlow(
        @PathParam("bucketId")
        @ApiParam("The bucket identifier")
            final String bucketId,
        @PathParam("flowId")
        @ApiParam("The flow identifier")
            final String flowId) {

    authorizeBucketAccess(RequestAction.DELETE, bucketId);
    final VersionedFlow deletedFlow = registryService.deleteFlow(bucketId, flowId);
    return Response.status(Response.Status.OK).entity(deletedFlow).build();
}
 
开发者ID:apache,项目名称:nifi-registry,代码行数:26,代码来源:BucketFlowResource.java


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