Ejemplo n.º 1
1
 public boolean hasGithubProperties() {
   return props.containsKey(GITHUB_USER) //
       && props.containsKey(GITHUB_PASSWORD) //
       && props.containsKey(GITHUB_OAUTH_TOKEN) //
       && props.containsKey(GITHUB_REPONAME) //
       && props.containsKey(GITHUB_REPOOWNER);
 }
Ejemplo n.º 2
0
  public EMSMongoClient() throws IOException {
    Properties config = new Properties();

    InputStream in = this.getClass().getClassLoader().getResourceAsStream("config.properties");

    config.load(in);

    MongoClient client;

    List<ServerAddress> serverAddresses =
        Arrays.asList(
            new ServerAddress(
                config.getProperty("mongo_host"),
                Integer.parseInt(config.getProperty("mongo_port"))));

    if (config.containsKey("mongo_user") && config.containsKey("mongo_password")) {
      MongoCredential credential =
          MongoCredential.createMongoCRCredential(
              config.getProperty("mongo_user"),
              config.getProperty("mongo_db"),
              config.getProperty("mongo_password").toCharArray());

      client = new MongoClient(serverAddresses, Arrays.asList(credential));
    } else {
      client = new MongoClient(serverAddresses);
    }

    DB db = client.getDB(config.getProperty("mongo_db"));

    this.collection = db.getCollection("sessions");
  }
Ejemplo n.º 3
0
  public void onEnable() {

    PluginDescriptionFile pdfFile = this.getDescription();

    Properties props = new Properties();
    try {
      props.load(new FileInputStream("server.properties"));
      if (props.containsKey("regen-rate"))
        rate = Double.parseDouble(props.getProperty("regen-rate"));
      if (props.containsKey("regen-amount"))
        healAmount = Integer.parseInt(props.getProperty("regen-amount"));
      if (props.containsKey("regen-max"))
        maxHeal = Integer.parseInt(props.getProperty("regen-max"));
      if (props.containsKey("regen-min"))
        maxHurt = Integer.parseInt(props.getProperty("regen-min"));
      if (props.containsKey("min-altitude"))
        minAltitude = Integer.parseInt(props.getProperty("min-altitude"));
    } catch (IOException ioe) {
      System.out.println(pdfFile.getName() + " : ERROR CAN/'T FIND server.properties");
    }
    System.out.print(
        pdfFile.getName()
            + " "
            + pdfFile.getVersion()
            + " enabled! Rate: "
            + rate
            + "s | Amount: "
            + healAmount);
    if (healAmount >= 0) System.out.println(" | Max: " + maxHeal);
    else System.out.println(" | Min: " + maxHurt);
    m_Timer.schedule(new SimpleTimer(this), 0, (long) (rate * 1000));
  }
Ejemplo n.º 4
0
  public static Properties getCyclosProperties() throws IOException {
    final Properties properties = new Properties();
    properties.put(MAX_MAIL_SENDER_THREADS, "5");
    properties.put(MAX_SMS_SENDER_THREADS, "50");
    properties.put(MAX_PAYMENT_REQUEST_SENDER_THREADS, "50");

    properties.load(CyclosConfiguration.class.getResourceAsStream(CYCLOS_PROPERTIES_FILE));

    final String dbMaxPoolSizeStr = properties.getProperty(HIBERNATE_C3P0_MAX_POOL_SIZE);
    final Integer dbMaxPoolSize =
        StringUtils.isEmpty(dbMaxPoolSizeStr)
            ? HIBERNATE_C3P0_MAX_POOL_SIZE_DEFAULT
            : Integer.parseInt(dbMaxPoolSizeStr);

    ensureProperty(TRANSACTION_CORE_POOL_SIZE, dbMaxPoolSize, properties);
    ensureProperty(TRANSACTION_MAX_POOL_SIZE, dbMaxPoolSize * 3, properties);
    ensureProperty(TRANSACTION_QUEUE_CAPACITY, dbMaxPoolSize * 5, properties);

    if (!properties.containsKey(Environment.HBM2DDL_AUTO)) {
      properties.put(Environment.HBM2DDL_AUTO, "validate");
    }
    if (!properties.containsKey(SCHEMA_EXPORT_FILE)) {
      properties.put(SCHEMA_EXPORT_FILE, DEFAULT_SCHEMA_EXPORT_FILE);
    }

    return properties;
  }
Ejemplo n.º 5
0
  public void configure(final Properties configuration) throws ConfigurationException {
    if (!configuration.containsKey("project")) {
      throw new ConfigurationException("project is required");
    }
    project = configuration.getProperty("project");
    if (!configuration.containsKey(CONFIG_FILE)) {
      throw new ConfigurationException(CONFIG_FILE + " is required");
    }
    scriptFile = new File(configuration.getProperty(CONFIG_FILE));
    if (!scriptFile.isFile()) {
      throw new ConfigurationException(
          CONFIG_FILE + " does not exist or is not a file: " + scriptFile.getAbsolutePath());
    }
    interpreter = configuration.getProperty(CONFIG_INTERPRETER);
    args = configuration.getProperty(CONFIG_ARGS);
    if (!configuration.containsKey(CONFIG_FORMAT)) {
      throw new ConfigurationException(CONFIG_FORMAT + " is required");
    }
    format = configuration.getProperty(CONFIG_FORMAT);

    interpreterArgsQuoted =
        Boolean.parseBoolean(configuration.getProperty(CONFIG_INTERPRETER_ARGS_QUOTED));

    configDataContext = new HashMap<String, Map<String, String>>();
    final HashMap<String, String> configdata = new HashMap<String, String>();
    configdata.put("project", project);
    configDataContext.put("context", configdata);

    executionDataContext =
        ScriptDataContextUtil.createScriptDataContextForProject(framework, project);

    executionDataContext.putAll(configDataContext);
  }
Ejemplo n.º 6
0
 public boolean hasJiraProperties() {
   return props.containsKey(JIRA_USER) //
       && props.containsKey(JIRA_PASSWORD) //
       && props.containsKey(JIRA_URL) //
       && props.containsKey(JIRA_PROJECTKEY)
       && props.containsKey(JIRA_FORCE_UPDATE);
 }
Ejemplo n.º 7
0
  static // executes only when class is loaded
  {
    prop = new Properties();
    try {

      String path = System.getProperty("user.dir") + "\\config.txt";

      prop.load(new FileInputStream(path));

      // trim all the spaces
    } catch (FileNotFoundException e) {

      System.out.println("No user defined config file......");
      System.out.println("Loading default configurations....");
    } catch (NullPointerException e) {
      System.out.println("Loading default configurations....");
    } catch (IOException e) {
      System.out.println("IOException");
    } catch (ExceptionInInitializerError e) {
      System.out.println("ExceptionInInitializerError ");
    }

    if (!prop.containsKey(WebUtil.Connection_Timeout)) {
      System.out.println("No Connection_timeout found in config file");
      prop.setProperty("Connection_timeout", "5000");
    }
    if (!prop.containsKey(WebUtil.Backlog)) {
      System.out.println("No Backlog found in config file");
      prop.setProperty(WebUtil.Backlog, "10");
    }

    System.out.println(prop);
  }
Ejemplo n.º 8
0
  public static Automobile parseProperties(Properties properObj) {
    Automobile autoObj = new Automobile();

    autoObj.setModelName(properObj.getProperty("CarModel"));
    properObj.remove("CarModel");
    autoObj.setMaker(properObj.getProperty("CarMake"));
    properObj.remove("CarMake");
    autoObj.setBasePrice(Float.parseFloat(properObj.getProperty("CarPrice")));
    properObj.remove("CarPrice");

    int i = 1;
    String key = "Option";
    while (!properObj.isEmpty()) {
      String optionsetName = properObj.getProperty(key + i);
      autoObj.setOptionset(optionsetName);
      properObj.remove(key + i);

      int j = 1;
      while (properObj.containsKey(key + i + "Value" + j)) {
        float optionPrice = 0;
        String optionName = properObj.getProperty(key + i + "Value" + j);
        properObj.remove(key + i + "Value" + j);
        if (properObj.containsKey(key + i + "Value" + j + "price")) {
          optionPrice = Float.parseFloat(properObj.getProperty(key + i + "Value" + j + "price"));
          properObj.remove(key + i + "Value" + j + "price");
        }
        autoObj.setOption(optionsetName, optionName, optionPrice);
        j++;
      }
      i++;
    }
    return autoObj;
  }
Ejemplo n.º 9
0
  private void setBaseProps() {
    if (!properties.containsKey("slac.log.dir")) {
      properties.setProperty(
          "slac.log.dir", SlacUtil.ensureDir(SlacUtil.path(homeDir, "log")).getPath());
    }

    if (!properties.containsKey("slac.data.dir")) {
      properties.setProperty(
          "slac.data.dir", SlacUtil.ensureDir(SlacUtil.path(homeDir, "data")).getPath());
    }

    if (!properties.containsKey("slac.conf.dir")) {
      properties.setProperty(
          "slac.conf.dir", SlacUtil.ensureDir(SlacUtil.path(homeDir, "conf")).getPath());
    }

    if (!properties.containsKey("slac.backup.dir")) {
      properties.setProperty("slac.backup.dir", SlacUtil.path(homeDir, "backup"));
    }

    if (!properties.containsKey("phantom.binary")) {
      for (String path :
          new String[] {
            SlacUtil.path(homeDir, "phantomjs"), "/usr/local/bin/phantomjs", "/usr/bin/phantomjs"
          }) {
        if (new File(path).canExecute()) {
          properties.setProperty("phantom.binary", path);
          break;
        }
      }
    }
  }
Ejemplo n.º 10
0
  public boolean shouldSign(File input, List<Properties> containers) {
    Properties inf = null;

    // 1: Are we excluded from signing by our parents?
    // innermost jar is first on the list, it overrides outer jars
    for (Iterator<Properties> iterator = containers.iterator(); iterator.hasNext(); ) {
      inf = iterator.next();
      if (inf.containsKey(Utils.MARK_EXCLUDE_CHILDREN_SIGN)) {
        if (Boolean.valueOf(inf.getProperty(Utils.MARK_EXCLUDE_CHILDREN_SIGN)).booleanValue()) {
          if (verbose)
            System.out.println(
                input.getName() + "is excluded from signing by its containers."); // $NON-NLS-1$
          return false;
        }
        break;
      }
    }

    // 2: Is this jar itself marked as exclude?
    inf = Utils.getEclipseInf(input, verbose);
    if (inf != null
        && inf.containsKey(Utils.MARK_EXCLUDE_SIGN)
        && Boolean.valueOf(inf.getProperty(Utils.MARK_EXCLUDE_SIGN)).booleanValue()) {
      if (verbose)
        System.out.println(
            "Excluding " + input.getName() + " from signing."); // $NON-NLS-1$ //$NON-NLS-2$
      return false;
    }
    return true;
  }
Ejemplo n.º 11
0
 protected void loadBuildProperties() {
   buildVersion = "1.0";
   buildTimestamp = "N/A";
   buildHash = "N/A";
   InputStream versionStream =
       getClass()
           .getClassLoader()
           .getResourceAsStream("org/appcelerator/titanium/build.properties");
   if (versionStream != null) {
     Properties properties = new Properties();
     try {
       properties.load(versionStream);
       if (properties.containsKey("build.version")) {
         buildVersion = properties.getProperty("build.version");
       }
       if (properties.containsKey("build.timestamp")) {
         buildTimestamp = properties.getProperty("build.timestamp");
       }
       if (properties.containsKey("build.githash")) {
         buildHash = properties.getProperty("build.githash");
       }
     } catch (IOException e) {
     }
   }
 }
  @Override
  public T withProperties(Properties properties) {
    super.withProperties(properties);

    if (properties.containsKey("betamax.proxyHost")) {
      proxyHost(properties.getProperty("betamax.proxyHost"));
    }

    if (properties.containsKey("betamax.proxyPort")) {
      proxyPort(TypedProperties.getInteger(properties, "betamax.proxyPort"));
    }

    if (properties.containsKey("betamax.proxyTimeoutSeconds")) {
      proxyTimeoutSeconds(TypedProperties.getInteger(properties, "betamax.proxyTimeoutSeconds"));
    }

    if (properties.containsKey("betamax.requestBufferSize")) {
      requestBufferSize(TypedProperties.getInteger(properties, "betamax.requestBufferSize"));
    }

    if (properties.containsKey("betamax.sslEnabled")) {
      sslEnabled(TypedProperties.getBoolean(properties, "betamax.sslEnabled"));
    }

    return self();
  }
Ejemplo n.º 13
0
  /**
   * Validates the configuration
   *
   * @return verdadero si no da valido
   */
  public boolean validate() {

    // Key DB_HOST
    if (!settings.containsKey("DB_HOST")) {
      System.err.println("Falta clave DB_HOST en el archivo de configuración.");
      return false;
    }

    // Key DB_USER
    if (!settings.containsKey("DB_USER")) {
      System.err.println("Falta clave DB_USER en el archivo de configuración.");
      return false;
    }

    if (!settings.containsKey("DB_PASS")) {
      System.err.println("Falta clave DB_PASS en el archivo de configuración.");
      return false;
    }

    if (!settings.containsKey("DB_SCHEMA")) {
      System.err.println("Falta la clave esquema en el archivo de configuración.");
      return false;
    }

    return true;
  }
Ejemplo n.º 14
0
  /**
   * This method parses the URL and adds properties to the the properties object. These include
   * required and any optional properties specified in the URL.
   *
   * @param The URL needed to be parsed.
   * @param The properties object which is to be updated with properties in the URL.
   * @throws SQLException if the URL is not in the expected format.
   */
  protected static void parseURL(String url, Properties info) throws SQLException {
    if (url == null) {
      String msg = Messages.getString(Messages.JDBC.urlFormat);
      throw new SQLException(msg);
    }
    try {
      JDBCURL jdbcURL = new JDBCURL(url);
      info.setProperty(TeiidURL.JDBC.VDB_NAME, jdbcURL.getVDBName());
      if (jdbcURL.getConnectionURL() != null) {
        info.setProperty(TeiidURL.CONNECTION.SERVER_URL, jdbcURL.getConnectionURL());
      }
      Properties optionalParams = jdbcURL.getProperties();
      JDBCURL.normalizeProperties(info);
      Enumeration<?> keys = optionalParams.keys();
      while (keys.hasMoreElements()) {
        String propName = (String) keys.nextElement();
        // Don't let the URL properties override the passed-in Properties object.
        if (!info.containsKey(propName)) {
          info.setProperty(propName, optionalParams.getProperty(propName));
        }
      }
      // add the property only if it is new because they could have
      // already been specified either through url or otherwise.
      if (!info.containsKey(TeiidURL.JDBC.VDB_VERSION) && jdbcURL.getVDBVersion() != null) {
        info.setProperty(TeiidURL.JDBC.VDB_VERSION, jdbcURL.getVDBVersion());
      }
      if (!info.containsKey(TeiidURL.CONNECTION.APP_NAME)) {
        info.setProperty(TeiidURL.CONNECTION.APP_NAME, TeiidURL.CONNECTION.DEFAULT_APP_NAME);
      }

    } catch (IllegalArgumentException iae) {
      throw new SQLException(Messages.getString(Messages.JDBC.urlFormat));
    }
  }
 /**
  * @param properties context properties for initializing rmi services
  * @return verification result <br>
  *     Four properties are mandatory:<br>
  *     a) Context.PROVIDER_URL<br>
  *     b) Context.SECURITY_PRINCIPAL<br>
  *     c) Context.SECURITY_CREDENTIALS<br>
  *     d) Context.INITIAL_CONTEXT_FACTORY<br>
  */
 private boolean validateJNDIProperties(Properties properties) {
   if (properties.containsKey(Context.PROVIDER_URL) //
       && properties.containsKey(Context.SECURITY_PRINCIPAL) //
       && properties.containsKey(Context.SECURITY_CREDENTIALS) //
       && properties.containsKey(Context.INITIAL_CONTEXT_FACTORY) //
   ) {
     return true;
   } else {
     Utils.printTrace(false);
     Utils.printMessage(
         "! four properties are manadatory: !\n +"
             + "\t"
             + Context.PROVIDER_URL
             + "\n"
             + "\t"
             + Context.SECURITY_PRINCIPAL
             + "\n"
             + "\t"
             + Context.SECURITY_CREDENTIALS
             + "\n"
             + "\t"
             + Context.INITIAL_CONTEXT_FACTORY
             + "\n");
     return false;
   }
 }
Ejemplo n.º 16
0
  protected void initializeMetadataVersions(List<StoreDefinition> storeDefs) {
    Store<ByteArray, byte[], byte[]> versionStore =
        storeRepository.getLocalStore(
            SystemStoreConstants.SystemStoreName.voldsys$_metadata_version_persistence.name());
    Properties props = new Properties();

    try {
      boolean isPropertyAdded = false;
      ByteArray metadataVersionsKey =
          new ByteArray(SystemStoreConstants.VERSIONS_METADATA_KEY.getBytes());
      List<Versioned<byte[]>> versionList = versionStore.get(metadataVersionsKey, null);
      VectorClock newClock = null;

      if (versionList != null && versionList.size() > 0) {
        byte[] versionsByteArray = versionList.get(0).getValue();
        if (versionsByteArray != null) {
          props.load(new ByteArrayInputStream(versionsByteArray));
        }
        newClock = (VectorClock) versionList.get(0).getVersion();
        newClock = newClock.incremented(0, System.currentTimeMillis());
      } else {
        newClock = new VectorClock();
      }

      // Check if version exists for cluster.xml
      if (!props.containsKey(SystemStoreConstants.CLUSTER_VERSION_KEY)) {
        props.setProperty(SystemStoreConstants.CLUSTER_VERSION_KEY, "0");
        isPropertyAdded = true;
      }

      // Check if version exists for stores.xml
      if (!props.containsKey(SystemStoreConstants.STORES_VERSION_KEY)) {
        props.setProperty(SystemStoreConstants.STORES_VERSION_KEY, "0");
        isPropertyAdded = true;
      }

      // Check if version exists for each store
      for (StoreDefinition def : storeDefs) {
        if (!props.containsKey(def.getName())) {
          props.setProperty(def.getName(), "0");
          isPropertyAdded = true;
        }
      }

      if (isPropertyAdded) {
        StringBuilder finalVersionList = new StringBuilder();
        for (String propName : props.stringPropertyNames()) {
          finalVersionList.append(propName + "=" + props.getProperty(propName) + "\n");
        }
        versionStore.put(
            metadataVersionsKey,
            new Versioned<byte[]>(finalVersionList.toString().getBytes(), newClock),
            null);
      }

    } catch (Exception e) {
      logger.error("Error while intializing metadata versions ", e);
    }
  }
Ejemplo n.º 17
0
  /** Parse a font given only the name of a builtin font */
  private void parseFont(String baseFont) throws IOException {
    // load the base fonts properties files, if it isn't already loaded
    if (props == null) {
      props = new Properties();
      props.load(BuiltinFont.class.getResourceAsStream("res/BaseFonts.properties"));
    }

    // make sure we're a known font
    if (!props.containsKey(baseFont + ".file")) {
      throw new IllegalArgumentException("Unknown Base Font: " + baseFont);
    }

    // get the font information from the properties file
    String file = props.getProperty(baseFont + ".file");

    // the size of the file
    int length = Integer.parseInt(props.getProperty(baseFont + ".length"));
    // the size of the unencrypted portion
    int length1 = 0;
    // the size of the encrypted portion
    int length2 = 0;

    // read the data from the file
    byte[] data = new byte[length];
    InputStream fontStream = NativeFont.class.getResourceAsStream("res/" + file);
    int cur = 0;
    while (cur < length) {
      cur += fontStream.read(data, cur, length - cur);
    }
    fontStream.close();

    // are we a pfb file?
    if ((data[0] & 0xff) == 0x80) {
      // read lengths from the file
      length1 = (data[2] & 0xff);
      length1 |= (data[3] & 0xff) << 8;
      length1 |= (data[4] & 0xff) << 16;
      length1 |= (data[5] & 0xff) << 24;
      length1 += 6;

      length2 = (data[length1 + 2] & 0xff);
      length2 |= (data[length1 + 3] & 0xff) << 8;
      length2 |= (data[length1 + 4] & 0xff) << 16;
      length2 |= (data[length1 + 5] & 0xff) << 24;
      length1 += 6;
    } else {
      // get the values from the properties file
      length1 = Integer.parseInt(props.getProperty(baseFont + ".length1"));

      if (props.containsKey(baseFont + ".length2")) {
        length2 = Integer.parseInt(props.getProperty(baseFont + ".lenth2"));
      } else {
        length2 = length - length1;
      }
    }

    parseFont(data, length1, length2);
  }
Ejemplo n.º 18
0
 /**
  * Create a SOCKS5 server that communicates with the client using the specified socket. This
  * method should not be invoked directly: new SOCKS5Server objects should be created by using
  * SOCKSServerFactory.createSOCSKServer(). It is assumed that the SOCKS VER field has been
  * stripped from the input stream of the client socket.
  *
  * @param clientSock client socket
  * @param props non-null
  */
 public SOCKS5Server(Socket clientSock, Properties props) {
   this.clientSock = clientSock;
   this.props = props;
   this.authRequired =
       Boolean.parseBoolean(props.getProperty(I2PTunnelHTTPClientBase.PROP_AUTH))
           && props.containsKey(I2PTunnelHTTPClientBase.PROP_USER)
           && props.containsKey(I2PTunnelHTTPClientBase.PROP_PW);
   _log = I2PAppContext.getGlobalContext().logManager().getLog(SOCKS5Server.class);
 }
Ejemplo n.º 19
0
  @Override
  public void open(Configuration parameters) throws Exception {
    super.open(parameters);

    KinesisProducerConfiguration producerConfig = new KinesisProducerConfiguration();

    producerConfig.setRegion(configProps.getProperty(ProducerConfigConstants.AWS_REGION));
    producerConfig.setCredentialsProvider(AWSUtil.getCredentialsProvider(configProps));
    if (configProps.containsKey(ProducerConfigConstants.COLLECTION_MAX_COUNT)) {
      producerConfig.setCollectionMaxCount(
          PropertiesUtil.getLong(
              configProps,
              ProducerConfigConstants.COLLECTION_MAX_COUNT,
              producerConfig.getCollectionMaxCount(),
              LOG));
    }
    if (configProps.containsKey(ProducerConfigConstants.AGGREGATION_MAX_COUNT)) {
      producerConfig.setAggregationMaxCount(
          PropertiesUtil.getLong(
              configProps,
              ProducerConfigConstants.AGGREGATION_MAX_COUNT,
              producerConfig.getAggregationMaxCount(),
              LOG));
    }

    producer = new KinesisProducer(producerConfig);
    callback =
        new FutureCallback<UserRecordResult>() {
          @Override
          public void onSuccess(UserRecordResult result) {
            if (!result.isSuccessful()) {
              if (failOnError) {
                thrownException = new RuntimeException("Record was not sent successful");
              } else {
                LOG.warn("Record was not sent successful");
              }
            }
          }

          @Override
          public void onFailure(Throwable t) {
            if (failOnError) {
              thrownException = t;
            } else {
              LOG.warn("An exception occurred while processing a record", t);
            }
          }
        };

    if (this.customPartitioner != null) {
      this.customPartitioner.initialize(
          getRuntimeContext().getIndexOfThisSubtask(),
          getRuntimeContext().getNumberOfParallelSubtasks());
    }

    LOG.info("Started Kinesis producer instance for region '{}'", producerConfig.getRegion());
  }
Ejemplo n.º 20
0
 /**
  * Returns true for a unit selection voice, false for an HMM-based voice.
  *
  * @return true if config.containsKey("unitselection.voices.list"), false if
  *     config.containsKey("hmm.voices.list")
  * @throws UnsupportedOperationException if the voice is neither a unit selection nor an HMM-based
  *     voice.
  */
 protected boolean isUnitSelectionVoice() throws UnsupportedOperationException {
   if (config.containsKey("unitselection.voices.list")) {
     return true;
   } else if (config.containsKey("hmm.voices.list")) {
     return false;
   } else {
     throw new UnsupportedOperationException(
         "The voice is neither a unit selection voice nor an HMM-based voice -- cannot convert to MARY 5 format.");
   }
 }
 /**
  * Constructor for reflection loading.
  *
  * @param args
  */
 public DiscriminativeAlignments(String... args) {
   Properties options = FeatureUtils.argsToProperties(args);
   this.addSourceDeletions = options.containsKey("sourceDeletionFeature");
   this.addTargetInsertions = options.containsKey("targetInsertionFeature");
   this.useClasses = options.containsKey("useClasses");
   if (useClasses) {
     sourceMap = SourceClassMap.getInstance();
     targetMap = TargetClassMap.getInstance();
   }
 }
 /**
  * Set the connection properties passed to the JDBC driver.
  *
  * <p>If <code>props</code> contains "user" and/or "password" properties, the corresponding
  * instance properties are set. If these properties are not present, they are filled in using
  * {@link #getUser()}, {@link #getPassword()} when {@link #getPooledConnection()} is called, or
  * using the actual parameters to the method call when {@link #getPooledConnection(String,
  * String)} is called. Calls to {@link #setUser(String)} or {@link #setPassword(String)} overwrite
  * the values of these properties if <code>connectionProperties</code> is not null.
  *
  * @param props Connection properties to use when creating new connections.
  * @since 1.3
  * @throws IllegalStateException if {@link #getPooledConnection()} has been called
  */
 public void setConnectionProperties(Properties props) {
   assertInitializationAllowed();
   connectionProperties = props;
   if (connectionProperties.containsKey("user")) {
     setUser(connectionProperties.getProperty("user"));
   }
   if (connectionProperties.containsKey("password")) {
     setPassword(connectionProperties.getProperty("password"));
   }
 }
Ejemplo n.º 23
0
  private void configure(
      final IProject project,
      Collection<IFile> filesToAnalyze,
      final Properties properties,
      final IProgressMonitor monitor) {
    String projectName = project.getName();
    String encoding;
    try {
      encoding = project.getDefaultCharset();
    } catch (CoreException e) {
      throw new SonarEclipseException("Unable to get charset from project", e);
    }

    properties.setProperty(SonarLintProperties.PROJECT_NAME_PROPERTY, projectName);
    properties.setProperty(SonarLintProperties.PROJECT_VERSION_PROPERTY, "0.1-SNAPSHOT");
    properties.setProperty(SonarLintProperties.ENCODING_PROPERTY, encoding);

    ProjectConfigurationRequest configuratorRequest =
        new ProjectConfigurationRequest(project, filesToAnalyze, properties);
    Collection<ProjectConfigurator> configurators = ConfiguratorUtils.getConfigurators();
    for (ProjectConfigurator configurator : configurators) {
      if (configurator.canConfigure(project)) {
        configurator.configure(configuratorRequest, monitor);
        usedConfigurators.add(configurator);
      }
    }

    ProjectConfigurator.appendProperty(
        properties,
        SonarConfiguratorProperties.TEST_INCLUSIONS_PROPERTY,
        PreferencesUtils.getTestFileRegexps());
    if (!properties.containsKey(SonarConfiguratorProperties.SOURCE_DIRS_PROPERTY)
        && !properties.containsKey(SonarConfiguratorProperties.TEST_DIRS_PROPERTY)) {
      // Try to analyze all files
      properties.setProperty(SonarConfiguratorProperties.SOURCE_DIRS_PROPERTY, ".");
      properties.setProperty(SonarConfiguratorProperties.TEST_DIRS_PROPERTY, ".");
      // Try to exclude derived folders
      try {
        for (IResource member : project.members()) {
          if (member.isDerived()) {
            ProjectConfigurator.appendProperty(
                properties,
                SonarConfiguratorProperties.SOURCE_EXCLUSIONS_PROPERTY,
                member.getName() + "/**/*");
            ProjectConfigurator.appendProperty(
                properties,
                SonarConfiguratorProperties.TEST_EXCLUSIONS_PROPERTY,
                member.getName() + "/**/*");
          }
        }
      } catch (CoreException e) {
        throw new IllegalStateException("Unable to list members of " + project, e);
      }
    }
  }
  /**
   * Check that no SQL database is configured.
   *
   * @param p Play configuration.
   * @return <code>true</code> if no Play SQL configuration is defined, <code>false</code>
   *     otherwise.
   * @since 2011.09.07
   */
  private boolean checkPlaySQLConfig(Properties p) {
    // We configure the Cloud Foundry SQL database only if no other Play DB
    // is configured.
    if (p.containsKey("db") || p.containsKey("db.url")) {
      Logger.warn(
          "[CloudFoundry] A SQL database configuration already exists. It will not be overriden.");
      return false;
    }

    return true;
  }
  @DeployableTestMethod(estimatedDuration = 0.0)
  @Test(timeout = 30000)
  public void testFileContainsAllJoints() {
    boolean containsAllJoints = true;

    DRCRobotJointMap jointMap = new AtlasJointMap(version);
    try {
      Properties properties = new Properties();
      InputStream stream = getClass().getClassLoader().getResourceAsStream("initialDrivingSetup");
      properties.load(stream);

      for (RobotSide robotSide : RobotSide.values()) {
        for (LegJointName jointName : LegJointName.values()) {
          String key = jointMap.getLegJointName(robotSide, jointName);
          if (key == null) {
            continue;
          }
          if (!properties.containsKey(key)) {
            System.out.println("File did not contain joint " + key);
            containsAllJoints = false;
          }
        }

        for (ArmJointName jointName : ArmJointName.values()) {
          String key = jointMap.getArmJointName(robotSide, jointName);
          if (key == null) {
            continue;
          }
          if (!properties.containsKey(key)) {
            System.out.println("File did not contain joint " + key);
            containsAllJoints = false;
          }
        }
      }

      for (SpineJointName jointName : SpineJointName.values) {
        String key = jointMap.getSpineJointName(jointName);
        if (key == null) {
          continue;
        }
        if (!properties.containsKey(key)) {
          System.out.println("File did not contain joint " + key);
          containsAllJoints = false;
        }
      }

      stream.close();
    } catch (IOException e) {
      throw new RuntimeException("Atlas joint parameter file cannot be loaded. ", e);
    }

    assertTrue(containsAllJoints);
  }
  /**
   * @param properties - service properties
   * @throws InvalidRMIServiceException <br>
   *     If null properties provided, default properties will be used. <br>
   *     If non-null properties provided, only three properties will be used for RMI calls: <br>
   *     a) Context.SECURITY_PRINCIPAL <br>
   *     b) Context.PROVIDER_URL <br>
   *     c) Context.SECURITY_CREDENTIALS <br>
   *     If any of them missing in the input, the corresponding default properties will be used.
   *     <br>
   *     If the input properties are NOT sufficient for initializing a service, return null. <br>
   */
  public RMIIQMAppModuleServices(Properties properties) throws InvalidRMIServiceException {
    super();
    //        Utils.printTrace(false);
    //        Utils.printMessage("start ... " + Utils.convertToString(new java.util.Date()));

    // collect the configured properties and default properties
    Properties tmpProps = RMIIQMAppModuleServicesConstants.getDefaultProperties();
    if (properties != null) {
      if (properties.containsKey(Context.SECURITY_PRINCIPAL)) {
        tmpProps.setProperty( //
            Context.SECURITY_PRINCIPAL, //
            properties.getProperty(Context.SECURITY_PRINCIPAL));
      }
      if (properties.containsKey(Context.PROVIDER_URL)) {
        tmpProps.setProperty( //
            Context.PROVIDER_URL, //
            properties.getProperty(Context.PROVIDER_URL));
      }
      if (properties.containsKey(Context.SECURITY_CREDENTIALS)) {
        tmpProps.setProperty( //
            Context.SECURITY_CREDENTIALS, //
            properties.getProperty(Context.SECURITY_CREDENTIALS));
      }
    }
    if (!this.validateJNDIProperties(tmpProps)) {
      Utils.printTrace(false);
      Utils.printMessage("!!!!! invalid properties for JNDI initialization !!!!!");
      Utils.printMessage(tmpProps.toString());
      //            tmpProps.list(System.out);
      // TODO , question: is it right to exit here, instead of throwing exceptions?
      return;
    } else {
      appServiceProperties = tmpProps;
      //            if (appServiceProperties.containsKey("print.service.properties")
      //                &&
      // appServiceProperties.get("print.service.properties").toString().equalsIgnoreCase("Y")) {
      //                Utils.printMessage(appServiceProperties.toString());
      ////                appServiceProperties.list(System.out);
      //            }
    }
    try {
      initJNDI(appServiceProperties);
      //            CurrencyLookupVO.set(this.getCurrencyLookup());
      //            MarketLookupVO.set(this.getMarketLookup());
      //            ModelMetadataLookupVO.set(this.getModelMetadataLookup());
      AttributeConverter.init(this);
    } catch (NamingException e) {
      throw new InvalidRMIServiceException(e);
    } catch (InvalidServiceMethodCallException | JSONException ex) {
      throw new InvalidRMIServiceException(ex);
    }
  }
Ejemplo n.º 27
0
  public void readCfg() {
    settings = new Properties();
    try {
      settings.load(new FileInputStream("plugins/AdminMode/settings.properties"));

      if (settings.containsKey("resetLoc")) {
        resetLoc = Boolean.parseBoolean(settings.getProperty("resetLoc"));
      }
      if (settings.containsKey("resetItems")) {
        resetItems = Boolean.parseBoolean(settings.getProperty("resetItems"));
      }
      if (settings.containsKey("resetHealth")) {
        resetHealth = Boolean.parseBoolean(settings.getProperty("resetHealth"));
      }

      if (settings.containsKey("items")) {
        String[] Items4Admins = settings.getProperty("items").split(",");

        int i = 0;
        for (String ItemStart : Items4Admins) {
          ItemStart.replaceAll("/", "");

          String[] info = ItemStart.split(":");
          int itemid = Integer.parseInt(info[0]);
          int amount = 1;

          if (info.length > 1) {
            amount = Integer.parseInt(info[1]);
          }

          AdminStack[i] = new ItemStack(itemid, amount);
          i++;
        }
      } else {
        log.log(Level.INFO, "No items defined.");
      }
    } catch (Exception e) {
      String FileContents = "AdminMode properties file";

      try {
        new File("plugins/AdminMode/").mkdirs();
        settings.setProperty("resetLoc", "true");
        settings.setProperty("resetHealth", "true");
        settings.setProperty("resetItems", "true");
        settings.setProperty("items", "278,1:64");
        settings.store(new FileOutputStream("plugins/AdminMode/settings.properties"), FileContents);
        log.log(Level.INFO, "[" + name + "] Created properties file.");
      } catch (IOException ex) {
        log.log(Level.INFO, "[" + name + "] Unable to automatically properties files.");
      }
    }
  }
Ejemplo n.º 28
0
 private Properties merge(Properties include, Properties exclude) {
   Set<Object> in = new HashSet<Object>(include.keySet());
   in.addAll(exclude.keySet());
   Properties merged = new Properties();
   for (Object key : in) {
     if (include.containsKey(key)) {
       merged.put(key, include.get(key));
     } else if (exclude.containsKey(key)) {
       merged.put(key, exclude.get(key));
     }
   }
   return merged;
 }
Ejemplo n.º 29
0
 @Test
 public void saveRowWithRecordIndex() {
   Row row = new Row(5);
   row.setCell(0, new Cell("I'm not empty", null));
   when(options.containsKey("rowIndex")).thenReturn(true);
   when(options.get("rowIndex")).thenReturn(0);
   when(options.containsKey("recordIndex")).thenReturn(true);
   when(options.get("recordIndex")).thenReturn(1);
   row.save(writer, options);
   Assert.assertEquals(
       writer.getBuffer().toString(),
       "{\"flagged\":false,\"starred\":false,\"cells\":[{\"v\":\"I'm not empty\"}],\"i\":0,\"j\":1}");
 }
Ejemplo n.º 30
0
  public static void main(String[] args) {
    final Properties options = StringUtils.argsToProperties(args, argOptionDefs());
    if (args.length < 1 || options.containsKey("help")) {
      System.err.println(usage());
      return;
    }

    final Pattern posPattern =
        options.containsKey("searchPos") ? Pattern.compile(options.getProperty("searchPos")) : null;
    final Pattern wordPattern =
        options.containsKey("searchWord")
            ? Pattern.compile(options.getProperty("searchWord"))
            : null;
    final boolean plainPrint = PropertiesUtils.getBool(options, "plain", false);
    final boolean ner = PropertiesUtils.getBool(options, "ner", false);
    final boolean detailedAnnotations =
        PropertiesUtils.getBool(options, "detailedAnnotations", false);

    String[] remainingArgs = options.getProperty("").split(" ");
    List<File> fileList = new ArrayList<>();
    for (int i = 0; i < remainingArgs.length; i++) fileList.add(new File(remainingArgs[i]));

    final SpanishXMLTreeReaderFactory trf =
        new SpanishXMLTreeReaderFactory(true, true, ner, detailedAnnotations);
    ExecutorService pool = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors());

    for (final File file : fileList) {
      pool.execute(
          new Runnable() {
            public void run() {
              try {
                Reader in =
                    new BufferedReader(
                        new InputStreamReader(new FileInputStream(file), "ISO-8859-1"));
                TreeReader tr = trf.newTreeReader(file.getPath(), in);
                process(file, tr, posPattern, wordPattern, plainPrint);
                tr.close();
              } catch (IOException e) {
                e.printStackTrace();
              }
            }
          });
    }

    pool.shutdown();
    try {
      pool.awaitTermination(Long.MAX_VALUE, TimeUnit.NANOSECONDS);
    } catch (InterruptedException e) {
      e.printStackTrace();
    }
  }