Exemplo n.º 1
0
  /**
   * Retrieves existing instances that qualify to be a target of this property, and instances that
   * already are a target of the property and anchor! Returns an array with first the range class
   * name, then those objects already in the range, then a 'null', and then all eligible objects.
   *
   * @param user user id
   * @param name property name
   * @param anchor Unique ID of Anchor
   * @param type session type
   * @param key browsing session id (null if session type is EDIT)
   * @return ExistingInstances, holds all necessary information about object that already are or
   *     could be in the range, empty if session expired, or null if error occurred.
   */
  public ExistingInstances getInstances(
      String user, String name, String anchor, int type, String key) {
    try {
      if (!userMap.containsKey(user)) {
        ExistingInstances result = new ExistingInstances();
        result.setRange(null, null);
        return result;
      }

      LiberSession session = userMap.get(user);
      synchronized (session) {
        session.setLastUpdated();
        ExistingInstances e = session.getRangeInstances(name, anchor, type, key);
        return e;
      }
    } catch (Exception e) {
      e.printStackTrace();
      return null;
    }
  }