public ServiceUSNHeader(UDN udn, ServiceType serviceType) { setValue(new NamedServiceType(udn, serviceType)); }
@Override public String toString() { return getUdn().toString() + "::" + getServiceType().toString(); }
public String getString() { return getValue().toString(); }
protected boolean isSupportedServiceAdvertisement(IncomingDatagramMessage message) { ServiceType[] exclusiveServiceTypes = getUpnpService().getConfiguration().getExclusiveServiceTypes(); if (exclusiveServiceTypes == null) return false; // Discovery is disabled if (exclusiveServiceTypes.length == 0) return true; // Any advertisement is fine String usnHeader = message.getHeaders().getFirstHeader(UpnpHeader.Type.USN.getHttpName()); if (usnHeader == null) return false; // Not a service advertisement, drop it try { NamedServiceType nst = NamedServiceType.valueOf(usnHeader); for (ServiceType exclusiveServiceType : exclusiveServiceTypes) { if (nst.getServiceType().implementsVersion(exclusiveServiceType)) return true; } } catch (InvalidValueException ex) { log.finest("Not a named service type header value: " + usnHeader); } log.fine("Service advertisement not supported, dropping it: " + usnHeader); return false; }
public UDN getRootDeviceUDN() { // This processes the headers as specified in UDA 1.0, tables in section 1.1.12 UpnpHeader<UDN> udnHeader = getHeaders().getFirstHeader(UpnpHeader.Type.USN, USNRootDeviceHeader.class); if (udnHeader != null) return udnHeader.getValue(); udnHeader = getHeaders().getFirstHeader(UpnpHeader.Type.USN, UDNHeader.class); if (udnHeader != null) return udnHeader.getValue(); UpnpHeader<NamedDeviceType> deviceTypeHeader = getHeaders().getFirstHeader(UpnpHeader.Type.USN, DeviceUSNHeader.class); if (deviceTypeHeader != null) return deviceTypeHeader.getValue().getUdn(); UpnpHeader<NamedServiceType> serviceTypeHeader = getHeaders().getFirstHeader(UpnpHeader.Type.USN, ServiceUSNHeader.class); if (serviceTypeHeader != null) return serviceTypeHeader.getValue().getUdn(); return null; }
public void setString(String s) throws InvalidHeaderException { try { setValue(NamedServiceType.valueOf(s)); } catch (Exception ex) { throw new InvalidHeaderException("Invalid service USN header value, " + ex.getMessage()); } }
protected boolean isSupportedServiceAdvertisement(IncomingDatagramMessage message) { ServiceType[] exclusiveServiceTypes = getUpnpService().getConfiguration().getExclusiveServiceTypes(); if (exclusiveServiceTypes == null) return false; // Discovery is disabled if (exclusiveServiceTypes.length == 0) return true; // Any advertisement is fine String usnHeader = message.getHeaders().getFirstHeader(UpnpHeader.Type.USN.getHttpName()); if (usnHeader == null) return false; // Not a service advertisement, drop it try { NamedServiceType nst = NamedServiceType.valueOf(usnHeader); for (ServiceType exclusiveServiceType : exclusiveServiceTypes) { if (nst.getServiceType().implementsVersion(exclusiveServiceType)) return true; } } catch (InvalidValueException ex) { log.finest("Not a named service type header value: " + usnHeader); } log.fine("Service advertisement not supported, dropping it: " + usnHeader); return false; }
/** * @return The UDN value after parsing various USN header values, or <code>null</code>. */ public UDN getUDN() { // This processes the headers as specified in UDA 1.0, tables in section 1.1.12 UpnpHeader<UDN> udnHeader = getHeaders().getFirstHeader(UpnpHeader.Type.USN, USNRootDeviceHeader.class); if (udnHeader != null) return udnHeader.getValue(); udnHeader = getHeaders().getFirstHeader(UpnpHeader.Type.USN, UDNHeader.class); if (udnHeader != null) return udnHeader.getValue(); UpnpHeader<NamedDeviceType> deviceTypeHeader = getHeaders().getFirstHeader(UpnpHeader.Type.USN, DeviceUSNHeader.class); if (deviceTypeHeader != null) return deviceTypeHeader.getValue().getUdn(); UpnpHeader<NamedServiceType> serviceTypeHeader = getHeaders().getFirstHeader(UpnpHeader.Type.USN, ServiceUSNHeader.class); if (serviceTypeHeader != null) return serviceTypeHeader.getValue().getUdn(); return null; }
public void setString(String s) throws InvalidHeaderException { try { setValue(NamedServiceType.valueOf(s)); } catch (Exception ex) { throw new InvalidHeaderException("Invalid service USN header value, " + ex.getMessage()); } }
@Override public String toString() { return getUdn().toString() + "::" + getServiceType().toString(); }
protected boolean isSupportedServiceAdvertisement(IncomingDatagramMessage message) { ServiceType[] exclusiveServiceTypes = getUpnpService().getConfiguration().getExclusiveServiceTypes(); if (exclusiveServiceTypes == null) return false; // Discovery is disabled if (exclusiveServiceTypes.length == 0) return true; // Any advertisement is fine String usnHeader = message.getHeaders().getFirstHeader(UpnpHeader.Type.USN.getHttpName()); if (usnHeader == null) return false; // Not a service advertisement, drop it try { NamedServiceType nst = NamedServiceType.valueOf(usnHeader); for (ServiceType exclusiveServiceType : exclusiveServiceTypes) { if (nst.getServiceType().implementsVersion(exclusiveServiceType)) return true; } } catch (InvalidValueException ex) { log.finest("Not a named service type header value: " + usnHeader); } log.fine("Service advertisement not supported, dropping it: " + usnHeader); return false; }
public UDN getRootDeviceUDN() { // This processes the headers as specified in UDA 1.0, tables in section 1.1.12 UpnpHeader<UDN> udnHeader = getHeaders().getFirstHeader(UpnpHeader.Type.USN, USNRootDeviceHeader.class); if (udnHeader != null) return udnHeader.getValue(); udnHeader = getHeaders().getFirstHeader(UpnpHeader.Type.USN, UDNHeader.class); if (udnHeader != null) return udnHeader.getValue(); UpnpHeader<NamedDeviceType> deviceTypeHeader = getHeaders().getFirstHeader(UpnpHeader.Type.USN, DeviceUSNHeader.class); if (deviceTypeHeader != null) return deviceTypeHeader.getValue().getUdn(); UpnpHeader<NamedServiceType> serviceTypeHeader = getHeaders().getFirstHeader(UpnpHeader.Type.USN, ServiceUSNHeader.class); if (serviceTypeHeader != null) return serviceTypeHeader.getValue().getUdn(); return null; }
public static NamedServiceType valueOf(String s) throws InvalidValueException { String[] strings = s.split("::"); if (strings.length != 2) { throw new InvalidValueException("Can't parse UDN::ServiceType from: " + s); } UDN udn; try { udn = UDN.valueOf(strings[0]); } catch (Exception ex) { throw new InvalidValueException("Can't parse UDN: " + strings[0]); } ServiceType serviceType = ServiceType.valueOf(strings[1]); return new NamedServiceType(udn, serviceType); }
public void setString(String s) throws InvalidHeaderException { try { setValue(NamedServiceType.valueOf(s)); } catch (Exception ex) { throw new InvalidHeaderException("Invalid service USN header value, " + ex.getMessage()); } }
public String getString() { return getValue().toString(); }
@Override public String toString() { return getUdn().toString() + "::" + getServiceType().toString(); }
/** * @return The UDN value after parsing various USN header values, or <code>null</code>. */ public UDN getUDN() { // This processes the headers as specified in UDA 1.0, tables in section 1.1.12 UpnpHeader<UDN> udnHeader = getHeaders().getFirstHeader(UpnpHeader.Type.USN, USNRootDeviceHeader.class); if (udnHeader != null) return udnHeader.getValue(); udnHeader = getHeaders().getFirstHeader(UpnpHeader.Type.USN, UDNHeader.class); if (udnHeader != null) return udnHeader.getValue(); UpnpHeader<NamedDeviceType> deviceTypeHeader = getHeaders().getFirstHeader(UpnpHeader.Type.USN, DeviceUSNHeader.class); if (deviceTypeHeader != null) return deviceTypeHeader.getValue().getUdn(); UpnpHeader<NamedServiceType> serviceTypeHeader = getHeaders().getFirstHeader(UpnpHeader.Type.USN, ServiceUSNHeader.class); if (serviceTypeHeader != null) return serviceTypeHeader.getValue().getUdn(); return null; }
public ServiceUSNHeader(UDN udn, ServiceType serviceType) { setValue(new NamedServiceType(udn, serviceType)); }
public String getString() { return getValue().toString(); }
public UDN getRootDeviceUDN() { // This processes the headers as specified in UDA 1.0, tables in section 1.1.12 UpnpHeader<UDN> udnHeader = getHeaders().getFirstHeader(UpnpHeader.Type.USN, USNRootDeviceHeader.class); if (udnHeader != null) return udnHeader.getValue(); udnHeader = getHeaders().getFirstHeader(UpnpHeader.Type.USN, UDNHeader.class); if (udnHeader != null) return udnHeader.getValue(); UpnpHeader<NamedDeviceType> deviceTypeHeader = getHeaders().getFirstHeader(UpnpHeader.Type.USN, DeviceUSNHeader.class); if (deviceTypeHeader != null) return deviceTypeHeader.getValue().getUdn(); UpnpHeader<NamedServiceType> serviceTypeHeader = getHeaders().getFirstHeader(UpnpHeader.Type.USN, ServiceUSNHeader.class); if (serviceTypeHeader != null) return serviceTypeHeader.getValue().getUdn(); return null; }