當前位置: 首頁>>代碼示例>>Java>>正文


Java MultivaluedMap.add方法代碼示例

本文整理匯總了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);
}
 
開發者ID:ipolyzos,項目名稱:cloudkarafka-broker,代碼行數:24,代碼來源:CloudKarafkaAdminService.java

示例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));
}
 
開發者ID:ipolyzos,項目名稱:cloudkarafka-broker,代碼行數:22,代碼來源:CloudKarafkaAdminService.java

示例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());
    }
}
 
開發者ID:minijax,項目名稱:minijax,代碼行數:26,代碼來源:ServletRequestContextTest.java

示例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;
}
 
開發者ID:minijax,項目名稱:minijax,代碼行數:20,代碼來源:MinijaxResourceMethod.java

示例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());
    }
}
 
開發者ID:minijax,項目名稱:minijax,代碼行數:17,代碼來源:ServletRequestContextTest.java

示例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());
    }
}
 
開發者ID:minijax,項目名稱:minijax,代碼行數:19,代碼來源:ServletRequestContextTest.java

示例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;
}
 
開發者ID:bcgov,項目名稱:nifi-atlas,代碼行數:12,代碼來源:NiFiAtlasClient.java

示例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();
}
 
開發者ID:tiglabs,項目名稱:jsf-sdk,代碼行數:40,代碼來源:FastJsonProvider.java

示例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");
}
 
開發者ID:groovylabs,項目名稱:lyre,代碼行數:10,代碼來源:CORSFilter.java

示例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());
}
 
開發者ID:minijax,項目名稱:minijax,代碼行數:9,代碼來源:HttpHeadersTest.java

示例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();
    }
}
 
開發者ID:minijax,項目名稱:minijax,代碼行數:14,代碼來源:ServletRequestContextTest.java

示例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";
    }
 
開發者ID:LithiumSR,項目名稱:media_information_service,代碼行數:36,代碼來源:OAuthController.java

示例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 を追加するべき?
}
 
開發者ID:openNaEF,項目名稱:openNaEF,代碼行數:8,代碼來源:CORSResponseFilter.java

示例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());
    }
}
 
開發者ID:minijax,項目名稱:minijax,代碼行數:16,代碼來源:ServletRequestContextTest.java


注:本文中的javax.ws.rs.core.MultivaluedMap.add方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。