+ @Override
+ public String startLink() throws Error.Failure {
+ try {
+ final URI deviceLinkUri = c.getNewProvisioningDeviceLinkUri();
+ return deviceLinkUri.toString();
+ } catch (TimeoutException | IOException e) {
+ throw new SignalControl.Error.Failure(e.getClass().getSimpleName() + " " + e.getMessage());
+ }
+ }
+
+ @Override
+ public String finishLink(String deviceLinkUri, final String newDeviceName) throws Error.Failure {
+ try {
+ final var provisioningManager = c.getProvisioningManagerFor(new URI(deviceLinkUri));
+ return provisioningManager.finishDeviceLink(newDeviceName);
+ } catch (TimeoutException | IOException | UserAlreadyExists | URISyntaxException e) {
+ throw new SignalControl.Error.Failure(e.getClass().getSimpleName() + " " + e.getMessage());
+ }
+ }
+