budget/src/main/java/budget/backend/stores/TagStore.java
@Override
  public boolean readFile(BufferedReader in) throws RuntimeException {

    // going from top to bottom, for all Tags, create them using their parents
    // (which always comes before the descendant and add them to the structure)
    boolean success = true;
    //TODO: decrypt data

    try {
      String line = in.readLine();
      if ((line == null) || (line.compareTo("tRoot") != 0)) 
        throw new IOException("Non-readable file");
      else {
        line = in.readLine();
      }
      //each line is a composed string of a Tag instance
      while (line != null){
        //split the line into components
        String[] parts = line.split(";");
        //find parent, check for null
        if (parts.length == 3){
          iTag parent = map.get(parts[2]);
          if (parent == null) success = false;
          //create new Tag instance
          Tag t = new Tag(parent, new LinkedList<Tag>(), parts[0], parts[1]);
          dataChecker.verifyTag(t);
          //add t as a descendant of the parent
          parent.addDescendant(t);
          map.put(t.getId(), t);
        }
        line = in.readLine();
      }
    } catch (Exception e) {
      System.out.println(e.getMessage());
      success = false;
    }
    return success;
  }
/**
   * Read data from a file, that is encrypted with the user's private key.
   */
Read data from a file, that is encrypted with the user's private key.
Read data from a file that is encrypted with the user ' s private key .
@Override
  public boolean readFile(BufferedReader in) throws RuntimeException {
    boolean success = true;
    try {
      String line = in.readLine();
      if ((line == null) || (line.compareTo("tRoot") != 0)) 
        throw new IOException("Non-readable file");
      else {
        line = in.readLine();
      }
      while (line != null){
        String[] parts = line.split(";");
        if (parts.length == 3){
          iTag parent = map.get(parts[2]);
          if (parent == null) success = false;
          Tag t = new Tag(parent, new LinkedList<Tag>(), parts[0], parts[1]);
          dataChecker.verifyTag(t);
          parent.addDescendant(t);
          map.put(t.getId(), t);
        }
        line = in.readLine();
      }
    } catch (Exception e) {
      System.out.println(e.getMessage());
      success = false;
    }
    return success;
  }
@ Override public boolean readFile ( BufferedReader in ) throws RuntimeException { boolean success = true ; try { String line = in . readLine ( ) ; if ( ( line == null ) || ( line . compareTo ( "tRoot" ) != 0 ) ) throw new IOException ( "Non-readable file" ) ; else { line = in . readLine ( ) ; } while ( line != null ) { String [ ] parts = line . split ( ";" ) ; if ( parts . length == 3 ) { iTag parent = map . get ( parts [ 2 ] ) ; if ( parent == null ) success = false ; Tag t = new Tag ( parent , new LinkedList < Tag > ( ) , parts [ 0 ] , parts [ 1 ] ) ; dataChecker . verifyTag ( t ) ; parent . addDescendant ( t ) ; map . put ( t . getId ( ) , t ) ; } line = in . readLine ( ) ; } } catch ( Exception e ) { System . out . println ( e . getMessage ( ) ) ; success = false ; } return success ; }
Read data from a file, that is encrypted with the user's private key.
Read data from a file that is encrypted with the user ' s private key .
// going from top to bottom, for all Tags, create them using their parents // (which always comes before the descendant and add them to the structure) //TODO: decrypt data //each line is a composed string of a Tag instance //split the line into components //find parent, check for null //create new Tag instance //add t as a descendant of the parent