Exemplo n.º 1
0
 public String getFirstPairedConnectionType() {
   ConnectedEntityRef pairedConnection = getFirstPairedConnection();
   if (pairedConnection != null) {
     return pairedConnection.getConnectionType();
   }
   return null;
 }
Exemplo n.º 2
0
 public UUID getFirstPairedConnectedEntityId() {
   ConnectedEntityRef pairedConnection = getFirstPairedConnection();
   if (pairedConnection != null) {
     return pairedConnection.getUuid();
   }
   return null;
 }
Exemplo n.º 3
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;
  }
Exemplo n.º 4
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;
  }
Exemplo n.º 5
0
 /** @return */
 @Override
 public String getConnectionType() {
   if (connectedEntity == null) {
     return null;
   }
   return connectedEntity.getConnectionType();
 }
Exemplo n.º 6
0
 /** @return */
 public UUID getConnectedEntityId() {
   return connectedEntity.getUuid();
 }
Exemplo n.º 7
0
 /** @return */
 public String getConnectedEntityType() {
   if (connectedEntity == null) {
     return null;
   }
   return connectedEntity.getType();
 }