load() private method

private load ( global par0 ) : void
par0 global
return void
Ejemplo n.º 1
0
        private void ApplyGlobalConfig()
        {
            var config = Path.Combine(SupportDirectoryFinderFactory.get().find().getAbsolute(),
                                      "default.properties");

            if (File.Exists(config))
            {
                try
                {
                    var properties = new java.util.Properties();
                    properties.load(new FileInputStream(config));
                    this.setDefaults(properties);
                }
                catch (Exception e)
                {
                    Log.warn($"Failure while reading {config}", e);
                }
            }
        }
Ejemplo n.º 2
0
        private void ApplyGlobalConfig()
        {
            var config = Path.Combine(PreferencesFactory.get().getProperty("application.support.path"),
                                      "default.properties");

            if (File.Exists(config))
            {
                try
                {
                    var properties = new java.util.Properties();
                    properties.load(new FileInputStream(config));
                    defaults.putAll(properties);
                }
                catch (Exception e)
                {
                    Log.warn($"Failure while reading {config}", e);
                }
            }
        }
        private void ApplyGlobalConfig()
        {
            var config = Path.Combine(SupportDirectoryFinderFactory.get().find().getAbsolute(),
                                      "default.properties");

            if (File.Exists(config))
            {
                try
                {
                    var properties = new java.util.Properties();
                    properties.load(new FileInputStream(config));
                    foreach (var key in Utils.ConvertFromJavaList <String>(properties.keySet()))
                    {
                        setDefault(key, properties.getProperty(key));
                    }
                }
                catch (Exception e)
                {
                    Log.warn($"Failure while reading {config}", e);
                }
            }
        }
Ejemplo n.º 4
0
 public PropertyManager(File file)
 {
     serverProperties = new Properties();
     serverPropertiesFile = file;
     if (file.exists())
     {
         try
         {
             serverProperties.load(new FileInputStream(file));
         }
         catch (Exception exception)
         {
             logger.log(Level.WARNING, (new StringBuilder()).append("Failed to load ").append(file).toString(),
                        exception);
             generateNewProperties();
         }
     }
     else
     {
         logger.log(Level.WARNING, (new StringBuilder()).append(file).append(" does not exist").toString());
         generateNewProperties();
     }
 }
Ejemplo n.º 5
0
		private static AppDomain createServletDomain(ServletConfig config)
		{
				string rootPath = J2EEUtils.GetApplicationRealPath(config.getServletContext ());
				AppDomainSetup domainSetup = new AppDomainSetup();
				string name = config.getServletName();//.getServletContextName();
				if (name == null)
					name = "GH Application";
				domainSetup.ApplicationName = name;
				domainSetup.ConfigurationFile = Path.Combine (rootPath, "Web.config");
				domainSetup.PrivateBinPath = Path.Combine (rootPath, "WEB-INF/lib");

				AppDomain servletDomain = AppDomain.CreateDomain(name, null, domainSetup);





				//servletDomain.SetData(IAppDomainConfig.APP_PHYS_DIR, J2EEUtils.GetApplicationPhysicalPath(config));
				//servletDomain.SetData(IAppDomainConfig.WEB_APP_DIR, rootPath);

				servletDomain.SetData(IAppDomainConfig.APP_PHYS_DIR, J2EEUtils.GetApplicationPhysicalPath(config.getServletContext ()));
				servletDomain.SetData(IAppDomainConfig.WEB_APP_DIR, rootPath);
				servletDomain.SetData(IAppDomainConfig.SERVLET_CONFIG, config);

				//Set DataDirectory substitution string (http://blogs.msdn.com/dataaccess/archive/2005/10/28/486273.aspx)
				string dataDirectory = config.getServletContext ().getInitParameter ("DataDirectory");
				if (dataDirectory == null)
					dataDirectory = "App_Data";

				if (!Path.IsPathRooted (dataDirectory)) {
					java.io.InputStream inputStream = config.getServletContext ().getResourceAsStream ("/WEB-INF/classes/appData.properties");
					string root;
					if (inputStream != null) {
						try {
							Properties props = new Properties ();
							props.load (inputStream);
							root = props.getProperty ("root.folder");
						}
						finally {
							inputStream.close ();
						}
					}
					else
						root = config.getServletContext ().getRealPath ("/");

					if (root == null)
						root = String.Empty;

					dataDirectory = Path.Combine (root, dataDirectory);
				}

				if (dataDirectory [dataDirectory.Length - 1] != Path.DirectorySeparatorChar)
					dataDirectory += Path.DirectorySeparatorChar;

				servletDomain.SetData ("DataDirectory", dataDirectory);

				if (config.getServletContext ().getRealPath ("/") == null)
					servletDomain.SetData(".appStartTime", DateTime.UtcNow);

				// The BaseDir is the full path to the physical dir of the app
				// and allows the application to modify files in the case of
				// open deployment.
				string webApp_baseDir = config.getServletContext().getRealPath("");
				if (webApp_baseDir == null || webApp_baseDir == "")
					webApp_baseDir = rootPath;
				servletDomain.SetData(IAppDomainConfig.APP_BASE_DIR , webApp_baseDir);
				Debug.WriteLine("Initialization of webapp " + webApp_baseDir);
				//servletDomain.SetData(".hostingVirtualPath", "/");
				//servletDomain.SetData(".hostingInstallDir", "/");
				return servletDomain;
		}
 public virtual void load(InputStream @in)
 {
   if (@in == null)
   {
     Throwable.__\u003CsuppressFillInStackTrace\u003E();
     throw new NullPointerException();
   }
   else
   {
     IOException ioException;
     try
     {
       BufferedInputStream bufferedInputStream = new BufferedInputStream(@in);
       Properties properties = new Properties();
       properties.load((InputStream) bufferedInputStream);
       ((Hashtable) this.getConfiguration()).putAll((Map) properties);
       bufferedInputStream.close();
       return;
     }
     catch (IOException ex)
     {
       int num = 1;
       ioException = (IOException) ByteCodeHelper.MapException<IOException>((Exception) ex, (ByteCodeHelper.MapFlags) num);
     }
     Log.warn((object) "Unable to read configuration", (Exception) ioException);
   }
 }
Ejemplo n.º 7
0
        protected override void setDefaults()
        {
            base.setDefaults();

            this.setDefault("application.name", Application.ProductName);
            this.setDefault("application.datafolder.name", Application.ProductName);
            this.setDefault("oauth.handler.scheme",
                            String.Format("x-{0}-action", StringUtils.deleteWhitespace(Application.ProductName.ToLower())));

            this.setDefault("application.version", ApplicationVersion);
            this.setDefault("application.revision", ApplicationRevision);
            this.setDefault("application.language", GetDefaultLanguage());
            this.setDefault("application.language.custom", false.ToString());
            this.setDefault("application.localization.enable", true.ToString());

            this.setDefault("update.feed.release", "https://version.cyberduck.io/windows/changelog.rss");
            this.setDefault("update.feed.beta", "https://version.cyberduck.io/windows/beta/changelog.rss");
            this.setDefault("update.feed.nightly", "https://version.cyberduck.io/windows/nightly/changelog.rss");

            // Importers
            this.setDefault("bookmark.import.winscp.location",
                            Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "WinSCP.ini"));
            this.setDefault("bookmark.import.filezilla.location",
                            Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "FileZilla",
                                         "sitemanager.xml"));
            this.setDefault("bookmark.import.smartftp.location",
                            Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "SmartFTP",
                                         "Client 2.0", "Favorites"));
            this.setDefault("bookmark.import.totalcommander.location",
                            Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "GHISLER",
                                         "wcx_ftp.ini"));
            this.setDefault("bookmark.import.flashfxp3.location",
                            Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "FlashFXP", "3",
                                         "Sites.dat"));
            this.setDefault("bookmark.import.flashfxp4.location",
                            Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "FlashFXP", "4",
                                         "Sites.dat"));
            this.setDefault("bookmark.import.flashfxp4.common.location",
                            Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), "FlashFXP",
                                         "4",
                                         "Sites.dat"));
            this.setDefault("bookmark.import.wsftp.location",
                            Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Ipswitch", "WS_FTP",
                                         "Sites"));
            this.setDefault("bookmark.import.fireftp.location",
                            Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Mozilla", "Firefox",
                                         "Profiles"));
            this.setDefault("bookmark.import.s3browser.location",
                            Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "S3Browser",
                                         "settings.ini"));
            this.setDefault("bookmark.import.crossftp.location", Path.Combine(HomeFolder, ".crossftp", "sites.xml"));
            this.setDefault("bookmark.import.cloudberry.s3.location",
                            Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),
                                         "CloudBerry S3 Explorer for Amazon S3", "settings.list"));
            this.setDefault("bookmark.import.cloudberry.google.location",
                            Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),
                                         "CloudBerry Explorer for Google Storage", "settings.list"));
            this.setDefault("bookmark.import.cloudberry.azure.location",
                            Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),
                                         "CloudBerry Explorer for Azure Blob Storage", "settings.list"));
            this.setDefault("bookmark.import.expandrive3.location",
                            Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),
                                         "ExpanDrive", "favorites.js"));
            this.setDefault("bookmark.import.expandrive4.location",
                            Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),
                                         "ExpanDrive", "expandrive4.favorites.js"));
            this.setDefault("bookmark.import.expandrive5.location",
                            Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),
                                         "ExpanDrive", "expandrive5.favorites.js"));
            this.setDefault("bookmark.import.expandrive6.location",
                            Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),
                                         "ExpanDrive", "expandrive6.favorites.js"));
            this.setDefault("bookmark.import.netdrive2.location",
                            Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
                                         "NetDrive2", "drives.dat"));

            //disable reminder for protocol handler registration
            this.setDefault("defaulthandler.reminder", false.ToString());

            this.setDefault("update.check.last", "0");
            this.setDefault("update.check.privilege", true.ToString());

            this.setDefault("queue.download.folder", DefaultDownloadPath);
            this.setDefault("queue.upload.permissions.default", true.ToString());

            this.setDefault("queue.dock.badge", true.ToString());

            this.setDefault("ssh.knownhosts",
                            Path.Combine(new RoamingSupportDirectoryFinder().find().getAbsolute(), "known_hosts"));
            this.setDefault("browser.enterkey.rename", false.ToString());
            this.setDefault("terminal.openssh.enable", true.ToString());
            this.setDefault("terminal.windowssubsystemlinux.enable", true.ToString());
            this.setDefault("terminal.command.ssh", Path.Combine(HomeFolder, "putty.exe"));
            this.setDefault("terminal.command.ssh.args", "-ssh {0} {1}@{2} -t -P {3} -m \"{4}\"");
            this.setDefault("terminal.command.openssh.args", "{1} {0}@{2} -t -p {3} \"cd '{4}'; $SHELL\"");

            this.setDefault("editor.bundleIdentifier", new SystemWatchEditorFactory.Notepad().getIdentifier());

            this.setDefault("notifications.timeout.milliseconds", "300");

            //default browser toolbar set
            this.setDefault("browser.toolbar", true.ToString());
            this.setDefault("browser.toolbar.openconnection", true.ToString());
            this.setDefault("browser.toolbar.quickconnect", true.ToString());
            this.setDefault("browser.toolbar.action", true.ToString());
            this.setDefault("browser.toolbar.info", true.ToString());
            this.setDefault("browser.toolbar.refresh", true.ToString());
            this.setDefault("browser.toolbar.edit", true.ToString());
            this.setDefault("browser.toolbar.openinbrowser", false.ToString());
            this.setDefault("browser.toolbar.openinterminal", false.ToString());
            this.setDefault("browser.toolbar.newfolder", false.ToString());
            this.setDefault("browser.toolbar.delete", false.ToString());
            this.setDefault("browser.toolbar.download", false.ToString());
            this.setDefault("browser.toolbar.upload", true.ToString());
            this.setDefault("browser.toolbar.transfers", true.ToString());

            //default transfer toolbar set
            this.setDefault("transfer.toolbar.resume", true.ToString());
            this.setDefault("transfer.toolbar.reload", true.ToString());
            this.setDefault("transfer.toolbar.stop", true.ToString());
            this.setDefault("transfer.toolbar.remove", true.ToString());
            this.setDefault("transfer.toolbar.cleanup", false.ToString());
            this.setDefault("transfer.toolbar.log", false.ToString());
            this.setDefault("transfer.toolbar.open", true.ToString());
            this.setDefault("transfer.toolbar.show", true.ToString());

            // Resolve symbolic links downloading target file instead. Cannot create symbolic links on FAT.
            this.setDefault("path.symboliclink.resolve", true.ToString());
            // Resolve local links uploading target file instead. Currently not supporting shortcuts on Windows.
            this.setDefault("local.symboliclink.resolve", true.ToString());

            this.setDefault("local.user.home", HomeFolder);
            this.setDefault("local.delimiter", "\\");
            this.setDefault("local.normalize.tilde", false.ToString());

            // SSL Keystore
            // Add mscapi security provider
            Security.addProvider(new SunMSCAPI());
            this.setDefault("connection.ssl.keystore.type", "Windows-MY");
            this.setDefault("connection.ssl.keystore.provider", "SunMSCAPI");

            // Override secure random strong algorithm. Outputs bytes from the Windows CryptGenRandom() API
            this.setDefault("connection.ssl.securerandom.algorithm", "Windows-PRNG");
            this.setDefault("connection.ssl.securerandom.provider", "SunMSCAPI");

            // Enable Integrated Windows Authentication
            this.setDefault("connection.proxy.windows.authentication.enable", true.ToString());

            this.setDefault("webdav.ntlm.environment", true.ToString());
            if (getBoolean("webdav.ntlm.environment"))
            {
                // NTLM Windows Domain
                try
                {
                    // Gets the network domain name associated with the current user
                    this.setDefault("webdav.ntlm.domain", Environment.UserDomainName);
                }
                catch (PlatformNotSupportedException e)
                {
                    // The operating system does not support retrieving the network domain name.
                }
                catch (InvalidOperationException e)
                {
                    // The network domain name cannot be retrieved.
                }
                try
                {
                    this.setDefault("webdav.ntlm.workstation", Environment.MachineName);
                }
                catch (InvalidOperationException e)
                {
                    // The name of this computer cannot be obtained.
                }
            }
            if (Utils.IsRunningAsUWP)
            {
                // Running from Windows Store
                this.setDefault("update.check", $"{false}");
                this.setDefault("tmp.dir", ApplicationData.Current.TemporaryFolder.Path);
            }
            // Apply global configuration
            var config = Path.Combine(new RoamingSupportDirectoryFinder().find().getAbsolute(),
                                      "default.properties");

            if (File.Exists(config))
            {
                try
                {
                    var properties = new java.util.Properties();
                    properties.load(new FileInputStream(config));
                    foreach (var key in Utils.ConvertFromJavaList <String>(properties.keySet()))
                    {
                        setDefault(key, properties.getProperty(key));
                    }
                }
                catch (Exception e)
                {
                    Log.warn($"Failure while reading {config}", e);
                }
            }
        }
        /// <summary>
        /// Train a Stanford NER model from a configuration file
        /// </summary>
        /// <param name="prop">Configuration file</param>
        public bool Train(string prop)
        {
            try
            {
                java.util.Properties props = new java.util.Properties();
                InputStream st = new BufferedInputStream(new FileInputStream(prop));
                InputStreamReader reader = new InputStreamReader(st, "utf-8");
                props.load(reader);
                _crfModel = new CRFClassifier(props);

                _crfModel.train();
                String serializeTo = _crfModel.flags.serializeTo;
                if (serializeTo != null)
                {
                    _crfModel.serializeClassifier(serializeTo);
                }

                return true;
            }
            catch (Exception e)
            {
                System.Console.WriteLine("Unable to train the Standford CRF model" + e.ToString());
                return false;

            }
        }
Ejemplo n.º 9
0
    public static Properties getProperties(string name)
    {
      Properties properties = new Properties();
      ((Hashtable) properties).put((object) "platform.name", (object) name);
      name = new StringBuilder().append("properties/").append(name).append(".properties").toString();
      InputStream resourceAsStream1 = ((Class) ClassLiteral<Loader>.Value).getResourceAsStream(name);
      try
      {
        try
        {
          properties.load((Reader) new InputStreamReader(resourceAsStream1));
          goto label_27;
        }
        catch (Exception ex)
        {
          int num = 2;
          if (ByteCodeHelper.MapException<NoSuchMethodError>(ex, (ByteCodeHelper.MapFlags) num) == null)
            throw;
        }
      }
      catch (Exception ex)
      {
        int num = 2;
        if (ByteCodeHelper.MapException<Exception>(ex, (ByteCodeHelper.MapFlags) num) == null)
          throw;
        else
          goto label_7;
      }
      try
      {
        properties.load(resourceAsStream1);
        goto label_27;
      }
      catch (Exception ex)
      {
        int num = 2;
        if (ByteCodeHelper.MapException<Exception>(ex, (ByteCodeHelper.MapFlags) num) == null)
          throw;
      }
      // ISSUE: variable of the null type
      __Null local = null;
      goto label_12;
label_7:
      local = null;
label_12:
      name = "properties/generic.properties";
      InputStream resourceAsStream2 = ((Class) ClassLiteral<Loader>.Value).getResourceAsStream(name);
      Exception exception1;
      try
      {
        try
        {
          properties.load((Reader) new InputStreamReader(resourceAsStream2));
          goto label_27;
        }
        catch (Exception ex)
        {
          int num = 2;
          if (ByteCodeHelper.MapException<NoSuchMethodError>(ex, (ByteCodeHelper.MapFlags) num) == null)
            throw;
        }
      }
      catch (Exception ex)
      {
        int num = 0;
        M0 m0 = ByteCodeHelper.MapException<Exception>(ex, (ByteCodeHelper.MapFlags) num);
        if (m0 == null)
        {
          throw;
        }
        else
        {
          exception1 = (Exception) m0;
          goto label_20;
        }
      }
      Exception exception2;
      try
      {
        properties.load(resourceAsStream2);
        goto label_27;
      }
      catch (Exception ex)
      {
        int num = 0;
        M0 m0 = ByteCodeHelper.MapException<Exception>(ex, (ByteCodeHelper.MapFlags) num);
        if (m0 == null)
          throw;
        else
          exception2 = (Exception) m0;
      }
      Exception exception3 = exception2;
      goto label_26;
label_20:
      exception3 = exception1;
label_26:
      string str1 = new StringBuilder().append("Could not even get generic properties: ").append(Throwable.instancehelper_getMessage((Exception) exception3)).toString();
      string name1 = ((Class) ClassLiteral<Loader>.Value).getName();
      string str2 = name;
      Throwable.__\u003CsuppressFillInStackTrace\u003E();
      throw new MissingResourceException(str1, name1, str2);
label_27:
      return properties;
    }