本文整理汇总了Java中javax.ws.rs.core.MultivaluedMap.containsKey方法的典型用法代码示例。如果您正苦于以下问题:Java MultivaluedMap.containsKey方法的具体用法?Java MultivaluedMap.containsKey怎么用?Java MultivaluedMap.containsKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.ws.rs.core.MultivaluedMap
的用法示例。
在下文中一共展示了MultivaluedMap.containsKey方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: filter
import javax.ws.rs.core.MultivaluedMap; //导入方法依赖的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());
}
}
示例2: getQueryParameterValue
import javax.ws.rs.core.MultivaluedMap; //导入方法依赖的package包/类
/**
* Get a URI query parameter value by name
* @param queryParameters URI query parameters
* @param name Parameter name
* @return Parameter value, or <code>null</code> if not found
*/
public static Optional<String> getQueryParameterValue(MultivaluedMap<String, String> queryParameters, String name) {
if (name != null) {
if (queryParameters != null && queryParameters.containsKey(name)) {
List<String> values = queryParameters.get(name);
if (values != null && !values.isEmpty()) {
if (values.size() == 1) {
return Optional.ofNullable(values.get(0));
} else {
StringBuilder sb = new StringBuilder();
for (String value : values) {
if (sb.length() > 0) {
sb.append(',');
}
sb.append(value);
}
return Optional.of(sb.toString());
}
}
}
}
return Optional.empty();
}
示例3: filter
import javax.ws.rs.core.MultivaluedMap; //导入方法依赖的package包/类
@Override
public void filter(ContainerRequestContext ctx) throws IOException {
MultivaluedMap<String, String> headers = ctx.getHeaders();
if(headers == null) {
handleError(ctx);
}
if(!headers.containsKey("X-Username")) {
handleError(ctx);
}
String username = headers.getFirst("X-Username");
if(username == null) {
handleError(ctx);
}
// Set the Username in the current Request Scope:
RequestContextHolder
.currentRequestAttributes()
.setAttribute("Username", username, SCOPE_REQUEST);
}
示例4: equalsRequestHeader
import javax.ws.rs.core.MultivaluedMap; //导入方法依赖的package包/类
private boolean equalsRequestHeader(ContainerRequestContext containerRequestContext) {
MultivaluedMap<String, String> requestHeader = containerRequestContext.getHeaders();
MultivaluedMap<String, Object> desiredHeader = endpoint.getHeader().getContent();
if (!StringUtils.isEmpty(desiredHeader)) {
if (!requestHeader.isEmpty()) {
for (Map.Entry<String, List<Object>> map : desiredHeader.entrySet()) {
if (!requestHeader.containsKey(map.getKey()) || !requestHeader.get(map.getKey()).containsAll(map.getValue()))
return false;
}
} else
return false;
}
return true;
}
示例5: getArgumentValue
import javax.ws.rs.core.MultivaluedMap; //导入方法依赖的package包/类
private Object getArgumentValue(String parameterName, MultivaluedMap<String, String> queryParameters, Type type) throws Exception {
if (overrides.containsKey(parameterName)) {
return overrides.get(parameterName);
} else if (queryParameters.containsKey(parameterName)) {
String value = ResourceUtils.popQueryParamValue(parameterName, queryParameters);
if (type != null) {
return StringConverter.getConverter(type).convert(value);
} else {
if (excludePrimitiveConversion.contains(parameterName)) {
return value;
}
return StringConverter.convert(value, primitiveConversionPrecedence);
}
} else if (defaults.containsKey(parameterName)) {
return defaults.get(parameterName);
} else {
return null;
}
}
示例6: build
import javax.ws.rs.core.MultivaluedMap; //导入方法依赖的package包/类
@GET
public Response build() {
MultivaluedMap<String, String> params = uriInfo.getQueryParameters();
String service = params.getFirst(CASLoginProtocol.SERVICE_PARAM);
boolean renew = params.containsKey(CASLoginProtocol.RENEW_PARAM);
boolean gateway = params.containsKey(CASLoginProtocol.GATEWAY_PARAM);
checkSsl();
checkRealm();
checkClient(service);
AuthorizationEndpointChecks checks = getOrCreateAuthenticationSession(client, null);
if (checks.response != null) {
return checks.response;
}
authenticationSession = checks.authSession;
updateAuthenticationSession();
// So back button doesn't work
CacheControlUtil.noBackButtonCacheControlHeader();
if (renew) {
authenticationSession.setClientNote(CASLoginProtocol.RENEW_PARAM, "true");
}
this.event.event(EventType.LOGIN);
return handleBrowserAuthenticationRequest(authenticationSession, new CASLoginProtocol(session, realm, uriInfo, headers, event), gateway, false);
}
示例7: writeTo
import javax.ws.rs.core.MultivaluedMap; //导入方法依赖的package包/类
@Override
public void writeTo(DatasetConfig datasetConfig, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType,
MultivaluedMap<String, Object> httpHeaders, OutputStream entityStream)
throws IOException, WebApplicationException {
final String hostname;
if (httpHeaders.containsKey(WebServer.X_DREMIO_HOSTNAME)) {
hostname = (String) httpHeaders.getFirst(WebServer.X_DREMIO_HOSTNAME);
} else {
hostname = masterNode;
}
// Change headers to force download and suggest a filename.
String fullPath = Joiner.on(".").join(datasetConfig.getFullPathList());
httpHeaders.putSingle(HttpHeaders.CONTENT_DISPOSITION, format("attachment; filename=\"%s.tds\"", fullPath));
try {
final XMLStreamWriter xmlStreamWriter = xmlOutputFactory.createXMLStreamWriter(entityStream, "UTF-8");
xmlStreamWriter.writeStartDocument("utf-8", "1.0");
writeDatasource(xmlStreamWriter, datasetConfig, hostname, mediaType);
xmlStreamWriter.writeEndDocument();
xmlStreamWriter.close();
} catch (XMLStreamException e) {
throw UserExceptionMapper.withStatus(
UserException.dataWriteError(e)
.message("Cannot generate TDS file")
.addContext("Details", e.getMessage()),
Status.INTERNAL_SERVER_ERROR
).build(logger);
}
}
示例8: hasOnceNonEmpty
import javax.ws.rs.core.MultivaluedMap; //导入方法依赖的package包/类
private boolean hasOnceNonEmpty(final MultivaluedMap<String, String> query, String key) {
return query.containsKey(key) && query.get(key).size() == 1 && StringUtils.isNotBlank(query.getFirst(key));
}
示例9: isAttributeRequestValid
import javax.ws.rs.core.MultivaluedMap; //导入方法依赖的package包/类
public boolean isAttributeRequestValid(final MultivaluedMap<String, String> attrsParams) {
return attrsParams.containsKey("token");
}