Search in sources :

Example 86 with MultivaluedMap

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

the class MidoNetElement method getGuestNetworkRouter.

private Router getGuestNetworkRouter(long id, String accountUuid, boolean isVpc) {
    MultivaluedMap qNetRouter = new MultivaluedMapImpl();
    String routerName = getRouterName(isVpc, id);
    qNetRouter.add("tenant_id", accountUuid);
    for (Router router : api.getRouters(qNetRouter)) {
        if (router.getName().equals(routerName)) {
            return router;
        }
    }
    return null;
}
Also used : Router(org.midonet.client.resource.Router) MultivaluedMapImpl(com.sun.jersey.core.util.MultivaluedMapImpl) MultivaluedMap(javax.ws.rs.core.MultivaluedMap)

Example 87 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 88 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 89 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)

Example 90 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)

Aggregations

MultivaluedMap (javax.ws.rs.core.MultivaluedMap)135 Map (java.util.Map)67 List (java.util.List)51 HashMap (java.util.HashMap)45 MediaType (javax.ws.rs.core.MediaType)35 MultivaluedHashMap (javax.ws.rs.core.MultivaluedHashMap)28 MetadataMap (org.apache.cxf.jaxrs.impl.MetadataMap)27 ArrayList (java.util.ArrayList)24 IOException (java.io.IOException)23 Test (org.junit.Test)21 WebApplicationException (javax.ws.rs.WebApplicationException)19 LinkedHashMap (java.util.LinkedHashMap)18 Type (java.lang.reflect.Type)16 Response (javax.ws.rs.core.Response)16 InputStream (java.io.InputStream)14 OutputStream (java.io.OutputStream)14 ByteArrayInputStream (java.io.ByteArrayInputStream)13 ClassResourceInfo (org.apache.cxf.jaxrs.model.ClassResourceInfo)13 Method (java.lang.reflect.Method)11 Optional (java.util.Optional)11