本文整理汇总了Java中javax.ws.rs.core.MultivaluedMap.add方法的典型用法代码示例。如果您正苦于以下问题:Java MultivaluedMap.add方法的具体用法?Java MultivaluedMap.add怎么用?Java MultivaluedMap.add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.ws.rs.core.MultivaluedMap
的用法示例。
在下文中一共展示了MultivaluedMap.add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createInstance
import javax.ws.rs.core.MultivaluedMap; //导入方法依赖的package包/类
/**
* Create a broker Instance
*
* @param brokerName
* @return
* @throws CloudKarafkaServiceException
*/
public CloudKarafkaCreateInstanceResponse createInstance(final String brokerName,
final String plan) throws CloudKarafkaServiceException {
// build input form
final MultivaluedMap<String, String> form = new MultivaluedHashMap<>();
form.add("name", brokerName);
form.add("plan", plan);
form.add("region", brokerConfig.getCloudKarafkaRegion());
//build post request
final String target = String.format("%s/%s", brokerConfig.getCloudkarafkaApiUrl(), "instances");
final WebTarget webTarget = client.target(target);
// call create broker instances API
return webTarget.request(MediaType.APPLICATION_JSON)
.post(Entity.form(form), CloudKarafkaCreateInstanceResponse.class);
}
示例2: changeInstance
import javax.ws.rs.core.MultivaluedMap; //导入方法依赖的package包/类
/**
* Change a broker Instance
*
* @param brokerName
* @throws CloudKarafkaServiceException
*/
public void changeInstance(final String instanseId,
final String brokerName,
final String plan) throws CloudKarafkaServiceException {
// build input form
final MultivaluedMap<String, String> form = new MultivaluedHashMap<>();
form.add("name", brokerName);
form.add("plan", plan);
//build post request
final String target = String.format("%s/%s/%s", brokerConfig.getCloudkarafkaApiUrl(), "instances",instanseId);
final WebTarget webTarget = client.target(target);
// call create broker instances API
webTarget.request(MediaType.APPLICATION_JSON).put(Entity.form(form));
}
示例3: testMultipartForm
import javax.ws.rs.core.MultivaluedMap; //导入方法依赖的package包/类
@Test
public void testMultipartForm() throws IOException {
final MultivaluedMap<String, String> mockHeaders = new MultivaluedHashMap<>();
mockHeaders.add("Content-Type", "multipart/form-data");
final String mockContent =
"------WebKitFormBoundarycTqA2AimXQHBAJbZ\n" +
"Content-Disposition: form-data; name=\"a\"\n" +
"\n" +
"b\n" +
"------WebKitFormBoundarycTqA2AimXQHBAJbZ";
final ByteArrayInputStream mockContentBody = new ByteArrayInputStream(mockContent.getBytes(StandardCharsets.UTF_8));
final MockHttpServletRequest mockRequest = new MockHttpServletRequest("POST", URI.create("/"), mockHeaders, mockContentBody, null);
try (final MinijaxRequestContext context = new MinijaxRequestContext(null, mockRequest, null)) {
final MinijaxForm form = context.getForm();
assertTrue(form instanceof MinijaxMultipartForm);
assertEquals("b", form.getString("a"));
// Assert that same cached object
assertTrue(form == context.getForm());
}
}
示例4: tryMatch
import javax.ws.rs.core.MultivaluedMap; //导入方法依赖的package包/类
public boolean tryMatch(final String httpMethod, final MinijaxUriInfo uriInfo) {
if (!this.httpMethod.equals(httpMethod)) {
return false;
}
final String requestPath = uriInfo.getRequestUri().getPath();
final Matcher matcher = pathPattern.getPattern().matcher(requestPath);
if (!matcher.matches()) {
return false;
}
final MultivaluedMap<String, String> pathParameters = new MultivaluedHashMap<>();
for (final String name : pathPattern.getParams()) {
pathParameters.add(name, matcher.group(name));
}
uriInfo.setPathParameters(pathParameters);
return true;
}
示例5: testAcceptableMediaTypes
import javax.ws.rs.core.MultivaluedMap; //导入方法依赖的package包/类
@Test
public void testAcceptableMediaTypes() throws IOException {
final MultivaluedMap<String, String> mockHeaders = new MultivaluedHashMap<>();
mockHeaders.add("Accept", "text/plain");
final MockHttpServletRequest mockRequest = new MockHttpServletRequest("GET", URI.create("/"), mockHeaders, null, null);
try (final MinijaxRequestContext context = new MinijaxRequestContext(null, mockRequest, null)) {
final List<MediaType> mediaTypes = context.getAcceptableMediaTypes();
assertEquals(1, mediaTypes.size());
assertEquals("text/plain", mediaTypes.get(0).toString());
// Assert that same cached object
assertTrue(mediaTypes == context.getAcceptableMediaTypes());
}
}
示例6: testUrlEncodedForm
import javax.ws.rs.core.MultivaluedMap; //导入方法依赖的package包/类
@Test
public void testUrlEncodedForm() throws IOException {
final MultivaluedMap<String, String> mockHeaders = new MultivaluedHashMap<>();
mockHeaders.add("Content-Type", "application/x-www-form-urlencoded");
final ByteArrayInputStream mockContentBody = new ByteArrayInputStream("a=b".getBytes(StandardCharsets.UTF_8));
final MockHttpServletRequest mockRequest = new MockHttpServletRequest("POST", URI.create("/"), mockHeaders, mockContentBody, null);
try (final MinijaxRequestContext context = new MinijaxRequestContext(null, mockRequest, null)) {
final MinijaxForm form = context.getForm();
assertTrue(form instanceof MinijaxUrlEncodedForm);
assertEquals("b", form.getString("a"));
// Assert that same cached object
assertTrue(form == context.getForm());
}
}
示例7: getTypeDefs
import javax.ws.rs.core.MultivaluedMap; //导入方法依赖的package包/类
private AtlasTypesDef getTypeDefs(String ... typeNames) throws AtlasServiceException {
final AtlasTypesDef typeDefs = new AtlasTypesDef();
for (int i = 0; i < typeNames.length; i++) {
final MultivaluedMap<String, String> searchParams = new MultivaluedMapImpl();
searchParams.add(SearchFilter.PARAM_NAME, typeNames[i]);
final AtlasTypesDef typeDef = atlasClient.getAllTypeDefs(new SearchFilter(searchParams));
typeDefs.getEntityDefs().addAll(typeDef.getEntityDefs());
}
logger.debug("typeDefs={}", typeDefs);
return typeDefs;
}
示例8: writeTo
import javax.ws.rs.core.MultivaluedMap; //导入方法依赖的package包/类
/**
* Method that JAX-RS container calls to serialize given value.
*/
public void writeTo(Object obj, //
Class<?> type, //
Type genericType, //
Annotation[] annotations, //
MediaType mediaType, //
MultivaluedMap<String, Object> httpHeaders, //
OutputStream entityStream //
) throws IOException, WebApplicationException {
SerializerFeature[] serializerFeatures = fastJsonConfig.getSerializerFeatures();
if (pretty) {
if (serializerFeatures == null)
serializerFeatures = new SerializerFeature[]{SerializerFeature.PrettyFormat};
else {
List<SerializerFeature> featureList = new ArrayList<SerializerFeature>(Arrays
.asList(serializerFeatures));
featureList.add(SerializerFeature.PrettyFormat);
serializerFeatures = featureList.toArray(serializerFeatures);
}
fastJsonConfig.setSerializerFeatures(serializerFeatures);
}
int len = JSON.writeJSONString(entityStream, //
fastJsonConfig.getCharset(), //
obj, //
fastJsonConfig.getSerializeConfig(), //
fastJsonConfig.getSerializeFilters(), //
fastJsonConfig.getDateFormat(), //
JSON.DEFAULT_GENERATE_FEATURE, //
fastJsonConfig.getSerializerFeatures());
// add Content-Length
httpHeaders.add("Content-Length", len);
entityStream.flush();
}
示例9: filter
import javax.ws.rs.core.MultivaluedMap; //导入方法依赖的package包/类
public void filter(ContainerRequestContext requestContext, ContainerResponseContext responseContext)
throws IOException {
MultivaluedMap<String, Object> headers = responseContext.getHeaders();
headers.add("Access-Control-Allow-Origin", "*");
headers.add("Access-Control-Allow-Methods", "GET, POST, DELETE, PUT, OPTIONS");
headers.add("Access-Control-Allow-Headers", "X-Requested-With, Content-Type");
}
示例10: testContentLength
import javax.ws.rs.core.MultivaluedMap; //导入方法依赖的package包/类
@Test
public void testContentLength() {
final MultivaluedMap<String, String> headers = new MultivaluedHashMap<>();
headers.add("Content-Length", "1024");
final MockHttpServletRequest request = new MockHttpServletRequest("GET", URI.create("/"), headers, null, null);
final MinijaxHttpHeaders httpHeaders = new MinijaxHttpHeaders(request);
assertEquals(1024, httpHeaders.getLength());
}
示例11: createInitResultPreventsAdptTStampInjection
import javax.ws.rs.core.MultivaluedMap; //导入方法依赖的package包/类
@Test
public void createInitResultPreventsAdptTStampInjection() throws Exception {
ReflectionTestUtils.setField(parser, "clock", Clock.fixed(Instant.ofEpochSecond(1489485600), ZoneId.systemDefault()));
when(authenticationHandlerUtils.createToken()).thenReturn("000000");
when(tupasStampIdService.getTupasStampCounter(anyInt())).thenReturn("0000001");
MultivaluedMap<String, String> requestParamsWithInjection = new MultivaluedHashMap<>();
requestParamsWithInjection.add("declRef", "nordea.tfi.tupas.fi");
requestParamsWithInjection.add("ckey", "e1s1");
requestParamsWithInjection.add("lang", "fi");
requestParamsWithInjection.add("ADPT_TSTAMP", "INJECTED");
String initResult = parser.createInitResult(requestParamsWithInjection);
assertFalse(initResult.contains("INJECTED"));
}
开发者ID:vrk-kpa,项目名称:e-identification-tupas-idp-public,代码行数:14,代码来源:SessionParserServiceRequestTest.java
示例12: testFormUnknownContentType
import javax.ws.rs.core.MultivaluedMap; //导入方法依赖的package包/类
@Test(expected = BadRequestException.class)
public void testFormUnknownContentType() throws IOException {
final MultivaluedMap<String, String> mockHeaders = new MultivaluedHashMap<>();
mockHeaders.add("Content-Type", "text/plain");
final ByteArrayInputStream mockContentBody = new ByteArrayInputStream("a=b".getBytes(StandardCharsets.UTF_8));
final MockHttpServletRequest mockRequest = new MockHttpServletRequest("POST", URI.create("/"), mockHeaders, mockContentBody, null);
try (final MinijaxRequestContext context = new MinijaxRequestContext(null, mockRequest, null)) {
context.getForm();
}
}
示例13: dropboxFlow
import javax.ws.rs.core.MultivaluedMap; //导入方法依赖的package包/类
@RequestMapping(value = "/dropboxcallback", method = {RequestMethod.GET, RequestMethod.POST})
public String dropboxFlow(@RequestParam(value = "code", defaultValue = "") String code, HttpServletRequest request, Model model) {
ClientConfig config = new DefaultClientConfig();
Client client = Client.create(config);
WebResource webResource = client.resource(UriBuilder.fromUri("https://api.dropboxapi.com/oauth2/token").build());
MultivaluedMap formData = new MultivaluedMapImpl();
formData.add("code", code);
formData.add("client_id", MISConfig.getDropbox_id());
formData.add("redirect_uri", MISConfig.getDropbox_redirect());
formData.add("client_secret",
MISConfig.getDropbox_secret());
formData.add("grant_type", "authorization_code");
ClientResponse response1 = webResource.type(MediaType.APPLICATION_FORM_URLENCODED_TYPE).post(ClientResponse.class, formData); //Exchange code for token
String json = response1.getEntity(String.class);
JSONObject jsonObj = new JSONObject(json);
String token=jsonObj.getString("access_token");
List<String> names= DbxAPIOp.dropboxGetFiles(token); //Get files name
List<FilmInfo> films=new LinkedList<FilmInfo>();
List<BookInfo> books=new LinkedList<BookInfo>();
List<MusicInfo> songs=new LinkedList<MusicInfo>();
try {
MediaOperations.findMediaInfo(names,books,films,songs); //Find info about files
} catch (Exception e) {
e.printStackTrace();
}
model.addAttribute("films",films);
model.addAttribute("books",books);
model.addAttribute("songs",songs);
if(names!=null) RabbitSend.sendOAuth(MediaOperations.getFilesName(names),"Dropbox", request);
//Generate HTML result page
if(books.size()==0 && films.size()==0 && songs.size()==0) return "error_scan";
else return "result_scan";
}
示例14: filter
import javax.ws.rs.core.MultivaluedMap; //导入方法依赖的package包/类
@Override
public void filter(ContainerRequestContext req, ContainerResponseContext res) throws IOException {
MultivaluedMap<String, Object> headers = res.getHeaders();
headers.add("Access-Control-Allow-Origin", "*");
headers.add("Access-Control-Allow-Methods", "GET, POST, DELETE, PUT, OPTIONS, HEAD");
headers.add("Access-Control-Allow-Headers", "Content-Type"); // X-Requested-With を追加するべき?
}
示例15: testHeaders
import javax.ws.rs.core.MultivaluedMap; //导入方法依赖的package包/类
@Test
public void testHeaders() throws IOException {
final MultivaluedMap<String, String> mockHeaders = new MultivaluedHashMap<>();
mockHeaders.add("a", "b");
final MockHttpServletRequest mockRequest = new MockHttpServletRequest("GET", URI.create("/"), mockHeaders, null, null);
try (final MinijaxRequestContext context = new MinijaxRequestContext(null, mockRequest, null)) {
final MultivaluedMap<String, String> headers = context.getHeaders();
assertEquals("b", headers.get("a").get(0));
// Assert that same cached object
assertTrue(headers == context.getHeaders());
}
}