Resource[] getResources(Device device) throws RegistrationException { try { return registry.getConfiguration().getNamespace().getResources(device); } catch (ValidationException ex) { throw new RegistrationException("Resource discover error: " + ex.toString(), ex); } }
private LocalDevice createDevice() { LocalDevice device; try { device = new LocalDevice( new DeviceIdentity(new UDN(UDN_ID)), new UDADeviceType("MediaServer"), new DeviceDetails("YAACC-LocalMediaServer", new ManufacturerDetails("YAACC")), createServices()); return device; } catch (ValidationException e) { // TODO Auto-generated catch block e.printStackTrace(); } return null; }
protected void execute() throws RouterException { UDN udn = getInputMessage().getUDN(); if (udn == null) { log.fine("Ignoring notification message without UDN: " + getInputMessage()); return; } RemoteDeviceIdentity rdIdentity = new RemoteDeviceIdentity(getInputMessage()); log.fine("Received device notification: " + rdIdentity); RemoteDevice rd; try { rd = new RemoteDevice(rdIdentity); } catch (ValidationException ex) { log.warning("Validation errors of device during discovery: " + rdIdentity); for (ValidationError validationError : ex.getErrors()) { log.warning(validationError.toString()); } return; } if (getInputMessage().isAliveMessage()) { log.fine( "Received device ALIVE advertisement, descriptor location is: " + rdIdentity.getDescriptorURL()); if (rdIdentity.getDescriptorURL() == null) { log.finer("Ignoring message without location URL header: " + getInputMessage()); return; } if (rdIdentity.getMaxAgeSeconds() == null) { log.finer("Ignoring message without max-age header: " + getInputMessage()); return; } if (getUpnpService().getRegistry().update(rdIdentity)) { log.finer("Remote device was already known: " + udn); return; } // Unfortunately, we always have to retrieve the descriptor because at this point we // have no idea if it's a root or embedded device getUpnpService() .getConfiguration() .getAsyncProtocolExecutor() .execute(new RetrieveRemoteDescriptors(getUpnpService(), rd)); } else if (getInputMessage().isByeByeMessage()) { log.fine("Received device BYEBYE advertisement"); boolean removed = getUpnpService().getRegistry().removeDevice(rd); if (removed) { log.fine("Removed remote device from registry: " + rd); } } else { log.finer("Ignoring unknown notification message: " + getInputMessage()); } }