/**
   * Ideally, start a master (calling serve), set a configuration, kill the master, and then reload
   * it. We make sure that there was an attempt to translate the configuration. This simulates a
   * ZK-backed master going down and coming back up with the previously specfied configuration.
   */
  @Test
  public void testReloadRefresh() throws IOException, InterruptedException, FlumeSpecException {

    ConfigurationManager cfgman2 = flumeMaster.getSpecMan();
    Map<String, FlumeConfigData> cfgs2 = cfgman2.getTranslatedConfigs();
    assertEquals(5, cfgs2.size());
  }
  public ConfigureAction(
      ApplicationProperties applicationProperties,
      ConfigurationManager configurationManager,
      GroupManager groupManager)
      throws Exception {
    this.applicationProperties = applicationProperties;
    this.configurationManager = configurationManager;
    this.groupManager = groupManager;

    // initialize params from saved properties
    dbHost = configurationManager.getDbHost();
    dbPort = configurationManager.getDbPort();
    database = configurationManager.getDatabase();
    username = configurationManager.getUsername();
    password = configurationManager.getPassword();
    mailRecipient = configurationManager.getMailRecipient();
    selectedReportGroups = configurationManager.getReportGroups();
    selectedHrReportGroups = configurationManager.getHrReportGroups();
    savedReportGroups =
        selectedReportGroups == null ? null : Arrays.asList(configurationManager.getReportGroups());
    savedHrReportGroups =
        selectedHrReportGroups == null
            ? null
            : Arrays.asList(configurationManager.getHrReportGroups());
  }
  /**
   * Authorize user.
   *
   * @param bean the bean
   * @param httpMethod the http method
   * @return true, if successful
   * @throws VtnServiceWebAPIException the vtn service web api exception
   */
  public static boolean authoriseUser(SessionBean bean, String httpMethod)
      throws VtnServiceWebAPIException {
    LOG.trace("Start VtnServiceCommonUtil#authoriseUser()");
    boolean ipStatus = false;
    final ConfigurationManager configurationManager = ConfigurationManager.getInstance();
    final String ipAddresses =
        configurationManager.getAccessProperty(ApplicationConstants.ACCESS_ALL);
    LOG.debug("Authorized IP Address from Configuration : " + ipAddresses);
    final String httpMethodAccessIpAddress =
        configurationManager.getAccessProperty(httpMethod.toUpperCase());
    LOG.debug("Authorized methods from Configuration : " + ipAddresses);

    if (ipAddresses != null && ApplicationConstants.WILD_CARD_STAR.equals(ipAddresses.trim())) {
      ipStatus = true;
    } else if (ipAddresses.indexOf(bean.getIpAddress()) != -1) {
      ipStatus = true;
    } else if (null != httpMethodAccessIpAddress
        && !httpMethodAccessIpAddress.isEmpty()
        && ApplicationConstants.WILD_CARD_STAR.equals(httpMethodAccessIpAddress.trim())) {
      ipStatus = true;
    } else if (null != httpMethodAccessIpAddress
        && !httpMethodAccessIpAddress.isEmpty()
        && httpMethodAccessIpAddress.indexOf(bean.getIpAddress()) != -1) {
      ipStatus = true;
    }

    LOG.debug("Authorize User Result : " + ipStatus);
    LOG.trace("Complete VtnServiceCommonUtil#authoriseUser()");
    return ipStatus;
  }
  @Test
  public void testGetConfigurations() throws URISyntaxException {
    // TODO make this more robust
    ProfileStoreConfiguration profileStoreConfiguration =
        configurationManager.getProfileStoreConfiguration();
    RecommenderConfiguration recommenderConfiguration =
        configurationManager.getRecommenderConfiguration();
    RecommendationsStorageConfiguration recommendationsStorageConfiguration =
        configurationManager.getRecommendationsStorageConfiguration();
    PermanentSearchStorageConfiguration permanentSearchStorageConfiguration =
        configurationManager.getPermanentSearchStorageConfiguration();
    CategoriesMappingStorageConfiguration categoriesMappingStorageStorageConfiguration =
        configurationManager.getCategoriesMappingStorageStorageConfiguration();

    assertNotNull(profileStoreConfiguration);
    assertNotNull(recommenderConfiguration);
    assertNotNull(categoriesMappingStorageStorageConfiguration);

    URI customAnnotationsTemplate = new URI("http://collective.com/annotation/user/");
    assertEquals(
        recommenderConfiguration.getIndexes().get("custom-annotations"), customAnnotationsTemplate);

    assertNotNull(recommendationsStorageConfiguration);
    assertNotNull(permanentSearchStorageConfiguration);
    assertTrue(
        permanentSearchStorageConfiguration
            .getProperties()
            .getProperty("url")
            .endsWith("collective-permanent-search"));
  }
 /** Test double use of config file. */
 @Test
 public void testEmailPropertiesEasy() {
   Assert.assertEquals(
       "email_smtp_address", configurationManager.getEmailConfiguration().getSmtpAddress());
   Assert.assertEquals(
       "email_auth_password", configurationManager.getEmailConfiguration().getAuthPassword());
 }
 /**
  * @param search
  * @return a list of urls
  */
 public static ArrayList<URL> getRemoteCoversList(String search) throws Exception {
   ArrayList alOut = new ArrayList(20); // URL list
   String sSearchUrl =
       "http://images.google.com/images?q="
           + URLEncoder.encode(search, "ISO-8859-1")
           + "&ie=ISO-8859-1&hl=en&btnG=Google+Search"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
   Log.debug("Search URL: " + sSearchUrl); // $NON-NLS-1$
   byte[] bRes = download(new URL(sSearchUrl), false);
   if (bRes == null || bRes.length == 0) {
     return alOut;
   }
   String sRes = new String(bRes);
   // get urls
   String[] strings = sRes.split("imgurl="); // $NON-NLS-1$
   for (int i = 1; i < strings.length; i++) {
     String s = strings[i].substring(0, strings[i].indexOf('&'));
     s = s.replaceAll("%2520", "%20"); // $NON-NLS-1$ //$NON-NLS-2$
     alOut.add(new URL(s));
   }
   // get sizes
   strings = sRes.split("pixels - "); // $NON-NLS-1$
   int iNbRemove = 0; // removes number used to compute new index
   for (int i = 1; i < strings.length; i++) {
     int iKPos = strings[i].indexOf('k');
     int iSize = Integer.parseInt(strings[i].substring(0, iKPos));
     if (iSize > ConfigurationManager.getInt(CONF_COVERS_MAX_SIZE)
         || iSize > MAX_COVER_SIZE
         || iSize < ConfigurationManager.getInt(CONF_COVERS_MIN_SIZE)) {
       alOut.remove(i - (1 + iNbRemove));
       iNbRemove++;
     }
   }
   return alOut;
 }
  /** Test to make sure that missing optional keys do not cause a malfunction. */
  @Test
  public void testInitializerWithOptionalKeys() {
    final String emptyKey = "empty.key";
    final String emptyValue = configurationManager.getOptionalProperty(emptyKey);
    Assert.assertEquals("", emptyValue);

    final String bogusKey = "bogus.key";
    final String nullValue = configurationManager.getOptionalProperty(bogusKey);
    Assert.assertNull(nullValue);
  }
 /**
  * @param sHostname, the host name
  * @param sProxyURL The proxy port, null if you don't use a proxy
  * @param iProxyPort, proxy port if you use one of -1 if not
  * @return An host configuration
  */
 private static HostConfiguration getHostConfiguration(
     String sHostname, String sProxyURL, int iProxyPort) {
   HostConfiguration host = new HostConfiguration();
   host.setHost(sHostname);
   if (sProxyURL != null && iProxyPort > 0) {
     host.setProxy(
         ConfigurationManager.getProperty(CONF_NETWORK_PROXY_HOSTNAME),
         ConfigurationManager.getInt(CONF_NETWORK_PROXY_PORT));
   }
   return host;
 }
  @Test
  public void testConfigFileWithOnlyServerList() {
    final String fullLocationFileWithList =
        ClassLoader.getSystemResource(testFileWithOnlyServerList).getFile();

    final ConfigurationManager protexCM =
        new TestConfigurationManagerBean(fullLocationFileWithList);

    final ServerBean protexServerBean = protexCM.getServerBean(protex);
    Assert.assertEquals("bla_protex", protexServerBean.getServerName());
  }
  /**
   * Test single use of config file.
   *
   * @throws IOException
   */
  @Test
  public void testEmailPropertiesSingleUse() throws IOException {
    final File workingConfigFile =
        File.createTempFile("ConfigurationManagerTest.testEmailPropertiesDifficult", "config");
    FileUtils.copyFile(
        new File("src/test/resources/email/email_test_config.properties"), workingConfigFile);
    final ConfigurationManager emailCM =
        new TestConfigurationManagerBean(workingConfigFile.getAbsolutePath());

    Assert.assertEquals("email_auth_password", emailCM.getEmailConfiguration().getAuthPassword());
  }
  /**
   * Tests to make sure that the list is parsed and the server bean is correct The list specified is
   * the /server/test_server_config.xml
   */
  @Test
  public void testConfigFileWithServerListAndOldConfig() {
    final String fullLocationFileWithList =
        ClassLoader.getSystemResource(testFileWithServerList).getFile();

    final ConfigurationManager cm = new TestConfigurationManagerBean(fullLocationFileWithList);

    final ServerBean protexServerBean = cm.getServerBean(protex);
    final ServerBean ccServerBean = cm.getServerBean(cc);

    Assert.assertEquals("bla_protex", protexServerBean.getServerName());
    Assert.assertEquals("bla_codecenter", ccServerBean.getServerName());
  }
 @Test
 public void testConfigurationClass() {
   TestConfiguration config = (TestConfiguration) ConfigurationManager.getConfigInstance();
   assertTrue(ConfigurationManager.isConfigurationInstalled());
   Object configSource = DynamicPropertyFactory.getInstance().getBackingConfigurationSource();
   assertTrue(configSource == config);
   try {
     ConfigurationManager.install(new BaseConfiguration());
     fail("IllegalStateException expected");
   } catch (IllegalStateException e) {
     assertNotNull(e);
   }
 }
  /**
   * Download the resource at the given url
   *
   * @param url to download
   * @param Use cache : store file in image cache
   * @throws Exception
   * @return result as an array of bytes, null if a problem occured
   */
  public static byte[] download(URL url, boolean bUseCache) throws Exception {
    byte[] bOut = null;
    // check if file is not already downloaded or being downloaded
    if (bUseCache) {
      if (new File(Util.getCachePath(url)).exists()) {
        return bOut;
      }
    }
    GetMethod get = null;
    HttpClient client = null;
    int iConTO = 1000 * ConfigurationManager.getInt(CONF_NETWORK_CONNECTION_TO);
    int iTraTO = 1000 * ConfigurationManager.getInt(CONF_NETWORK_TRANSFERT_TO);
    if (ConfigurationManager.getBoolean(CONF_NETWORK_USE_PROXY)) {
      client =
          getHTTPClient(
              ConfigurationManager.getProperty(CONF_NETWORK_PROXY_LOGIN),
              DownloadManager.getProxyPwd(),
              iConTO,
              iTraTO);
    } else {
      client = getHTTPClient(iConTO, iTraTO);
    }
    get = new GetMethod(url.toString());
    get.addRequestHeader(
        "Accept",
        "image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*"); //$NON-NLS-1$ //$NON-NLS-2$
    get.addRequestHeader("Accept-Language", "en-us"); // $NON-NLS-1$ //$NON-NLS-2$
    get.addRequestHeader(
        "User-Agent",
        "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)"); //$NON-NLS-1$ //$NON-NLS-2$
    get.addRequestHeader("Connection", "Keep-Alive"); // $NON-NLS-1$ //$NON-NLS-2$
    int status = client.executeMethod(get);
    if (bUseCache) {

      BufferedOutputStream bos =
          new BufferedOutputStream(new FileOutputStream(Util.getCachePath(url)));
      BufferedInputStream bis = new BufferedInputStream(get.getResponseBodyAsStream());
      int i;
      while ((i = bis.read()) != -1) {
        bos.write(i);
      }
      bos.close();
      bis.close();
    } else {
      bOut = get.getResponseBody();
    }
    if (get != null && get.isRequestSent()) {
      get.releaseConnection();
    }
    return bOut;
  }
Example #14
0
  public void initialize(String logName, boolean debugMode) throws IOException {

    if (VersionChecker.runningOnAndroid())
      outFile =
          new BufferedWriter(
              new FileWriter(ConfigurationManager.getMindPath() + logName + "-Log.txt"));
    else
      outFile =
          new BufferedWriter(
              new FileWriter(ConfigurationManager.getMindPath() + logName + "-log.txt"));

    this._debugMode = debugMode;
    this._initialized = true;
  }
Example #15
0
 @Override
 public void windowClosing(WindowEvent e) {
   System.out.println("windowClosing");
   frame.closeCurrentConnection();
   String winState = "Norm";
   if ((frame.getExtendedState() & Frame.MAXIMIZED_BOTH) == Frame.MAXIMIZED_BOTH) {
     winState = "Max";
   }
   winState = wsl.x + "," + wsl.y + "," + wsl.w + "," + wsl.h + "," + winState;
   ConfigurationManager.setConfigItem(ConfigurationManager.CONFIG_WINDOWSTATE, winState);
   if (ConfigurationManager.saveConfig()) {
     System.out.println("config saved");
   }
   frame.dispose();
 }
 public ParameterTypeConfigurable(String key, String description, String typeId) {
   super(key, description);
   if (!ConfigurationManager.getInstance().hasTypeId(typeId)) {
     throw new IllegalArgumentException("Unknown configurable type: " + typeId);
   }
   this.typeId = typeId;
 }
 /** Test initializer with good file and missing value. */
 @Test
 public void testInitializerWithGoodFileAndMissingValue() {
   final String emptyKey = "empty.key";
   exception.expect(IllegalArgumentException.class);
   exception.expectMessage("Value DNE for key: " + emptyKey);
   configurationManager.getProperty(emptyKey);
 }
 /** Test initializer with good file and missing key. */
 @Test
 public void testInitializerWithGoodFileAndMissingKey() {
   final String bogusKey = "BOGUS KEY";
   exception.expect(IllegalArgumentException.class);
   exception.expectMessage("Property key DNE: " + bogusKey);
   configurationManager.getProperty(bogusKey);
 }
  @Test
  public void testCalendar() {
    Date now = new Date();
    StringDerivedProperty<Date> calendarProperty =
        new StringDerivedProperty<Date>(
            "myproperty",
            now,
            new Function<String, Date>() {
              @Override
              public Date apply(@Nullable String input) {
                Date d = new Date();
                try {
                  d.setTime(Long.parseLong(input));
                } catch (Exception e) {
                  return new Date(0);
                }
                return d;
              }
            });
    assertEquals(now, calendarProperty.getValue());

    Date newTime = new Date();
    newTime.setTime(now.getTime() + 60000);

    ConfigurationManager.getConfigInstance()
        .setProperty("myproperty", String.valueOf(newTime.getTime()));
    assertEquals(newTime, calendarProperty.getValue());
  }
Example #20
0
  /** Initializes and constructs this panel. */
  private void init() {
    this.phoneNumberCombo.setEditable(true);

    this.callViaPanel.add(callViaLabel);
    this.callViaPanel.add(accountSelectorBox);

    this.comboPanel.add(phoneNumberCombo, BorderLayout.CENTER);

    this.callButton.setName("call");
    this.hangupButton.setName("hangup");
    this.minimizeButton.setName("minimize");
    this.restoreButton.setName("restore");

    this.minimizeButton.setToolTipText(
        Messages.getI18NString("hideCallPanel").getText() + " Ctrl - H");
    this.restoreButton.setToolTipText(
        Messages.getI18NString("showCallPanel").getText() + " Ctrl - H");

    this.callButton.addActionListener(this);
    this.hangupButton.addActionListener(this);
    this.minimizeButton.addActionListener(this);
    this.restoreButton.addActionListener(this);

    this.buttonsPanel.add(callButton);
    this.buttonsPanel.add(hangupButton);

    this.callButton.setEnabled(false);

    this.hangupButton.setEnabled(false);

    this.add(minimizeButtonPanel, BorderLayout.SOUTH);

    this.setCallPanelVisible(ConfigurationManager.isCallPanelShown());
  }
Example #21
0
  /**
   * Validators can use project level settings (Project natures and facets) to determine if they are
   * applicable to the project or not.
   *
   * @param project The project that the configuration is based on.
   * @param useProject Specifies how to use the project preferences. This can be used to force the
   *     project properties to be used. There is a case where the user has toggled the Enable
   *     project specific settings checkbox in the dialog, but has not yet committed the changes.
   *     This allows that setting to be passed through.
   * @return The validators that are configured to run on this project based on the project level
   *     settings. These are the "live" validators, they are not copies.
   * @throws ProjectUnavailableError
   */
  public Validator[] getValidatorsConfiguredForProject(
      IProject project, UseProjectPreferences useProject) throws ProjectUnavailableError {
    Map<String, Validator> v2Vals = getV2Validators(project, useProject);
    TreeSet<Validator> sorted = new TreeSet<Validator>();
    sorted.addAll(v2Vals.values());

    if (useProject == UseProjectPreferences.MustNotUse) {
      sorted.addAll(ExtensionValidators.instance().getV1Validators(project));
    } else {
      try {
        ValidationConfiguration vc =
            ConfigurationManager.getManager().getProjectConfiguration(project);
        ValidatorMetaData[] vmds = vc.getValidators();
        for (ValidatorMetaData vmd : vmds) {
          Validator v = Validator.create(vmd, vc, project);
          sorted.add(v);
        }
      } catch (InvocationTargetException e) {
        ValidationPlugin.getPlugin().handleException(e);
      }
    }

    List<Validator> list = new LinkedList<Validator>();
    for (Validator v : sorted) {
      if (v.shouldValidateProject(project, false, false)) list.add(v);
    }

    Validator[] vals = new Validator[list.size()];
    list.toArray(vals);
    return vals;
  }
Example #22
0
  /**
   * Answer all the validators for the given project.
   *
   * <p>Individual projects may override the global validation preference settings. If the project
   * has it's own settings, then those validators are returned via this method.
   *
   * <p>The following approach is used. For version 1 validators, the validator is only returned if
   * it is defined to operate on this project type. This is the way that the previous version of the
   * framework did it. For version 2 validators, they are all returned.
   *
   * @param project This may be null, in which case the global preferences are returned.
   * @return The validators in name sorted order.
   */
  private Validator[] getValidatorsNotCached(IProject project) throws ProjectUnavailableError {
    Map<String, Validator> v2Vals = getV2Validators(project, UseProjectPreferences.Normal);
    TreeSet<Validator> sorted = new TreeSet<Validator>();
    sorted.addAll(v2Vals.values());

    try {
      ValidationConfiguration vc = ConfigurationManager.getManager().getConfiguration(project);
      if (project == null) {
        // If the project is null we need to use this approach, since you can not use new
        // ManualValidatorsOperation(null)
        ValidatorMetaData[] vmds = vc.getValidators();
        for (ValidatorMetaData vmd : vmds) {
          Validator v = Validator.create(vmd, vc, project);
          sorted.add(v);
        }
      } else {
        ManualValidatorsOperation mvo = new ManualValidatorsOperation(project);
        Set<ValidatorMetaData> vmds = mvo.getEnabledValidators();
        for (ValidatorMetaData vmd : vmds) {
          Validator v = Validator.create(vmd, vc, project);
          sorted.add(v);
        }
      }
    } catch (InvocationTargetException e) {
      ValidationPlugin.getPlugin().handleException(e);
    }

    Validator[] vals = new Validator[sorted.size()];
    sorted.toArray(vals);
    return vals;
  }
Example #23
0
  private Configurable getComponentFromAnnotation(String name, S4Component s4Component) {
    Configurable configurable;
    Class<? extends Configurable> defClass = s4Component.defaultClass();

    if (defClass.equals(Configurable.class) && s4Component.mandatory()) {
      throw new InternalConfigurationException(
          getInstanceName(), name, "mandatory property is not set!");
    }

    if (Modifier.isAbstract(defClass.getModifiers()) && s4Component.mandatory())
      throw new InternalConfigurationException(
          getInstanceName(), name, defClass.getName() + " is abstract!");

    // because we're forced to use the default type, make sure that it
    // is set
    if (defClass.equals(Configurable.class)) {
      if (s4Component.mandatory()) {
        throw new InternalConfigurationException(
            getInstanceName(), name, instanceName + ": no default class defined for " + name);
      } else {
        return null;
      }
    }

    configurable = ConfigurationManager.getInstance(defClass);
    if (configurable == null) {
      throw new InternalConfigurationException(
          getInstanceName(), name, "instantiation of referenenced configurable failed");
    }

    return configurable;
  }
Example #24
0
  /**
   * Gets a component associated with the given parameter name. First search the component in
   * property table, then try to get component by name from the manager, then creates component with
   * default properties.
   *
   * @param name the parameter name
   * @return the component associated with the name
   * @throws edu.cmu.sphinx.util.props.PropertyException if the component does not exist or is of
   *     the wrong type.
   */
  public Configurable getComponent(String name) throws PropertyException {
    S4PropWrapper s4PropWrapper = getProperty(name, S4Component.class);
    Configurable configurable = null;

    S4Component s4Component = (S4Component) s4PropWrapper.getAnnotation();
    Class<? extends Configurable> expectedType = s4Component.type();

    Object propVal = propValues.get(name);

    if (propVal != null && propVal instanceof Configurable) {
      return (Configurable) propVal;
    }

    if (propVal != null && propVal instanceof String) {
      PropertySheet ps = cm.getPropertySheet(flattenProp(name));
      if (ps != null) configurable = ps.getOwner();
      else
        throw new InternalConfigurationException(
            getInstanceName(), name, "component '" + flattenProp(name) + "' is missing");
    }

    if (configurable != null && !expectedType.isInstance(configurable))
      throw new InternalConfigurationException(
          getInstanceName(), name, "mismatch between annotation and component type");

    if (configurable != null) {
      propValues.put(name, configurable);
      return configurable;
    }

    configurable = getComponentFromAnnotation(name, s4Component);

    propValues.put(name, configurable);
    return configurable;
  }
  @Override
  protected String doExecute() throws Exception {
    configurationManager.setDbHost(dbHost);
    configurationManager.setDbPort(dbPort);
    configurationManager.setDatabase(database);
    configurationManager.setUsername(username);
    configurationManager.setPassword(password);
    configurationManager.setMailRecipient(mailRecipient);
    configurationManager.setReportGroups(selectedReportGroups);
    configurationManager.setHrReportGroups(selectedHrReportGroups);
    savedReportGroups = Arrays.asList(configurationManager.getReportGroups());
    savedHrReportGroups = Arrays.asList(configurationManager.getHrReportGroups());
    setSaved(true);

    return getRedirect("ViewRegerConfiguration!default.jspa?saved=true");
  }
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.about);
    // set display size
    final Display display = getWindowManager().getDefaultDisplay();
    ThumbSize.setScreenSize(display.getWidth(), display.getHeight());

    try {
      mEventClientManager = ManagerFactory.getEventClientManager(null);
      final String versionName =
          getPackageManager().getPackageInfo(getPackageName(), 0).versionName;
      final int versionCode = getPackageManager().getPackageInfo(getPackageName(), 0).versionCode;
      ((TextView) findViewById(R.id.about_version)).setText("v" + versionName);
      ((TextView) findViewById(R.id.about_revision)).setText("Revision " + versionCode);
      TextView message = (TextView) findViewById(R.id.about_url_message);

      message.setText(
          Html.fromHtml(
              "Visit our project page at <a href=\"http://code.google.com/p/android-xbmcremote\">Google Code</a>."));
      message.setMovementMethod(LinkMovementMethod.getInstance());
    } catch (NameNotFoundException e) {
      ((TextView) findViewById(R.id.about_version)).setText("Error reading version");
    }
    mConfigurationManager = ConfigurationManager.getInstance(this);
  }
  public T loadExistingOrCreateNewConfiguration() throws JAXBException {
    ConfigurationManager configurationManager = ConfigurationManager.getInstance();
    Object confObject =
        configurationManager.loadConfiguration(configPath, defaultConfiguration.getClass());
    T configuration = null;

    // existuje konfigurační soubor ?
    if (confObject == null) {
      // neexistuje - vytvoř implicitní a ulož
      configuration = defaultConfiguration;
      configurationManager.storeConfiguration(configPath, configuration);
    } else {
      configuration = (T) confObject;
    }
    return configuration;
  }
 /**
  * @param URI
  * @return
  * @throws VtnServiceWebAPIException
  */
 public static boolean validateGetAPI(String URI) throws VtnServiceWebAPIException {
   LOG.trace("Start VtnServiceCommonUtil#validateGetAPI()");
   boolean status = false;
   if (null != URI && !URI.isEmpty()) {
     if (URI.trim().contains(ApplicationConstants.CONTROLLERSTR)
         && URI.trim().contains(ApplicationConstants.DOMAINSTR)
         && URI.trim().contains(ApplicationConstants.LOGICALPORTSSTR)) {
       status = true;
     } else if (URI.trim().startsWith(ApplicationConstants.SESSIONSTR)
         && URI.trim().length() > ApplicationConstants.SESSIONSTR.length()) {
       status = true;
     } else {
       final String getListAPI =
           ConfigurationManager.getInstance().getConfProperty(ApplicationConstants.GETLISTAPI);
       if (null != getListAPI && !getListAPI.isEmpty()) {
         final String[] tempList = getListAPI.split(ApplicationConstants.COMMA_STR);
         for (int i = 0; i < tempList.length; i++) {
           final String getStr = tempList[i];
           if (URI.trim().equals(getStr.trim())) {
             status = true;
             break;
           }
         }
       }
     }
   }
   LOG.trace("Complete VtnServiceCommonUtil#validateGetAPI()");
   return status;
 }
  @Test
  public void testPropertyChanged() {
    final AtomicBoolean derived = new AtomicBoolean(false);

    final String defaultVal = "hi";
    StringDerivedProperty<String> p =
        new StringDerivedProperty<String>(
            "com.netflix.hello",
            defaultVal,
            new Function<String, String>() {
              @Override
              public String apply(String input) {
                derived.set(true);
                return String.format("%s/derived", input);
              }
            });

    assertEquals(defaultVal, p.getValue());

    ConfigurationManager.getConfigInstance().setProperty("com.netflix.hello", "archaius");

    assertTrue("derive() was not called", derived.get());

    assertEquals(String.format("%s/derived", "archaius"), p.getValue());
  }
 /** Set default proxy settings, used by cobra for ie */
 public static synchronized void setDefaultProxySettings() {
   String sProxyHost = ConfigurationManager.getProperty(CONF_NETWORK_PROXY_HOSTNAME);
   int iProxyPort = ConfigurationManager.getInt(CONF_NETWORK_PROXY_PORT);
   String sProxyLogin = ConfigurationManager.getProperty(CONF_NETWORK_PROXY_LOGIN);
   String sProxyPwd = ConfigurationManager.getProperty(CONF_NETWORK_PROXY_PWD);
   Type proxyType = Type.DIRECT;
   if (ConfigurationManager.getBoolean(CONF_NETWORK_USE_PROXY)) {
     // Set default proxy value
     if (PROXY_TYPE_HTTP.equals(ConfigurationManager.getProperty(CONF_NETWORK_PROXY_TYPE))) {
       proxyType = Type.HTTP;
     } else if (PROXY_TYPE_SOCKS.equals(
         ConfigurationManager.getProperty(CONF_NETWORK_PROXY_TYPE))) {
       proxyType = Type.SOCKS;
     }
     try {
       proxy = new Proxy(proxyType, sProxyHost, iProxyPort, sProxyLogin, sProxyPwd);
     } catch (Exception e) {
       Log.error(e);
       return;
     }
   }
   // Set system defaults proxy values, if we don't use DownloadManager
   // methods
   // see http://java.sun.com/j2se/1.4.2/docs/guide/net/properties.html
   if (ConfigurationManager.getBoolean(CONF_NETWORK_USE_PROXY)) {
     System.getProperties().put("proxySet", "true");
     if (PROXY_TYPE_HTTP.equals(ConfigurationManager.getProperty(CONF_NETWORK_PROXY_TYPE))) {
       System.setProperty("http.proxyHost", sProxyHost);
       System.setProperty("http.proxyPort", Integer.toString(iProxyPort));
     } else if (PROXY_TYPE_SOCKS.equals(
         ConfigurationManager.getProperty(CONF_NETWORK_PROXY_TYPE))) {
       System.setProperty("socksProxyHost", sProxyHost);
       System.setProperty("socksProxyPort ", Integer.toString(iProxyPort));
     }
     Authenticator.setDefault(
         new Authenticator() {
           @Override
           protected PasswordAuthentication getPasswordAuthentication() {
             String user = ConfigurationManager.getProperty(CONF_NETWORK_PROXY_LOGIN);
             char[] pwd =
                 Util.rot13(ConfigurationManager.getProperty(CONF_NETWORK_PROXY_PWD))
                     .toCharArray();
             return new PasswordAuthentication(user, pwd);
           }
         });
   }
 }