本文整理匯總了Java中javax.ws.rs.core.MultivaluedMap.size方法的典型用法代碼示例。如果您正苦於以下問題:Java MultivaluedMap.size方法的具體用法?Java MultivaluedMap.size怎麽用?Java MultivaluedMap.size使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.ws.rs.core.MultivaluedMap
的用法示例。
在下文中一共展示了MultivaluedMap.size方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: handleIvrEvent
import javax.ws.rs.core.MultivaluedMap; //導入方法依賴的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;
}
示例2: getHeaders
import javax.ws.rs.core.MultivaluedMap; //導入方法依賴的package包/類
private Header[] getHeaders(MultivaluedMap<String, String> headers) {
if (headers == null || headers.isEmpty()) {
return new Header[0];
}
int i = 0;
headers.remove(CONTENT_LENGTH);
Header[] headerz = new Header[headers.size()];
for (String key : headers.keySet()) {
headerz[i] = new BasicHeader(key, headers.getFirst(key));
i++;
}
return headerz;
}
示例3: toResponse
import javax.ws.rs.core.MultivaluedMap; //導入方法依賴的package包/類
@Override
public Response toResponse(WebApplicationException exception) {
LOGGER.error("WebApplicationException:", exception);
LOGGER.debug("Constructing Error Response for: [{}]", exception.toString());
ErrorResponse errorResponse = new ErrorResponse();
Response exceptionResponse = exception.getResponse();
Response.StatusType statusInfo = exceptionResponse.getStatusInfo();
errorResponse.setCode(statusInfo.getStatusCode());
errorResponse.setStatus(statusInfo.getReasonPhrase());
errorResponse.setMessage(exception.getMessage());
Response.ResponseBuilder responseBuilder = Response.status(statusInfo)
.entity(errorResponse)
.type(MediaType.APPLICATION_JSON);
MultivaluedMap<String, Object> headers = exceptionResponse.getHeaders();
if (headers.size() > 0) {
LOGGER.debug("Adding headers:");
for (Map.Entry<String, List<Object>> entry : headers.entrySet()) {
String headerKey = entry.getKey();
List<Object> headerValues = entry.getValue();
LOGGER.debug(" {} -> {}", headerKey, headerValues);
if (headerValues.size() == 1) {
responseBuilder.header(headerKey, headerValues.get(0));
} else {
responseBuilder.header(headerKey, headerValues);
}
}
}
return responseBuilder.build();
}
開發者ID:durimkryeziu,項目名稱:jersey-2.x-webapp-for-servlet-container,代碼行數:36,代碼來源:WebApplicationExceptionMapper.java