@Override public String toString() { return "(" + getClass().getSimpleName() + ") UDN: " + getUdn(); }
public DeviceItem(Device device) { this.udn = device.getIdentity().getUdn(); this.device = device; }
public DeviceItem(Device device, String... label) { this.udn = device.getIdentity().getUdn(); this.device = device; this.label = label; }
@Override public List<ValidationError> validate() { List<ValidationError> errors = new ArrayList<>(); if (getUdn() == null) { errors.add(new ValidationError( getClass(), "major", "Device has no UDN" )); } return errors; } }
protected String getDevicePath(Device device) { if (device.getIdentity().getUdn() == null) { throw new IllegalStateException("Can't generate local URI prefix without UDN"); } StringBuilder s = new StringBuilder(); s.append(DEVICE).append("/"); s.append(URIUtil.encodePathSegment(device.getIdentity().getUdn().getIdentifierString())); return s.toString(); }
boolean contains(D device) { return contains(device.getIdentity().getUdn()); }
protected Collection<D> findEmbeddedDevices(D current) { Collection<D> devices = new HashSet<>(); if (!current.isRoot() && current.getIdentity().getUdn() != null) devices.add(current); if (current.hasEmbeddedDevices()) { for (D embeddedDevice : (D[]) current.getEmbeddedDevices()) { devices.addAll(findEmbeddedDevices(embeddedDevice)); } } return devices; }
protected D find(UDN udn, D current) { if (current.getIdentity() != null && current.getIdentity().getUdn() != null) { if (current.getIdentity().getUdn().equals(udn)) return current; } if (current.hasEmbeddedDevices()) { for (D embeddedDevice : (D[]) current.getEmbeddedDevices()) { D match; if ((match = find(udn, embeddedDevice)) != null) return match; } } return null; }
public OutgoingNotificationRequestUDN(Location location, LocalDevice device, NotificationSubtype type) { super(location, device, type); getHeaders().add(UpnpHeader.Type.NT, new UDNHeader(device.getIdentity().getUdn())); getHeaders().add(UpnpHeader.Type.USN, new UDNHeader(device.getIdentity().getUdn())); }
public OutgoingSearchResponseUDN(IncomingDatagramMessage request, Location location, LocalDevice device) { super(request, location, device); getHeaders().add(UpnpHeader.Type.ST, new UDNHeader(device.getIdentity().getUdn())); getHeaders().add(UpnpHeader.Type.USN, new UDNHeader(device.getIdentity().getUdn())); } }
public ServiceReference getReference() { return new ServiceReference(getDevice().getIdentity().getUdn(), getServiceId()); }
protected boolean isAdvertisementDisabled(LocalDevice device) { DiscoveryOptions options = getUpnpService().getRegistry().getDiscoveryOptions(device.getIdentity().getUdn()); return options != null && !options.isAdvertised(); }
/** * Returns root and embedded devices registered under the given UDN. * * @param udn A unique device name. * @param rootOnly Set to true if only root devices (no embedded) should be searched * @return Any registered root or embedded device under the given UDN, <tt>null</tt> if * no device with the given UDN has been registered. */ D get(UDN udn, boolean rootOnly) { for (RegistryItem<UDN, D> item : deviceItems) { D device = item.getItem(); if (device.getIdentity().getUdn().equals(udn)) { return device; } if (!rootOnly) { D foundDevice = (D)item.getItem().findDevice(udn); if (foundDevice != null) return foundDevice; } } return null; }
public OutgoingSearchResponseRootDevice(IncomingDatagramMessage request, Location location, LocalDevice device) { super(request, location, device); getHeaders().add(UpnpHeader.Type.ST, new RootDeviceHeader()); getHeaders().add(UpnpHeader.Type.USN, new USNRootDeviceHeader(device.getIdentity().getUdn())); } }
public OutgoingNotificationRequestServiceType(Location location, LocalDevice device, NotificationSubtype type, ServiceType serviceType) { super(location, device, type); getHeaders().add(UpnpHeader.Type.NT, new ServiceTypeHeader(serviceType)); getHeaders().add(UpnpHeader.Type.USN, new ServiceUSNHeader(device.getIdentity().getUdn(), serviceType)); }
public OutgoingSearchResponseServiceType(IncomingDatagramMessage request, Location location, LocalDevice device, ServiceType serviceType) { super(request, location, device); getHeaders().add(UpnpHeader.Type.ST, new ServiceTypeHeader(serviceType)); getHeaders().add(UpnpHeader.Type.USN, new ServiceUSNHeader(device.getIdentity().getUdn(), serviceType)); }
void add(final LocalDevice localDevice, DiscoveryOptions options) throws RegistrationException { setDiscoveryOptions(localDevice.getIdentity().getUdn(), options); if (registry.getDevice(localDevice.getIdentity().getUdn(), false) != null) { log.fine("Ignoring addition, device already registered: " + localDevice); return; localDevice.getIdentity().getUdn(), localDevice, localDevice.getIdentity().getMaxAgeSeconds()
public OutgoingNotificationRequestRootDevice(Location location, LocalDevice device, NotificationSubtype type) { super(location, device, type); getHeaders().add(UpnpHeader.Type.NT, new RootDeviceHeader()); getHeaders().add(UpnpHeader.Type.USN, new USNRootDeviceHeader(device.getIdentity().getUdn())); if ("true".equals(System.getProperty(Constants.SYSTEM_PROPERTY_ANNOUNCE_MAC_ADDRESS)) && location.getNetworkAddress().getHardwareAddress() != null) { getHeaders().add( UpnpHeader.Type.EXT_IFACE_MAC, new InterfaceMacHeader(location.getNetworkAddress().getHardwareAddress()) ); } }
public OutgoingNotificationRequestDeviceType(Location location, LocalDevice device, NotificationSubtype type) { super(location, device, type); getHeaders().add(UpnpHeader.Type.NT, new DeviceTypeHeader(device.getType())); getHeaders().add(UpnpHeader.Type.USN, new DeviceUSNHeader(device.getIdentity().getUdn(), device.getType())); }
public OutgoingSearchResponseDeviceType(IncomingDatagramMessage request, Location location, LocalDevice device) { super(request, location, device); getHeaders().add(UpnpHeader.Type.ST, new DeviceTypeHeader(device.getType())); getHeaders().add(UpnpHeader.Type.USN, new DeviceUSNHeader(device.getIdentity().getUdn(), device.getType())); }