Java 类org.apache.commons.configuration.DataConfiguration 实例源码

项目:otroslogviewer    文件:ShowConfigTest.java   
public static void main(String[] args) throws UnsupportedLookAndFeelException {
    UIManager.setLookAndFeel(new PlasticXPLookAndFeel());
//    OtrosApplication otrosApplication = new OtrosApplication();
//    otrosApplication.setConfiguration(new DataConfiguration(new BaseConfiguration()));
//    DataConfiguration configuration = otrosApplication.getConfiguration();
    DataConfiguration configuration = new DataConfiguration(new BaseConfiguration());
    ConfigurationProvider configurationProvider = new ConfigurationProviderImpl(configuration, new File(System.getProperty("java.io.tmpdir")));
    configuration.setProperty("view1.text", "ASD ASD");
    configuration.setProperty("view2.text", "sdf\nd\ndf\ns");
    JFrame f = new JFrame("CV");
    f.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    f.getContentPane().setLayout(new BorderLayout());
    ConfigView[] configViews = {
        new View1(), // 
        new View2(), //
        new ViewTable(),// 
        new DateFormatView(),// 
        new ValidationView(),
        new ValidationView2()//
    };
    f.getContentPane().add(new ConfigComponent(configurationProvider, configViews));
    f.pack();
    f.setVisible(true);
  }
项目:otroslogviewer    文件:StyleProperties.java   
public static boolean isStyleForGroupDeclared(int group, DataConfiguration styleConfig) {
  String groupSuffix = "." + group;
  if (group <= 0) {
    groupSuffix = "";
  }
  String sb = styleConfig.getString(PROP_FONT_FAMILY + groupSuffix, "") +
    styleConfig.getString(PROP_FONT_SIZE + groupSuffix, "") +
    styleConfig.getString(PROP_FONT_BOLD + groupSuffix, "") +
    styleConfig.getString(PROP_FONT_ITALIC + groupSuffix, "") +
    styleConfig.getString(PROP_FONT_UNDERLINE + groupSuffix, "") +
    styleConfig.getString(PROP_BACKGROUND + groupSuffix, "") +
    styleConfig.getString(PROP_FOREGROUND + groupSuffix, "");

  return sb.trim().length() > 0;

}
项目:otroslogviewer    文件:PropertyPatternMessageColorizer.java   
public void init(InputStream in) throws ConfigurationException {
  propertiesConfiguration = new PropertiesConfiguration();
  propertiesConfiguration.setDelimiterParsingDisabled(true);
  propertiesConfiguration.load(in, "UTF-8");
  configuration = new DataConfiguration(propertiesConfiguration);
  configuration.setDelimiterParsingDisabled(true);
  String pa = configuration.getString(PROP_PATTERN);
  int flags = 0;
  flags = flags | (configuration.getBoolean(PROP_PATTERN_CANON_EQ, false) ? Pattern.CANON_EQ : 0);
  flags = flags | (configuration.getBoolean(PROP_PATTERN_CASE_INSENSITIVE, false) ? Pattern.CASE_INSENSITIVE : 0);
  flags = flags | (configuration.getBoolean(PROP_PATTERN_COMMENTS, false) ? Pattern.COMMENTS : 0);
  flags = flags | (configuration.getBoolean(PROP_PATTERN_DOTALL, false) ? Pattern.DOTALL : 0);
  flags = flags | (configuration.getBoolean(PROP_PATTERN_LITERAL, false) ? Pattern.LITERAL : 0);
  flags = flags | (configuration.getBoolean(PROP_PATTERN_MULTILINE, false) ? Pattern.MULTILINE : 0);
  flags = flags | (configuration.getBoolean(PROP_PATTERN_UNICODE_CASE, false) ? Pattern.UNICODE_CASE : 0);
  flags = flags | (configuration.getBoolean(PROP_PATTERN_UNIX_LINES, false) ? Pattern.UNIX_LINES : 0);

  pattern = Pattern.compile(pa, flags);
  groupCount = countGroups(pattern);
  name = configuration.getString(PROP_NAME, "NAME NOT SET!");
  description = configuration.getString(PROP_DESCRIPTION, "DESCRIPTION NOT SET!");
  testMessage = configuration.getString(PROP_TEST_MESSAGE, "");

}
项目:otroslogviewer    文件:CheckForNewVersionAbstract.java   
@Override
protected String doInBackground() throws Exception {
  String running;
  String current = null;
  final DataConfiguration c = getOtrosApplication().getConfiguration();

  Proxy proxy = Proxy.NO_PROXY;
  if (c.getBoolean(HTTP_PROXY_USE, false)) {
    Proxy.Type proxyType = Proxy.Type.HTTP;
    final InetSocketAddress proxySocketAddress = new InetSocketAddress(c.getString(HTTP_PROXY_HOST, ""), c.getInt(HTTP_PROXY_PORT, 80));
    proxy = new Proxy(proxyType, proxySocketAddress);
  }
  try {
    running = VersionUtil.getRunningVersion();
    current = VersionUtil.getCurrentVersion(running, proxy, getOtrosApplication());
  } catch (Exception e) {
    LOGGER.error("Error checking version: " + e.getMessage());
  }
  return current;
}
项目:otroslogviewer    文件:ExitAction.java   
protected void askAndExit() {
  final DataConfiguration configuration = getOtrosApplication().getConfiguration();
  boolean doConfirm = configuration.getBoolean(ConfKeys.CONFIRM_QUIT, true);
  JPanel panel = new JPanel(new MigLayout("left"));
  panel.add(new JLabel("Do you want to exit OtrosLogViewer and parse logs with 'grep'?"), "growx, wrap");
  getOtrosApplication().getConfiguration().getBoolean(ConfKeys.CONFIRM_QUIT, true);
  final JCheckBox box = new JCheckBox("Always ask before exit", doConfirm);
  box.addActionListener(e -> configuration.setProperty(ConfKeys.CONFIRM_QUIT, box.isSelected()));
  panel.add(box, "growx, wrap");

  if (!doConfirm || JOptionPane.showConfirmDialog(frame, panel, "Are you sure?", JOptionPane.YES_NO_OPTION)
    == JOptionPane.YES_OPTION) {
    frame.setVisible(false);
    frame.dispose();
    System.exit(0);
  }
}
项目:otroslogviewer    文件:ConnectToSocketHubAppenderAction.java   
protected Socket tryToConnectToSocket(DataConfiguration configuration, String hostAndPortString, SocketFactory socketFactory) throws IOException {
  List<Object> list1 = configuration.getList(ConfKeys.SOCKET_HUB_APPENDER_ADDRESSES);
  String[] hostPort = hostAndPortString.split(":");
  host = hostPort[0];
  if (hostPort.length > 1) {
    port = Integer.parseInt(hostPort[1]);
  } else {
    port = 4560;
  }

  Socket socket = socketFactory.createSocket(host, port);
  if (list1.contains(hostAndPortString)) {
    list1.remove(hostAndPortString);
  }
  list1.add(0, hostAndPortString);
  if (list1.size() > 30) {
    list1.remove(list1.size() - 1);
  }
  configuration.setProperty(ConfKeys.SOCKET_HUB_APPENDER_ADDRESSES, list1);
  return socket;
}
项目:otroslogviewer    文件:ConnectToSocketHubAppenderActionTest.java   
@Test
public void tryToConnect() throws IOException {
  OtrosApplication otrosApplication = new OtrosApplication();
  ConnectToSocketHubAppenderAction action = new ConnectToSocketHubAppenderAction(otrosApplication);
  DataConfiguration dc = new DataConfiguration(new BaseConfiguration());
  String hostAndPort = "abc:50";
  SocketFactory socketFactory = mock(SocketFactory.class);
  Socket mockSocket = mock(Socket.class);
  when(socketFactory.createSocket("abc", 50)).thenReturn(mockSocket);

  Socket socket = action.tryToConnectToSocket(dc, hostAndPort, socketFactory);

  assertEquals(mockSocket, socket);
  assertEquals(1, dc.getList(ConfKeys.SOCKET_HUB_APPENDER_ADDRESSES).size());
  assertEquals("abc:50", dc.getList(ConfKeys.SOCKET_HUB_APPENDER_ADDRESSES).get(0));
}
项目:otroslogviewer    文件:ConnectToSocketHubAppenderActionTest.java   
@Test
public void tryToConnectFail() throws IOException {
  OtrosApplication otrosApplication = new OtrosApplication();
  ConnectToSocketHubAppenderAction action = new ConnectToSocketHubAppenderAction(otrosApplication);
  DataConfiguration dc = new DataConfiguration(new BaseConfiguration());
  String hostAndPort = "abc:50";
  SocketFactory socketFactory = mock(SocketFactory.class);
  when(socketFactory.createSocket("abc", 50)).thenThrow(new UnknownHostException());

  try {
    action.tryToConnectToSocket(dc, hostAndPort, socketFactory);
    Assert.fail();
  } catch (UnknownHostException e) {
    //success
  }

  assertEquals(0, dc.getList(ConfKeys.SOCKET_HUB_APPENDER_ADDRESSES).size());
}
项目:otroslogviewer    文件:ConfTest.java   
public static void main(String[] args) throws IOException {

    System.getProperties().store(System.out,"");
    BaseConfiguration bc = new BaseConfiguration();
    DataConfiguration dc = new DataConfiguration(bc);
    DataConfiguration oc = new OtrosConfiguration(bc);
    bc.addConfigurationListener(new ConfigurationLogListener("Base"));
    dc.addConfigurationListener(new ConfigurationLogListener("Data"));
    oc.addConfigurationListener(new ConfigurationLogListener("Otros"));

    dc.setProperty("A", "B");

    System.out.println("Base size: " + bc.getConfigurationListeners().size());
    System.out.println("Data size: " + dc.getConfigurationListeners().size());
    System.out.println("Otros size: " + oc.getConfigurationListeners().size());

  }
项目:common-security-module    文件:AuthorizationDAOImpl.java   
@Override
public void validateUser(User user) throws CSException{
    //For LDAP user, password is empty. Password is not a required field.
    DataConfiguration config = ConfigurationHelper.getConfiguration();
    log.info("******Inside Validate User(((((()))))))))....");
    if(user.getPassword() != null && user.getPassword().trim().length() > 0)
    {
        validatePassword(user.getPassword());
        // added PV below

        if(user.getLoginName().equalsIgnoreCase(user.getPassword()))
        {
            throw new CSException("The password and LoginName should be different values...");
        }

        // added PV below 
        if(checkPasswordHistory(user.getLoginName(), user.getPassword(),Integer.parseInt(config.getString("PASSWORD_MATCH_NUM"))))
        {
            throw new CSException("The password should be different from the previous passwords");
        }

    }
}
项目:caarray    文件:EmailHelper.java   
/**
 * @param project the newly created project
 * @param projectLink the link to view the details of the project
 * @throws MessagingException on other error
 */
public static void sendSubmitExperimentEmail(Project project, String projectLink) throws MessagingException {
    DataConfiguration config = ConfigurationHelper.getConfiguration();

    String subject = config.getString(ConfigParamEnum.SUBMIT_EXPERIMENT_EMAIL_SUBJECT.name());
    String from = config.getString(ConfigParamEnum.EMAIL_FROM.name());
    String plainMailBodyPattern = config.getString(ConfigParamEnum.SUBMIT_EXPERIMENT_EMAIL_PLAIN_CONTENT.name());
    String htmlMailBodyPattern = config.getString(ConfigParamEnum.SUBMIT_EXPERIMENT_EMAIL_HTML_CONTENT.name());

    Person pi = project.getExperiment().getPrimaryInvestigator().getContact();
    String plainMailBody =
            MessageFormat.format(plainMailBodyPattern, pi.getName(), project.getExperiment().getTitle(),
                    projectLink);
    String htmlMailBody =
            MessageFormat.format(htmlMailBodyPattern, pi.getName(), project.getExperiment().getTitle(),
                    projectLink);

    if (!StringUtils.isEmpty(pi.getEmail())) {
        EmailUtil.sendMultipartMail(Collections.singletonList(pi.getEmail()), from, subject, htmlMailBody,
                plainMailBody);
    }
}
项目:zayf    文件:ServerProxyImpl.java   
private void loadZanataUserConfig()
{
   File userConfig = new File(System.getProperty("user.home"), DEFAULT_CONFIG_LOCATION);
   System.out.println("Config file: " + userConfig.getAbsolutePath());
   try
   {
      HierarchicalINIConfiguration config = new HierarchicalINIConfiguration(userConfig);
      SubnodeConfiguration serverConfig = config.getSection("servers");
      DataConfiguration dataConfig = new DataConfiguration(serverConfig);
      servers = getServerList(dataConfig);
   }
   catch (ConfigurationException e)
   {
      System.out.println("Failed to load configuration from " + userConfig.getAbsolutePath());
      e.printStackTrace();
   }
}
项目:zayf    文件:ConfigLoader.java   
private List<String> findPrefixes(DataConfiguration serverConfig)
{
   List<String> prefixes = new ArrayList<String>();
   Iterator<String> iter = serverConfig.getKeys();
   while (iter.hasNext())
   {
      String key = iter.next();
      if (key.endsWith(URL_KEY_SUFFIX))
      {
         String prefix = key.substring(0, key.length() - URL_KEY_SUFFIX.length());
         if (!prefix.isEmpty())
         {
            prefixes.add(prefix);
         }
      }
   }
   return prefixes;
}
项目:zayf    文件:ConfigLoader.java   
private List<ServerInfo> findServerInfoByPrefixes(
                                                  DataConfiguration serverConfig,
                                                  List<String> prefixes)
{
   List<ServerInfo> servers = new ArrayList<ServerInfo>();
   for (String prefix : prefixes)
   {
      String urlKey = prefix + URL_KEY_SUFFIX;
      String userNameKey = prefix + USER_NAME_SUFFIX;
      String apiKeyKey = prefix + API_KEY_SUFFIX;
      ServerInfo server =
            new ServerInfo(prefix, serverConfig.getURL(urlKey, null),
                           serverConfig.getString(userNameKey, null),
                           serverConfig.getString(apiKeyKey, null));
      servers.add(server);
   }
   return servers;
}
项目:loom    文件:FakeConfig.java   
public void loadFromProperties(final PropertiesConfiguration props) {
    DataConfiguration config = new DataConfiguration(props);

    projectNbr = config.getIntArray("fake.data.projectNbr");

    // all regions
    regionNbr = config.getIntArray("fake.data.regionNbr");
    // per region per project
    imageNbr = config.getIntArray("fake.data.imageNbr");
    extraVols = config.getIntArray("fake.data.extraVols");
    volSizeMax = config.getIntArray("fake.data.volSizeMax");
    sizeSteps = config.getIntArray("fake.data.sizeSteps");
    extraNets = config.getIntArray("fake.data.extraNets");
    rebootCount = config.getIntArray("fake.data.rebootCount");


    // discover like data generation attrs
    networkNbr = config.getIntArray("fake.data.networkNbr");
    subnetPerNetworkNbr = config.getIntArray("fake.data.subnetPerNetworkNbr");
    vmPerSubnetNbr = config.getIntArray("fake.data.vmPerSubnetNbr");
    vmWithVolumeRatio = config.getIntArray("fake.data.vmWithVolumeRatio");


    // old data generation attrs
    instanceNbr = config.getIntArray("fake.data.instanceNbr");
    volsPerVm = config.getIntArray("fake.data.volsPerVm");
    subsPerVm = config.getIntArray("fake.data.subsPerVm");
    subsPerExtraNets = config.getIntArray("fake.data.subsPerExtraNet");


    instanceQuota = config.getIntArray("fake.quota.instances");
    coreQuota = config.getIntArray("fake.quota.cores");
    volumeQuota = config.getIntArray("fake.quota.volumes");
    gigabyteQuota = config.getIntArray("fake.quota.gigabytes");
    ramQuota = config.getIntArray("fake.quota.ram");

    quotaRepeatNbr = config.getInt("fake.quota.repeatNbr");

    index = config.getInt("fake.index", 0);
}
项目:loom    文件:DiscoverConfig.java   
@Override
public void loadFromProperties(final PropertiesConfiguration props) {
    super.loadFromProperties(props);
    DataConfiguration config = new DataConfiguration(props);
    workloadNbrPerType = config.getIntArray("discover.data.workloadNbrPerType");
    workloadTypeNbr = config.getIntArray("discover.data.workloadTypeNbr");
    networkNbr = config.getIntArray("discover.data.networkNbr");
    subnetPerNetworkNbr = config.getIntArray("discover.data.subnetPerNetworkNbr");
    vmPerSubnetNbr = config.getIntArray("discover.data.vmPerSubnetNbr");
    vmWithVolumeRatio = config.getIntArray("discover.data.vmWithVolumeRatio");
}
项目:otroslogviewer    文件:ConfigComponent.java   
public void reload() {
  boolean mainConfigLoaded = false;
  for (ConfigView configView : configViews) {
    Configuration configurationForView;

    try {
      configurationForView = configurationProvider.getConfigurationForView(configView);
      if (configurationForView instanceof DataConfiguration) {
        DataConfiguration dc = (DataConfiguration) configurationForView;
        configurationForView = dc.getConfiguration();
      }
      if (configurationForView instanceof FileConfiguration) {
        FileConfiguration fc = (FileConfiguration) configurationForView;
        if (configView instanceof InMainConfig) {
          if (!mainConfigLoaded) {
            fc.reload();
            mainConfigLoaded = true;
          }
        } else {
          fc.reload();
        }
        configView.loadConfiguration(fc);
      }
    } catch (ConfigurationException e1) {
      //TODO ??
      e1.printStackTrace();
    }
  }
}
项目:otroslogviewer    文件:FavoritesUtils.java   
public static List<Favorite> loadFromProperties(DataConfiguration conf) {
  ArrayList<Favorite> list = new ArrayList<Favorite>();
  int count = conf.getInt("favorites.count", 0);
  LOGGER.info("Loading favorites {}", count);
  for (int i = 0; i < count; i++) {
    String name = conf.getString(String.format("favorite.item_%d.name", i));
    String url = conf.getString(String.format("favorite.item_%d.url", i));
    Favorite favorite = new Favorite(name, url, Type.USER);
    list.add(favorite);
  }
  return list;
}
项目:otroslogviewer    文件:FavoritesUtils.java   
public static void storeFavorites(DataConfiguration configuration, List<Favorite> favoriteList) {
  int i = 0;
  for (Favorite favorite : favoriteList) {
    if (favorite.getType().equals(Type.USER)) {
      configuration.setProperty(String.format("favorite.item_%d.name", i), favorite.getName());
      configuration.setProperty(String.format("favorite.item_%d.url", i), favorite.getUrl());
      i++;
    }
  }
  configuration.setProperty("favorites.count", i);
}
项目:otroslogviewer    文件:VfsBrowser.java   
public VfsBrowser(Configuration configuration, final String initialPath, SelectionListener... listeners) {
  super();
  this.configuration = new DataConfiguration(configuration);
  this.listeners = listeners;
  initGui(initialPath);
  VFSUtils.loadAuthStore();
}
项目:otroslogviewer    文件:ExampleLogDataParsedListener.java   
@Override
public void processingStarted(BatchProcessingContext batchProcessingContext) {
  System.out.println("Batch processing started");
  DataConfiguration configuration = batchProcessingContext.getConfiguration();
  System.out.println("Dumping batch processing configuration.");
  Iterator<String> keys = configuration.getKeys();
  while (keys.hasNext()) {
    String next = keys.next();
    System.out.printf("%s=%s%n", next, configuration.getString(next));
  }
}
项目:otroslogviewer    文件:BufferingLogDataCollectorProxy.java   
public BufferingLogDataCollectorProxy(LogDataCollector delegate, final long sleepTime, Configuration configuration) {
  super();
  this.delegate = delegate;
  final DataConfiguration dataConfiguration = new DataConfiguration(configuration);
  proxyLogDataCollector = new ProxyLogDataCollector();
  Runnable r = () -> {
    while (!stop) {
      if (dataConfiguration.getBoolean(ConfKeys.TAILING_PANEL_PLAY)) {
        synchronized (BufferingLogDataCollectorProxy.this) {
          LogData[] logData = proxyLogDataCollector.getLogData();
          if (logData.length > 0) {
            proxyLogDataCollector = new ProxyLogDataCollector();
            addToDelegateInEDT(logData);
          }
        }
      }

      try {
        Thread.sleep(sleepTime);
      } catch (InterruptedException ignore) {
      }

    }

  };
  Thread t = new Thread(r, "BufferingLogDataCollectorProxy");
  t.setDaemon(true);
  t.start();
}
项目:otroslogviewer    文件:StyleProperties.java   
public static Style getStyle(StyleContext styleContext, DataConfiguration styleConfig, String styleName, int group) {
  Style style = styleContext.addStyle(styleName, styleContext.getStyle(StyleContext.DEFAULT_STYLE));

  String groupSuffix = "." + group;
  if (group <= 0) {
    groupSuffix = "";
  }

  String fontFamily = styleConfig.getString(PROP_FONT_FAMILY + groupSuffix, "");
  if (fontFamily.trim().length() > 0) {
    StyleConstants.setFontFamily(style, styleConfig.getString(PROP_FONT_FAMILY + groupSuffix));
  }

  if (styleConfig.getString(PROP_FONT_SIZE + groupSuffix, "").trim().length() > 0) {
    StyleConstants.setFontSize(style, styleConfig.getInt(PROP_FONT_SIZE + groupSuffix));
  }

  if (styleConfig.getString(PROP_FONT_BOLD + groupSuffix, "").trim().length() > 0) {
    StyleConstants.setBold(style, styleConfig.getBoolean(PROP_FONT_BOLD + groupSuffix));
  }

  if (styleConfig.getString(PROP_FONT_ITALIC + groupSuffix, "").trim().length() > 0) {
    StyleConstants.setItalic(style, styleConfig.getBoolean(PROP_FONT_ITALIC + groupSuffix));
  }

  if (styleConfig.getString(PROP_FONT_UNDERLINE + groupSuffix, "").trim().length() > 0) {
    StyleConstants.setUnderline(style, styleConfig.getBoolean(PROP_FONT_UNDERLINE + groupSuffix));
  }

  if (styleConfig.getString(PROP_BACKGROUND + groupSuffix, "").trim().length() > 0) {
    StyleConstants.setBackground(style, styleConfig.getColor(PROP_BACKGROUND + groupSuffix));
  }

  if (styleConfig.getString(PROP_FOREGROUND + groupSuffix, "").trim().length() > 0) {
    StyleConstants.setForeground(style, styleConfig.getColor(PROP_FOREGROUND + groupSuffix));
  }
  return style;
}
项目:otroslogviewer    文件:Renderers.java   
private Renderers(OtrosApplication otrosApplication) {
  final DataConfiguration configuration = otrosApplication.getConfiguration();
  classWrapperRenderer = new ClassWrapperRenderer();
  classWrapperRenderer.reloadConfiguration(configuration.getString(LOG_TABLE_FORMAT_PACKAGE_ABBREVIATIONS, StringUtils.EMPTY));
  levelRenderer = new LevelRenderer(configuration.get(LevelRenderer.Mode.class, LOG_TABLE_FORMAT_LEVEL_RENDERER, LevelRenderer.Mode.IconsOnly));
  dateRenderer = new DateRenderer(configuration.getString(LOG_TABLE_FORMAT_DATE_FORMAT, "HH:mm:ss.SSS"));
  stringRenderer = new StringRenderer();
  configuration.addConfigurationListener(event -> {
    if (event.isBeforeUpdate()) {
      return;
    }
    final String property = event.getPropertyName();
    final String value = event.getPropertyValue() != null ? event.getPropertyValue().toString() : "";
    switch (property) {
      case LOG_TABLE_FORMAT_PACKAGE_ABBREVIATIONS:
        classWrapperRenderer.reloadConfiguration(value);
        break;
      case LOG_TABLE_FORMAT_LEVEL_RENDERER:
        final LevelRenderer.Mode mode = configuration.get(LevelRenderer.Mode.class, LOG_TABLE_FORMAT_LEVEL_RENDERER, LevelRenderer.Mode.IconsOnly);
        levelRenderer.setMode(mode);
        break;
      case LOG_TABLE_FORMAT_DATE_FORMAT:
        dateRenderer.setDateFormatter(new SimpleDateFormat(value));
        break;
      default:
    }
  });
}
项目:otroslogviewer    文件:LogTableFormatConfigView.java   
public static void saveColumnLayouts(List<ColumnLayout> list, Configuration c) {
  final DataConfiguration dc = new DataConfiguration(c);
  final Iterator<String> keys = dc.getKeys(COL_LAYOUT);
  while (keys.hasNext()) {
    dc.clearProperty(keys.next());
  }

  dc.setProperty(COL_LAYOUT + ".count", list.size());
  for (int i = 0; i < list.size(); i++) {
    dc.setProperty(String.format("%s._%d.name", COL_LAYOUT, i), list.get(i).getName());
    dc.setProperty(String.format("%s._%d.columns", COL_LAYOUT, i), list.get(i).getColumns());
  }

}
项目:otroslogviewer    文件:LogTableFormatConfigView.java   
public static List<ColumnLayout> loadColumnLayouts(Configuration configuration) {
  List<ColumnLayout> layouts = new ArrayList<>();
  DataConfiguration dc = new DataConfiguration(configuration);
  final int count = dc.getInt(COL_LAYOUT + ".count", 0);
  for (int i = 0; i < count; i++) {
    String columnLayoutName = dc.getString(COL_LAYOUT + "._" + i + ".name");
    List<String> list = dc.getList(String.class, COL_LAYOUT + "._" + i + ".columns");
    ColumnLayout columnLayout = new ColumnLayout(columnLayoutName, list);
    layouts.add(columnLayout);
  }
  return layouts;
}
项目:otroslogviewer    文件:IdeIntegrationConfigAction.java   
private void showConfigDialog() {
  final OtrosApplication otrosApplication = getOtrosApplication();
  final DataConfiguration configuration = otrosApplication.getConfiguration();

  IdeIntegrationConfigurationPanel ideIntegrationConfigurationPanel = new IdeIntegrationConfigurationPanel(getOtrosApplication());

  int confirmDialog = JOptionPane.showConfirmDialog(otrosApplication.getApplicationJFrame(), ideIntegrationConfigurationPanel, "IDE integration configuration", JOptionPane.OK_CANCEL_OPTION);
  if (confirmDialog == JOptionPane.YES_OPTION) {
    configuration.setProperty(ConfKeys.JUMP_TO_CODE_HOST, StringUtils.defaultIfBlank(ideIntegrationConfigurationPanel.getSelectedHostname(), null));
    configuration.setProperty(ConfKeys.JUMP_TO_CODE_PORT, ideIntegrationConfigurationPanel.getSelectedPort());
    configuration.setProperty(ConfKeys.JUMP_TO_CODE_AUTO_JUMP_ENABLED, ideIntegrationConfigurationPanel.isAutoJumpEnabled());
    configuration.setProperty(ConfKeys.JUMP_TO_CODE_ENABLED, ideIntegrationConfigurationPanel.isEnabledIdeIntegration());
  }

}
项目:common-security-module    文件:StringEncrypter.java   
public StringEncrypter(String encryptionScheme) throws EncryptionException {
    if(encryptionScheme != null && encryptionScheme.equals(Constants.DES_ENCRYPTION) )
        encryption = new DESEncryption();
    else
    {   
        DataConfiguration config = null; 
        try {
            config = ConfigurationHelper.getConfiguration();
        } catch (CSConfigurationException e) {
            e.printStackTrace();
        }
        encryption = new AESEncryption(config.getString("AES_ENCRYPTION_KEY"), Boolean.parseBoolean(config.getString("MD5_HASH_KEY")));
    }
}
项目:common-security-module    文件:ConfigurationHelper.java   
private ConfigurationHelper(String applicationContextName)
{   

 DataSource ds = getDataSourceForContext(applicationContextName);                   
 DatabaseConfiguration config = new DatabaseConfiguration(ds,
                 TABLE_NAME, KEY_COLUMN, VALUE_COLUMN);

 ConfigurationListener listener = new LockoutConfigurationListener();
 config.addConfigurationListener(listener);
 config.addErrorListener((ConfigurationErrorListener) listener);            
 config.setDelimiterParsingDisabled(true);
 dataConfig = new DataConfiguration(config);
}
项目:caarray    文件:TemporaryFileCacheImpl.java   
private File getWorkingDirectory() {
    final DataConfiguration config = ConfigurationHelper.getConfiguration();
    String tempDir = config.getString(ConfigParamEnum.STRUTS_MULTIPART_SAVEDIR.name());
    if (StringUtils.isBlank(tempDir)) {
        tempDir = System.getProperty(TEMP_DIR_PROPERTY_KEY);
    }
    final String workingDirectoryPath = System.getProperty(WORKING_DIRECTORY_PROPERTY_KEY, tempDir);
    return new File(workingDirectoryPath);
}
项目:caarray    文件:ConfigurationHelper.java   
/**
 * @return the system configuration.
 */
public static DataConfiguration getConfiguration() {
    DataSource ds = null;
    try {
        ds = (DataSource) ServiceLocatorFactory.getLocator().lookup(DATASOURCE_JNDI_LOC);
        if (ds == null) {
            ds = getAdhocDataSource();
        }
    } catch (IllegalStateException e) {
        ds = getAdhocDataSource();
    }
    DatabaseConfiguration config = new DatabaseConfiguration(ds, TABLE_NAME, PARAM_NAME_COLUMN, PARAM_VALUE_COLUMN);
    config.setDelimiterParsingDisabled(true);
    return new DataConfiguration(config);
}
项目:caarray    文件:EmailHelper.java   
/**
 * @param registrationRequest request
 * @throws MessagingException on other error
 */
public static void registerEmail(RegistrationRequest registrationRequest) throws MessagingException {
    DataConfiguration config = ConfigurationHelper.getConfiguration();

    if (!config.getBoolean(ConfigParamEnum.SEND_CONFIRM_EMAIL.name())) {
        return;
    }

    String subject = config.getString(ConfigParamEnum.CONFIRM_EMAIL_SUBJECT.name());
    String from = config.getString(ConfigParamEnum.EMAIL_FROM.name());
    String mailBodyPattern = config.getString(ConfigParamEnum.CONFIRM_EMAIL_CONTENT.name());
    String mailBody = MessageFormat.format(mailBodyPattern, registrationRequest.getId());

    EmailUtil.sendMail(Collections.singletonList(registrationRequest.getEmail()), from, subject, mailBody);
}
项目:caarray    文件:EmailHelper.java   
/**
 * @param registrationRequest request
 * @throws MessagingException on error
 */
public static void registerEmailAdmin(RegistrationRequest registrationRequest) throws MessagingException {
    DataConfiguration config = ConfigurationHelper.getConfiguration();
    if (!config.getBoolean(ConfigParamEnum.SEND_ADMIN_EMAIL.name())) {
        return;
    }

    String subject = config.getString(ConfigParamEnum.REG_EMAIL_SUBJECT.name());
    String from = registrationRequest.getEmail();
    String admin = config.getString(ConfigParamEnum.REG_EMAIL_TO.name());

    String mailBody = "Registration Request:\n"
        + "First Name: " + registrationRequest.getFirstName() + "\n"
        + "Middle Initial: " + registrationRequest.getMiddleInitial() + "\n"
        + "Last Name: " + registrationRequest.getLastName() + "\n"
        + "Email: " + registrationRequest.getEmail() + "\n"
        + "Phone: " + registrationRequest.getPhone() + "\n"
        + "Fax: " + registrationRequest.getFax() + "\n"
        + "Organization: " + registrationRequest.getOrganization() + "\n"
        + "Address1: " + registrationRequest.getAddress1() + "\n"
        + "Address2: " + registrationRequest.getAddress2() + "\n"
        +  "City: " + registrationRequest.getCity() + "\n"
        + "State: " + registrationRequest.getState() + "\n"
        + "Province: " + registrationRequest.getProvince() + "\n"
        + "Country: " + registrationRequest.getCountry().getPrintableName() + "\n"
        + "Zip: " + registrationRequest.getZip() + "\n"
        + "Role: " + registrationRequest.getRole();

    EmailUtil.sendMail(Collections.singletonList(admin), from, subject, mailBody);
}
项目:caarray    文件:CaarrayStruts2FilterDispatcher.java   
/**
 * set the upload temporary directory based on our config.
 * {@inheritDoc}
 */
@Override
protected void postInit(Dispatcher dispatcher, FilterConfig filterConfig) {
    DataConfiguration config = ConfigurationHelper.getConfiguration();
    String multiPartSaveDir = config.getString(ConfigParamEnum.STRUTS_MULTIPART_SAVEDIR.name());
    if (StringUtils.isNotBlank(multiPartSaveDir)) {
        dispatcher.setMultipartSaveDir(multiPartSaveDir);
    }
}
项目:zayf    文件:ConfigLoader.java   
private List<ServerInfo> getServerList() throws ConfigurationException
{
   HierarchicalINIConfiguration config = new HierarchicalINIConfiguration(userConfig);
   SubnodeConfiguration serverConfig = config.getSection("servers");
   DataConfiguration dataConfig = new DataConfiguration(serverConfig);
   List<String> prefixes = findPrefixes(dataConfig);
   return findServerInfoByPrefixes(dataConfig, prefixes);
}
项目:otroslogviewer    文件:JOtrosVfsBrowserDialog.java   
public JOtrosVfsBrowserDialog(final String initialPath, SelectionListener... listeners) {
  this(new DataConfiguration(new BaseConfiguration()), initialPath, listeners);
}
项目:otroslogviewer    文件:JOtrosVfsBrowserDialog.java   
public JOtrosVfsBrowserDialog( SelectionListener... listeners) {
  this(new DataConfiguration(new BaseConfiguration()), listeners);
}
项目:otroslogviewer    文件:ShowErrorDialogExceptionHandler.java   
@Override
protected void uncaughtExceptionInSwingEDT(Thread thread,
                                           Throwable throwable) {
  String stackTraceAsString = Throwables.getStackTraceAsString(throwable);
  if (caughtStackTraces.contains(stackTraceAsString)) {
    LOGGER.info("Not sending the same error report twice");
    return;
  }
  caughtStackTraces.add(stackTraceAsString);
  JPanel message = new JPanel(new BorderLayout());
  message.add(new JLabel("Error in thread " + thread.getName()), BorderLayout.NORTH);

  String stackTrace = getStackTrace(throwable);
  JTextArea textArea = new JTextArea(10, 70);
  textArea.setText(stackTrace);
  textArea.setCaretPosition(0);
  message.add(new JScrollPane(textArea));

  JOptionPane.showMessageDialog(null, message, "Error", JOptionPane.ERROR_MESSAGE);

  Map<String, String> errorReportData = generateReportData(thread, throwable, otrosApplication);
  JComponent jComponent = createDialogView();
  String[] options = {"Send", "Do not send"};
  int sendReport = JOptionPane.showOptionDialog(
    otrosApplication.getApplicationJFrame(),
    jComponent,
    "Send error report confirmation",
    JOptionPane.YES_NO_OPTION,
    JOptionPane.QUESTION_MESSAGE,
    Icons.MEGAPHONE_24,
    options, options[0]);
  errorReportData.put("USER:email", emailTextField.getText());
  errorReportData.put("USER:comment", commentTextArea.getText());

  if (sendReport == JOptionPane.YES_OPTION) {
    DataConfiguration c = otrosApplication.getConfiguration();
    c.setProperty(ConfKeys.HTTP_PROXY_USE, checkBoxUseProxy.isSelected());
    c.setProperty(ConfKeys.HTTP_PROXY_HOST, proxyTf.getText());
    c.setProperty(ConfKeys.HTTP_PROXY_PORT, proxyPortModel.getNumber().intValue());
    c.setProperty(ConfKeys.HTTP_PROXY_USER, proxyUser.getText());
    sendReportInNewBackground(errorReportData);
  } else {
    LOGGER.info("Not sending error report");
  }

  logErrorReport(errorReportData);

}
项目:otroslogviewer    文件:ShowErrorDialogExceptionHandler.java   
protected JComponent createDialogView() {
  JPanel jPanel = new JPanel(new MigLayout());
  JLabel label = new JLabel("Do you want to send error report?");
  label.setFont(label.getFont().deriveFont(Font.BOLD));
  jPanel.add(label, "span 4, wrap, center");
  jPanel.add(new JLabel("Comment:"));
  commentTextArea = new JTextArea(10, 30);
  commentTextArea.setWrapStyleWord(true);
  commentTextArea.setLineWrap(true);
  JScrollPane jScrollPane = new JScrollPane(commentTextArea, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
  jPanel.add(jScrollPane, "span 3, wrap");
  jPanel.add(new JLabel("Email (optional):"));
  emailTextField = new JTextField(30);
  jPanel.add(emailTextField, "span 3, wrap");

  jPanel.add(new JSeparator(), "span 4, wrap, grow");
  checkBoxUseProxy = new JCheckBox("Use HTTP proxy");
  proxyTf = new JTextField();
  proxyPortModel = new SpinnerNumberModel(80, 1, 256 * 256 - 1, 1);
  proxyUser = new JTextField();
  proxyPasswordField = new JPasswordField();
  proxySpinner = new JSpinner(proxyPortModel);

  jPanel.add(checkBoxUseProxy, "wrap");
  labelProxyHost = new JLabel("Proxy address");
  jPanel.add(labelProxyHost);
  jPanel.add(proxyTf, "wrap, span 3, grow");
  labelProxyPort = new JLabel("Proxy port");
  jPanel.add(labelProxyPort);
  jPanel.add(proxySpinner, "wrap");
  labelProxyUser = new JLabel("User");
  jPanel.add(labelProxyUser);
  jPanel.add(proxyUser, "grow");
  labelProxyPassword = new JLabel("Password");
  jPanel.add(labelProxyPassword);
  jPanel.add(proxyPasswordField, "grow");

  checkBoxUseProxy.addChangeListener(e -> setProxyEnabled(checkBoxUseProxy.isSelected()));
  DataConfiguration c = otrosApplication.getConfiguration();
  proxyTf.setText(c.getString(ConfKeys.HTTP_PROXY_HOST, ""));
  proxyUser.setText(c.getString(ConfKeys.HTTP_PROXY_USER, ""));
  proxyPortModel.setValue(Integer.valueOf(c.getInt(ConfKeys.HTTP_PROXY_PORT, 80)));
  boolean useProxy = c.getBoolean(ConfKeys.HTTP_PROXY_USE, false);
  checkBoxUseProxy.setSelected(useProxy);
  setProxyEnabled(useProxy);

  return jPanel;
}
项目:otroslogviewer    文件:GuiAppender.java   
public static void start(LogDataCollector dataCollector, DataConfiguration configuration) {
  bufferingLogDataCollectorProxy = new BufferingLogDataCollectorProxy(dataCollector, 5000, configuration);
}