Search in sources :

Example 1 with Tad

use of org.eclipse.kura.core.configuration.metatype.Tad in project kura by eclipse.

the class XmlJavaMetadataMapper method parseAD.

private Tad parseAD(Element adElement) {
    Tad tad = new Tad();
    String id = adElement.getAttribute(METADATA_AD_ID);
    String name = adElement.getAttribute(METADATA_AD_NAME);
    Tscalar type = Tscalar.fromValue(adElement.getAttribute(METADATA_AD_TYPE));
    Integer cardinality;
    try {
        cardinality = Integer.parseInt(adElement.getAttribute(METADATA_AD_CARDINALITY));
    } catch (NumberFormatException e) {
        cardinality = null;
    }
    Boolean required = null;
    String requiredAttr = adElement.getAttribute(METADATA_AD_REQUIRED);
    if (requiredAttr != null && !requiredAttr.trim().isEmpty()) {
        required = Boolean.parseBoolean(adElement.getAttribute(METADATA_AD_REQUIRED));
    }
    String defaultVal = adElement.getAttribute(METADATA_AD_DEFAULT);
    String description = adElement.getAttribute(METADATA_AD_DESCRIPTION);
    String min = adElement.getAttribute(METADATA_AD_MIN);
    String max = adElement.getAttribute(METADATA_AD_MAX);
    if (id != null && !id.trim().isEmpty()) {
        tad.setId(id);
    }
    if (name != null && !name.trim().isEmpty()) {
        tad.setName(name);
    }
    if (type != null) {
        tad.setType(type);
    }
    if (cardinality != null) {
        tad.setCardinality(cardinality);
    }
    if (required != null) {
        tad.setRequired(required);
    }
    if (defaultVal != null && !defaultVal.trim().isEmpty()) {
        tad.setDefault(defaultVal);
    }
    if (description != null && !description.trim().isEmpty()) {
        tad.setDescription(description);
    }
    if (min != null && !min.trim().isEmpty()) {
        tad.setMin(min);
    }
    if (max != null && !max.trim().isEmpty()) {
        tad.setMax(max);
    }
    // parse Option
    NodeList optionChilds = adElement.getChildNodes();
    Element[] optionChildElements = getElementNodes(optionChilds);
    for (Element node : optionChildElements) {
        String localName = node.getNodeName();
        if (localName.equals(METADATA_AD_OPTION)) {
            // parse Option
            Toption tOption = parseOption(node);
            tad.setOption(tOption);
        }
    }
    return tad;
}
Also used : BigInteger(java.math.BigInteger) Tad(org.eclipse.kura.core.configuration.metatype.Tad) NodeList(org.w3c.dom.NodeList) Element(org.w3c.dom.Element) Tscalar(org.eclipse.kura.core.configuration.metatype.Tscalar) Toption(org.eclipse.kura.core.configuration.metatype.Toption)

Example 2 with Tad

use of org.eclipse.kura.core.configuration.metatype.Tad in project kura by eclipse.

the class XmlJavaMetadataMapper method parseOCD.

private Tocd parseOCD(Element ocd) {
    String ocdName = ocd.getAttribute(METADATA_OCD_NAME);
    String ocdID = ocd.getAttribute(METADATA_OCD_ID);
    String ocdDescription = ocd.getAttribute(METADATA_OCD_DESCRIPTION);
    Tocd tocd = new Tocd();
    if (ocdID != null && !ocdID.trim().isEmpty()) {
        tocd.setId(ocdID);
    }
    if (ocdName != null && !ocdName.trim().isEmpty()) {
        tocd.setName(ocdName);
    }
    if (ocdDescription != null && !ocdDescription.trim().isEmpty()) {
        tocd.setDescription(ocdDescription);
    }
    NodeList ocdChilds = ocd.getChildNodes();
    Element[] ocdChildElements = getElementNodes(ocdChilds);
    for (Element node : ocdChildElements) {
        String localName = node.getNodeName();
        if (localName.equals(METADATA_ICON)) {
            // parse Icon
            Ticon tIcon = parseIcon(node);
            tocd.setIcon(tIcon);
        } else if (localName.equals(METADATA_AD)) {
            // parse AD
            Tad tad = parseAD(node);
            tocd.addAD(tad);
        }
    }
    return tocd;
}
Also used : Tad(org.eclipse.kura.core.configuration.metatype.Tad) NodeList(org.w3c.dom.NodeList) Element(org.w3c.dom.Element) Tocd(org.eclipse.kura.core.configuration.metatype.Tocd) Ticon(org.eclipse.kura.core.configuration.metatype.Ticon)

Example 3 with Tad

use of org.eclipse.kura.core.configuration.metatype.Tad in project kura by eclipse.

the class XmlUtilTest method getSampleTocdObject.

private static Tocd getSampleTocdObject() {
    Tad tad = new Tad();
    tad.setCardinality(1);
    tad.setDefault("default");
    tad.setDescription("This is a sample description for tad");
    tad.setId("1");
    tad.setMax("10");
    tad.setMin("1");
    tad.setName("Tad");
    tad.setRequired(true);
    tad.setType(Tscalar.PASSWORD);
    Tocd tocd = new Tocd();
    tocd.setId("1");
    tocd.setName("Tocd");
    tocd.setDescription("This is a sample description for Tocd");
    tocd.addAD(tad);
    return tocd;
}
Also used : Tad(org.eclipse.kura.core.configuration.metatype.Tad) Tocd(org.eclipse.kura.core.configuration.metatype.Tocd)

Example 4 with Tad

use of org.eclipse.kura.core.configuration.metatype.Tad in project kura by eclipse.

the class FirewallConfigurationServiceImpl method getDefinition.

private Tocd getDefinition() throws KuraException {
    ObjectFactory objectFactory = new ObjectFactory();
    Tocd tocd = objectFactory.createTocd();
    tocd.setName("FirewallConfigurationService");
    tocd.setId("org.eclipse.kura.net.admin.FirewallConfigurationService");
    tocd.setDescription("Firewall Configuration Service");
    Tad tad = objectFactory.createTad();
    tad.setId(FirewallConfiguration.OPEN_PORTS_PROP_NAME);
    tad.setName(FirewallConfiguration.OPEN_PORTS_PROP_NAME);
    tad.setType(Tscalar.STRING);
    tad.setCardinality(10000);
    tad.setRequired(true);
    tad.setDefault(FirewallConfiguration.DFLT_OPEN_PORTS_VALUE);
    tad.setDescription(NetworkAdminConfigurationMessages.getMessage(NetworkAdminConfiguration.PLATFORM_INTERFACES));
    tocd.addAD(tad);
    tad = objectFactory.createTad();
    tad.setId(FirewallConfiguration.PORT_FORWARDING_PROP_NAME);
    tad.setName(FirewallConfiguration.PORT_FORWARDING_PROP_NAME);
    tad.setType(Tscalar.STRING);
    tad.setCardinality(10000);
    tad.setRequired(true);
    tad.setDefault(FirewallConfiguration.DFLT_PORT_FORWARDING_VALUE);
    tad.setDescription(NetworkAdminConfigurationMessages.getMessage(NetworkAdminConfiguration.PLATFORM_INTERFACES));
    tocd.addAD(tad);
    tad = objectFactory.createTad();
    tad.setId(FirewallConfiguration.NAT_PROP_NAME);
    tad.setName(FirewallConfiguration.NAT_PROP_NAME);
    tad.setType(Tscalar.STRING);
    tad.setCardinality(10000);
    tad.setRequired(true);
    tad.setDefault(FirewallConfiguration.DFLT_NAT_VALUE);
    tad.setDescription(NetworkAdminConfigurationMessages.getMessage(NetworkAdminConfiguration.PLATFORM_INTERFACES));
    tocd.addAD(tad);
    return tocd;
}
Also used : ObjectFactory(org.eclipse.kura.core.configuration.metatype.ObjectFactory) Tad(org.eclipse.kura.core.configuration.metatype.Tad) Tocd(org.eclipse.kura.core.configuration.metatype.Tocd)

Example 5 with Tad

use of org.eclipse.kura.core.configuration.metatype.Tad in project kura by eclipse.

the class NetworkConfigurationServiceImpl method getDefinition.

private Tocd getDefinition() throws KuraException {
    ObjectFactory objectFactory = new ObjectFactory();
    Tocd tocd = objectFactory.createTocd();
    tocd.setName("NetworkConfigurationService");
    tocd.setId("org.eclipse.kura.net.admin.NetworkConfigurationService");
    tocd.setDescription("Network Configuration Service");
    // get the USB network interfaces (if any)
    List<UsbNetDevice> usbNetDevices = this.m_usbService.getUsbNetDevices();
    Tad tad = objectFactory.createTad();
    tad.setId("net.interfaces");
    tad.setName("net.interfaces");
    tad.setType(Tscalar.STRING);
    tad.setCardinality(10000);
    tad.setRequired(true);
    tad.setDefault("");
    tad.setDescription(NetworkAdminConfigurationMessages.getMessage(NetworkAdminConfiguration.PLATFORM_INTERFACES));
    tocd.addAD(tad);
    // Get the network interfaces on the platform
    try {
        List<String> networkInterfaceNames = LinuxNetworkUtil.getAllInterfaceNames();
        for (String ifaceName : networkInterfaceNames) {
            // get the current configuration for this interface
            NetInterfaceType type = LinuxNetworkUtil.getType(ifaceName);
            String prefix = "net.interface.";
            if (type == NetInterfaceType.LOOPBACK) {
                tad = objectFactory.createTad();
                tad.setId(new StringBuffer().append(prefix).append(ifaceName).append(".config.mtu").toString());
                tad.setName(new StringBuffer().append(prefix).append(ifaceName).append(".config.mtu").toString());
                tad.setType(Tscalar.INTEGER);
                tad.setCardinality(0);
                tad.setRequired(true);
                tad.setDefault("");
                tad.setDescription(NetworkAdminConfigurationMessages.getMessage(NetworkAdminConfiguration.CONFIG_MTU));
                tocd.addAD(tad);
                tad = objectFactory.createTad();
                tad.setId(new StringBuffer().append(prefix).append(ifaceName).append(".config.autoconnect").toString());
                tad.setName(new StringBuffer().append(prefix).append(ifaceName).append(".config.autoconnect").toString());
                tad.setType(Tscalar.BOOLEAN);
                tad.setCardinality(0);
                tad.setRequired(true);
                tad.setDefault("");
                tad.setDescription(NetworkAdminConfigurationMessages.getMessage(NetworkAdminConfiguration.CONFIG_AUTOCONNECT));
                tocd.addAD(tad);
                tad = objectFactory.createTad();
                tad.setId(new StringBuffer().append(prefix).append(ifaceName).append(".config.driver").toString());
                tad.setName(new StringBuffer().append(prefix).append(ifaceName).append(".config.driver").toString());
                tad.setType(Tscalar.STRING);
                tad.setCardinality(0);
                tad.setRequired(false);
                tad.setDefault("");
                tad.setDescription(NetworkAdminConfigurationMessages.getMessage(NetworkAdminConfiguration.CONFIG_DRIVER));
                tocd.addAD(tad);
                tad = objectFactory.createTad();
                tad.setId(new StringBuffer().append(prefix).append(ifaceName).append(".config.ip4.address").toString());
                tad.setName(new StringBuffer().append(prefix).append(ifaceName).append(".config.ip4.address").toString());
                tad.setType(Tscalar.STRING);
                tad.setCardinality(0);
                tad.setRequired(false);
                tad.setDefault("");
                tad.setDescription(NetworkAdminConfigurationMessages.getMessage(NetworkAdminConfiguration.CONFIG_IPV4_ADDRESS));
                tocd.addAD(tad);
                tad = objectFactory.createTad();
                tad.setId(new StringBuffer().append(prefix).append(ifaceName).append(".config.ip4.prefix").toString());
                tad.setName(new StringBuffer().append(prefix).append(ifaceName).append(".config.ip4.prefix").toString());
                tad.setType(Tscalar.SHORT);
                tad.setCardinality(0);
                tad.setRequired(false);
                tad.setDefault("");
                tad.setDescription(NetworkAdminConfigurationMessages.getMessage(NetworkAdminConfiguration.CONFIG_IPV4_PREFIX));
                tocd.addAD(tad);
            } else if (type == NetInterfaceType.ETHERNET || type == NetInterfaceType.WIFI) {
                if (usbNetDevices != null) {
                    for (UsbNetDevice usbNetDevice : usbNetDevices) {
                        if (usbNetDevice.getInterfaceName().equals(ifaceName)) {
                            // found a match - add the read only fields?
                            tad = objectFactory.createTad();
                            tad.setId(new StringBuffer().append(prefix).append(ifaceName).append(".usb.port").toString());
                            tad.setName(new StringBuffer().append(prefix).append(ifaceName).append(".usb.port").toString());
                            tad.setType(Tscalar.STRING);
                            tad.setCardinality(0);
                            tad.setRequired(false);
                            tad.setDefault("");
                            tad.setDescription(NetworkAdminConfigurationMessages.getMessage(NetworkAdminConfiguration.USB_PORT));
                            tocd.addAD(tad);
                            tad = objectFactory.createTad();
                            tad.setId(new StringBuffer().append(prefix).append(ifaceName).append(".usb.manufacturer").toString());
                            tad.setName(new StringBuffer().append(prefix).append(ifaceName).append(".usb.manfacturer").toString());
                            tad.setType(Tscalar.STRING);
                            tad.setCardinality(0);
                            tad.setRequired(false);
                            tad.setDefault("");
                            tad.setDescription(NetworkAdminConfigurationMessages.getMessage(NetworkAdminConfiguration.USB_MANUFACTURER));
                            tocd.addAD(tad);
                            tad = objectFactory.createTad();
                            tad.setId(new StringBuffer().append(prefix).append(ifaceName).append(".usb.product").toString());
                            tad.setName(new StringBuffer().append(prefix).append(ifaceName).append(".usb.product").toString());
                            tad.setType(Tscalar.STRING);
                            tad.setCardinality(0);
                            tad.setRequired(false);
                            tad.setDefault("");
                            tad.setDescription(NetworkAdminConfigurationMessages.getMessage(NetworkAdminConfiguration.USB_PRODUCT));
                            tocd.addAD(tad);
                            tad = objectFactory.createTad();
                            tad.setId(new StringBuffer().append(prefix).append(ifaceName).append(".usb.manufacturer.id").toString());
                            tad.setName(new StringBuffer().append(prefix).append(ifaceName).append(".usb.manfacturer.id").toString());
                            tad.setType(Tscalar.STRING);
                            tad.setCardinality(0);
                            tad.setRequired(false);
                            tad.setDefault("");
                            tad.setDescription(NetworkAdminConfigurationMessages.getMessage(NetworkAdminConfiguration.USB_MANUFACTURER_ID));
                            tocd.addAD(tad);
                            tad = objectFactory.createTad();
                            tad.setId(new StringBuffer().append(prefix).append(ifaceName).append(".usb.product.id").toString());
                            tad.setName(new StringBuffer().append(prefix).append(ifaceName).append(".usb.product.id").toString());
                            tad.setType(Tscalar.STRING);
                            tad.setCardinality(0);
                            tad.setRequired(false);
                            tad.setDefault("");
                            tad.setDescription(NetworkAdminConfigurationMessages.getMessage(NetworkAdminConfiguration.USB_PRODUCT_ID));
                            tocd.addAD(tad);
                            // no need to continue
                            break;
                        }
                    }
                }
                tad = objectFactory.createTad();
                tad.setId(new StringBuffer().append(prefix).append(ifaceName).append(".config.mtu").toString());
                tad.setName(new StringBuffer().append(prefix).append(ifaceName).append(".config.mtu").toString());
                tad.setType(Tscalar.INTEGER);
                tad.setCardinality(0);
                tad.setRequired(true);
                tad.setDefault("");
                tad.setDescription(NetworkAdminConfigurationMessages.getMessage(NetworkAdminConfiguration.CONFIG_MTU));
                tocd.addAD(tad);
                tad = objectFactory.createTad();
                tad.setId(new StringBuffer().append(prefix).append(ifaceName).append(".config.autoconnect").toString());
                tad.setName(new StringBuffer().append(prefix).append(ifaceName).append(".config.autoconnect").toString());
                tad.setType(Tscalar.BOOLEAN);
                tad.setCardinality(0);
                tad.setRequired(true);
                tad.setDefault("");
                tad.setDescription(NetworkAdminConfigurationMessages.getMessage(NetworkAdminConfiguration.CONFIG_AUTOCONNECT));
                tocd.addAD(tad);
                tad = objectFactory.createTad();
                tad.setId(new StringBuffer().append(prefix).append(ifaceName).append(".config.dhcpClient4.enabled").toString());
                tad.setName(new StringBuffer().append(prefix).append(ifaceName).append(".config.dhcpClient4.enabled").toString());
                tad.setType(Tscalar.BOOLEAN);
                tad.setCardinality(0);
                tad.setRequired(true);
                tad.setDefault("");
                tad.setDescription(NetworkAdminConfigurationMessages.getMessage(NetworkAdminConfiguration.CONFIG_IPV4_DHCP_CLIENT_ENABLED));
                tocd.addAD(tad);
                tad = objectFactory.createTad();
                tad.setId(new StringBuffer().append(prefix).append(ifaceName).append(".config.ip4.address").toString());
                tad.setName(new StringBuffer().append(prefix).append(ifaceName).append(".config.ip4.address").toString());
                tad.setType(Tscalar.STRING);
                tad.setCardinality(0);
                tad.setRequired(false);
                tad.setDefault("");
                tad.setDescription(NetworkAdminConfigurationMessages.getMessage(NetworkAdminConfiguration.CONFIG_IPV4_ADDRESS));
                tocd.addAD(tad);
                tad = objectFactory.createTad();
                tad.setId(new StringBuffer().append(prefix).append(ifaceName).append(".config.ip4.prefix").toString());
                tad.setName(new StringBuffer().append(prefix).append(ifaceName).append(".config.ip4.prefix").toString());
                tad.setType(Tscalar.SHORT);
                tad.setCardinality(0);
                tad.setRequired(false);
                tad.setDefault("");
                tad.setDescription(NetworkAdminConfigurationMessages.getMessage(NetworkAdminConfiguration.CONFIG_IPV4_PREFIX));
                tocd.addAD(tad);
                tad = objectFactory.createTad();
                tad.setId(new StringBuffer().append(prefix).append(ifaceName).append(".config.ip4.gateway").toString());
                tad.setName(new StringBuffer().append(prefix).append(ifaceName).append(".config.ip4.gateway").toString());
                tad.setType(Tscalar.STRING);
                tad.setCardinality(0);
                tad.setRequired(false);
                tad.setDefault("");
                tad.setDescription(NetworkAdminConfigurationMessages.getMessage(NetworkAdminConfiguration.CONFIG_IPV4_GATEWAY));
                tocd.addAD(tad);
                // DNS and WINS
                tad = objectFactory.createTad();
                tad.setId(new StringBuffer().append(prefix).append(ifaceName).append(".config.dnsServers").toString());
                tad.setName(new StringBuffer().append(prefix).append(ifaceName).append(".config.dnsServers").toString());
                tad.setType(Tscalar.STRING);
                tad.setCardinality(10000);
                tad.setRequired(false);
                tad.setDefault("");
                tad.setDescription(NetworkAdminConfigurationMessages.getMessage(NetworkAdminConfiguration.CONFIG_DNS_SERVERS));
                tocd.addAD(tad);
                tad = objectFactory.createTad();
                tad.setId(new StringBuffer().append(prefix).append(ifaceName).append(".config.winsServers").toString());
                tad.setName(new StringBuffer().append(prefix).append(ifaceName).append(".config.winsServers").toString());
                tad.setType(Tscalar.STRING);
                tad.setCardinality(10000);
                tad.setRequired(false);
                tad.setDefault("");
                tad.setDescription(NetworkAdminConfigurationMessages.getMessage(NetworkAdminConfiguration.CONFIG_WINS_SERVERS));
                tocd.addAD(tad);
                tad = objectFactory.createTad();
                tad.setId(new StringBuffer().append(prefix).append(ifaceName).append(".config.dhcpServer4.enabled").toString());
                tad.setName(new StringBuffer().append(prefix).append(ifaceName).append(".config.dhcpServer4.enabled").toString());
                tad.setType(Tscalar.BOOLEAN);
                tad.setCardinality(0);
                tad.setRequired(false);
                tad.setDefault("");
                tad.setDescription(NetworkAdminConfigurationMessages.getMessage(NetworkAdminConfiguration.CONFIG_IPV4_DHCP_SERVER_ENABLED));
                tocd.addAD(tad);
                tad = objectFactory.createTad();
                tad.setId(new StringBuffer().append(prefix).append(ifaceName).append(".config.dhcpServer4.defaultLeaseTime").toString());
                tad.setName(new StringBuffer().append(prefix).append(ifaceName).append(".config.dhcpServer4.defaultLeaseTime").toString());
                tad.setType(Tscalar.INTEGER);
                tad.setCardinality(0);
                tad.setRequired(false);
                tad.setDefault("");
                tad.setDescription(NetworkAdminConfigurationMessages.getMessage(NetworkAdminConfiguration.CONFIG_IPV4_DHCP_SERVER_DEFAULT_LEASE_TIME));
                tocd.addAD(tad);
                tad = objectFactory.createTad();
                tad.setId(new StringBuffer().append(prefix).append(ifaceName).append(".config.dhcpServer4.maxLeaseTime").toString());
                tad.setName(new StringBuffer().append(prefix).append(ifaceName).append(".config.dhcpServer4.maxLeaseTime").toString());
                tad.setType(Tscalar.INTEGER);
                tad.setCardinality(0);
                tad.setRequired(false);
                tad.setDefault("");
                tad.setDescription(NetworkAdminConfigurationMessages.getMessage(NetworkAdminConfiguration.CONFIG_IPV4_DHCP_SERVER_MAX_LEASE_TIME));
                tocd.addAD(tad);
                tad = objectFactory.createTad();
                tad.setId(new StringBuffer().append(prefix).append(ifaceName).append(".config.dhcpServer4.prefix").toString());
                tad.setName(new StringBuffer().append(prefix).append(ifaceName).append(".config.dhcpServer4.prefix").toString());
                tad.setType(Tscalar.SHORT);
                tad.setCardinality(0);
                tad.setRequired(false);
                tad.setDefault("");
                tad.setDescription(NetworkAdminConfigurationMessages.getMessage(NetworkAdminConfiguration.CONFIG_IPV4_DHCP_SERVER_PREFIX));
                tocd.addAD(tad);
                tad = objectFactory.createTad();
                tad.setId(new StringBuffer().append(prefix).append(ifaceName).append(".config.dhcpServer4.rangeStart").toString());
                tad.setName(new StringBuffer().append(prefix).append(ifaceName).append(".config.dhcpServer4.rangeStart").toString());
                tad.setType(Tscalar.STRING);
                tad.setCardinality(0);
                tad.setRequired(false);
                tad.setDefault("");
                tad.setDescription(NetworkAdminConfigurationMessages.getMessage(NetworkAdminConfiguration.CONFIG_IPV4_DHCP_SERVER_RANGE_START));
                tocd.addAD(tad);
                tad = objectFactory.createTad();
                tad.setId(new StringBuffer().append(prefix).append(ifaceName).append(".config.dhcpServer4.rangeEnd").toString());
                tad.setName(new StringBuffer().append(prefix).append(ifaceName).append(".config.dhcpServer4.rangeEnd").toString());
                tad.setType(Tscalar.STRING);
                tad.setCardinality(0);
                tad.setRequired(false);
                tad.setDefault("");
                tad.setDescription(NetworkAdminConfigurationMessages.getMessage(NetworkAdminConfiguration.CONFIG_IPV4_DHCP_SERVER_RANGE_END));
                tocd.addAD(tad);
                tad = objectFactory.createTad();
                tad.setId(new StringBuffer().append(prefix).append(ifaceName).append(".config.dhcpServer4.passDns").toString());
                tad.setName(new StringBuffer().append(prefix).append(ifaceName).append(".config.dhcpServer4.passDns").toString());
                tad.setType(Tscalar.BOOLEAN);
                tad.setCardinality(0);
                tad.setRequired(false);
                tad.setDefault("");
                tad.setDescription(NetworkAdminConfigurationMessages.getMessage(NetworkAdminConfiguration.CONFIG_IPV4_DHCP_SERVER_PASS_DNS));
                tocd.addAD(tad);
                tad = objectFactory.createTad();
                tad.setId(new StringBuffer().append(prefix).append(ifaceName).append(".config.nat.enabled").toString());
                tad.setName(new StringBuffer().append(prefix).append(ifaceName).append(".config.nat.enabled").toString());
                tad.setType(Tscalar.BOOLEAN);
                tad.setCardinality(0);
                tad.setRequired(false);
                tad.setDefault("");
                tad.setDescription(NetworkAdminConfigurationMessages.getMessage(NetworkAdminConfiguration.CONFIG_IPV4_DHCP_SERVER_NAT_ENABLED));
                tocd.addAD(tad);
                if (type == NetInterfaceType.WIFI) {
                    // Common
                    tad = objectFactory.createTad();
                    tad.setId(new StringBuffer().append(prefix).append(ifaceName).append(".wifi.capabilities").toString());
                    tad.setName(new StringBuffer().append(prefix).append(ifaceName).append(".wifi.capabilities").toString());
                    tad.setType(Tscalar.STRING);
                    tad.setCardinality(0);
                    tad.setRequired(false);
                    tad.setDefault("");
                    tad.setDescription(NetworkAdminConfigurationMessages.getMessage(NetworkAdminConfiguration.WIFI_CAPABILITIES));
                    tocd.addAD(tad);
                    tad = objectFactory.createTad();
                    tad.setId(new StringBuffer().append(prefix).append(ifaceName).append(".config.wifi.mode").toString());
                    tad.setName(new StringBuffer().append(prefix).append(ifaceName).append(".config.wifi.mode").toString());
                    tad.setType(Tscalar.STRING);
                    tad.setCardinality(0);
                    tad.setRequired(false);
                    tad.setDefault("");
                    tad.setDescription(NetworkAdminConfigurationMessages.getMessage(NetworkAdminConfiguration.CONFIG_WIFI_MODE));
                    tocd.addAD(tad);
                    // INFRA
                    tad = objectFactory.createTad();
                    tad.setId(new StringBuffer().append(prefix).append(ifaceName).append(".config.wifi.infra.ssid").toString());
                    tad.setName(new StringBuffer().append(prefix).append(ifaceName).append(".config.wifi.infra.ssid").toString());
                    tad.setType(Tscalar.STRING);
                    tad.setCardinality(0);
                    tad.setRequired(false);
                    tad.setDefault("");
                    tad.setDescription(NetworkAdminConfigurationMessages.getMessage(NetworkAdminConfiguration.CONFIG_WIFI_INFRA_SSID));
                    tocd.addAD(tad);
                    tad = objectFactory.createTad();
                    tad.setId(new StringBuffer().append(prefix).append(ifaceName).append(".config.wifi.infra.hardwareMode").toString());
                    tad.setName(new StringBuffer().append(prefix).append(ifaceName).append(".config.wifi.infra.hardwareMode").toString());
                    tad.setType(Tscalar.STRING);
                    tad.setCardinality(0);
                    tad.setRequired(false);
                    tad.setDefault("");
                    tad.setDescription(NetworkAdminConfigurationMessages.getMessage(NetworkAdminConfiguration.CONFIG_WIFI_INFRA_HARDWARE_MODE));
                    tocd.addAD(tad);
                    tad = objectFactory.createTad();
                    tad.setId(new StringBuffer().append(prefix).append(ifaceName).append(".config.wifi.infra.radioMode").toString());
                    tad.setName(new StringBuffer().append(prefix).append(ifaceName).append(".config.wifi.infra.radioMode").toString());
                    tad.setType(Tscalar.STRING);
                    tad.setCardinality(0);
                    tad.setRequired(false);
                    tad.setDefault("");
                    tad.setDescription(NetworkAdminConfigurationMessages.getMessage(NetworkAdminConfiguration.CONFIG_WIFI_INFRA_HARDWARE_MODE));
                    tocd.addAD(tad);
                    tad = objectFactory.createTad();
                    tad.setId(new StringBuffer().append(prefix).append(ifaceName).append(".config.wifi.infra.securityType").toString());
                    tad.setName(new StringBuffer().append(prefix).append(ifaceName).append(".config.wifi.infra.securityType").toString());
                    tad.setType(Tscalar.STRING);
                    tad.setCardinality(0);
                    tad.setRequired(false);
                    tad.setDefault("");
                    tad.setDescription(NetworkAdminConfigurationMessages.getMessage(NetworkAdminConfiguration.CONFIG_WIFI_INFRA_SECURITY_TYPE));
                    tocd.addAD(tad);
                    tad = objectFactory.createTad();
                    tad.setId(new StringBuffer().append(prefix).append(ifaceName).append(".config.wifi.infra.passphrase").toString());
                    tad.setName(new StringBuffer().append(prefix).append(ifaceName).append(".config.wifi.infra.passphrase").toString());
                    tad.setType(Tscalar.PASSWORD);
                    tad.setCardinality(0);
                    tad.setRequired(false);
                    tad.setDefault("");
                    tad.setDescription(NetworkAdminConfigurationMessages.getMessage(NetworkAdminConfiguration.CONFIG_WIFI_INFRA_PASSPHRASE));
                    tocd.addAD(tad);
                    tad = objectFactory.createTad();
                    tad.setId(new StringBuffer().append(prefix).append(ifaceName).append(".config.wifi.infra.pairwiseCiphers").toString());
                    tad.setName(new StringBuffer().append(prefix).append(ifaceName).append(".config.wifi.infra.pairwiseCiphers").toString());
                    tad.setType(Tscalar.STRING);
                    tad.setCardinality(0);
                    tad.setRequired(false);
                    tad.setDefault("");
                    tad.setDescription(NetworkAdminConfigurationMessages.getMessage(NetworkAdminConfiguration.CONFIG_WIFI_INFRA_PAIRWISE_CIPHERS));
                    tocd.addAD(tad);
                    tad = objectFactory.createTad();
                    tad.setId(new StringBuffer().append(prefix).append(ifaceName).append(".config.wifi.infra.groupCiphers").toString());
                    tad.setName(new StringBuffer().append(prefix).append(ifaceName).append(".config.wifi.infra.groupCiphers").toString());
                    tad.setType(Tscalar.STRING);
                    tad.setCardinality(0);
                    tad.setRequired(false);
                    tad.setDefault("");
                    tad.setDescription(NetworkAdminConfigurationMessages.getMessage(NetworkAdminConfiguration.CONFIG_WIFI_INFRA_GROUP_CIPHERS));
                    tocd.addAD(tad);
                    tad = objectFactory.createTad();
                    tad.setId(new StringBuffer().append(prefix).append(ifaceName).append(".config.wifi.infra.channel").toString());
                    tad.setName(new StringBuffer().append(prefix).append(ifaceName).append(".config.wifi.infra.channel").toString());
                    tad.setType(Tscalar.STRING);
                    tad.setCardinality(0);
                    tad.setRequired(false);
                    tad.setDefault("");
                    tad.setDescription(NetworkAdminConfigurationMessages.getMessage(NetworkAdminConfiguration.CONFIG_WIFI_INFRA_CHANNEL));
                    tocd.addAD(tad);
                    // MASTER
                    tad = objectFactory.createTad();
                    tad.setId(new StringBuffer().append(prefix).append(ifaceName).append(".config.wifi.master.ssid").toString());
                    tad.setName(new StringBuffer().append(prefix).append(ifaceName).append(".config.wifi.master.ssid").toString());
                    tad.setType(Tscalar.STRING);
                    tad.setCardinality(0);
                    tad.setRequired(false);
                    tad.setDefault("");
                    tad.setDescription(NetworkAdminConfigurationMessages.getMessage(NetworkAdminConfiguration.CONFIG_WIFI_MASTER_SSID));
                    tocd.addAD(tad);
                    tad = objectFactory.createTad();
                    tad.setId(new StringBuffer().append(prefix).append(ifaceName).append(".config.wifi.master.broadcast").toString());
                    tad.setName(new StringBuffer().append(prefix).append(ifaceName).append(".config.wifi.master.broadcast").toString());
                    tad.setType(Tscalar.BOOLEAN);
                    tad.setCardinality(0);
                    tad.setRequired(false);
                    tad.setDefault("");
                    tad.setDescription(NetworkAdminConfigurationMessages.getMessage(NetworkAdminConfiguration.CONFIG_WIFI_MASTER_BROADCAST_ENABLED));
                    tocd.addAD(tad);
                    tad = objectFactory.createTad();
                    tad.setId(new StringBuffer().append(prefix).append(ifaceName).append(".config.wifi.master.hardwareMode").toString());
                    tad.setName(new StringBuffer().append(prefix).append(ifaceName).append(".config.wifi.master.hardwareMode").toString());
                    tad.setType(Tscalar.STRING);
                    tad.setCardinality(0);
                    tad.setRequired(false);
                    tad.setDefault("");
                    tad.setDescription(NetworkAdminConfigurationMessages.getMessage(NetworkAdminConfiguration.CONFIG_WIFI_MASTER_HARDWARE_MODE));
                    tocd.addAD(tad);
                    tad = objectFactory.createTad();
                    tad.setId(new StringBuffer().append(prefix).append(ifaceName).append(".config.wifi.master.radioMode").toString());
                    tad.setName(new StringBuffer().append(prefix).append(ifaceName).append(".config.wifi.master.radioMode").toString());
                    tad.setType(Tscalar.STRING);
                    tad.setCardinality(0);
                    tad.setRequired(false);
                    tad.setDefault("");
                    tad.setDescription(NetworkAdminConfigurationMessages.getMessage(NetworkAdminConfiguration.CONFIG_WIFI_MASTER_HARDWARE_MODE));
                    tocd.addAD(tad);
                    tad = objectFactory.createTad();
                    tad.setId(new StringBuffer().append(prefix).append(ifaceName).append(".config.wifi.master.securityType").toString());
                    tad.setName(new StringBuffer().append(prefix).append(ifaceName).append(".config.wifi.master.securityType").toString());
                    tad.setType(Tscalar.STRING);
                    tad.setCardinality(0);
                    tad.setRequired(false);
                    tad.setDefault("");
                    tad.setDescription(NetworkAdminConfigurationMessages.getMessage(NetworkAdminConfiguration.CONFIG_WIFI_MASTER_SECURITY_TYPE));
                    tocd.addAD(tad);
                    tad = objectFactory.createTad();
                    tad.setId(new StringBuffer().append(prefix).append(ifaceName).append(".config.wifi.master.passphrase").toString());
                    tad.setName(new StringBuffer().append(prefix).append(ifaceName).append(".config.wifi.master.passphrase").toString());
                    tad.setType(Tscalar.PASSWORD);
                    tad.setCardinality(0);
                    tad.setRequired(false);
                    tad.setDefault("");
                    tad.setDescription(NetworkAdminConfigurationMessages.getMessage(NetworkAdminConfiguration.CONFIG_WIFI_MASTER_PASSPHRASE));
                    tocd.addAD(tad);
                    tad = objectFactory.createTad();
                    tad.setId(new StringBuffer().append(prefix).append(ifaceName).append(".config.wifi.master.channel").toString());
                    tad.setName(new StringBuffer().append(prefix).append(ifaceName).append(".config.wifi.master.channel").toString());
                    tad.setType(Tscalar.STRING);
                    tad.setCardinality(0);
                    tad.setRequired(false);
                    tad.setDefault("");
                    tad.setDescription(NetworkAdminConfigurationMessages.getMessage(NetworkAdminConfiguration.CONFIG_WIFI_MASTER_CHANNEL));
                    tocd.addAD(tad);
                /*
                         * // ADHOC
                         * tad = objectFactory.createTad();
                         * tad.setId((new
                         * StringBuffer().append(prefix).append(ifaceName).append(".config.wifi.adhoc.ssid")).toString()
                         * );
                         * tad.setName((new
                         * StringBuffer().append(prefix).append(ifaceName).append(".config.wifi.adhoc.ssid")).toString()
                         * );
                         * tad.setType(Tscalar.STRING);
                         * tad.setCardinality(0);
                         * tad.setRequired(false);
                         * tad.setDefault("");
                         * tad.setDescription(NetworkAdminConfigurationMessages.getMessage(NetworkAdminConfiguration.
                         * CONFIG_WIFI_ADHOC_SSID));
                         * tocd.addAD(tad);
                         *
                         * tad = objectFactory.createTad();
                         * tad.setId((new
                         * StringBuffer().append(prefix).append(ifaceName).append(".config.wifi.adhoc.hardwareMode")).
                         * toString());
                         * tad.setName((new
                         * StringBuffer().append(prefix).append(ifaceName).append(".config.wifi.adhoc.hardwareMode")).
                         * toString());
                         * tad.setType(Tscalar.STRING);
                         * tad.setCardinality(0);
                         * tad.setRequired(false);
                         * tad.setDefault("");
                         * tad.setDescription(NetworkAdminConfigurationMessages.getMessage(NetworkAdminConfiguration.
                         * CONFIG_WIFI_ADHOC_HARDWARE_MODE));
                         * tocd.addAD(tad);
                         *
                         * tad = objectFactory.createTad();
                         * tad.setId((new
                         * StringBuffer().append(prefix).append(ifaceName).append(".config.wifi.adhoc.radioMode")).
                         * toString());
                         * tad.setName((new
                         * StringBuffer().append(prefix).append(ifaceName).append(".config.wifi.adhoc.radioMode")).
                         * toString());
                         * tad.setType(Tscalar.STRING);
                         * tad.setCardinality(0);
                         * tad.setRequired(false);
                         * tad.setDefault("");
                         * tad.setDescription(NetworkAdminConfigurationMessages.getMessage(NetworkAdminConfiguration.
                         * CONFIG_WIFI_ADHOC_HARDWARE_MODE));
                         * tocd.addAD(tad);
                         *
                         * tad = objectFactory.createTad();
                         * tad.setId((new
                         * StringBuffer().append(prefix).append(ifaceName).append(".config.wifi.adhoc.securityType")).
                         * toString());
                         * tad.setName((new
                         * StringBuffer().append(prefix).append(ifaceName).append(".config.wifi.adhoc.securityType")).
                         * toString());
                         * tad.setType(Tscalar.STRING);
                         * tad.setCardinality(0);
                         * tad.setRequired(false);
                         * tad.setDefault("");
                         * tad.setDescription(NetworkAdminConfigurationMessages.getMessage(NetworkAdminConfiguration.
                         * CONFIG_WIFI_ADHOC_SECURITY_TYPE));
                         * tocd.addAD(tad);
                         *
                         * tad = objectFactory.createTad();
                         * tad.setId((new
                         * StringBuffer().append(prefix).append(ifaceName).append(".config.wifi.adhoc.passphrase")).
                         * toString());
                         * tad.setName((new
                         * StringBuffer().append(prefix).append(ifaceName).append(".config.wifi.adhoc.passphrase")).
                         * toString());
                         * tad.setType(Tscalar.STRING);
                         * tad.setCardinality(0);
                         * tad.setRequired(false);
                         * tad.setDefault("");
                         * tad.setDescription(NetworkAdminConfigurationMessages.getMessage(NetworkAdminConfiguration.
                         * CONFIG_WIFI_ADHOC_PASSPHRASE));
                         * tocd.addAD(tad);
                         *
                         * tad = objectFactory.createTad();
                         * tad.setId((new
                         * StringBuffer().append(prefix).append(ifaceName).append(".config.wifi.adhoc.channel")).
                         * toString());
                         * tad.setName((new
                         * StringBuffer().append(prefix).append(ifaceName).append(".config.wifi.adhoc.channel")).
                         * toString());
                         * tad.setType(Tscalar.STRING);
                         * tad.setCardinality(0);
                         * tad.setRequired(false);
                         * tad.setDefault("");
                         * tad.setDescription(NetworkAdminConfigurationMessages.getMessage(NetworkAdminConfiguration.
                         * CONFIG_WIFI_ADHOC_CHANNEL));
                         * tocd.addAD(tad);
                         */
                }
            // TODO - deal with USB devices (READ ONLY)
            }
        }
    } catch (Exception e) {
        throw new KuraException(KuraErrorCode.CONFIGURATION_ERROR, e);
    }
    return tocd;
}
Also used : ObjectFactory(org.eclipse.kura.core.configuration.metatype.ObjectFactory) NetInterfaceType(org.eclipse.kura.net.NetInterfaceType) Tad(org.eclipse.kura.core.configuration.metatype.Tad) KuraException(org.eclipse.kura.KuraException) UsbNetDevice(org.eclipse.kura.usb.UsbNetDevice) Tocd(org.eclipse.kura.core.configuration.metatype.Tocd) KuraException(org.eclipse.kura.KuraException)

Aggregations

Tad (org.eclipse.kura.core.configuration.metatype.Tad)5 Tocd (org.eclipse.kura.core.configuration.metatype.Tocd)4 ObjectFactory (org.eclipse.kura.core.configuration.metatype.ObjectFactory)2 Element (org.w3c.dom.Element)2 NodeList (org.w3c.dom.NodeList)2 BigInteger (java.math.BigInteger)1 KuraException (org.eclipse.kura.KuraException)1 Ticon (org.eclipse.kura.core.configuration.metatype.Ticon)1 Toption (org.eclipse.kura.core.configuration.metatype.Toption)1 Tscalar (org.eclipse.kura.core.configuration.metatype.Tscalar)1 NetInterfaceType (org.eclipse.kura.net.NetInterfaceType)1 UsbNetDevice (org.eclipse.kura.usb.UsbNetDevice)1