Exemplo n.º 1
0
 /**
  * Generates handles response. This is were we would pass stuff to cli or gui, etc
  *
  * @param n the processed policy object
  * @return the policyObjected as accepted by user (potentially modified
  */
 public PolicyObject userResponse(PolicyObject n) {
   if ((parseAct(genProps.getProperty("userResponse", null)) == null)
       && !Boolean.parseBoolean(genProps.getProperty("blanketAccept", "false"))) {
     return userInterface.userResponse(n);
   } else {
     if (Boolean.parseBoolean(genProps.getProperty("blanketAccept", "false"))) {
       return n.setAction(n.getAction().setOverride(true));
     } else {
       return n.setAction(parseAct(genProps.getProperty("userResponse", null)));
     }
   }
 }
Exemplo n.º 2
0
  /**
   * A constructor permitting a user interface class to launch everything and be in control.
   *
   * @param args any commandline arguements
   * @param ui the known UserIO object
   * @throws Exception Mostly from loadWeights, but should also happen for loadFromConfig
   */
  public Gio(String[] args, UserIO ui) throws Exception {

    userInterface = ui;
    genProps = loadFromConfig("./PrivacyAdviser.cfg");
    loadCLO(args);
    // TODO add method to check validity of genProps (after each file load, clo load, and ui load).

    if ((genProps.getProperty("genConfig") != null)
        && (genProps.getProperty("genConfig") != "./PrivacyAdvisor.cfg")) {
      System.err.println("clo config call");
      genProps = loadFromConfig(genProps.getProperty("genConfig")); // TODO merge, not override
      loadCLO(args);
    }

    // start the logger
    logger =
        startLogger(
            genProps.getProperty("loglocation", "./LOG.txt"),
            genProps.getProperty("loglevel", "INFO"));
    if (userInterface == null) {
      selectUI(genProps.getProperty("userIO"));
    }
    selectPDB(genProps.getProperty("policyDB"));

    // load the weights configuration file
    origWeights = new Properties();
    origWeights = loadWeights();
    if (Boolean.parseBoolean(genProps.getProperty("useNet", "false"))) {
      startNetwork();
    } else {
      nr = null;
    }
  }
Exemplo n.º 3
0
 /**
  * Loads the case history into cache. This is where the background database chosen.
  *
  * @param dLoc the location of the database
  */
 public void loadDB() {
   try {
     // TODO what about if we want to create a new db?
     if (!Boolean.parseBoolean(genProps.getProperty("newDB"))) {
       pdb.loadDB();
     }
   } catch (Exception e) {
     System.err.println("Something wrong with loading DB");
   }
   try {
     loadCLPolicies();
   } catch (Exception e) {
     System.err.println("Error. Probably wrong path to P3P folder");
   }
 }
Exemplo n.º 4
0
 /**
  * call the user interface's general configuration method if the userInit option is true, and a
  * user interface exists
  */
 public void configUI() {
   if (Boolean.parseBoolean(genProps.getProperty("userInit", "false"))
       && !(userInterface == null)) {
     userInterface.user_init(genProps);
   }
 }