Esempio n. 1
0
  public static UUID getIndexId(
      int variant,
      EntityRef connectingEntity,
      String connectionType,
      String connectedEntityType,
      ConnectedEntityRef... pairedConnections) {

    switch (variant) {
      case ALL:
        if (connectionsNull(pairedConnections)) {
          return connectingEntity.getUuid();
        } else {
          return getIndexId(connectingEntity, null, null, pairedConnections);
        }

      case BY_ENTITY_TYPE:
        return getIndexId(connectingEntity, null, connectedEntityType, pairedConnections);

      case BY_CONNECTION_TYPE:
        return getIndexId(connectingEntity, connectionType, null, pairedConnections);

      case BY_CONNECTION_AND_ENTITY_TYPE:
        return getIndexId(connectingEntity, connectionType, connectedEntityType, pairedConnections);
    }

    return connectingEntity.getUuid();
  }
Esempio n. 2
0
  public static UUID getIndexId(
      EntityRef connectingEntity,
      String connectionType,
      String connectedEntityType,
      ConnectedEntityRef... pairedConnections) {

    UUID uuid = null;
    try {

      if (connectionsNull(pairedConnections)
          && ((connectionType == null) && (connectedEntityType == null))) {
        return connectingEntity.getUuid();
      }

      ByteArrayOutputStream byteStream =
          new ByteArrayOutputStream(16 + (32 * pairedConnections.length));

      byteStream.write(uuidToBytesNullOk(connectingEntity.getUuid()));

      for (ConnectedEntityRef connection : pairedConnections) {
        String type = connection.getConnectionType();
        UUID id = connection.getUuid();

        byteStream.write(ascii(StringUtils.lowerCase(type)));
        byteStream.write(uuidToBytesNullOk(id));
      }

      if (connectionType == null) {
        connectionType = NULL_ENTITY_TYPE;
      }
      if (connectedEntityType == null) {
        connectedEntityType = NULL_ENTITY_TYPE;
      }

      byteStream.write(ascii(StringUtils.lowerCase(connectionType)));
      byteStream.write(ascii(StringUtils.lowerCase(connectedEntityType)));

      byte[] raw_id = byteStream.toByteArray();

      logger.info("raw connection index id: " + Hex.encodeHexString(raw_id));

      uuid = UUID.nameUUIDFromBytes(raw_id);

      logger.info("connection index uuid: " + uuid);
    } catch (IOException e) {
      logger.error("Unable to create connection index UUID", e);
    }
    return uuid;
  }
  /* adds a single device for delivery - used only by tests */
  public void addDevice(EntityRef notification, EntityRef device) throws Exception {

    String jobQueueName = getJobQueueName(notification);
    Message message = new Message();
    message.setObjectProperty(MESSAGE_PROPERTY_DEVICE_UUID, device.getUuid());
    sm.getQueueManager().postToQueue(jobQueueName, message);
  }
 public Notification getSourceNotification(EntityRef receipt) throws Exception {
   Receipt r = em.get(receipt.getUuid(), Receipt.class);
   return em.get(r.getNotificationUUID(), Notification.class);
 }
 public String getJobQueueName(EntityRef notification) {
   return "notifications/" + notification.getUuid();
 }
Esempio n. 6
0
 /** @return */
 public UUID getConnectingEntityId() {
   if (connectingEntity == null) {
     return null;
   }
   return connectingEntity.getUuid();
 }
Esempio n. 7
0
 /** @return */
 public String getConnectingEntityType() {
   if (connectingEntity == null) {
     return null;
   }
   return connectingEntity.getType();
 }