Пример #1
0
  /**
   * Initialises a new editing session.
   *
   * @param user user id
   * @param data Data provided about resource
   * @return AnchorInfo[] containing the feedback text.
   */
  public AnchorInfo[] initSession(String user, InstanceData data) {
    try {
      LiberSession session = userMap.get(user);

      Runtime r = Runtime.getRuntime();
      r.gc(); // FORCES GARBAGE COLLECTION
      r.runFinalization();

      synchronized (session) {
        session.setLastUpdated();
        return session.init(data); // initialise the session and return the text
      }
    } catch (Exception e) {
      e.printStackTrace();
      return new AnchorInfo[0];
    }
  }
Пример #2
0
  /**
   * Initialises a new browsing session, creating a new session for this user.
   *
   * @param user user id
   * @param resource Resource id
   * @param type Type of session (edit, query, browse)
   * @return AnchorInfo[] containing the feedback text.
   */
  public AnchorInfo[] initSession(String user, String resource, int type) {
    try {
      if (type == LiberSession.BROWSE) // make a new user session if this is the browse tab
      userMap.put(
            user, new LiberSession(ontology, user, null, resource.replaceAll("\"", ""), type));
      else if (!userMap.containsKey(user)) return null;

      LiberSession session = userMap.get(user);
      Runtime r = Runtime.getRuntime();
      r.gc(); // FORCES GARBAGE COLLECTION
      r.runFinalization();

      synchronized (session) {
        session.setLastUpdated();
        return session.init(
            resource.replaceAll("\"", "")); // initialise the session and return the text
      }
    } catch (Exception e) {
      e.printStackTrace();
      return new AnchorInfo[0];
    }
  }