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


Java UriInfo.getQueryParameters方法代码示例

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


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

示例1: PaginationOptionsFromQueryParams

import javax.ws.rs.core.UriInfo; //导入方法依赖的package包/类
/**
 *  Extracts the pagination options from the request.
 * @param uri The request context.
 */
public PaginationOptionsFromQueryParams(UriInfo uri) {
    MultivaluedMap<String, String> queryParams = uri.getQueryParameters();
    String pageQuery = queryParams.getFirst("page");
    if (pageQuery == null || pageQuery.isEmpty()) {
        page = 1;
    } else {
        page = Integer.parseInt(pageQuery);
    }

    String perPageQuery = queryParams.getFirst("per_page");
    if (perPageQuery == null || perPageQuery.isEmpty()) {
        perPage = 20;
    } else {
        perPage = Integer.parseInt(perPageQuery);
    }
}
 
开发者ID:syndesisio,项目名称:syndesis,代码行数:21,代码来源:PaginationOptionsFromQueryParams.java

示例2: filter

import javax.ws.rs.core.UriInfo; //导入方法依赖的package包/类
@Override
public void filter(ContainerRequestContext reqCtx, ContainerResponseContext respCtx) throws IOException {
    final UriInfo uriInfo = reqCtx.getUriInfo();
    final MultivaluedMap<String, String> queryParameters = uriInfo.getQueryParameters();
    if (queryParameters.containsKey("pretty")) {
        ObjectWriterInjector.set(new IndentingModifier());
    }
}
 
开发者ID:stevespringett,项目名称:Alpine,代码行数:9,代码来源:PrettyPrintFilter.java

示例3: queryInfo

import javax.ws.rs.core.UriInfo; //导入方法依赖的package包/类
QueryInfo queryInfo(UriInfo uriInfo) {
    MultivaluedMap<String, String> mm = uriInfo.getQueryParameters(true);
    Integer top = QueryParser.parseTopQuery(mm.getFirst("$top"));
    Integer skip = QueryParser.parseSkipQuery(mm.getFirst("$skip"));

    return new QueryInfo(
            null,
            top,
            skip,
            null,
            null,
            null,
            null,
            null,
            null);
}
 
开发者ID:personium,项目名称:personium-core,代码行数:17,代码来源:ODataLinksResource.java

示例4: executeQuery

import javax.ws.rs.core.UriInfo; //导入方法依赖的package包/类
@GET
@javax.ws.rs.Path("/commands/{commandName}/query")
@Consumes(MediaType.MEDIA_TYPE_WILDCARD)
@Produces({MediaType.APPLICATION_JSON, MediaType.TEXT_PLAIN})
public Response executeQuery(@Context UriInfo uriInfo,
                             @PathParam("commandName") String commandName,
                             @Context HttpHeaders headers)
        throws Exception {
    validateCommand(commandName);
    String stepIndex = null;
    MultivaluedMap<String, String> parameters = uriInfo.getQueryParameters();
    List<String> stepValues = parameters.get("stepIndex");
    if (stepValues != null && !stepValues.isEmpty()) {
        stepIndex = stepValues.get(0);
    }
    if (stepIndex == null) {
        stepIndex = "0";
    }
    final JsonBuilder jsonBuilder = new JsonBuilder().createJson(Integer.valueOf(stepIndex));
    for (Map.Entry<String, List<String>> entry : parameters.entrySet()) {
        String key = entry.getKey();
        if (!"stepIndex".equals(key)) {
            jsonBuilder.addInput(key, entry.getValue());
        }
    }

    final Response response = executeCommandJson(jsonBuilder.build(), commandName, headers);
    if (response.getEntity() instanceof JsonObject) {
        JsonObject responseEntity = (JsonObject) response.getEntity();
        String error = ((JsonObject) responseEntity.getJsonArray("messages").get(0)).getString("description");
        return Response.status(Status.PRECONDITION_FAILED).entity(unwrapJsonObjects(error)).build();
    }
    return response;
}
 
开发者ID:fabric8-launcher,项目名称:launcher-backend,代码行数:35,代码来源:LaunchResource.java

示例5: getParameters

import javax.ws.rs.core.UriInfo; //导入方法依赖的package包/类
private Map<String, Set<String>> getParameters(UriInfo uriInfo) {
	MultivaluedMap<String, String> queryParametersMultiMap = uriInfo.getQueryParameters();
	Map<String, Set<String>> queryParameters = new HashMap<>();

	for (Map.Entry<String, List<String>> queryEntry : queryParametersMultiMap.entrySet()) {
		queryParameters.put(queryEntry.getKey(), new LinkedHashSet<>(queryEntry.getValue()));
	}
	return queryParameters;
}
 
开发者ID:crnk-project,项目名称:crnk-framework,代码行数:10,代码来源:JaxrsRequestContext.java

示例6: handleIvrEvent

import javax.ws.rs.core.UriInfo; //导入方法依赖的package包/类
@POST
public Response handleIvrEvent(
    @Context UriInfo uriInfo,
    JsonNode payload) {

  StringBuilder builder = new StringBuilder();
  MultivaluedMap<String, String> params = uriInfo.getQueryParameters();
  
  if (params != null && params.size() > 0) {
    params.keySet().forEach(key -> {
      List<String> list = params.get(key);
      list.forEach(value -> {
        builder.append("&").append(key).append("=").append(value);
      });
    });
  }
  
  LOGGER.debug("/event_ivr{}", builder.toString());
  LOGGER.debug("payload: {}", payload);
  
  Response response = null;

  try {
    String answerNcco = strategy.continueAnswerInboundCall(payload, params);
    LOGGER.debug("/event_ivr ncco: {}", answerNcco);
    response = Response.ok(answerNcco, MediaType.APPLICATION_JSON).build();
  } catch (Exception ex) {
    LOGGER.error("failed to handle event_ivr {}", ex.getMessage());
    response =  Response.status(Response.Status.INTERNAL_SERVER_ERROR)
        .entity(ex.getMessage()).build();
  }

  LOGGER.debug("/event_ivr response: {}", response.toString());
  return response;
}
 
开发者ID:Nexmo,项目名称:comms-router,代码行数:36,代码来源:NexMoEventIvrResource.java

示例7: DefaultJaxrsHttpRequest

import javax.ws.rs.core.UriInfo; //导入方法依赖的package包/类
/**
 * Construct and {@link HttpRequest} using JAX-RS context informations
 * @param request Request
 * @param uriInfo URI informations
 * @param headers Headers informations
 */
public DefaultJaxrsHttpRequest(Request request, UriInfo uriInfo, HttpHeaders headers) {
	super();
	ObjectUtils.argumentNotNull(uriInfo, "UriInfo must be not null");
	ObjectUtils.argumentNotNull(headers, "HttpHeaders must be not null");

	this.method = (request != null) ? request.getMethod() : null;
	this.uriInfo = uriInfo;
	this.headers = headers;
	this.queryParameters = uriInfo.getQueryParameters();
}
 
开发者ID:holon-platform,项目名称:holon-jaxrs,代码行数:17,代码来源:DefaultJaxrsHttpRequest.java

示例8: newItemQuick

import javax.ws.rs.core.UriInfo; //导入方法依赖的package包/类
@Override
public Response newItemQuick(UriInfo uriInfo, String filename, InputStream binaryData)
{
	try( InputStream bd = binaryData )
	{
		Map<String, List<String>> params = uriInfo.getQueryParameters();
		Pair<ItemId, Attachment> attInfo = quickUploadService.createOrSelectExisting(bd, filename, params);

		return Response.status(Status.CREATED).location(itemLinkService.getItemURI(attInfo.getFirst())).build();
	}
	catch( Exception e )
	{
		throw Throwables.propagate(e);
	}
}
 
开发者ID:equella,项目名称:Equella,代码行数:16,代码来源:ItemResourceImpl.java

示例9: getUiPageRequest

import javax.ws.rs.core.UriInfo; //导入方法依赖的package包/类
/**
 * Get JQGrid pagination information from query parameters.
 * 
 * @param uriInfo
 *            query parameters.
 * @param ormMapping
 *            Optional JSon to ORM property mapping.
 * @return a page request build with sort and filter.
 */
public UiPageRequest getUiPageRequest(final UriInfo uriInfo, final Map<String, String> ormMapping) {
	final MultivaluedMap<String, String> parameters = uriInfo.getQueryParameters();

	// Build the page request object
	final UiPageRequest request = new UiPageRequest();
	request.setUiFilter(buildFilter(parameters.getFirst("filters")));
	request.setUiSort(buildSort(getOrmColumn(ormMapping, getSortColumn(parameters)), getSortDirection(parameters)));
	request.setPage(ObjectUtils.defaultIfNull(getPage(parameters), 1));
	request.setPageSize(getPageLength(parameters));
	return request;
}
 
开发者ID:ligoj,项目名称:bootstrap,代码行数:21,代码来源:PaginationJson.java

示例10: filter

import javax.ws.rs.core.UriInfo; //导入方法依赖的package包/类
@Override
public void filter(ContainerRequestContext requestContext)
    throws IOException {
  final UriInfo info = requestContext.getUriInfo();
  MultivaluedMap<String, String> parameters = info.getQueryParameters();

  String format = parameters.getFirst("format");
  if (format == null) {
    return;
  }
  requestContext.getHeaders().putSingle(HttpHeaders.ACCEPT, format);
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:13,代码来源:MediaTypeFilter.java

示例11: queryInfo

import javax.ws.rs.core.UriInfo; //导入方法依赖的package包/类
static QueryInfo queryInfo(UriInfo uriInfo, String fullTextSearchKeyword) {
    MultivaluedMap<String, String> mm = uriInfo.getQueryParameters(true);

    Integer top = QueryParser.parseTopQuery(mm.getFirst("$top"));
    Integer skip = QueryParser.parseSkipQuery(mm.getFirst("$skip"));
    BoolCommonExpression filter = QueryParser.parseFilterQuery(mm.getFirst("$filter"));
    List<EntitySimpleProperty> select = QueryParser.parseSelectQuery(mm.getFirst("$select"));
    List<EntitySimpleProperty> expand = QueryParser.parseExpandQuery(mm.getFirst("$expand"));
    InlineCount inlineCount = QueryParser.parseInlinecountQuery(mm.getFirst("$inlinecount"));
    String skipToken = QueryParser.parseSkipTokenQuery(mm.getFirst("$skiptoken"));
    List<OrderByExpression> orderBy = QueryParser.parseOderByQuery(mm.getFirst("$orderby"));

    // 全文検索クエリqのバリデート
    if (fullTextSearchKeyword != null && (fullTextSearchKeyword.getBytes().length < 1
            || fullTextSearchKeyword.getBytes().length > Q_MAX_LENGTH)) {
        throw PersoniumCoreException.OData.QUERY_INVALID_ERROR.params("q", fullTextSearchKeyword);
    }

    // $expand指定時は$topの最大値が変わるためチェックする
    if (expand != null && top != null && top > PersoniumUnitConfig.getTopQueryMaxSizeWithExpand()) {
        // Integerでそのまま値を返却すると、カンマが付くため、文字列でエラーメッセージを返却する
        throw PersoniumCoreException.OData.QUERY_INVALID_ERROR.params("$top", top.toString());
    }

    Map<String, String> options = new HashMap<String, String>();
    options.put("q", fullTextSearchKeyword);
    return new QueryInfo(
            inlineCount,
            top,
            skip,
            filter,
            orderBy,
            skipToken,
            options,
            expand,
            select);
}
 
开发者ID:personium,项目名称:personium-core,代码行数:38,代码来源:ODataEntitiesResource.java

示例12: getBinary

import javax.ws.rs.core.UriInfo; //导入方法依赖的package包/类
@GET
@Produces(MIMETYPE_BINARY)
public Response getBinary(final @Context UriInfo uriInfo) {
  if (LOG.isDebugEnabled()) {
    LOG.debug("GET " + uriInfo.getAbsolutePath() + " as "+ MIMETYPE_BINARY);
  }
  servlet.getMetrics().incrementRequests(1);
  // doesn't make sense to use a non specific coordinate as this can only
  // return a single cell
  if (!rowspec.hasColumns() || rowspec.getColumns().length > 1) {
    servlet.getMetrics().incrementFailedGetRequests(1);
    return Response.status(Response.Status.BAD_REQUEST).type(MIMETYPE_TEXT)
        .entity("Bad request: Either 0 or more than 1 columns specified." + CRLF).build();
  }
  MultivaluedMap<String, String> params = uriInfo.getQueryParameters();
  try {
    ResultGenerator generator =
      ResultGenerator.fromRowSpec(tableResource.getName(), rowspec, null,
        !params.containsKey(NOCACHE_PARAM_NAME));
    if (!generator.hasNext()) {
      servlet.getMetrics().incrementFailedGetRequests(1);
      return Response.status(Response.Status.NOT_FOUND)
        .type(MIMETYPE_TEXT).entity("Not found" + CRLF)
        .build();
    }
    Cell value = generator.next();
    ResponseBuilder response = Response.ok(CellUtil.cloneValue(value));
    response.header("X-Timestamp", value.getTimestamp());
    servlet.getMetrics().incrementSucessfulGetRequests(1);
    return response.build();
  } catch (Exception e) {
    servlet.getMetrics().incrementFailedGetRequests(1);
    return processException(e);
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:36,代码来源:RowResource.java

示例13: FilterOptionsFromQueryParams

import javax.ws.rs.core.UriInfo; //导入方法依赖的package包/类
FilterOptionsFromQueryParams(UriInfo uri) {
    MultivaluedMap<String, String> queryParams = uri.getQueryParameters();
    String query = queryParams.getFirst("query");
    this.queryFilters = FilterOptionsParser.fromString(query);
}
 
开发者ID:syndesisio,项目名称:syndesis,代码行数:6,代码来源:FilterOptionsFromQueryParams.java

示例14: SortOptionsFromQueryParams

import javax.ws.rs.core.UriInfo; //导入方法依赖的package包/类
public SortOptionsFromQueryParams(UriInfo uri) {
    MultivaluedMap<String, String> queryParams = uri.getQueryParameters();
    sortField = queryParams.getFirst("sort");
    String dir = queryParams.getFirst("direction");
    sortDirection = dir == null ?  SortOptions.SortDirection.ASC : SortOptions.SortDirection.valueOf(dir.toUpperCase(Locale.US));
}
 
开发者ID:syndesisio,项目名称:syndesis,代码行数:7,代码来源:SortOptionsFromQueryParams.java

示例15: PSFUriPart

import javax.ws.rs.core.UriInfo; //导入方法依赖的package包/类
public PSFUriPart(UriInfo uriInfo, String... namedParameter) {
	this(uriInfo.getQueryParameters(true), namedParameter);
}
 
开发者ID:phoenixctms,项目名称:ctsms,代码行数:4,代码来源:PSFUriPart.java


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