Ejemplo 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)));
     }
   }
 }
Ejemplo 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;
    }
  }
Ejemplo 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");
   }
 }
Ejemplo n.º 4
0
  private void doReincarnation() throws RDCException {
    try {
      // TODO JavaClassRunner is very simple and primitive.
      // Feel free to beef it up...

      String[] props = normalProps;

      if (Boolean.parseBoolean(System.getenv("AS_SUPER_DEBUG")))
        props = debuggerProps; // very very difficult to debug this stuff otherwise!

      new JavaClassRunner(classpath, props, classname, args);
    } catch (Exception e) {
      logger.severe(strings.get("restart.server.jvmError", e));
      throw new RDCException();
    }
  }
Ejemplo n.º 5
0
 /**
  * Returns whether or not the device supports triggers.
  *
  * @return <code>true</code> if the device supports triggers, <code>false</code> otherwise.
  */
 public boolean isTriggerSupported() {
   final String value = this.properties.get(DEVICE_FEATURE_TRIGGERS);
   return Boolean.parseBoolean(value);
 }
Ejemplo n.º 6
0
 /**
  * Returns whether or not the device supports a testing mode.
  *
  * @return <code>true</code> if testing mode is supported by the device, <code>false</code>
  *     otherwise.
  */
 public boolean isTestModeSupported() {
   final String value = this.properties.get(DEVICE_FEATURE_TEST_MODE);
   return Boolean.parseBoolean(value);
 }
Ejemplo n.º 7
0
 /**
  * Returns whether the device send its samples in "reverse" order.
  *
  * @return <code>true</code> if samples are send in reverse order (= last sample first), <code>
  *     false</code> otherwise.
  */
 public boolean isSamplesInReverseOrder() {
   final String rawValue = this.properties.get(DEVICE_SAMPLE_REVERSE_ORDER);
   return Boolean.parseBoolean(rawValue);
 }
Ejemplo n.º 8
0
 /**
  * Returns whether or not the device supports RLE (Run-Length Encoding).
  *
  * @return <code>true</code> if a RLE encoder is present in the device, <code>false</code>
  *     otherwise.
  */
 public boolean isRleSupported() {
   final String value = this.properties.get(DEVICE_FEATURE_RLE);
   return Boolean.parseBoolean(value);
 }
Ejemplo n.º 9
0
 /**
  * Returns whether upon opening the DTR line needs to be high (= <code>true</code>) or low (=
  * <code>false</code>).
  *
  * <p>This method has no meaning if the used interface is <em>not</em> {@link
  * DeviceInterface#SERIAL}.
  *
  * @return <code>true</code> if the DTR line needs to be set upon opening the serial port, <code>
  *     false</code> if the DTR line needs to be reset upon opening the serial port.
  */
 public boolean isOpenPortDtr() {
   final String value = this.properties.get(DEVICE_OPEN_PORT_DTR);
   return Boolean.parseBoolean(value);
 }
Ejemplo n.º 10
0
 /**
  * Returns whether or not the device supports a noise filter.
  *
  * @return <code>true</code> if a noise filter is present in the device, <code>false</code>
  *     otherwise.
  */
 public boolean isNoiseFilterSupported() {
   final String value = this.properties.get(DEVICE_FEATURE_NOISEFILTER);
   return Boolean.parseBoolean(value);
 }
Ejemplo n.º 11
0
 private void initConsoleLog() {
   String consoleLogStr = getProperty(consoleLogKey, "false");
   consoleLog = Boolean.parseBoolean(consoleLogStr);
 }
Ejemplo n.º 12
0
 /**
  * Returns whether or not the device supports "complex" triggers.
  *
  * @return <code>true</code> if complex triggers are supported by the device, <code>false</code>
  *     otherwise.
  */
 public boolean isComplexTriggersSupported() {
   final String value = this.properties.get(DEVICE_TRIGGER_COMPLEX);
   return Boolean.parseBoolean(value);
 }
Ejemplo n.º 13
0
 /**
  * Returns whether or not the capture size is bound to the number of channels.
  *
  * @return <code>true</code> if the capture size is bound to the number of channels, <code>false
  *     </code> otherwise.
  */
 public boolean isCaptureSizeBoundToEnabledChannels() {
   final String value = this.properties.get(DEVICE_CAPTURESIZE_BOUND);
   return Boolean.parseBoolean(value);
 }
Ejemplo n.º 14
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);
   }
 }
Ejemplo n.º 15
0
 ////////////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////////////
 /////////               ALL PRIVATE BELOW               ////////////////////
 ////////////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////////////
 private void init(AdminCommandContext context) throws IOException {
   logger = context.getLogger();
   props = Globals.get(StartupContext.class).getArguments();
   verbose = Boolean.parseBoolean(props.getProperty("-verbose", "false"));
   logger.info(strings.get("restart.server.init"));
 }
Ejemplo n.º 16
0
 /**
  * Returns whether or not the device supports "double-data rate" sampling, also known as
  * "demux"-sampling.
  *
  * @return <code>true</code> if DDR is supported by the device, <code>false</code> otherwise.
  */
 public boolean isDoubleDataRateSupported() {
   final String value = this.properties.get(DEVICE_SUPPORTS_DDR);
   return Boolean.parseBoolean(value);
 }
Ejemplo n.º 17
0
  /**
   * Gets the value of a specific property as a <tt>boolean</tt>. If the specified property name is
   * associated with a value, the string representation of the value is parsed into a
   * <tt>boolean</tt> according to the rules of {@link Boolean#parseBoolean(String)} . Otherwise,
   * <tt>defaultValue</tt> is returned.
   *
   * @param propertyName the name of the property to get the value of as a <tt>boolean</tt>
   * @param defaultValue the value to be returned if the specified property name is not associated
   *     with a value
   * @return the value of the property with the specified name as a <tt>boolean</tt>;
   *     <tt>defaultValue</tt> if the property with the specified name is not associated with a
   *     value
   */
  public static boolean getBoolean(String propertyName, boolean defaultValue) {
    String str = getString(propertyName);

    return (str == null) ? defaultValue : Boolean.parseBoolean(str);
  }