public ThingState registerThing(Jid registry, Thing thing) throws NotConnectedException, InterruptedException, NoResponseException, XMPPErrorException, IoTClaimedException { final XMPPConnection connection = connection(); IoTRegister iotRegister = new IoTRegister(thing.getMetaTags(), thing.getNodeInfo(), thing.isSelfOwened()); iotRegister.setTo(registry); IQ result = connection.createStanzaCollectorAndSend(iotRegister).nextResultOrThrow(); if (result instanceof IoTClaimed) { IoTClaimed iotClaimedResult = (IoTClaimed) result; throw new IoTClaimedException(iotClaimedResult); } ThingState state = getStateFor(thing.getNodeInfo()); state.setRegistry(registry.asBareJid()); interactWithRegistry(registry); IoTDataManager.getInstanceFor(connection).installThing(thing); IoTControlManager.getInstanceFor(connection).installThing(thing); return state; }
public ThingState registerThing(Jid registry, Thing thing) throws NotConnectedException, InterruptedException, NoResponseException, XMPPErrorException, IoTClaimedException { final XMPPConnection connection = connection(); IoTRegister iotRegister = new IoTRegister(thing.getMetaTags(), thing.getNodeInfo(), thing.isSelfOwened()); iotRegister.setTo(registry); IQ result = connection.createStanzaCollectorAndSend(iotRegister).nextResultOrThrow(); if (result instanceof IoTClaimed) { IoTClaimed iotClaimedResult = (IoTClaimed) result; throw new IoTClaimedException(iotClaimedResult); } ThingState state = getStateFor(thing.getNodeInfo()); state.setRegistry(registry.asBareJid()); interactWithRegistry(registry); IoTDataManager.getInstanceFor(connection).installThing(thing); IoTControlManager.getInstanceFor(connection).installThing(thing); return state; }