org.fourthline.cling.model.ValidationException Java Examples

The following examples show how to use org.fourthline.cling.model.ValidationException. 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: MutableDevice.java    From DroidDLNA with GNU General Public License v3.0 6 votes vote down vote up
public Device build(Device prototype, UDAVersion deviceVersion, URL baseURL) throws ValidationException {

        List<Device> embeddedDevicesList = new ArrayList();
        for (MutableDevice embeddedDevice : embeddedDevices) {
            embeddedDevicesList.add(embeddedDevice.build(prototype, deviceVersion, baseURL));
        }
        return prototype.newInstance(
                udn,
                deviceVersion,
                createDeviceType(),
                createDeviceDetails(baseURL),
                createIcons(),
                createServices(prototype),
                embeddedDevicesList
        );
    }
 
Example #2
Source File: MutableDevice.java    From TVRemoteIME with GNU General Public License v2.0 6 votes vote down vote up
public Device build(Device prototype, UDAVersion deviceVersion, URL baseURL) throws ValidationException {

        List<Device> embeddedDevicesList = new ArrayList();
        for (MutableDevice embeddedDevice : embeddedDevices) {
            embeddedDevicesList.add(embeddedDevice.build(prototype, deviceVersion, baseURL));
        }
        return prototype.newInstance(
                udn,
                deviceVersion,
                createDeviceType(),
                createDeviceDetails(baseURL),
                createIcons(),
                createServices(prototype),
                embeddedDevicesList
        );
    }
 
Example #3
Source File: SempDiscovery.java    From SmartApplianceEnabler with GNU General Public License v2.0 6 votes vote down vote up
private LocalDevice createDevice()
        throws ValidationException, LocalServiceBindingException, IOException {

    DeviceIdentity identity =
            new DeviceIdentity(
                    UDN.uniqueSystemIdentifier(SmartApplianceEnabler.class.getSimpleName())
            );

    DeviceType type = new SmartApplianceEnablerDeviceType();

    DeviceDetails details =
            new DeviceDetails(
                    SmartApplianceEnabler.class.getSimpleName(),
                    new ManufacturerDetails(SmartApplianceEnabler.MANUFACTURER_NAME, URI.create(SmartApplianceEnabler.MANUFACTURER_URI)),
                    new ModelDetails(
                            SmartApplianceEnabler.class.getSimpleName(),
                            SmartApplianceEnabler.DESCRIPTION,
                            SmartApplianceEnabler.VERSION,
                            URI.create(SmartApplianceEnabler.MODEL_URI)
                    )
            );

    return new LocalDevice(identity, type, details, (Icon) null, (LocalService) null);
}
 
Example #4
Source File: AnnotationLocalServiceBinder.java    From DroidDLNA with GNU General Public License v3.0 6 votes vote down vote up
public LocalService read(Class<?> clazz, ServiceId id, ServiceType type,
                               boolean supportsQueryStateVariables, Set<Class> stringConvertibleTypes)
        throws LocalServiceBindingException {

    Map<StateVariable, StateVariableAccessor> stateVariables = readStateVariables(clazz, stringConvertibleTypes);
    Map<Action, ActionExecutor> actions = readActions(clazz, stateVariables, stringConvertibleTypes);

    // Special treatment of the state variable querying action
    if (supportsQueryStateVariables) {
        actions.put(new QueryStateVariableAction(), new QueryStateVariableExecutor());
    }

    try {
        return new LocalService(type, id, actions, stateVariables, stringConvertibleTypes, supportsQueryStateVariables);

    } catch (ValidationException ex) {
        log.severe("Could not validate device model: " + ex.toString());
        for (ValidationError validationError : ex.getErrors()) {
            log.severe(validationError.toString());
        }
        throw new LocalServiceBindingException("Validation of model failed, check the log");
    }
}
 
Example #5
Source File: Service.java    From TVRemoteIME with GNU General Public License v2.0 6 votes vote down vote up
public Service(ServiceType serviceType, ServiceId serviceId,
               Action<S>[] actions, StateVariable<S>[] stateVariables) throws ValidationException {

    this.serviceType = serviceType;
    this.serviceId = serviceId;

    if (actions != null) {
        for (Action action : actions) {
            this.actions.put(action.getName(), action);
            action.setService(this);
        }
    }

    if (stateVariables != null) {
        for (StateVariable stateVariable : stateVariables) {
            this.stateVariables.put(stateVariable.getName(), stateVariable);
            stateVariable.setService(this);
        }
    }

}
 
Example #6
Source File: MutableDevice.java    From DroidDLNA with GNU General Public License v3.0 5 votes vote down vote up
public Service[] createServices(Device prototype) throws ValidationException {
    Service[] services = prototype.newServiceArray(this.services.size());
    int i = 0;
    for (MutableService service : this.services) {
        services[i++] = service.build(prototype);
    }
    return services;
}
 
Example #7
Source File: MutableDevice.java    From TVRemoteIME with GNU General Public License v2.0 5 votes vote down vote up
public Service[] createServices(Device prototype) throws ValidationException {
    Service[] services = prototype.newServiceArray(this.services.size());
    int i = 0;
    for (MutableService service : this.services) {
        services[i++] = service.build(prototype);
    }
    return services;
}
 
Example #8
Source File: MutableService.java    From TVRemoteIME with GNU General Public License v2.0 5 votes vote down vote up
public Service build(Device prototype) throws ValidationException {
    return prototype.newInstance(
            serviceType, serviceId,
            descriptorURI, controlURI, eventSubscriptionURI,
            createActions(),
            createStateVariables()
    );
}
 
Example #9
Source File: LocalDevice.java    From DroidDLNA with GNU General Public License v3.0 5 votes vote down vote up
@Override
public LocalDevice newInstance(UDN udn, UDAVersion version, DeviceType type, DeviceDetails details,
                               Icon[] icons, LocalService[] services, List<LocalDevice> embeddedDevices)
        throws ValidationException {
    return new LocalDevice(
            new DeviceIdentity(udn, getIdentity().getMaxAgeSeconds()),
            version, type, details, icons,
            services,
            embeddedDevices.size() > 0 ? embeddedDevices.toArray(new LocalDevice[embeddedDevices.size()]) : null
    );
}
 
Example #10
Source File: LocalDevice.java    From DroidDLNA with GNU General Public License v3.0 5 votes vote down vote up
@Override
public LocalService newInstance(ServiceType serviceType, ServiceId serviceId,
                                URI descriptorURI, URI controlURI, URI eventSubscriptionURI,
                                Action<LocalService>[] actions, StateVariable<LocalService>[] stateVariables) throws ValidationException {
    return new LocalService(
            serviceType, serviceId,
            actions, stateVariables
    );
}
 
Example #11
Source File: RemoteService.java    From TVRemoteIME with GNU General Public License v2.0 5 votes vote down vote up
public RemoteService(ServiceType serviceType, ServiceId serviceId,
                     URI descriptorURI, URI controlURI, URI eventSubscriptionURI,
                     Action<RemoteService>[] actions, StateVariable<RemoteService>[] stateVariables) throws ValidationException {
    super(serviceType, serviceId, actions, stateVariables);

    this.descriptorURI = descriptorURI;
    this.controlURI = controlURI;
    this.eventSubscriptionURI = eventSubscriptionURI;

    List<ValidationError> errors = validateThis();
    if (errors.size() > 0) {
        throw new ValidationException("Validation of device graph failed, call getErrors() on exception", errors);
    }
}
 
Example #12
Source File: RemoteDevice.java    From DroidDLNA with GNU General Public License v3.0 5 votes vote down vote up
@Override
public RemoteDevice newInstance(UDN udn, UDAVersion version, DeviceType type, DeviceDetails details,
                                Icon[] icons, RemoteService[] services,
                                List<RemoteDevice> embeddedDevices) throws ValidationException {
    return new RemoteDevice(
            new RemoteDeviceIdentity(udn, getIdentity()),
            version, type, details, icons,
            services,
            embeddedDevices.size() > 0 ? embeddedDevices.toArray(new RemoteDevice[embeddedDevices.size()]) : null
    );
}
 
Example #13
Source File: RegistryItems.java    From DroidDLNA with GNU General Public License v3.0 5 votes vote down vote up
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);
    }
}
 
Example #14
Source File: RemoteDevice.java    From TVRemoteIME with GNU General Public License v2.0 5 votes vote down vote up
@Override
public RemoteService newInstance(ServiceType serviceType, ServiceId serviceId,
                                 URI descriptorURI, URI controlURI, URI eventSubscriptionURI,
                                 Action<RemoteService>[] actions, StateVariable<RemoteService>[] stateVariables) throws ValidationException {
    return new RemoteService(
            serviceType, serviceId,
            descriptorURI, controlURI, eventSubscriptionURI,
            actions, stateVariables
    );
}
 
Example #15
Source File: LocalDevice.java    From TVRemoteIME with GNU General Public License v2.0 5 votes vote down vote up
@Override
public LocalDevice newInstance(UDN udn, UDAVersion version, DeviceType type, DeviceDetails details,
                               Icon[] icons, LocalService[] services, List<LocalDevice> embeddedDevices)
        throws ValidationException {
    return new LocalDevice(
            new DeviceIdentity(udn, getIdentity().getMaxAgeSeconds()),
            version, type, details, icons,
            services,
            embeddedDevices.size() > 0 ? embeddedDevices.toArray(new LocalDevice[embeddedDevices.size()]) : null
    );
}
 
Example #16
Source File: MediaServer.java    From DroidDLNA with GNU General Public License v3.0 5 votes vote down vote up
public MediaServer(Context context ) throws ValidationException {
    mContext = context;
    DeviceType type = new UDADeviceType(deviceType, version);

    DeviceDetails details = new DeviceDetails(SettingActivity.getDeviceName(context) + " ("
            + android.os.Build.MODEL + ")", new ManufacturerDetails(
            android.os.Build.MANUFACTURER), new ModelDetails(android.os.Build.MODEL,
            Utils.DMS_DESC, "v1"));

    LocalService service = new AnnotationLocalServiceBinder()
            .read(ContentDirectoryService.class);

    service.setManager(new DefaultServiceManager<ContentDirectoryService>(service,
            ContentDirectoryService.class));

    udn = UpnpUtil.uniqueSystemIdentifier("msidms");

    localDevice = new LocalDevice(new DeviceIdentity(udn), type, details, createDefaultDeviceIcon(), service);

    Log.v(LOGTAG, "MediaServer device created: ");
    Log.v(LOGTAG, "friendly name: " + details.getFriendlyName());
    Log.v(LOGTAG, "manufacturer: " + details.getManufacturerDetails().getManufacturer());
    Log.v(LOGTAG, "model: " + details.getModelDetails().getModelName());

    // start http server
    try {
        new HttpServer(PORT);
    } catch (IOException ioe) {
        System.err.println("Couldn't start server:\n" + ioe);
        System.exit(-1);
    }

    Log.v(LOGTAG, "Started Http Server on port " + PORT);
}
 
Example #17
Source File: LocalDevice.java    From TVRemoteIME with GNU General Public License v2.0 5 votes vote down vote up
@Override
public LocalService newInstance(ServiceType serviceType, ServiceId serviceId,
                                URI descriptorURI, URI controlURI, URI eventSubscriptionURI,
                                Action<LocalService>[] actions, StateVariable<LocalService>[] stateVariables) throws ValidationException {
    return new LocalService(
            serviceType, serviceId,
            actions, stateVariables
    );
}
 
Example #18
Source File: RemoteDevice.java    From DroidDLNA with GNU General Public License v3.0 5 votes vote down vote up
@Override
public RemoteService newInstance(ServiceType serviceType, ServiceId serviceId,
                                 URI descriptorURI, URI controlURI, URI eventSubscriptionURI,
                                 Action<RemoteService>[] actions, StateVariable<RemoteService>[] stateVariables) throws ValidationException {
    return new RemoteService(
            serviceType, serviceId,
            descriptorURI, controlURI, eventSubscriptionURI,
            actions, stateVariables
    );
}
 
Example #19
Source File: LocalDevice.java    From TVRemoteIME with GNU General Public License v2.0 4 votes vote down vote up
public LocalDevice(DeviceIdentity identity, DeviceType type, DeviceDetails details,
                   Icon icon, LocalService[] services, LocalDevice[] embeddedDevices) throws ValidationException {
    super(identity, type, details, new Icon[]{icon}, services, embeddedDevices);
    this.deviceDetailsProvider = null;
}
 
Example #20
Source File: LocalDevice.java    From TVRemoteIME with GNU General Public License v2.0 4 votes vote down vote up
public LocalDevice(DeviceIdentity identity, DeviceType type, DeviceDetails details,
                   Icon icon, LocalService service, LocalDevice embeddedDevice) throws ValidationException {
    super(identity, type, details, new Icon[]{icon}, new LocalService[]{service}, new LocalDevice[]{embeddedDevice});
    this.deviceDetailsProvider = null;
}
 
Example #21
Source File: LocalDevice.java    From TVRemoteIME with GNU General Public License v2.0 4 votes vote down vote up
public LocalDevice(DeviceIdentity identity, DeviceType type, DeviceDetails details,
                   Icon icon, LocalService service) throws ValidationException {
    super(identity, type, details, new Icon[]{icon}, new LocalService[]{service});
    this.deviceDetailsProvider = null;
}
 
Example #22
Source File: RemoteDevice.java    From DroidDLNA with GNU General Public License v3.0 4 votes vote down vote up
public RemoteDevice(RemoteDeviceIdentity identity, DeviceType type, DeviceDetails details,
                   Icon[] icons, RemoteService[] services) throws ValidationException {
    super(identity, type, details, icons, services);
}
 
Example #23
Source File: Device.java    From DroidDLNA with GNU General Public License v3.0 4 votes vote down vote up
public abstract D newInstance(UDN udn, UDAVersion version, DeviceType type, DeviceDetails details,
Icon[] icons, S[] services, List<D> embeddedDevices) throws ValidationException;
 
Example #24
Source File: LocalDevice.java    From TVRemoteIME with GNU General Public License v2.0 4 votes vote down vote up
public LocalDevice(DeviceIdentity identity, DeviceType type, DeviceDetailsProvider deviceDetailsProvider,
                   Icon[] icons, LocalService service, LocalDevice embeddedDevice) throws ValidationException {
    super(identity, type, null, icons, new LocalService[]{service}, new LocalDevice[]{embeddedDevice});
    this.deviceDetailsProvider = deviceDetailsProvider;
}
 
Example #25
Source File: LocalDevice.java    From TVRemoteIME with GNU General Public License v2.0 4 votes vote down vote up
public LocalDevice(DeviceIdentity identity, DeviceType type, DeviceDetails details,
                   Icon[] icons, LocalService[] services) throws ValidationException {
    super(identity, type, details, icons, services);
    this.deviceDetailsProvider = null;
}
 
Example #26
Source File: LocalDevice.java    From TVRemoteIME with GNU General Public License v2.0 4 votes vote down vote up
public LocalDevice(DeviceIdentity identity, DeviceType type, DeviceDetails details,
                   Icon[] icons, LocalService[] services, LocalDevice[] embeddedDevices) throws ValidationException {
    super(identity, type, details, icons, services, embeddedDevices);
    this.deviceDetailsProvider = null;
}
 
Example #27
Source File: LocalDevice.java    From TVRemoteIME with GNU General Public License v2.0 4 votes vote down vote up
public LocalDevice(DeviceIdentity identity, UDAVersion version, DeviceType type, DeviceDetails details,
                   Icon[] icons, LocalService[] services, LocalDevice[] embeddedDevices) throws ValidationException {
    super(identity, version, type, details, icons, services, embeddedDevices);
    this.deviceDetailsProvider = null;
}
 
Example #28
Source File: LocalDevice.java    From TVRemoteIME with GNU General Public License v2.0 4 votes vote down vote up
public LocalDevice(DeviceIdentity identity, UDAVersion version, DeviceType type, DeviceDetailsProvider deviceDetailsProvider,
                   Icon[] icons, LocalService[] services, LocalDevice[] embeddedDevices) throws ValidationException {
    super(identity, version, type, null, icons, services, embeddedDevices);
    this.deviceDetailsProvider = deviceDetailsProvider;
}
 
Example #29
Source File: LocalDevice.java    From DroidDLNA with GNU General Public License v3.0 4 votes vote down vote up
public LocalDevice(DeviceIdentity identity, DeviceType type, DeviceDetails details,
                   LocalService[] services) throws ValidationException {
    super(identity, type, details, null, services);
    this.deviceDetailsProvider = null;
}
 
Example #30
Source File: LocalDevice.java    From TVRemoteIME with GNU General Public License v2.0 4 votes vote down vote up
public LocalDevice(DeviceIdentity identity, DeviceType type, DeviceDetails details,
                   Icon[] icons, LocalService service, LocalDevice embeddedDevice) throws ValidationException {
    super(identity, type, details, icons, new LocalService[]{service}, new LocalDevice[]{embeddedDevice});
    this.deviceDetailsProvider = null;
}