protected Collection<D> find(ServiceType serviceType, D current) { Collection<S> services = findServices(serviceType, null, current); Collection<D> devices = new HashSet<>(); for (Service service : services) { devices.add((D) service.getDevice()); } return devices; }
public List<ValidationError> validate() { List<ValidationError> errors = new ArrayList<>(); if (getServiceType() == null) { errors.add(new ValidationError( getClass(), if (getServiceId() == null) { errors.add(new ValidationError( getClass(), if (hasStateVariables()) { for (StateVariable stateVariable : getStateVariables()) { errors.addAll(stateVariable.validate()); if (hasActions()) { for (Action action : getActions()) { if(actionErrors.size() > 0) { log.warning("Discarding invalid action of service '" + getServiceId() + "': " + action.getName()); for (ValidationError actionError : actionErrors) { log.warning("Invalid action '" + action.getName() + "': " + actionError);
public RemoveMessage(Service service, int id) { super(new ActionInvocation(service.getAction("RemoveMessage"))); getActionInvocation().setInput("MessageID", id); }
protected String getServicePath(Service service) { if (service.getServiceId() == null) { throw new IllegalStateException("Can't generate local URI prefix without service ID"); } StringBuilder s = new StringBuilder(); s.append(SERVICE); s.append("/"); s.append(service.getServiceId().getNamespace()); s.append("/"); s.append(service.getServiceId().getId()); return getDevicePath(service.getDevice()) + s.toString(); } }
private boolean isMatch(Service s, ServiceType serviceType, ServiceId serviceId) { boolean matchesType = serviceType == null || s.getServiceType().implementsVersion(serviceType); boolean matchesId = serviceId == null || s.getServiceId().equals(serviceId); return matchesType && matchesId; }
public void init(Service service) { serviceReference = service.getReference(); wakeOnLANBytes = service.getDevice() instanceof RemoteDevice ? ((RemoteDevice) service.getDevice()).getIdentity().getWakeOnLANBytes() : null; reconnectView.setPresenter(this); init(reconnectView); }
if (service.getStateVariable("Volume") != null) { volumeRange = service.getStateVariable("Volume").getTypeDetails().getAllowedValueRange(); view.setTitle(service.getDevice().getDetails().getFriendlyName());
deviceNode.add(serviceNode); addIfNotNull(serviceNode, "Service Type: ", service.getServiceType().toString()); addIfNotNull(serviceNode, "Service ID: ", service.getServiceId().toString()); for (Action action : service.getActions()) { for (StateVariable stateVariable : service.getStateVariables()) { DefaultMutableTreeNode stateVariableNode = new DefaultMutableTreeNode(stateVariable); serviceNode.add(stateVariableNode);
public boolean hasActions() { return getActions() != null && getActions().length > 0; }
public ServiceType[] findServiceTypes() { Collection<S> services = findServices(null, null, (D) this); Collection<ServiceType> col = new HashSet<>(); for (S service : services) { col.add(service.getServiceType()); } return col.toArray(new ServiceType[col.size()]); }
@Override public ActionInvocation<RemoteService> getActionInvocation() { final Action<RemoteService> action = service.getAction(actionName); if (action == null) { throw new ClingRouterException("No action found for name '" + actionName + "'. Available actions: " + Arrays.toString(service.getActions())); } final ActionArgumentValue<RemoteService>[] argumentArray = getArguments(action); return new ActionInvocation<RemoteService>(action, argumentArray); }
public boolean hasStateVariables() { // TODO: Spec says always has to have at least one... return getStateVariables() != null && getStateVariables().length > 0; }
@Override public String toString() { return "(" + getClass().getSimpleName() + ") ServiceId: " + getServiceId(); } }
public StateVariable<S> getRelatedStateVariable(ActionArgument argument) { return getStateVariable(argument.getRelatedStateVariableName()); }
@Override public void received(ActionInvocation invocation, int peerConnectionID, int rcsID, int avTransportID) { ConnectionInfo info = new ConnectionInfo( localConnectionID, rcsID, avTransportID, protInfo, peerService.getReference(), peerConnectionID, direction.getOpposite(), // If I prepared you for output, then I do input ConnectionInfo.Status.OK ); storeConnection(info); }
public ServiceReference getReference() { return new ServiceReference(getDevice().getIdentity().getUdn(), getServiceId()); }
protected void hydrateBasic(MutableService descriptor, Service undescribedService) { descriptor.serviceId = undescribedService.getServiceId(); descriptor.serviceType = undescribedService.getServiceType(); if (undescribedService instanceof RemoteService) { RemoteService rs = (RemoteService) undescribedService; descriptor.controlURI = rs.getControlURI(); descriptor.eventSubscriptionURI = rs.getEventSubscriptionURI(); descriptor.descriptorURI = rs.getDescriptorURI(); } }
)); } else if (!ModelUtil.isValidUDAName(getName())) { log.warning("UPnP specification violation of: " + getService().getDevice()); log.warning("Invalid action name: " + this); if (getService().getStateVariable(actionArgument.getRelatedStateVariableName()) == null) { errors.add(new ValidationError( getClass(), log.warning("UPnP specification violation of :" + getService().getDevice()); log.warning("Input argument can not have <retval/>"); } else { if (retValueArgument != null) { log.warning("UPnP specification violation of: " + getService().getDevice()); log.warning("Only one argument of action '" + getName() + "' can be <retval/>"); ActionArgument a = getArguments()[j]; if (a.getDirection() == ActionArgument.Direction.OUT) { log.warning("UPnP specification violation of: " + getService().getDevice()); log.warning("Argument '" + retValueArgument.getName() + "' of action '" + getName() + "' is <retval/> but not the first OUT argument");
private void generateActionList(Service serviceModel, Document descriptor, Element scpdElement) { Element actionListElement = appendNewElement(descriptor, scpdElement, ELEMENT.actionList); for (Action action : serviceModel.getActions()) { if (!action.getName().equals(QueryStateVariableAction.ACTION_NAME)) generateAction(action, descriptor, actionListElement); } }
public ControlPointAdapter getControlPointAdapter(Service service) { // TODO: Just take the first, we really should provide a drop-down menu for (ControlPointAdapter controlPointAdapter : controlPointLoader) { if (controlPointAdapter.getServiceType().implementsVersion(service.getServiceType())) { return controlPointAdapter; } } return null; }