Search in sources :

Example 26 with MultivaluedMap

use of javax.ws.rs.core.MultivaluedMap in project cloudstack by apache.

the class MidoNetElement method getNetworkBridge.

private Bridge getNetworkBridge(long networkID, String accountUuid) {
    MultivaluedMap qNetBridge = new MultivaluedMapImpl();
    String networkUUIDStr = String.valueOf(networkID);
    qNetBridge.add("tenant_id", accountUuid);
    for (Bridge b : this.api.getBridges(qNetBridge)) {
        if (b.getName().equals(networkUUIDStr)) {
            return b;
        }
    }
    return null;
}
Also used : MultivaluedMapImpl(com.sun.jersey.core.util.MultivaluedMapImpl) MultivaluedMap(javax.ws.rs.core.MultivaluedMap) Bridge(org.midonet.client.resource.Bridge)

Example 27 with MultivaluedMap

use of javax.ws.rs.core.MultivaluedMap in project cloudstack by apache.

the class MidoNetVifDriver method plug.

@Override
public LibvirtVMDef.InterfaceDef plug(NicTO nic, String guestOsType, String nicAdapter) throws InternalErrorException, LibvirtException {
    if (s_logger.isDebugEnabled()) {
        s_logger.debug("nic=" + nic);
    }
    LibvirtVMDef.InterfaceDef intf = new LibvirtVMDef.InterfaceDef();
    String trafficLabel = nic.getName();
    if (nic.getBroadcastType() == Networks.BroadcastDomainType.Mido && (nic.getType() == Networks.TrafficType.Guest || nic.getType() == Networks.TrafficType.Public)) {
        /*
            * create the tap.
            */
        String tapName = addTap();
        /*
            * grab the tenant id and the network id from the Broadcast URI.
            * We need to pluck the values out of the String. The string
            * should look like "mido://[tenant_id].[bridge_name]"
            */
        MultivaluedMap qNet = new MultivaluedMapImpl();
        String nicAuthority = nic.getBroadcastUri().getAuthority();
        String tenantId = nicAuthority.split("\\.")[0];
        qNet.add("tenant_id", tenantId);
        String url = nicAuthority.split("\\.")[1];
        String netName = url.split(":")[0];
        MidonetApi api = new MidonetApi(_midoApiLocation);
        api.enableLogging();
        for (Bridge b : api.getBridges(qNet)) {
            if (b.getName().equals(netName)) {
                for (BridgePort p : b.getPorts()) {
                    UUID pvif = p.getVifId();
                    if (pvif != null && p.getVifId().toString().equals(nic.getUuid())) {
                        getMyHost(api).addHostInterfacePort().interfaceName(tapName).portId(p.getId()).create();
                        break;
                    }
                }
            }
        }
        intf.defEthernet(tapName, nic.getMac(), getGuestNicModel(guestOsType, nicAdapter), "");
    } else {
        throw new InternalErrorException("Only NICs of BroadcastDomain type Mido are supported by the MidoNetVifDriver");
    }
    return intf;
}
Also used : BridgePort(org.midonet.client.resource.BridgePort) LibvirtVMDef(com.cloud.hypervisor.kvm.resource.LibvirtVMDef) MultivaluedMapImpl(com.sun.jersey.core.util.MultivaluedMapImpl) InternalErrorException(com.cloud.exception.InternalErrorException) MultivaluedMap(javax.ws.rs.core.MultivaluedMap) UUID(java.util.UUID) Bridge(org.midonet.client.resource.Bridge) MidonetApi(org.midonet.client.MidonetApi)

Example 28 with MultivaluedMap

use of javax.ws.rs.core.MultivaluedMap in project tika by apache.

the class TarWriter method writeTo.

public void writeTo(Map<String, byte[]> parts, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, Object> httpHeaders, OutputStream entityStream) throws IOException, WebApplicationException {
    TarArchiveOutputStream zip = new TarArchiveOutputStream(entityStream);
    for (Map.Entry<String, byte[]> entry : parts.entrySet()) {
        tarStoreBuffer(zip, entry.getKey(), entry.getValue());
    }
    zip.close();
}
Also used : TarArchiveOutputStream(org.apache.commons.compress.archivers.tar.TarArchiveOutputStream) MultivaluedMap(javax.ws.rs.core.MultivaluedMap) Map(java.util.Map)

Example 29 with MultivaluedMap

use of javax.ws.rs.core.MultivaluedMap in project ddf by codice.

the class TestGetRecordsMessageBodyReader method testConfigurationArguments.

@Test
public void testConfigurationArguments() throws Exception {
    CswSourceConfiguration config = new CswSourceConfiguration(encryptionService);
    config.setMetacardCswMappings(DefaultCswRecordMap.getCswToMetacardAttributeNames());
    config.setOutputSchema(CswConstants.CSW_OUTPUT_SCHEMA);
    config.setCswAxisOrder(CswAxisOrder.LAT_LON);
    config.putMetacardCswMapping(Core.THUMBNAIL, CswConstants.CSW_REFERENCES);
    config.putMetacardCswMapping(Core.RESOURCE_URI, CswConstants.CSW_SOURCE);
    GetRecordsMessageBodyReader reader = new GetRecordsMessageBodyReader(mockProvider, config);
    InputStream is = TestGetRecordsMessageBodyReader.class.getResourceAsStream("/getRecordsResponse.xml");
    MultivaluedMap<String, String> httpHeaders = new MultivaluedHashMap<>();
    ArgumentCaptor<UnmarshallingContext> captor = ArgumentCaptor.forClass(UnmarshallingContext.class);
    reader.readFrom(CswRecordCollection.class, null, null, null, httpHeaders, is);
    // Verify the context arguments were set correctly
    verify(mockProvider, times(1)).unmarshal(any(HierarchicalStreamReader.class), captor.capture());
    UnmarshallingContext context = captor.getValue();
    // Assert the properties needed for CswRecordConverter
    assertThat(context.get(CswConstants.CSW_MAPPING), notNullValue());
    Object cswMapping = context.get(CswConstants.CSW_MAPPING);
    assertThat(cswMapping, instanceOf(Map.class));
    assertThat(context.get(Core.RESOURCE_URI), instanceOf(String.class));
    assertThat(context.get(Core.RESOURCE_URI), is(CswConstants.CSW_SOURCE));
    assertThat(context.get(Core.THUMBNAIL), instanceOf(String.class));
    assertThat(context.get(Core.THUMBNAIL), is(CswConstants.CSW_REFERENCES));
    assertThat(context.get(CswConstants.AXIS_ORDER_PROPERTY), instanceOf(CswAxisOrder.class));
    assertThat(context.get(CswConstants.AXIS_ORDER_PROPERTY), is(CswAxisOrder.LAT_LON));
    // Assert the output Schema is set.
    assertThat(context.get(CswConstants.OUTPUT_SCHEMA_PARAMETER), instanceOf(String.class));
    assertThat(context.get(CswConstants.OUTPUT_SCHEMA_PARAMETER), is(CswConstants.CSW_OUTPUT_SCHEMA));
    assertThat(context.get(CswConstants.TRANSFORMER_LOOKUP_KEY), instanceOf(String.class));
    assertThat(context.get(CswConstants.TRANSFORMER_LOOKUP_KEY), is(TransformerManager.SCHEMA));
    assertThat(context.get(CswConstants.TRANSFORMER_LOOKUP_VALUE), instanceOf(String.class));
    assertThat(context.get(CswConstants.TRANSFORMER_LOOKUP_VALUE), is(CswConstants.CSW_OUTPUT_SCHEMA));
}
Also used : CswSourceConfiguration(org.codice.ddf.spatial.ogc.csw.catalog.common.CswSourceConfiguration) MultivaluedHashMap(javax.ws.rs.core.MultivaluedHashMap) CswAxisOrder(org.codice.ddf.spatial.ogc.csw.catalog.common.CswAxisOrder) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) HierarchicalStreamReader(com.thoughtworks.xstream.io.HierarchicalStreamReader) UnmarshallingContext(com.thoughtworks.xstream.converters.UnmarshallingContext) DefaultCswRecordMap(org.codice.ddf.spatial.ogc.csw.catalog.common.converter.DefaultCswRecordMap) HashMap(java.util.HashMap) Map(java.util.Map) MultivaluedHashMap(javax.ws.rs.core.MultivaluedHashMap) MultivaluedMap(javax.ws.rs.core.MultivaluedMap) Test(org.junit.Test)

Aggregations

MultivaluedMap (javax.ws.rs.core.MultivaluedMap)29 Map (java.util.Map)11 MultivaluedMapImpl (com.sun.jersey.core.util.MultivaluedMapImpl)8 List (java.util.List)8 IOException (java.io.IOException)6 MediaType (javax.ws.rs.core.MediaType)6 MultivaluedHashMap (javax.ws.rs.core.MultivaluedHashMap)6 OutputStream (java.io.OutputStream)5 HashMap (java.util.HashMap)5 ByteArrayInputStream (java.io.ByteArrayInputStream)4 InputStream (java.io.InputStream)4 WebApplicationException (javax.ws.rs.WebApplicationException)4 OutputStreamWriter (java.io.OutputStreamWriter)3 Type (java.lang.reflect.Type)3 URI (java.net.URI)3 MessageBodyWriter (javax.ws.rs.ext.MessageBodyWriter)3 JSONEntitlement (com.sun.identity.entitlement.JSONEntitlement)2 OAuthServiceException (com.sun.identity.oauth.service.OAuthServiceException)2 UniformInterfaceException (com.sun.jersey.api.client.UniformInterfaceException)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2