Package org.waveprotocol.box.server.robots

Examples of org.waveprotocol.box.server.robots.RobotCapabilities


  public void testFetchCapabilities() throws Exception {
    when(connection.get(TEST_CAPABILITIES_ENDPOINT)).thenReturn(CAPABILITIES_XML);

    RobotAccountData accountData = connector.fetchCapabilities(ROBOT_ACCOUNT, "");

    RobotCapabilities capabilities = accountData.getCapabilities();
    assertEquals("Expected capabilities hash as specified in the xml", CAPABILITIES_HASH,
        capabilities.getCapabilitiesHash());
    assertEquals("Expected protocol version as specified in the xml", ProtocolVersion.V2_2,
        capabilities.getProtocolVersion());
    Map<EventType, Capability> capabilitiesMap = capabilities.getCapabilitiesMap();
    assertTrue("Expected capabilities as specified in the xml", capabilitiesMap.size() == 2);
    assertTrue("Expected capabilities as specified in the xml",
        capabilitiesMap.containsKey(EventType.WAVELET_SELF_ADDED));
    assertTrue("Expected capabilities as specified in the xml",
        capabilitiesMap.containsKey(EventType.OPERATION_ERROR));
View Full Code Here


    capabilities.put(EventType.BLIP_SUBMITTED,
        new Capability(EventType.BLIP_SUBMITTED,
            CollectionUtils.newArrayList(Context.SIBLINGS, Context.PARENT), "blah"));

    robotAccountWithCapabilities =
        new RobotAccountDataImpl(ROBOT_ID, "example.com", "secret", new RobotCapabilities(
            capabilities, "FAKEHASH", ProtocolVersion.DEFAULT), true);

    humanAccount = new HumanAccountDataImpl(HUMAN_ID);
    humanAccountWithDigest = new HumanAccountDataImpl(HUMAN_ID,
        new PasswordDigest("password".toCharArray()));
View Full Code Here

   */
  public RobotAccountData fetchCapabilities(RobotAccountData account, String activeApiUrl)
      throws CapabilityFetchException {
    RobotCapabilitiesParser parser = new RobotCapabilitiesParser(
        account.getUrl() + Robot.CAPABILITIES_URL, connection, activeApiUrl);
    RobotCapabilities capabilities = new RobotCapabilities(
        parser.getCapabilities(), parser.getCapabilitiesHash(), parser.getProtocolVersion());

    return new RobotAccountDataImpl(account.getId(), account.getUrl(), account.getConsumerSecret(),
        capabilities, account.isVerified());
  }
View Full Code Here

      throw new InvalidRequestException("Can't exectute robot.notify for unknown robot "
          + robotAccountId);
    }

    RobotAccountData robotAccountData = account.asRobot();
    RobotCapabilities capabilities = robotAccountData.getCapabilities();
    if (capabilities != null && capabilitiesHash.equals(capabilities.getCapabilitiesHash())) {
      // No change in capabilities indicated
      context.constructResponse(operation, Maps.<ParamsProperty, Object> newHashMap());
      return;
    }
View Full Code Here

                + ") at version " + wavelet.getVersionAfterDeltas(), e);
        return;
      }
    }

    RobotCapabilities capabilities = account.getCapabilities();
    EventMessageBundle messages =
        eventGenerator.generateEvents(wavelet, capabilities.getCapabilitiesMap(),
            converterManager.getEventDataConverter(capabilities.getProtocolVersion()));

    if (messages.getEvents().isEmpty()) {
      // No events were generated, we are done
      LOG.info(robotName + ": no events were generated");
      return;
    }

    LOG.info(robotName + ": sending events");
    List<OperationRequest> response =
        connector.sendMessageBundle(messages, this, capabilities.getProtocolVersion());
    LOG.info(robotName + ": received operations");

    operationApplicator.applyOperations(
        response, wavelet.getSnapshotAfterDeltas(), wavelet.getVersionAfterDeltas(), account);
  }
View Full Code Here

    capabilities.put(EventType.BLIP_SUBMITTED,
        new Capability(EventType.BLIP_SUBMITTED,
            CollectionUtils.newArrayList(Context.SIBLINGS, Context.PARENT), "blah"));
   
    updatedRobotAccount =
        new RobotAccountDataImpl(ROBOT_ID, "example.com", "secret", new RobotCapabilities(
            capabilities, "FAKEHASH", ProtocolVersion.DEFAULT), true);
    convertedRobot = new HumanAccountDataImpl(ROBOT_ID);
  }
View Full Code Here

  }

  private AccountData objectToRobot(ParticipantId id, DBObject robot) {
    String url = (String) robot.get(ROBOT_URL_FIELD);
    String secret = (String) robot.get(ROBOT_SECRET_FIELD);
    RobotCapabilities capabilities =
        objectToCapabilities((DBObject) robot.get(ROBOT_CAPABILITIES_FIELD));
    boolean verified = (Boolean) robot.get(ROBOT_VERIFIED_FIELD);
    return new RobotAccountDataImpl(id, url, secret, capabilities, verified);
  }
View Full Code Here

    String capabilitiesHash = (String) object.get(CAPABILITIES_HASH_FIELD);
    ProtocolVersion version =
        ProtocolVersion.valueOf((String) object.get(CAPABILITIES_VERSION_FIELD));

    return new RobotCapabilities(capabilities, capabilitiesHash, version);
  }
View Full Code Here

    return PasswordDigest.from(data.getSalt().toByteArray(), data.getDigest().toByteArray());
  }

  private static RobotAccountData deserialize(String account_id, ProtoRobotAccountData data) {
    ParticipantId id = ParticipantId.ofUnsafe(account_id);
    RobotCapabilities capabilities = null;
    if (data.hasRobotCapabilities()) {
      capabilities = deserialize(data.getRobotCapabilities());
    }
    return new RobotAccountDataImpl(id, data.getUrl(), data.getConsumerSecret(),
        capabilities, data.getIsVerified());
View Full Code Here

    Map<EventType, Capability> capabilities = Maps.newHashMap();
    for (ProtoRobotCapability capabilityData: data.getCapabilityList()) {
      Capability capability = deserialize(capabilityData);
      capabilities.put(capability.getEventType(), capability);
    }
    return new RobotCapabilities(capabilities, data.getCapabilitiesHash(),
        ProtocolVersion.fromVersionString(data.getProtocolVersion()));
  }
View Full Code Here

TOP

Related Classes of org.waveprotocol.box.server.robots.RobotCapabilities

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.