Пример #1
0
  @Override
  public void refreshStatus() {
    super.refreshStatus();

    // refresh coordinates from system
    String cooString = this.getSystemProperty(CP_COORDINATE);

    InMemoSharkKB imkb = null;
    imkb = new InMemoSharkKB();

    XMLSerializer xs = new XMLSerializer();
    try {
      // create in memory copy and use it
      this.setContextCoordinates(xs.deserializeContextCoordinates(imkb, cooString));
    } catch (SharkKBException ex) {
      L.w(
          "cannot deserialize context coordinates from persistent storage: " + ex.getMessage(),
          this);
    }

    // info folder
    String foldernames = this.getSystemProperty(INFO_FOLDERNAME_PROPERTY);

    if (foldernames != null) {
      this.infoFolder = Util.string2Vector(foldernames, DELIMITER);

      if (this.infoFolder != null) {
        // recreate Information
        Enumeration<String> infoFoldernameEnum = this.infoFolder.elements();
        while (infoFoldernameEnum.hasMoreElements()) {
          String infoFoldername = infoFoldernameEnum.nextElement();

          // create property holder
          FSPropertyHolder fsph = new FSPropertyHolder(infoFoldername);

          // create cp with this propery holder
          FSInformation fsInfo;
          try {
            fsInfo = new FSInformation(fsph);
            fsInfo.refreshStatus();
            // add it to memory
            super.putInformation(fsInfo);
          } catch (SharkKBException ex) {
            //
          }
        }
      }
    } else {
      L.w(
          "strange: there was a cp read from file without information - that cp shouldn't exist: TODO",
          this);
    }
  }
Пример #2
0
  @Override
  public void removeInformation(Information info) {
    // this.infoFolder.remove(this.getInfoFoldername());
    super.removeInformation(info);

    FSInformation fsinfo = (FSInformation) info;

    FSSharkKB.removeFSStorage(fsinfo.getPath());

    this.infoFolder.remove(fsinfo.getPath());
    if (this.information.isEmpty()) {
      File file = new File(getCPFildername() + "/.sharkfw_st_systemProperties");
      file.delete();
    } else {
      this.persist();
    }
  }
Пример #3
0
  @Override
  public FSInformation addInformation() {
    FSPropertyHolder fsph = FSSharkKB.createFSPropertyHolder(this.getInfoFoldername());

    FSInformation newInfo = null;
    try {
      newInfo = new FSInformation(fsph);
    } catch (SharkKBException ex) {
      L.w("couldn't restore information from file", this);
    }
    super.putInformation(newInfo);

    // remember folder
    this.infoFolder.add(fsph.getFolderName());

    newInfo.persist();
    this.persist();

    return newInfo;
  }
Пример #4
0
  /** write status into system properties */
  @Override
  public void persist() {
    super.persist();

    XMLSerializer xs = new XMLSerializer();
    try {
      String cooString = xs.serializeSharkCS(this.getContextCoordinates());

      // save
      this.setSystemProperty(CP_COORDINATE, cooString);

    } catch (SharkKBException ex) {
      L.w(ex.getMessage(), this);
    }

    if (this.infoFolder != null) {
      // info folder
      String foldernames = Util.enumeration2String(this.infoFolder.elements(), DELIMITER);

      if (foldernames != null && foldernames.length() > 0) {
        this.setSystemProperty(INFO_FOLDERNAME_PROPERTY, foldernames);
      }
    }
  }