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


Java MultivaluedMap类代码示例

本文整理汇总了Java中javax.ws.rs.core.MultivaluedMap的典型用法代码示例。如果您正苦于以下问题:Java MultivaluedMap类的具体用法?Java MultivaluedMap怎么用?Java MultivaluedMap使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


MultivaluedMap类属于javax.ws.rs.core包,在下文中一共展示了MultivaluedMap类的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: readFrom

import javax.ws.rs.core.MultivaluedMap; //导入依赖的package包/类
@Override
public Representation readFrom(Class<Representation> type,
        Type genericType, Annotation[] annotations, MediaType mediaType,
        MultivaluedMap<String, String> httpHeaders, InputStream entityStream)
        throws IOException, WebApplicationException {

    try (InputStreamReader reader = new InputStreamReader(entityStream,
            CommonParams.CHARSET)) {
        Gson gson = new GsonBuilder().setDateFormat(
                CommonParams.FORMAT_DATE).create();
        return gson.fromJson(reader, genericType);

    } catch (JsonSyntaxException e) {
        throw WebException.badRequest()
                .message(CommonParams.ERROR_JSON_FORMAT)
                .moreInfo(e.getMessage()).build();

    }
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:20,代码来源:GsonMessageProvider.java

示例3: writeTo

import javax.ws.rs.core.MultivaluedMap; //导入依赖的package包/类
@Override public void writeTo(
    Object object, Class<?> type, Type genericType,
    Annotation[] annotations, MediaType mediaType,
    MultivaluedMap<String, Object> httpHeaders,
    OutputStream entityStream) throws IOException, WebApplicationException {

    try (OutputStreamWriter writer = new OutputStreamWriter(entityStream, UTF_8)) {
        Type jsonType;
        if (type.equals(genericType)) {
            jsonType = type;
        } else {
            jsonType = genericType;
        }
        Globals.newGson().toJson(object, jsonType, writer);
    }
}
 
开发者ID:drakeet,项目名称:rebase-server,代码行数:17,代码来源:GsonBodyProvider.java

示例4: map_ReturnsOptionalParameter_WithValidData

import javax.ws.rs.core.MultivaluedMap; //导入依赖的package包/类
@Test
public void map_ReturnsOptionalParameter_WithValidData() {
  // Arrange
  MultivaluedMap<String, String> queryParameters = new MultivaluedHashMap<>();

  // Note there are multiple values for this parameter, to test that the first value is used only
  queryParameters.put(optionalParameter.getName(), ImmutableList.of("value", "valueB"));

  when(uriInfoMock.getQueryParameters()).thenReturn(queryParameters);

  // Act
  Map<String, String> result = representationRequestParameterMapper.map(product, contextMock);

  // Assert
  assertThat(result.size(), is(1));
  assertThat(result, hasEntry(optionalParameter.getName(), "value"));
}
 
开发者ID:dotwebstack,项目名称:dotwebstack-framework,代码行数:18,代码来源:RepresentationRequestParameterMapperTest.java

示例5: writeTo

import javax.ws.rs.core.MultivaluedMap; //导入依赖的package包/类
@Override
public void writeTo(CharmAttachmentPost attachment, Class<?> type, Type genericType, Annotation[] annotations,
		MediaType mediaType, MultivaluedMap<String, Object> httpHeaders, OutputStream entityStream)
		throws IOException, WebApplicationException {

	try {

		JAXBContext context = JAXBContext.newInstance(CharmAttachmentPost.class);
		Marshaller taskMarshaller = context.createMarshaller();
		taskMarshaller.marshal(attachment, entityStream);

	} catch (JAXBException e) {
		throw new ProcessingException("Error serializing Attachment to output stream");
	}

}
 
开发者ID:theits,项目名称:CharmMylynConnector,代码行数:17,代码来源:CharmAttachmentPostWriter.java

示例6: readFrom

import javax.ws.rs.core.MultivaluedMap; //导入依赖的package包/类
@Override
public Object readFrom(
        final Class<Object> type,
        final Type genericType,
        final Annotation[] annotations,
        final MediaType mediaType,
        final MultivaluedMap<String, String> httpHeaders,
        final InputStream entityStream)
                throws IOException {

    try {
        return objectMapper.readValue(entityStream, type);
    } catch (final JsonProcessingException ex) {
        throw new BadRequestException(ex.getMessage(), ex);
    }
}
 
开发者ID:minijax,项目名称:minijax,代码行数:17,代码来源:MinijaxJsonReader.java

示例7: map_ReturnsRequiredParameter_WithValidData

import javax.ws.rs.core.MultivaluedMap; //导入依赖的package包/类
@Test
public void map_ReturnsRequiredParameter_WithValidData() {
  // Arrange
  MultivaluedMap<String, String> queryParameters = new MultivaluedHashMap<>();

  // Note there are multiple values for this parameter, to test that the first value is used only
  queryParameters.put(requiredParameter.getName(), ImmutableList.of("value", "valueB"));

  when(uriInfoMock.getQueryParameters()).thenReturn(queryParameters);

  // Act
  Map<String, String> result = representationRequestParameterMapper.map(product, contextMock);

  // Assert
  assertThat(result.size(), is(1));
  assertThat(result, hasEntry(requiredParameter.getName(), "value"));
}
 
开发者ID:dotwebstack,项目名称:dotwebstack-framework,代码行数:18,代码来源:RepresentationRequestParameterMapperTest.java

示例8: map_ReturnsCorrectParameterName_ForQueryParameter

import javax.ws.rs.core.MultivaluedMap; //导入依赖的package包/类
@Test
public void map_ReturnsCorrectParameterName_ForQueryParameter() {
  // Arrange
  QueryParameter queryParameter = new QueryParameter();

  queryParameter.setName("param1");
  queryParameter.setIn("query");
  queryParameter.setVendorExtension(OpenApiSpecificationExtensions.PARAMETER,
      parameter.getIdentifier().stringValue());

  Operation operation = new Operation();
  operation.addParameter(queryParameter);

  MultivaluedMap<String, String> queryParameters = new MultivaluedHashMap<>();
  queryParameters.put(queryParameter.getName(), ImmutableList.of("value", "valueB"));

  // Act
  Map<String, String> result = mapper.map(operation, product, requestParameters);

  // Assert
  assertThat(result.size(), is(1));
  assertThat(result, hasEntry(parameter.getName(), "value"));
}
 
开发者ID:dotwebstack,项目名称:dotwebstack-framework,代码行数:24,代码来源:RequestParameterMapperTest.java

示例9: testGet

import javax.ws.rs.core.MultivaluedMap; //导入依赖的package包/类
@Test
public void testGet() throws Exception {

    MockRequestParameters params = new MockRequestParameters();
    params.setId(1L);

    UriInfo uriinfo = mock(UriInfo.class);
    MultivaluedMap<String, String> map = new MultivaluedHashMap<>();
    map.putSingle(CommonParams.PARAM_VERSION, "v" + Integer.valueOf(CommonParams.VERSION_1).toString());
    Mockito.when(uriinfo.getPathParameters()).thenReturn(map);

    Response response = get(uriinfo, backendGet, params, true);

    assertEquals(Status.OK.getStatusCode(), response.getStatus());
    assertNotNull(response.getEntity());
    assertThat(response.getEntity(), instanceOf(MockRepresentation.class));
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:18,代码来源:RestResourceTest.java

示例10: testVersionFilter

import javax.ws.rs.core.MultivaluedMap; //导入依赖的package包/类
@SuppressWarnings("boxing")
private MultivaluedMap<String, String> testVersionFilter(String version) throws WebApplicationException, NoSuchMethodException {

    ResourceInfo resourceInfo = mock(ResourceInfo.class);
    ContainerRequestContext request = mock(ContainerRequestContext.class);
    UriInfo uriInfo = mock(UriInfo.class);
    when(request.getUriInfo()).thenReturn(uriInfo);

    Method method = SinceClass.class.getMethod("dummy");

    MultivaluedMap<String, String> prop = new MultivaluedHashMap<>();
    prop.putSingle(CommonParams.PARAM_VERSION, version);
    when(uriInfo.getPathParameters()).thenReturn(prop);

    VersionFilter filter = spy(new VersionFilter());
    when(filter.getResourceInfo()).thenReturn(resourceInfo);
    when(resourceInfo.getResourceMethod()).thenReturn(method);
    filter.filter(request);

    return prop;
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:22,代码来源:VersionFilterTest.java

示例11: extAuthnHandlerSetsErrorAttributeWhenIdentificationFails

import javax.ws.rs.core.MultivaluedMap; //导入依赖的package包/类
@Test
public void extAuthnHandlerSetsErrorAttributeWhenIdentificationFails() throws Exception {
    when(mockAuthenticationHandlerService.buildSession(any()))
            .thenReturn(null);
    when(mockAuthenticationHandlerService.purgeSession(any()))
            .thenReturn(mock(MultivaluedMap.class));
    ProfileRequestContext profileRequestContext = new ProfileRequestContext();
    profileRequestContext.addSubcontext(new AuthenticationContext());

    MockHttpServletRequest request = getQueryParamRequest(getValidTupasResponseParams());
    MockHttpServletResponse response = new MockHttpServletResponse();

    when(ExternalAuthentication.getProfileRequestContext("e1s1", request)).thenReturn(profileRequestContext);

    extAuthnHandler.doGet(request, response);

    AuthenticationContext authenticationContext = profileRequestContext.getSubcontext(AuthenticationContext.class);
    assertNotNull(authenticationContext);
    TupasContext tupasContext = authenticationContext.getSubcontext(TupasContext.class);
    assertNull(tupasContext);
    assertNotNull(response.getRedirectedUrl());
}
 
开发者ID:vrk-kpa,项目名称:e-identification-tupas-idp-public,代码行数:23,代码来源:ShibbolethExtAuthnHandlerTest.java

示例12: parseSessionDataFailsIfStampIsExpired

import javax.ws.rs.core.MultivaluedMap; //导入依赖的package包/类
@Test
public void parseSessionDataFailsIfStampIsExpired() throws Exception {
    ReflectionTestUtils.setField(parser, "clock", expired);

    MultivaluedMap<String,String> initParams = getValidInitParams();
    initParams.putSingle("sessionId", "1234567890");
    when(authenticationHandlerUtils.popFromCache(any())).thenReturn(initParams);

    Map<String,String> attributeNameMap = mock(Map.class);
    when(attributeNameMap.get("B02K_CUSTID")).thenReturn("ATTRNAME_CUSTID");
    when(attributeNameMap.get("B02K_CUSTNAME")).thenReturn("ATTRNAME_CUSTNAME");

    MultivaluedMap<String,String> sessionParams = getValidSessionParamsWithHetu();
    sessionParams.putSingle("sessionId", "1234567890");

    assertNull(parser.parseSessionData(sessionParams));
}
 
开发者ID:vrk-kpa,项目名称:e-identification-tupas-idp-public,代码行数:18,代码来源:SessionParserServiceSessionTest.java

示例13: writeTo

import javax.ws.rs.core.MultivaluedMap; //导入依赖的package包/类
@Override
public void writeTo(User t, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, Object> httpHeaders, OutputStream entityStream) throws IOException, WebApplicationException {
    t.setPassword(null);
    JsonbConfig config = new JsonbConfig().withNullValues(false);
    JsonbBuilder.create(config)
        .toJson(t, entityStream);
}
 
开发者ID:hantsy,项目名称:javaee8-jaxrs-sample,代码行数:8,代码来源:UserMessageBodyWiter.java

示例14: logHttpHeaders

import javax.ws.rs.core.MultivaluedMap; //导入依赖的package包/类
protected void logHttpHeaders(MultivaluedMap<String, String> headers) {
    StringBuilder msg = new StringBuilder("The HTTP headers are: \n");
    for (Map.Entry<String, List<String>> entry : headers.entrySet()) {
        msg.append(entry.getKey()).append(": ");
        for (int i = 0; i < entry.getValue().size(); i++) {
            msg.append(entry.getValue().get(i));
            if (i < entry.getValue().size() - 1) {
                msg.append(", ");
            }
        }
        msg.append("\n");
    }
    logger.info(msg.toString());
}
 
开发者ID:yunhaibin,项目名称:dubbox-hystrix,代码行数:15,代码来源:LoggingFilter.java

示例15: writeTo

import javax.ws.rs.core.MultivaluedMap; //导入依赖的package包/类
@Override
public void writeTo(ApplicationResponse t, Class<?> type, Type genericType, Annotation[] annotations,
        MediaType mediaType, MultivaluedMap<String, Object> httpHeaders, OutputStream entityStream)
        throws IOException {
    
    ByteArrayOutputStream boss = new ByteArrayOutputStream();
    ObjectMapper om = jsonProvider.locateMapper(type, MediaType.APPLICATION_JSON_TYPE);
    if(om != null) {
        jsonProvider.writeTo(t, type, genericType, annotations, MediaType.APPLICATION_JSON_TYPE, httpHeaders, boss);
        boss.flush();
    }

    Writer osWriter = new OutputStreamWriter(entityStream);
    String code, text, prefix;
    if(StringUtils.hasText(t.getMsgCode())) { 
        code = "400"; prefix = t.getMsgCode();
    } else {
        code = "200"; prefix = "";
    }
    if(StringUtils.hasText(t.getMessage())) { 
        text = prefix + " " + t.getMessage();
    } else {
        text = "ok";
    }
    osWriter.write("<html><body status='"+code+"' statusText='" + text + "'>");
    osWriter.flush();
    entityStream.write(boss.toByteArray());
    boss.close();
    osWriter.write("</body></html>");
    osWriter.close();
}
 
开发者ID:cerner,项目名称:jwala,代码行数:32,代码来源:ResponseMessageBodyWriter.java


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