예제 #1
0
  public static UUID getId(
      EntityRef connectingEntity,
      ConnectedEntityRef connectedEntity,
      ConnectedEntityRef... pairedConnections) {
    UUID uuid = null;
    try {

      if (connectionsNull(pairedConnections) && connectionsNull(connectedEntity)) {
        return connectingEntity.getUuid();
      }

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

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

      for (ConnectedEntityRef connection : pairedConnections) {
        String connectionType = connection.getConnectionType();
        UUID connectedEntityID = connection.getUuid();

        byteStream.write(ascii(StringUtils.lowerCase(connectionType)));
        byteStream.write(uuidToBytesNullOk(connectedEntityID));
      }

      String connectionType = connectedEntity.getConnectionType();
      if (connectionType == null) {
        connectionType = NULL_ENTITY_TYPE;
      }

      UUID connectedEntityID = connectedEntity.getUuid();

      byteStream.write(ascii(StringUtils.lowerCase(connectionType)));
      byteStream.write(uuidToBytesNullOk(connectedEntityID));

      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 UUID", e);
    }
    return uuid;
  }
예제 #2
0
 public UUID getFirstPairedConnectedEntityId() {
   ConnectedEntityRef pairedConnection = getFirstPairedConnection();
   if (pairedConnection != null) {
     return pairedConnection.getUuid();
   }
   return null;
 }
예제 #3
0
  public static boolean connectionsNull(ConnectedEntityRef... pairedConnections) {
    if ((pairedConnections == null) || (pairedConnections.length == 0)) {
      return true;
    }

    for (ConnectedEntityRef pairedConnection : pairedConnections) {
      if (pairedConnection == null
          || pairedConnection.getUuid() == null
          || pairedConnection.getUuid().equals(NULL_ID)) {
        return true;
      }
    }

    return false;
  }
예제 #4
0
 /** @return */
 public UUID getConnectedEntityId() {
   return connectedEntity.getUuid();
 }