org.fourthline.cling.model.Namespace Java Examples

The following examples show how to use org.fourthline.cling.model.Namespace. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: UDA10DeviceDescriptorBinderImpl.java    From DroidDLNA with GNU General Public License v3.0 6 votes vote down vote up
public Document buildDOM(Device deviceModel, RemoteClientInfo info, Namespace namespace) throws DescriptorBindingException {

        try {
            log.fine("Generating DOM from device model: " + deviceModel);

            DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
            factory.setNamespaceAware(true);

            Document d = factory.newDocumentBuilder().newDocument();
            generateRoot(namespace, deviceModel, d, info);

            return d;

        } catch (Exception ex) {
            throw new DescriptorBindingException("Could not generate device descriptor: " + ex.getMessage(), ex);
        }
    }
 
Example #2
Source File: UDA10DeviceDescriptorBinderImpl.java    From TVRemoteIME with GNU General Public License v2.0 6 votes vote down vote up
public Document buildDOM(Device deviceModel, RemoteClientInfo info, Namespace namespace) throws DescriptorBindingException {

        try {
            log.fine("Generating DOM from device model: " + deviceModel);

            DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
            factory.setNamespaceAware(true);

            Document d = factory.newDocumentBuilder().newDocument();
            generateRoot(namespace, deviceModel, d, info);

            return d;

        } catch (Exception ex) {
            throw new DescriptorBindingException("Could not generate device descriptor: " + ex.getMessage(), ex);
        }
    }
 
Example #3
Source File: SempDeviceDescriptorBinderImpl.java    From SmartApplianceEnabler with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected void generateDevice(Namespace namespace, Device deviceModel, Document descriptor, Element rootElement,
        RemoteClientInfo info) {
    super.generateDevice(namespace, deviceModel, descriptor, rootElement, info);
    
    
    NodeList deviceElements = rootElement.getElementsByTagName(org.fourthline.cling.binding.xml.Descriptor.Device.ELEMENT.device.toString());
    if(deviceElements.getLength() > 0) {
        Element deviceElement = (Element) deviceElements.item(0);
        
        Element sempServiceElement = appendNewElementIfNotNull(
                descriptor, deviceElement, Semp.prefixed(ELEMENT.X_SEMPSERVICE),
                "", "urn:" + Semp.NAMESPACE + ":service-1-0"
        );
        
        appendNewElementIfNotNull(descriptor, sempServiceElement, Semp.prefixed(ELEMENT.server), sempServerUrl);
        appendNewElementIfNotNull(descriptor, sempServiceElement, Semp.prefixed(ELEMENT.basePath), "/semp");
        appendNewElementIfNotNull(descriptor, sempServiceElement, Semp.prefixed(ELEMENT.transport), "HTTP/Pull");
        appendNewElementIfNotNull(descriptor, sempServiceElement, Semp.prefixed(ELEMENT.exchangeFormat), "XML");
        appendNewElementIfNotNull(descriptor, sempServiceElement, Semp.prefixed(ELEMENT.wsVersion), Semp.XSD_VERSION);
    }
}
 
Example #4
Source File: UDA10DeviceDescriptorBinderImpl.java    From DroidDLNA with GNU General Public License v3.0 6 votes vote down vote up
protected void generateIconList(Namespace namespace, Device deviceModel, Document descriptor, Element deviceElement) {
    if (!deviceModel.hasIcons()) return;

    Element iconListElement = appendNewElement(descriptor, deviceElement, ELEMENT.iconList);

    for (Icon icon : deviceModel.getIcons()) {
        Element iconElement = appendNewElement(descriptor, iconListElement, ELEMENT.icon);

        appendNewElementIfNotNull(descriptor, iconElement, ELEMENT.mimetype, icon.getMimeType());
        appendNewElementIfNotNull(descriptor, iconElement, ELEMENT.width, icon.getWidth());
        appendNewElementIfNotNull(descriptor, iconElement, ELEMENT.height, icon.getHeight());
        appendNewElementIfNotNull(descriptor, iconElement, ELEMENT.depth, icon.getDepth());
        if (deviceModel instanceof RemoteDevice) {
        	appendNewElementIfNotNull(descriptor, iconElement, ELEMENT.url,  icon.getUri());
        } else if (deviceModel instanceof LocalDevice) {
        	appendNewElementIfNotNull(descriptor, iconElement, ELEMENT.url,  namespace.getIconPath(icon));
        }
    }
}
 
Example #5
Source File: UDA10DeviceDescriptorBinderImpl.java    From DroidDLNA with GNU General Public License v3.0 6 votes vote down vote up
protected void generateServiceList(Namespace namespace, Device deviceModel, Document descriptor, Element deviceElement) {
    if (!deviceModel.hasServices()) return;

    Element serviceListElement = appendNewElement(descriptor, deviceElement, ELEMENT.serviceList);

    for (Service service : deviceModel.getServices()) {
        Element serviceElement = appendNewElement(descriptor, serviceListElement, ELEMENT.service);

        appendNewElementIfNotNull(descriptor, serviceElement, ELEMENT.serviceType, service.getServiceType());
        appendNewElementIfNotNull(descriptor, serviceElement, ELEMENT.serviceId, service.getServiceId());
        if (service instanceof RemoteService) {
            RemoteService rs = (RemoteService) service;
            appendNewElementIfNotNull(descriptor, serviceElement, ELEMENT.SCPDURL, rs.getDescriptorURI());
            appendNewElementIfNotNull(descriptor, serviceElement, ELEMENT.controlURL, rs.getControlURI());
            appendNewElementIfNotNull(descriptor, serviceElement, ELEMENT.eventSubURL, rs.getEventSubscriptionURI());
        } else if (service instanceof LocalService) {
            LocalService ls = (LocalService) service;
            appendNewElementIfNotNull(descriptor, serviceElement, ELEMENT.SCPDURL, namespace.getDescriptorPath(ls));
            appendNewElementIfNotNull(descriptor, serviceElement, ELEMENT.controlURL, namespace.getControlPath(ls));
            appendNewElementIfNotNull(descriptor, serviceElement, ELEMENT.eventSubURL, namespace.getEventSubscriptionPath(ls));
        }
    }
}
 
Example #6
Source File: UDA10DeviceDescriptorBinderImpl.java    From TVRemoteIME with GNU General Public License v2.0 6 votes vote down vote up
protected void generateIconList(Namespace namespace, Device deviceModel, Document descriptor, Element deviceElement) {
    if (!deviceModel.hasIcons()) return;

    Element iconListElement = appendNewElement(descriptor, deviceElement, ELEMENT.iconList);

    for (Icon icon : deviceModel.getIcons()) {
        Element iconElement = appendNewElement(descriptor, iconListElement, ELEMENT.icon);

        appendNewElementIfNotNull(descriptor, iconElement, ELEMENT.mimetype, icon.getMimeType());
        appendNewElementIfNotNull(descriptor, iconElement, ELEMENT.width, icon.getWidth());
        appendNewElementIfNotNull(descriptor, iconElement, ELEMENT.height, icon.getHeight());
        appendNewElementIfNotNull(descriptor, iconElement, ELEMENT.depth, icon.getDepth());
        if (deviceModel instanceof RemoteDevice) {
        	appendNewElementIfNotNull(descriptor, iconElement, ELEMENT.url,  icon.getUri());
        } else if (deviceModel instanceof LocalDevice) {
        	appendNewElementIfNotNull(descriptor, iconElement, ELEMENT.url,  namespace.getIconPath(icon));
        }
    }
}
 
Example #7
Source File: UDA10DeviceDescriptorBinderImpl.java    From TVRemoteIME with GNU General Public License v2.0 6 votes vote down vote up
protected void generateServiceList(Namespace namespace, Device deviceModel, Document descriptor, Element deviceElement) {
    if (!deviceModel.hasServices()) return;

    Element serviceListElement = appendNewElement(descriptor, deviceElement, ELEMENT.serviceList);

    for (Service service : deviceModel.getServices()) {
        Element serviceElement = appendNewElement(descriptor, serviceListElement, ELEMENT.service);

        appendNewElementIfNotNull(descriptor, serviceElement, ELEMENT.serviceType, service.getServiceType());
        appendNewElementIfNotNull(descriptor, serviceElement, ELEMENT.serviceId, service.getServiceId());
        if (service instanceof RemoteService) {
            RemoteService rs = (RemoteService) service;
            appendNewElementIfNotNull(descriptor, serviceElement, ELEMENT.SCPDURL, rs.getDescriptorURI());
            appendNewElementIfNotNull(descriptor, serviceElement, ELEMENT.controlURL, rs.getControlURI());
            appendNewElementIfNotNull(descriptor, serviceElement, ELEMENT.eventSubURL, rs.getEventSubscriptionURI());
        } else if (service instanceof LocalService) {
            LocalService ls = (LocalService) service;
            appendNewElementIfNotNull(descriptor, serviceElement, ELEMENT.SCPDURL, namespace.getDescriptorPath(ls));
            appendNewElementIfNotNull(descriptor, serviceElement, ELEMENT.controlURL, namespace.getControlPath(ls));
            appendNewElementIfNotNull(descriptor, serviceElement, ELEMENT.eventSubURL, namespace.getEventSubscriptionPath(ls));
        }
    }
}
 
Example #8
Source File: RemoteDevice.java    From DroidDLNA with GNU General Public License v3.0 6 votes vote down vote up
@Override
public Resource[] discoverResources(Namespace namespace) {
    List<Resource> discovered = new ArrayList();

    // Services
    for (RemoteService service : getServices()) {
    	if(service == null) continue;
        discovered.add(new ServiceEventCallbackResource(namespace.getEventCallbackPath(service), service));
    }

    // Embedded devices
    if (hasEmbeddedDevices()) {
        for (Device embeddedDevice : getEmbeddedDevices()) {
if(embeddedDevice == null) continue;
            discovered.addAll(Arrays.asList(embeddedDevice.discoverResources(namespace)));
        }
    }

    return discovered.toArray(new Resource[discovered.size()]);
}
 
Example #9
Source File: RemoteDevice.java    From TVRemoteIME with GNU General Public License v2.0 6 votes vote down vote up
@Override
public Resource[] discoverResources(Namespace namespace) {
    List<Resource> discovered = new ArrayList();

    // Services
    for (RemoteService service : getServices()) {
    	if(service == null) continue;
        discovered.add(new ServiceEventCallbackResource(namespace.getEventCallbackPath(service), service));
    }

    // Embedded devices
    if (hasEmbeddedDevices()) {
        for (Device embeddedDevice : getEmbeddedDevices()) {
if(embeddedDevice == null) continue;
            discovered.addAll(Arrays.asList(embeddedDevice.discoverResources(namespace)));
        }
    }

    return discovered.toArray(new Resource[discovered.size()]);
}
 
Example #10
Source File: UDA10DeviceDescriptorBinderImpl.java    From DroidDLNA with GNU General Public License v3.0 5 votes vote down vote up
public String generate(Device deviceModel, RemoteClientInfo info, Namespace namespace) throws DescriptorBindingException {
    try {
        log.fine("Generating XML descriptor from device model: " + deviceModel);

        return XMLUtil.documentToString(buildDOM(deviceModel, info, namespace));

    } catch (Exception ex) {
        throw new DescriptorBindingException("Could not build DOM: " + ex.getMessage(), ex);
    }
}
 
Example #11
Source File: UDA10DeviceDescriptorBinderImpl.java    From DroidDLNA with GNU General Public License v3.0 5 votes vote down vote up
protected void generateRoot(Namespace namespace, Device deviceModel, Document descriptor, RemoteClientInfo info) {

        Element rootElement = descriptor.createElementNS(Descriptor.Device.NAMESPACE_URI, ELEMENT.root.toString());
        descriptor.appendChild(rootElement);

        generateSpecVersion(namespace, deviceModel, descriptor, rootElement);

        /* UDA 1.1 spec says: Don't use URLBase anymore
        if (deviceModel.getBaseURL() != null) {
            appendChildElementWithTextContent(descriptor, rootElement, "URLBase", deviceModel.getBaseURL());
        }
        */

        generateDevice(namespace, deviceModel, descriptor, rootElement, info);
    }
 
Example #12
Source File: UDA10DeviceDescriptorBinderImpl.java    From DroidDLNA with GNU General Public License v3.0 5 votes vote down vote up
protected void generateDeviceList(Namespace namespace, Device deviceModel, Document descriptor, Element deviceElement, RemoteClientInfo info) {
    if (!deviceModel.hasEmbeddedDevices()) return;

    Element deviceListElement = appendNewElement(descriptor, deviceElement, ELEMENT.deviceList);

    for (Device device : deviceModel.getEmbeddedDevices()) {
        generateDevice(namespace, device, descriptor, deviceListElement, info);
    }
}
 
Example #13
Source File: RemoteGENASubscription.java    From TVRemoteIME with GNU General Public License v2.0 5 votes vote down vote up
synchronized public List<URL> getEventCallbackURLs(List<NetworkAddress> activeStreamServers, Namespace namespace) {
    List<URL> callbackURLs = new ArrayList();
    for (NetworkAddress activeStreamServer : activeStreamServers) {
        callbackURLs.add(
                new Location(
                        activeStreamServer,
                        namespace.getEventCallbackPath(getService())
                ).getURL());
    }
    return callbackURLs;
}
 
Example #14
Source File: RemoteGENASubscription.java    From DroidDLNA with GNU General Public License v3.0 5 votes vote down vote up
synchronized public List<URL> getEventCallbackURLs(List<NetworkAddress> activeStreamServers, Namespace namespace) {
    List<URL> callbackURLs = new ArrayList();
    for (NetworkAddress activeStreamServer : activeStreamServers) {
        callbackURLs.add(
                new Location(
                        activeStreamServer,
                        namespace.getEventCallbackPath(getService())
                ).getURL());
    }
    return callbackURLs;
}
 
Example #15
Source File: UDA10DeviceDescriptorBinderImpl.java    From TVRemoteIME with GNU General Public License v2.0 5 votes vote down vote up
protected void generateDeviceList(Namespace namespace, Device deviceModel, Document descriptor, Element deviceElement, RemoteClientInfo info) {
    if (!deviceModel.hasEmbeddedDevices()) return;

    Element deviceListElement = appendNewElement(descriptor, deviceElement, ELEMENT.deviceList);

    for (Device device : deviceModel.getEmbeddedDevices()) {
        generateDevice(namespace, device, descriptor, deviceListElement, info);
    }
}
 
Example #16
Source File: UDA10DeviceDescriptorBinderImpl.java    From TVRemoteIME with GNU General Public License v2.0 5 votes vote down vote up
protected void generateRoot(Namespace namespace, Device deviceModel, Document descriptor, RemoteClientInfo info) {

        Element rootElement = descriptor.createElementNS(Descriptor.Device.NAMESPACE_URI, ELEMENT.root.toString());
        descriptor.appendChild(rootElement);

        generateSpecVersion(namespace, deviceModel, descriptor, rootElement);

        /* UDA 1.1 spec says: Don't use URLBase anymore
        if (deviceModel.getBaseURL() != null) {
            appendChildElementWithTextContent(descriptor, rootElement, "URLBase", deviceModel.getBaseURL());
        }
        */

        generateDevice(namespace, deviceModel, descriptor, rootElement, info);
    }
 
Example #17
Source File: UDA10DeviceDescriptorBinderImpl.java    From TVRemoteIME with GNU General Public License v2.0 5 votes vote down vote up
public String generate(Device deviceModel, RemoteClientInfo info, Namespace namespace) throws DescriptorBindingException {
    try {
        log.fine("Generating XML descriptor from device model: " + deviceModel);

        return XMLUtil.documentToString(buildDOM(deviceModel, info, namespace));

    } catch (Exception ex) {
        throw new DescriptorBindingException("Could not build DOM: " + ex.getMessage(), ex);
    }
}
 
Example #18
Source File: LocalDevice.java    From DroidDLNA with GNU General Public License v3.0 4 votes vote down vote up
@Override
public Resource[] discoverResources(Namespace namespace) {
    List<Resource> discovered = new ArrayList();

    // Device
    if (isRoot()) {
        // This should guarantee that each logical local device tree (with all its embedded devices) has only
        // one device descriptor resource - because only one device in the tree isRoot().
        discovered.add(new DeviceDescriptorResource(namespace.getDescriptorPath(this), this));
    }

    // Services
    for (LocalService service : getServices()) {

        discovered.add(
                new ServiceDescriptorResource(namespace.getDescriptorPath(service), service)
        );

        // Control
        discovered.add(
                new ServiceControlResource(namespace.getControlPath(service), service)
        );

        // Event subscription
        discovered.add(
                new ServiceEventSubscriptionResource(namespace.getEventSubscriptionPath(service), service)
        );

    }

    // Icons
    for (Icon icon : getIcons()) {
        discovered.add(new IconResource(namespace.prefixIfRelative(this, icon.getUri()), icon));
    }

    // Embedded devices
    if (hasEmbeddedDevices()) {
        for (Device embeddedDevice : getEmbeddedDevices()) {
            discovered.addAll(Arrays.asList(embeddedDevice.discoverResources(namespace)));
        }
    }

    return discovered.toArray(new Resource[discovered.size()]);
}
 
Example #19
Source File: ManagedUpnpServiceConfiguration.java    From DroidDLNA with GNU General Public License v3.0 4 votes vote down vote up
public Namespace getNamespace() {
    return namespace;
}
 
Example #20
Source File: ManagedUpnpServiceConfiguration.java    From DroidDLNA with GNU General Public License v3.0 4 votes vote down vote up
protected Namespace createNamespace() {
    return new Namespace();
}
 
Example #21
Source File: DefaultUpnpServiceConfiguration.java    From DroidDLNA with GNU General Public License v3.0 4 votes vote down vote up
public Namespace getNamespace() {
    return namespace;
}
 
Example #22
Source File: DefaultUpnpServiceConfiguration.java    From DroidDLNA with GNU General Public License v3.0 4 votes vote down vote up
protected Namespace createNamespace() {
    return new Namespace();
}
 
Example #23
Source File: UDA10DeviceDescriptorBinderImpl.java    From DroidDLNA with GNU General Public License v3.0 4 votes vote down vote up
protected void generateDevice(Namespace namespace, Device deviceModel, Document descriptor, Element rootElement, RemoteClientInfo info) {

        Element deviceElement = appendNewElement(descriptor, rootElement, ELEMENT.device);

        appendNewElementIfNotNull(descriptor, deviceElement, ELEMENT.deviceType, deviceModel.getType());

        DeviceDetails deviceModelDetails = deviceModel.getDetails(info);
        appendNewElementIfNotNull(
                descriptor, deviceElement, ELEMENT.friendlyName,
                deviceModelDetails.getFriendlyName()
        );
        if (deviceModelDetails.getManufacturerDetails() != null) {
            appendNewElementIfNotNull(
                    descriptor, deviceElement, ELEMENT.manufacturer,
                    deviceModelDetails.getManufacturerDetails().getManufacturer()
            );
            appendNewElementIfNotNull(
                    descriptor, deviceElement, ELEMENT.manufacturerURL,
                    deviceModelDetails.getManufacturerDetails().getManufacturerURI()
            );
        }
        if (deviceModelDetails.getModelDetails() != null) {
            appendNewElementIfNotNull(
                    descriptor, deviceElement, ELEMENT.modelDescription,
                    deviceModelDetails.getModelDetails().getModelDescription()
            );
            appendNewElementIfNotNull(
                    descriptor, deviceElement, ELEMENT.modelName,
                    deviceModelDetails.getModelDetails().getModelName()
            );
            appendNewElementIfNotNull(
                    descriptor, deviceElement, ELEMENT.modelNumber,
                    deviceModelDetails.getModelDetails().getModelNumber()
            );
            appendNewElementIfNotNull(
                    descriptor, deviceElement, ELEMENT.modelURL,
                    deviceModelDetails.getModelDetails().getModelURI()
            );
        }
        appendNewElementIfNotNull(
                descriptor, deviceElement, ELEMENT.serialNumber,
                deviceModelDetails.getSerialNumber()
        );
        appendNewElementIfNotNull(descriptor, deviceElement, ELEMENT.UDN, deviceModel.getIdentity().getUdn());
        appendNewElementIfNotNull(
                descriptor, deviceElement, ELEMENT.presentationURL,
                deviceModelDetails.getPresentationURI()
        );
        appendNewElementIfNotNull(
                descriptor, deviceElement, ELEMENT.UPC,
                deviceModelDetails.getUpc()
        );

        if (deviceModelDetails.getDlnaDocs() != null) {
            for (DLNADoc dlnaDoc : deviceModelDetails.getDlnaDocs()) {
                appendNewElementIfNotNull(
                        descriptor, deviceElement, Descriptor.Device.DLNA_PREFIX + ":" + ELEMENT.X_DLNADOC,
                        dlnaDoc, Descriptor.Device.DLNA_NAMESPACE_URI
                );
            }
        }
        appendNewElementIfNotNull(
                descriptor, deviceElement, Descriptor.Device.DLNA_PREFIX + ":" + ELEMENT.X_DLNACAP,
                deviceModelDetails.getDlnaCaps(), Descriptor.Device.DLNA_NAMESPACE_URI
        );
        
        appendNewElementIfNotNull(
                descriptor, deviceElement, Descriptor.Device.SEC_PREFIX + ":" + ELEMENT.ProductCap,
                deviceModelDetails.getSecProductCaps(), Descriptor.Device.SEC_NAMESPACE_URI
        );
        
        appendNewElementIfNotNull(
                descriptor, deviceElement, Descriptor.Device.SEC_PREFIX + ":" + ELEMENT.X_ProductCap,
                deviceModelDetails.getSecProductCaps(), Descriptor.Device.SEC_NAMESPACE_URI
        );

        generateIconList(namespace, deviceModel, descriptor, deviceElement);
        generateServiceList(namespace, deviceModel, descriptor, deviceElement);
        generateDeviceList(namespace, deviceModel, descriptor, deviceElement, info);
    }
 
Example #24
Source File: UDA10DeviceDescriptorBinderImpl.java    From DroidDLNA with GNU General Public License v3.0 4 votes vote down vote up
protected void generateSpecVersion(Namespace namespace, Device deviceModel, Document descriptor, Element rootElement) {
    Element specVersionElement = appendNewElement(descriptor, rootElement, ELEMENT.specVersion);
    appendNewElementIfNotNull(descriptor, specVersionElement, ELEMENT.major, deviceModel.getVersion().getMajor());
    appendNewElementIfNotNull(descriptor, specVersionElement, ELEMENT.minor, deviceModel.getVersion().getMinor());
}
 
Example #25
Source File: ProtocolFactoryImpl.java    From TVRemoteIME with GNU General Public License v2.0 4 votes vote down vote up
public ReceivingSync createReceivingSync(StreamRequestMessage message) throws ProtocolCreationException {
    log.fine("Creating protocol for incoming synchronous: " + message);

    if (message.getOperation().getMethod().equals(UpnpRequest.Method.GET)) {

        return createReceivingRetrieval(message);

    } else if (getUpnpService().getConfiguration().getNamespace().isControlPath(message.getUri())) {

        if (message.getOperation().getMethod().equals(UpnpRequest.Method.POST))
            return createReceivingAction(message);

    } else if (getUpnpService().getConfiguration().getNamespace().isEventSubscriptionPath(message.getUri())) {

        if (message.getOperation().getMethod().equals(UpnpRequest.Method.SUBSCRIBE)) {
            return createReceivingSubscribe(message);
        } else if (message.getOperation().getMethod().equals(UpnpRequest.Method.UNSUBSCRIBE)) {
            return createReceivingUnsubscribe(message);
        }

    } else if (getUpnpService().getConfiguration().getNamespace().isEventCallbackPath(message.getUri())) {

        if (message.getOperation().getMethod().equals(UpnpRequest.Method.NOTIFY))
            return createReceivingEvent(message);

    } else {

        // TODO: UPNP VIOLATION: Onkyo devices send event messages with trailing garbage characters
        // dev/1234/svc/upnp-org/MyService/event/callback192%2e168%2e10%2e38
        if (message.getUri().getPath().contains(Namespace.EVENTS + Namespace.CALLBACK_FILE)) {
            log.warning("Fixing trailing garbage in event message path: " + message.getUri().getPath());
            String invalid = message.getUri().toString();
            message.setUri(
                URI.create(invalid.substring(
                    0, invalid.indexOf(Namespace.CALLBACK_FILE) + Namespace.CALLBACK_FILE.length()
                ))
            );
            if (getUpnpService().getConfiguration().getNamespace().isEventCallbackPath(message.getUri())
                && message.getOperation().getMethod().equals(UpnpRequest.Method.NOTIFY))
                return createReceivingEvent(message);
        }

    }

    throw new ProtocolCreationException("Protocol for message type not found: " + message);
}
 
Example #26
Source File: AndroidUpnpServiceConfiguration.java    From DroidDLNA with GNU General Public License v3.0 4 votes vote down vote up
@Override
protected Namespace createNamespace() {
    // For the Jetty server, this is the servlet context path
    return new Namespace("/upnp");
}
 
Example #27
Source File: ProtocolFactoryImpl.java    From DroidDLNA with GNU General Public License v3.0 4 votes vote down vote up
public ReceivingSync createReceivingSync(StreamRequestMessage message) throws ProtocolCreationException {
    log.fine("Creating protocol for incoming synchronous: " + message);

    if (message.getOperation().getMethod().equals(UpnpRequest.Method.GET)) {

        return createReceivingRetrieval(message);

    } else if (getUpnpService().getConfiguration().getNamespace().isControlPath(message.getUri())) {

        if (message.getOperation().getMethod().equals(UpnpRequest.Method.POST))
            return createReceivingAction(message);

    } else if (getUpnpService().getConfiguration().getNamespace().isEventSubscriptionPath(message.getUri())) {

        if (message.getOperation().getMethod().equals(UpnpRequest.Method.SUBSCRIBE)) {
            return createReceivingSubscribe(message);
        } else if (message.getOperation().getMethod().equals(UpnpRequest.Method.UNSUBSCRIBE)) {
            return createReceivingUnsubscribe(message);
        }

    } else if (getUpnpService().getConfiguration().getNamespace().isEventCallbackPath(message.getUri())) {

        if (message.getOperation().getMethod().equals(UpnpRequest.Method.NOTIFY))
            return createReceivingEvent(message);

    } else {

        // TODO: UPNP VIOLATION: Onkyo devices send event messages with trailing garbage characters
        // dev/1234/svc/upnp-org/MyService/event/callback192%2e168%2e10%2e38
        if (message.getUri().getPath().contains(Namespace.EVENTS + Namespace.CALLBACK_FILE)) {
            log.warning("Fixing trailing garbage in event message path: " + message.getUri().getPath());
            String invalid = message.getUri().toString();
            message.setUri(
                URI.create(invalid.substring(
                    0, invalid.indexOf(Namespace.CALLBACK_FILE) + Namespace.CALLBACK_FILE.length()
                ))
            );
            if (getUpnpService().getConfiguration().getNamespace().isEventCallbackPath(message.getUri())
                && message.getOperation().getMethod().equals(UpnpRequest.Method.NOTIFY))
                return createReceivingEvent(message);
        }

    }

    throw new ProtocolCreationException("Protocol for message type not found: " + message);
}
 
Example #28
Source File: JettyAsyncUpnpServiceConfiguration.java    From bt with Apache License 2.0 4 votes vote down vote up
@Override
protected Namespace createNamespace() {
    return new Namespace("/bt-upnp");
}
 
Example #29
Source File: AndroidUpnpServiceConfiguration.java    From TVRemoteIME with GNU General Public License v2.0 4 votes vote down vote up
@Override
protected Namespace createNamespace() {
    // For the Jetty server, this is the servlet context path
    return new Namespace("/upnp");
}
 
Example #30
Source File: DefaultUpnpServiceConfiguration.java    From TVRemoteIME with GNU General Public License v2.0 4 votes vote down vote up
protected Namespace createNamespace() {
    return new Namespace();
}