/**
   * Reset the fields of this dialog to the values from the previous viewing (if the mine name is
   * the same) or the default values, ready for display.
   *
   * <p>This method does not make the dialog visible.
   *
   * @param props The properties so far for the mine.
   * @param location The position on the screen to position this dialog.
   */
  public void open(Properties props, Point location) {

    String mineName = props.getProperty(InterminePropertyKeys.MINE_NAME);
    assert mineName != null;

    if (mineName.equals(lastMineName)) {

      assert previousProperties != null;
      previousProperties.putAll(props);

    } else {

      Properties currentProperties = MinePropertiesLoader.readPreviousProperties(mineName);
      currentProperties.putAll(props);

      previousProperties = currentProperties;

      String lname = mineName.toLowerCase();

      String defaultServer = "localhost";
      String defaultProduction = lname;
      String defaultItems = "items-" + lname;
      String defaultProfile = "userprofile-" + lname;
      String defaultUsername = System.getProperty("user.name");
      String defaultPassword = "******";

      productionServerField.setText(
          previousProperties.getProperty(InterminePropertyKeys.PRODUCTION_SERVER, defaultServer));
      productionNameField.setText(
          previousProperties.getProperty(InterminePropertyKeys.PRODUCTION_NAME, defaultProduction));
      productionUserNameField.setText(
          previousProperties.getProperty(
              InterminePropertyKeys.PRODUCTION_USER_NAME, defaultUsername));
      productionPasswordField.setText(
          previousProperties.getProperty(
              InterminePropertyKeys.PRODUCTION_PASSWORD, defaultPassword));

      itemsServerField.setText(
          previousProperties.getProperty(InterminePropertyKeys.ITEMS_SERVER, defaultServer));
      itemsNameField.setText(
          previousProperties.getProperty(InterminePropertyKeys.ITEMS_NAME, defaultItems));
      itemsUserNameField.setText(
          previousProperties.getProperty(InterminePropertyKeys.ITEMS_USER_NAME, defaultUsername));
      itemsPasswordField.setText(
          previousProperties.getProperty(InterminePropertyKeys.ITEMS_PASSWORD, defaultPassword));

      profileServerField.setText(
          previousProperties.getProperty(InterminePropertyKeys.PROFILE_SERVER, defaultServer));
      profileNameField.setText(
          previousProperties.getProperty(InterminePropertyKeys.PROFILE_NAME, defaultProfile));
      profileUserNameField.setText(
          previousProperties.getProperty(InterminePropertyKeys.PROFILE_USER_NAME, defaultUsername));
      profilePasswordField.setText(
          previousProperties.getProperty(InterminePropertyKeys.PROFILE_PASSWORD, defaultPassword));

      lastMineName = mineName;
    }

    setLocation(location);
  }
Example #2
0
    private void configureProperties(final MavenExecutionRequest request) {
      assert request != null;
      assert config != null;

      Properties sys = new Properties();
      sys.putAll(System.getProperties());

      Properties user = new Properties();
      user.putAll(config.getProperties());

      // Add the env vars to the property set, with the "env." prefix
      boolean caseSensitive = !Os.isFamily(Os.FAMILY_WINDOWS);
      for (Map.Entry<String, String> entry : System.getenv().entrySet()) {
        String key =
            "env." + (caseSensitive ? entry.getKey() : entry.getKey().toUpperCase(Locale.ENGLISH));
        sys.setProperty(key, entry.getValue());
      }

      request.setUserProperties(user);

      // HACK: Some bits of Maven still require using System.properties :-(
      sys.putAll(user);
      System.getProperties().putAll(user);

      request.setSystemProperties(sys);
    }
    @Override
    public Properties getMessages(String baseBundlename, Locale locale) throws IOException {
      if (messages.get(baseBundlename) == null
          || messages.get(baseBundlename).get(locale) == null) {
        Properties messages = new Properties();

        if (!Locale.ENGLISH.equals(locale)) {
          messages.putAll(getMessages(baseBundlename, Locale.ENGLISH));
        }

        ListIterator<Theme> itr = themes.listIterator(themes.size());
        while (itr.hasPrevious()) {
          Properties m = itr.previous().getMessages(baseBundlename, locale);
          if (m != null) {
            messages.putAll(m);
          }
        }

        this.messages.putIfAbsent(baseBundlename, new ConcurrentHashMap<Locale, Properties>());
        this.messages.get(baseBundlename).putIfAbsent(locale, messages);

        return messages;
      } else {
        return messages.get(baseBundlename).get(locale);
      }
    }
Example #4
0
  private MessageBundle createMessageBundle(
      final ApplicationKey applicationKey, final Locale locale) {
    final Properties props = new Properties();

    if (locale == null) {
      props.putAll(loadBundle(applicationKey, ""));
      return new MessageBundleImpl(props);
    }

    String lang = locale.getLanguage();
    String country = locale.getCountry();
    String variant = locale.getVariant();

    props.putAll(loadBundle(applicationKey, ""));

    if (StringUtils.isNotEmpty(lang)) {
      lang = lang.toLowerCase();
      props.putAll(loadBundle(applicationKey, DELIMITER + lang));
    }

    if (StringUtils.isNotEmpty(country)) {
      props.putAll(loadBundle(applicationKey, DELIMITER + lang + DELIMITER + country));
    }

    if (StringUtils.isNotEmpty(variant)) {
      variant = variant.toLowerCase();
      props.putAll(
          loadBundle(applicationKey, DELIMITER + lang + DELIMITER + country + DELIMITER + variant));
    }

    return new MessageBundleImpl(props);
  }
Example #5
0
 @Override
 public JulDotCaseProperties withFallback(JulDotCaseProperties other) {
   Properties mergedProperties = new Properties();
   mergedProperties.putAll(other.properties);
   mergedProperties.putAll(this.properties);
   return new JulDotCaseProperties(mergedProperties);
 }
Example #6
0
  public EmbeddedKafka(Map<String, String> customProps) throws Exception {
    super();
    Map<String, String> defaultProps = Maps.newHashMap();
    defaultProps.put("broker.id", "0");
    defaultProps.put("host.name", "127.0.0.1");
    defaultProps.put("port", "9092");
    defaultProps.put("advertised.host.name", "127.0.0.1");
    defaultProps.put("advertised.port", "9092");
    defaultProps.put("log.dir", createTempDir().getAbsolutePath());
    defaultProps.put("zookeeper.connect", package$.MODULE$.ZookeeperConnectionString());
    defaultProps.put("replica.high.watermark.checkpoint.interval.ms", "5000");
    defaultProps.put("log.flush.interval.messages", "1");
    defaultProps.put("replica.socket.timeout.ms", "500");
    defaultProps.put("controlled.shutdown.enable", "false");
    defaultProps.put("auto.leader.rebalance.enable", "false");

    Properties props = new Properties();
    props.putAll(defaultProps);
    props.putAll(customProps);

    final KafkaConfig kafkaConfig = new KafkaConfig(props);

    zookeeper = new EmbeddedZookeeper((String) props.get("zookeeper.connect"));
    awaitCond(aVoid -> zookeeper.isRunning(), 3000, 100);

    server = new KafkaServer(kafkaConfig, SystemTime$.MODULE$);
    Thread.sleep(2000);

    log.info("Starting the Kafka server at {}", kafkaConfig.zkConnect());
    server.startup();
    Thread.sleep(2000);
  }
Example #7
0
 public Properties asProperties() {
   Properties result = new Properties();
   for (Properties p : config.values()) {
     result.putAll(p);
   }
   result.putAll(getDataNucleusProperties());
   return result;
 }
Example #8
0
 /**
  * Returns the union of table and partition properties, with partition properties taking
  * precedence.
  *
  * @param tblProps
  * @param partProps
  * @return the overlayed properties
  */
 public static Properties createOverlayedProperties(Properties tblProps, Properties partProps) {
   Properties props = new Properties();
   props.putAll(tblProps);
   if (partProps != null) {
     props.putAll(partProps);
   }
   return props;
 }
Example #9
0
 public SchemaUpdate(Configuration cfg, Properties connectionProperties)
     throws HibernateException {
   this.configuration = cfg;
   dialect = Dialect.getDialect(connectionProperties);
   Properties props = new Properties();
   props.putAll(dialect.getDefaultProperties());
   props.putAll(connectionProperties);
   connectionProvider = ConnectionProviderFactory.newConnectionProvider(props);
 }
 public Properties createGlobalProperties() {
   Properties p = new Properties();
   p.putAll(session.getCurrentProject().getProperties());
   p.putAll(envProps);
   p.putAll(session.getSystemProperties());
   p.putAll(session.getUserProperties());
   p.putAll(propertyDecryptor.decryptProperties(p));
   return p;
 }
Example #11
0
  /**
   * Test constructor for TachyonConfTest class.
   *
   * <p>Here is the order of the sources to load the properties: -) System properties if desired -)
   * Environment variables via tachyon-env.sh or from OS settings -) Site specific properties via
   * tachyon-site.properties file -) Default properties via tachyon-default.properties file
   */
  TachyonConf(boolean includeSystemProperties) {
    // Load default
    Properties defaultProps = new Properties();

    // Override runtime default
    defaultProps.setProperty(Constants.MASTER_HOSTNAME, NetworkAddressUtils.getLocalHostName(250));
    defaultProps.setProperty(
        Constants.WORKER_MIN_WORKER_THREADS,
        String.valueOf(Runtime.getRuntime().availableProcessors()));
    defaultProps.setProperty(
        Constants.MASTER_MIN_WORKER_THREADS,
        String.valueOf(Runtime.getRuntime().availableProcessors()));

    InputStream defaultInputStream =
        TachyonConf.class.getClassLoader().getResourceAsStream(DEFAULT_PROPERTIES);
    if (defaultInputStream == null) {
      throw new RuntimeException("The default Tachyon properties file does not exist.");
    }
    try {
      defaultProps.load(defaultInputStream);
    } catch (IOException e) {
      throw new RuntimeException("Unable to load default Tachyon properties file.", e);
    }

    // Load site specific properties file
    Properties siteProps = new Properties();
    InputStream siteInputStream =
        TachyonConf.class.getClassLoader().getResourceAsStream(SITE_PROPERTIES);
    if (siteInputStream != null) {
      try {
        siteProps.load(siteInputStream);
      } catch (IOException e) {
        LOG.warn("Unable to load site Tachyon configuration file.", e);
      }
    }

    // Load system properties
    Properties systemProps = new Properties();
    if (includeSystemProperties) {
      systemProps.putAll(System.getProperties());
    }

    // Now lets combine
    mProperties.putAll(defaultProps);
    mProperties.putAll(siteProps);
    mProperties.putAll(systemProps);

    // Update tachyon.master_address
    String masterHostname = mProperties.getProperty(Constants.MASTER_HOSTNAME);
    String masterPort = mProperties.getProperty(Constants.MASTER_PORT);
    boolean useZk = Boolean.parseBoolean(mProperties.getProperty(Constants.USE_ZOOKEEPER));
    String masterAddress =
        (useZk ? Constants.HEADER_FT : Constants.HEADER) + masterHostname + ":" + masterPort;
    mProperties.setProperty(Constants.MASTER_ADDRESS, masterAddress);
  }
Example #12
0
 /**
  * @param languagePack
  * @param lang
  */
 public void handleLanguageLoad(Properties languagePack, String lang) {
   Properties usPack = modLanguageData.get("en_US");
   if (usPack != null) {
     languagePack.putAll(usPack);
   }
   Properties langPack = modLanguageData.get(lang);
   if (langPack == null) {
     return;
   }
   languagePack.putAll(langPack);
 }
Example #13
0
 @Override
 public void writeToFile() throws IOException {
   final File aPropertyFile = getPropertyFile();
   if (aPropertyFile == null) {
     return;
   }
   m_Props.putAll(m_IntegerValues);
   m_Props.putAll(m_HourValues);
   final OutputStream out = new FileOutputStream(aPropertyFile);
   m_Props.store(out, "This is an optional header comment string");
 }
Example #14
0
  public String parseUri(String uri, String... paths) throws Exception {
    Properties prop = null;
    if (paths != null) {
      // location may contain JVM system property or OS environment variables
      // so we need to parse those
      String[] locations = parseLocations(paths);

      // check cache first
      CacheKey key = new CacheKey(locations);
      prop = cache ? cacheMap.get(key) : null;
      if (prop == null) {
        prop =
            propertiesResolver.resolveProperties(
                getVramelContext(), ignoreMissingLocation, locations);
        if (cache) {
          cacheMap.put(key, prop);
        }
      }
    }

    // use override properties
    if (prop != null && overrideProperties != null) {
      // make a copy to avoid affecting the original properties
      Properties override = new Properties();
      override.putAll(prop);
      override.putAll(overrideProperties);
      prop = override;
    }

    // enclose tokens if missing
    if (!uri.contains(prefixToken) && !uri.startsWith(prefixToken)) {
      uri = prefixToken + uri;
    }
    if (!uri.contains(suffixToken) && !uri.endsWith(suffixToken)) {
      uri = uri + suffixToken;
    }

    LOG.trace("Parsing uri {} with properties: {}", uri, prop);

    if (propertiesParser instanceof AugmentedPropertyNameAwarePropertiesParser) {
      return ((AugmentedPropertyNameAwarePropertiesParser) propertiesParser)
          .parseUri(
              uri,
              prop,
              prefixToken,
              suffixToken,
              propertyPrefix,
              propertySuffix,
              fallbackToUnaugmentedProperty);
    } else {
      return propertiesParser.parseUri(uri, prop, prefixToken, suffixToken);
    }
  }
 /**
  * {@inheritDoc}
  *
  * <p>This implementation considers existing system properties as well as platform specific ones,
  * defined in this class. The system properties are convenient for changing the configuration
  * directly from the command line (useful for CI builds) leaving the programmer to ultimately
  * decide the actual configuration used.
  */
 public Properties getConfigurationProperties() {
   // check if defaults should apply
   if (configurationProperties == null) {
     configurationProperties = new Properties();
     // system properties
     configurationProperties.putAll(System.getProperties());
     // local properties
     configurationProperties.putAll(getPlatformProperties());
     return configurationProperties;
   }
   return configurationProperties;
 }
  public static Properties getSystemProperties() {
    Properties res = ourSystemProperties;
    if (res == null) {
      res = new Properties();
      res.putAll(System.getProperties());

      for (Iterator<Object> itr = res.keySet().iterator(); itr.hasNext(); ) {
        final String propertyName = itr.next().toString();
        if (propertyName.startsWith("idea.")) {
          itr.remove();
        }
      }

      for (Map.Entry<String, String> entry : System.getenv().entrySet()) {
        String key = entry.getKey();
        if (key.startsWith("=")) {
          continue;
        }
        if (SystemInfo.isWindows) {
          key = key.toUpperCase();
        }
        res.setProperty("env." + key, entry.getValue());
      }

      ourSystemProperties = res;
    }
    return res;
  }
Example #17
0
  public KafkaCluster(Properties baseProperties, int numOfBrokers) throws IOException {

    this.zookeeper = new EmbeddedZookeeper();
    this.brokers = new ArrayList<KafkaServer>();

    this.props = new Properties();

    this.props.putAll(baseProperties);

    StringBuilder builder = null;

    for (int i = 0; i < numOfBrokers; ++i) {
      if (builder != null) builder.append(",");
      else builder = new StringBuilder();

      int brokerPort = getAvailablePort();

      builder.append("localhost:");
      builder.append(brokerPort);

      Properties properties = new Properties();
      properties.putAll(baseProperties);
      properties.setProperty("zookeeper.connect", zookeeper.getConnection());
      properties.setProperty("broker.id", String.valueOf(i + 1));
      properties.setProperty("host.name", "localhost");
      properties.setProperty("port", Integer.toString(brokerPort));
      properties.setProperty("log.dir", getTempDir().getAbsolutePath());
      properties.setProperty("log.flush.interval.messages", String.valueOf(1));

      brokers.add(startBroker(properties));
    }

    this.props.put("metadata.broker.list", builder.toString());
    this.props.put("zookeeper.connect", zookeeper.getConnection());
  }
  /**
   * All the BND magic happens here.
   *
   * @param jarInputStream On what to operate.
   * @param instructions BND instructions from user API
   * @param symbolicName Mandatory Header. In case user does not set it.
   * @return Bundle Jar Stream
   * @throws Exception Problems go here
   */
  private InputStream createBundle(
      InputStream jarInputStream, Properties instructions, String symbolicName) throws Exception {
    NullArgumentException.validateNotNull(jarInputStream, "Jar URL");
    NullArgumentException.validateNotNull(instructions, "Instructions");
    NullArgumentException.validateNotEmpty(symbolicName, "Jar info");

    final Jar jar = new Jar("dot", sink(jarInputStream));

    final Properties properties = new Properties();
    properties.putAll(instructions);

    final Analyzer analyzer = new Analyzer();
    analyzer.setJar(jar);
    analyzer.setProperties(properties);

    // throw away already existing headers that we overwrite:

    analyzer.mergeManifest(jar.getManifest());

    checkMandatoryProperties(analyzer, jar, symbolicName);
    Manifest manifest = analyzer.calcManifest();
    jar.setManifest(manifest);

    return createInputStream(jar);
  }
Example #19
0
  public static void main(String[] args) {
    java.util.Properties props = new Properties();
    props.putAll(System.getProperties());
    props.put("org.omg.CORBA.ORBClass", "org.apache.yoko.orb.CORBA.ORB");
    props.put("org.omg.CORBA.ORBSingletonClass", "org.apache.yoko.orb.CORBA.ORBSingleton");

    int status = 0;
    ORB orb = null;

    try {
      orb = ORB.init(args, props);
      status = run(orb, false, args);
    } catch (Exception ex) {
      ex.printStackTrace();
      status = 1;
    }

    if (orb != null) {
      try {
        orb.destroy();
      } catch (Exception ex) {
        ex.printStackTrace();
        status = 1;
      }
    }

    System.exit(status);
  }
  protected void mergeFileTemplate(Template pTemplate, Context pContext, Writer pWriter)
      throws MergeTemplateException {

    Properties props = WebMacroHelper.getDefaultProperties();
    props.putAll(this.properties);

    props.setProperty("TemplateEncoding", pTemplate.getInputEncoding());
    String path = pTemplate.getResource();
    if (log.isDebugEnabled()) {
      log.debug("模板文件: \"" + path + "\" 采用WebMacro引擎进行合并.");
      log.debug("模板文件: \"" + path + "\" 输入编码方式是:" + pTemplate.getInputEncoding());
    }

    /**
     * @FIXME 由于WebMacro没有提供运行时,设置模板编码方式,所以要求每次实例化Engine,这样性能有些影响,希望以后版本
     * WebMacro会提供该方法。不过好在,是单机版本的,性能问题不大.
     */
    WM wm = WebMacroHelper.getWMEngine(props);

    org.webmacro.Context c = new org.webmacro.Context(wm.getBroker());
    Map params = pContext.getParameters();
    for (Iterator i = params.keySet().iterator(); i.hasNext(); ) {
      String key = (String) i.next();
      Object value = params.get(key);
      c.put(key, value);
    }

    org.webmacro.Template t = null;
    try {
      t = wm.getTemplate(pTemplate.getResource());
    } catch (ResourceException e) {
      final String MSG = "合并模板文件 \"" + path + "\"  失败!" + e.getMessage();
      if (log.isErrorEnabled()) {
        log.error(MSG, e);
      }
      throw new MergeTemplateException(MSG, e);
    }

    String result = null;
    try {
      //			result = t.evaluateAsString(c);
      //		} catch (PropertyException e) {
    } catch (Exception e) {
      final String MSG = "合并模板文件 \"" + path + "\"  失败!" + e.getMessage();
      if (log.isErrorEnabled()) {
        log.error(MSG, e);
      }
      throw new MergeTemplateException(MSG, e);
    }

    try {
      pWriter.write(result);
    } catch (IOException e) {
      final String MSG = "合并模板文件 \"" + path + "\"  失败!" + e.getMessage();
      if (log.isErrorEnabled()) {
        log.error(MSG, e);
      }
      throw new MergeTemplateException(MSG, e);
    }
  }
  static {
    // pick up system properties
    TESTING_PROPS.putAll(System.getProperties());

    // override with test settings
    try {
      TESTING_PROPS.load(TestUtils.class.getResourceAsStream("/test.properties"));
    } catch (IOException e) {
      throw new RuntimeException("Cannot load default Hadoop test properties");
    }

    // manually select the hadoop properties
    String fs = System.getProperty("hd.fs");
    String jt = System.getProperty("hd.jt");

    // override
    if (StringUtils.hasText(fs)) {
      System.out.println("Setting FS to " + fs);
      TESTING_PROPS.put("fs.default.name", fs.trim());
    }

    if (StringUtils.hasText(jt)) {
      System.out.println("Setting JT to " + jt);
      TESTING_PROPS.put("mapred.job.tracker", jt.trim());
    }
  }
Example #22
0
 /**
  * Merge two properties files together. The additions will overwrite any existing properties in
  * source if required.
  *
  * @param source Properties
  * @param additions Properties
  * @return Properties
  */
 public Properties mergePropertiesFiles(Properties source, Properties additions) {
   if (null == source && null == additions) return new Properties();
   if (null == source) return stripReservedProperties(additions);
   if (null == additions) return stripReservedProperties(source);
   source.putAll(additions);
   return stripReservedProperties(source);
 }
Example #23
0
 /**
  * list the configurations of resource model providers.
  *
  * @return a list of maps containing:
  *     <ul>
  *       <li>type - provider type name
  *       <li>props - configuration properties
  *     </ul>
  */
 @Override
 public synchronized List<Map<String, Object>> listResourceModelConfigurations() {
   Map propertiesMap = projectConfig.getProperties();
   Properties properties = new Properties();
   properties.putAll(propertiesMap);
   return listResourceModelConfigurations(properties);
 }
  private static String[] createContainerCommands(SpringYarnAppmasterLaunchContextProperties syalcp)
      throws Exception {
    LaunchCommandsFactoryBean factory = new LaunchCommandsFactoryBean();
    String containerJar = syalcp.getArchiveFile();

    if (StringUtils.hasText(containerJar) && containerJar.endsWith("jar")) {
      factory.setJarFile(containerJar);
    } else if (StringUtils.hasText(syalcp.getRunnerClass())) {
      factory.setRunnerClass(syalcp.getRunnerClass());
    } else if (StringUtils.hasText(containerJar) && containerJar.endsWith("zip")) {
      factory.setRunnerClass("org.springframework.boot.loader.PropertiesLauncher");
    }

    factory.setArgumentsList(syalcp.getArgumentsList());

    if (syalcp.getArguments() != null) {
      Properties arguments = new Properties();
      arguments.putAll(syalcp.getArguments());
      factory.setArguments(arguments);
    }

    factory.setOptions(syalcp.getOptions());

    factory.setStdout("<LOG_DIR>/Container.stdout");
    factory.setStderr("<LOG_DIR>/Container.stderr");
    factory.afterPropertiesSet();
    return factory.getObject();
  }
Example #25
0
 /**
  * Merges the current configuration properties with alternate properties. A property from the new
  * configuration wins if it also appears in the current configuration.
  *
  * @param properties The source {@link Properties} to be merged
  */
 public static void merge(Map<?, ?> properties) {
   if (properties != null) {
     // merge the system properties
     PROPERTIES.putAll(properties);
   }
   checkUserFileBufferBytes();
 }
  public Properties getChecksumFromDatabase() {
    Properties dbSum = new Properties();
    for (final String table : tables) {
      dbSum.putAll(
          templ.queryForMap(
              CHECKSUM_SQL.replaceFirst("%s", table),
              new MapRowMapper<String, String>() {

                @Override
                public String mapRow(ResultSet resultSet, int position) throws SQLException {
                  return resultSet.getString(2);
                }

                @Override
                public Map<String, String> getMap() {
                  return CollectionUtils.createHashMap(1);
                }

                @Override
                public String getKey(ResultSet resultSet) throws SQLException {
                  return resultSet.getString(1);
                }

                @Override
                public void existingObject(String currentValue, ResultSet resultSet, int position)
                    throws SQLException {
                  throw new RuntimeException();
                }
              }));
    }
    return dbSum;
  }
Example #27
0
 protected void readExtraProperties() {
   String propFile = parameters.get("-propertyfile");
   if (propFile != null) {
     try {
       extraProperties = new Properties();
       extraProperties.load(new FileInputStream(propFile));
     } catch (IOException ioe) {
       logger.log(
           SEVERE,
           "Specified properties file {0} can''t be read due {1}",
           new Object[] {propFile, ioe});
     }
   }
   propFile = parameters.get("-xpropertyfile");
   if (propFile != null) {
     try {
       Properties xmlProperties = new Properties();
       xmlProperties.loadFromXML(new FileInputStream(propFile));
       if (extraProperties != null) extraProperties.putAll(xmlProperties);
       else extraProperties = xmlProperties;
     } catch (IOException ioe) {
       logger.log(
           SEVERE,
           "Specified properties file {0} can''t be read due {1}",
           new Object[] {propFile, ioe});
     }
   }
 }
Example #28
0
  private void _addProperties(UnicodeProperties unicodeProperties) {
    Properties properties = new Properties();

    properties.putAll(unicodeProperties);

    _addProperties(properties);
  }
  /**
   * Find valid library AndroidManifest files referenced from an already loaded AndroidManifest's
   * "project.properties" file.
   *
   * @param androidManifest
   */
  private static List<FsFile> findLibraries(AndroidManifest androidManifest) {
    List<FsFile> libraryBaseDirs = new ArrayList<>();

    if (androidManifest.getResDirectory() != null) {
      FsFile baseDir = androidManifest.getResDirectory().getParent();
      final Properties properties = getProperties(baseDir.join("project.properties"));
      Properties overrideProperties = getProperties(baseDir.join("test-project.properties"));
      properties.putAll(overrideProperties);

      int libRef = 1;
      String lib;
      while ((lib = properties.getProperty("android.library.reference." + libRef)) != null) {
        FsFile libraryBaseDir = baseDir.join(lib);
        if (libraryBaseDir.isDirectory()) {
          // Ignore directories without any files
          FsFile[] libraryBaseDirFiles = libraryBaseDir.listFiles();
          if (libraryBaseDirFiles != null && libraryBaseDirFiles.length > 0) {
            libraryBaseDirs.add(libraryBaseDir);
          }
        }

        libRef++;
      }
    }
    return libraryBaseDirs;
  }
  /**
   * Store item properties.
   *
   * @param iProps the i props
   * @throws StorageException the storage exception
   */
  protected void storeItemProperties(ItemProperties iProps) throws StorageException {
    if (!iProps.isFile()) {
      throw new IllegalArgumentException("Only files can be stored!");
    }
    logger.debug(
        "Storing metadata in [{}] in storage directory {}", iProps.getPath(), getMetadataBaseDir());
    try {

      File target = new File(getMetadataBaseDir(), iProps.getPath());
      target.getParentFile().mkdirs();
      Properties metadata = new Properties();
      metadata.putAll(iProps.getAllMetadata());
      FileOutputStream os = new FileOutputStream(target);
      try {
        metadata.store(os, "Written by " + this.getClass());
        os.flush();
      } finally {
        os.close();
      }
      target.setLastModified(iProps.getLastModified().getTime());

    } catch (IOException ex) {
      throw new StorageException("IOException in FS storage " + getMetadataBaseDir(), ex);
    }
  }