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

项目:KernelHive    文件:KernelRepository.java   
@Override
public KernelRepositoryEntry getEntryForGraphNodeType(GraphNodeType type)
        throws ConfigurationException {
    config.load(resource);

    List<ConfigurationNode> entryNodes = config.getRootNode().getChildren(ENTRY_NODE);
    for(ConfigurationNode node : entryNodes){
        List<ConfigurationNode> typeAttrList = node.getAttributes(ENTRY_NODE_TYPE_ATTRIBUTE);

        if(typeAttrList.size()>0){
            String val = (String) typeAttrList.get(0).getValue();

            if(type.equals(GraphNodeType.getType(val))){
                return getEntryFromConfigurationNode(node);
            }
        } else{
            throw new ConfigurationException("KH: no required '"+ENTRY_NODE_TYPE_ATTRIBUTE+"' attribute in "+ENTRY_NODE+" node");
        }
    }

    return null;
}
项目:KernelHive    文件:RemoteRepositoryConfiguration.java   
/**
 * gets instance
 * 
 * @return {@link AppConfiguration} instance
 */
public static RemoteRepositoryConfiguration getInstance() {
    if (_commonConfig == null) {
        try {
            _commonConfig = new RemoteRepositoryConfiguration();
            _commonConfig.reloadConfiguration();
            return _commonConfig;
        } catch (final ConfigurationException e) {
            LOG.severe("KH: " + e.getMessage());
            e.printStackTrace();
            return null;
        }
    } else {
        return _commonConfig;
    }
}
项目:loom    文件:FakeAdapterTest.java   
private PropertiesConfiguration loadProperties() throws ConfigurationException {
    String deploymentProperties = "src/test/resources/deployment-fakeAdapterTest.properties";
    PropertiesConfiguration props = new PropertiesConfiguration(deploymentProperties);
    return props;
    // try {
    // Properties prop = null;
    // Resource res = appContext.getResource(deploymentProperties);
    // InputStream in = res.getInputStream();
    // if (in == null) {
    // LOG.warn("Failed to locate properties file on classpath: " + deploymentProperties);
    // } else {
    // LOG.info("Found '" + deploymentProperties + "' on the classpath");
    // prop = new Properties();
    // prop.load(in);
    // }
    // return prop;
    // } catch (IOException e) {
    // LOG.error("Failed to load properties file '" + deploymentProperties + "'", e);
    // throw new RuntimeException("Failed to initialise from properties file " +
    // deploymentProperties);
    // }
}
项目:openNaEF    文件:BuilderConfiguration.java   
@Override
protected synchronized void reloadConfigurationInner() throws IOException {
    try {
        XMLConfiguration config = new XMLConfiguration();
        config.setDelimiterParsingDisabled(true);
        config.load(getConfigFile());

        String __isSystemUserUpdateEnabled = config.getString(KEY_ENABLE_SYSTEM_USER_UPDATE);
        boolean _isSystemUserUpdateEnabled = (__isSystemUserUpdateEnabled == null ? false :
                Boolean.parseBoolean(__isSystemUserUpdateEnabled));

        this.isSystemUserUpdateEnabled = _isSystemUserUpdateEnabled;

        log().info("isSystemUserUpdateEnabled=" + this.isSystemUserUpdateEnabled);
        log().info("reload finished.");
    } catch (ConfigurationException e) {
        log().error(e.getMessage(), e);
        throw new IOException("failed to reload config: " + FILE_NAME);
    }
}
项目:openNaEF    文件:NmsCoreRsvpLspConfiguration.java   
@Override
protected boolean loadExtraConfigration() throws IOException {
    try {
        XMLConfiguration config = new XMLConfiguration();
        config.setDelimiterParsingDisabled(true);
        config.load(getConfigFile());

        for (Object obj : config.getRootNode().getChildren()) {
            Node node = (Node) obj;
            if (node.getName().equals(KEY_HOP_IP_PATH_FIELD_NAME)) {
                List<String> values = new ArrayList<String>();

                for (Object value : node.getChildren()) {
                    values.add((String) ((Node) value).getValue());
                }
                setHopIpPathFieldsName(values);
                return true;
            }
        }
    } catch (ConfigurationException e) {
        log.error(e.getMessage(), e);
        throw new IOException("failed to reload config: " + getConfigFile());
    }
    return false;
}
项目:KernelHive    文件:EngineGraphConfiguration.java   
private Node createGraphNodeForEngine(final EngineGraphNodeDecorator node)
        throws ConfigurationException {
    try {
        final Node configNode = createNodeForEngine(node);
        final Node sendToNode = createSendToSubNode(node.getGraphNode());
        final Node childrenNode = createChildrenSubNode(node.getGraphNode());
        final Node propertiesNode = createPropertiesSubNode(node
                .getGraphNode());
        final Node sourcesNode = createKernelsSubNode(node);
        configNode.addChild(childrenNode);
        configNode.addChild(sendToNode);
        configNode.addChild(propertiesNode);
        configNode.addChild(sourcesNode);
        return configNode;
    } catch (final NullPointerException e) {
        throw new ConfigurationException(e);
    }
}
项目:KernelHive    文件:EngineGraphConfiguration.java   
private IKernelString loadKernel(final ConfigurationNode node)
        throws ConfigurationException {
    String src;
    String srcId;

    final List<ConfigurationNode> idSourceAttrs = node
            .getAttributes(KERNEL_ID_ATTRIBUTE);
    if (idSourceAttrs.size() > 0) {
        srcId = (String) idSourceAttrs.get(0).getValue();
    } else {
        throw new ConfigurationException("KH: no required attribute '"
                + KERNEL_ID_ATTRIBUTE + "' found in " + KERNEL + " node");
    }

    final List<ConfigurationNode> srcAttrs = node
            .getAttributes(KERNEL_SRC_ATTRIBUTE);
    if (srcAttrs.size() > 0) {
        src = (String) srcAttrs.get(0).getValue();
    } else {
        throw new ConfigurationException(
                "KH: no required attribute 'src' in " + KERNEL + " node");
    }

    final Map<String, Object> properties = loadKernelProperties(node);
    return new KernelString(srcId, src, properties);
}
项目:openNaEF    文件:NmsCorePseudoWireConfiguration.java   
@Override
protected boolean loadExtraConfigration() throws IOException {
    try {
        XMLConfiguration config = new XMLConfiguration();
        config.setDelimiterParsingDisabled(true);
        config.load(getConfigFile());

        for (Object obj : config.getRootNode().getChildren()) {
            Node node = (Node) obj;
            if (node.getName().equals(KEY_RELATED_LSP_FIELD_NAME)) {
                setRelatedRsvplspFieldName((String) node.getValue());
                return true;
            }
        }
    } catch (ConfigurationException e) {
        log.error(e.getMessage(), e);
        throw new IOException("failed to reload config: " + getConfigFile());
    }
    return false;
}
项目:athena    文件:YangXmlUtilsTest.java   
/**
 * Tests getting a single object configuration via passing the path and the map of the desired values.
 *
 * @throws ConfigurationException if the testing xml file is not there.
 */
@Test
public void testGetXmlConfigurationFromMap() throws ConfigurationException {
    Map<String, String> pathAndValues = new HashMap<>();
    pathAndValues.put("capable-switch.id", "openvswitch");
    pathAndValues.put("switch.id", "ofc-bridge");
    pathAndValues.put("controller.id", "tcp:1.1.1.1:1");
    pathAndValues.put("controller.ip-address", "1.1.1.1");
    XMLConfiguration cfg = utils.getXmlConfiguration(OF_CONFIG_XML_PATH, pathAndValues);
    testCreateConfig.load(getClass().getResourceAsStream("/testCreateSingleYangConfig.xml"));
    assertNotEquals("Null testConfiguration", new XMLConfiguration(), testCreateConfig);

    assertEquals("Wrong configuaration", IteratorUtils.toList(testCreateConfig.getKeys()),
                 IteratorUtils.toList(cfg.getKeys()));

    assertEquals("Wrong string configuaration", utils.getString(testCreateConfig),
                 utils.getString(cfg));
}
项目:KernelHive    文件:GUIGraphConfiguration.java   
private Node createGraphNodeForGUI(GUIGraphNodeDecorator node, File file)
        throws ConfigurationException {
    try {
        Node configNode = createNodeForGUI(node);
        Node sendToNode = createSendToSubNode(node.getGraphNode());
        Node childrenNode = createChildrenSubNode(node.getGraphNode());
        Node propertiesNode = createPropertiesSubNode(node.getGraphNode());
        Node sourcesNode = createSourceFilesSubNode(node, file);
        configNode.addChild(childrenNode);
        configNode.addChild(sendToNode);
        configNode.addChild(propertiesNode);
        configNode.addChild(sourcesNode);
        return configNode;
    } catch (NullPointerException e) {
        throw new ConfigurationException(e);
    }
}
项目:athena    文件:YangXmlUtilsTest.java   
/**
 * Tests getting a multiple object nested configuration via passing the path
 * and a list of YangElements containing with the element and desired value.
 *
 * @throws ConfigurationException
 */
@Test
public void getXmlConfigurationFromYangElements() throws ConfigurationException {

    assertNotEquals("Null testConfiguration", new XMLConfiguration(), testCreateConfig);
    testCreateConfig.load(getClass().getResourceAsStream("/testYangConfig.xml"));
    List<YangElement> elements = new ArrayList<>();
    elements.add(new YangElement("capable-switch", ImmutableMap.of("id", "openvswitch")));
    elements.add(new YangElement("switch", ImmutableMap.of("id", "ofc-bridge")));
    List<ControllerInfo> controllers =
            ImmutableList.of(new ControllerInfo(IpAddress.valueOf("1.1.1.1"), 1, "tcp"),
                             new ControllerInfo(IpAddress.valueOf("2.2.2.2"), 2, "tcp"));
    controllers.stream().forEach(cInfo -> {
        elements.add(new YangElement("controller", ImmutableMap.of("id", cInfo.target(),
                                                                   "ip-address", cInfo.ip().toString())));
    });
    XMLConfiguration cfg =
            new XMLConfiguration(YangXmlUtils.getInstance()
                                         .getXmlConfiguration(OF_CONFIG_XML_PATH, elements));
    assertEquals("Wrong configuaration", IteratorUtils.toList(testCreateConfig.getKeys()),
                 IteratorUtils.toList(cfg.getKeys()));
    assertEquals("Wrong string configuaration", utils.getString(testCreateConfig),
                 utils.getString(cfg));
}
项目:KernelHive    文件:GUIGraphConfiguration.java   
private GUIGraphNodeDecorator loadGraphNodeForGUI(ConfigurationNode node)
        throws ConfigurationException {

    IGraphNode graphNode = loadGraphNode(node);
    int x = -1, y = -1;

    List<ConfigurationNode> xAttrList = node
            .getAttributes(NODE_X_ATTRIBUTE);
    List<ConfigurationNode> yAttrList = node
            .getAttributes(NODE_Y_ATTRIBUTE);
    if (xAttrList.size() > 0) {
        x = Integer.parseInt((String) xAttrList.get(0).getValue());
    }
    if (yAttrList.size() > 0) {
        y = Integer.parseInt((String) yAttrList.get(0).getValue());
    }

    GUIGraphNodeDecorator guiNode = new GUIGraphNodeDecorator(graphNode);
    guiNode.setX(x);
    guiNode.setY(y);

    return guiNode;
}
项目:KernelHive    文件:GUIGraphConfiguration.java   
@Override
public void saveGraphForGUI(List<GUIGraphNodeDecorator> guiGraphNodes,
        File file) throws ConfigurationException {
    XMLConfiguration tempConfig = (XMLConfiguration) config.clone();
    try {
        config.clear();
        config.setRootNode(tempConfig.getRootNode());
        config.getRootNode().removeChildren();
        for (GUIGraphNodeDecorator guiNode : guiGraphNodes) {
            config.getRoot().addChild(createGraphNodeForGUI(guiNode, file));
        }
        config.save(file);
    } catch (ConfigurationException e) {
        config = tempConfig;
        config.save(file);
        throw e;
    }
}
项目:KernelHive    文件:AbstractGraphConfiguration.java   
protected Node createNode(final IGraphNode node)
        throws ConfigurationException {
    final Node configNode = new Node(NODE);
    final Node idAttr = new Node(NODE_ID_ATTRIBUTE, node.getNodeId());
    idAttr.setAttribute(true);
    final Node hashAttr = new Node(NODE_HASH_ATTRIBUTE, node.hashCode());
    hashAttr.setAttribute(true);
    final Node parentAttr = new Node(NODE_PARENT_ID_ATTRIBUTE,
            node.getParentNode() != null ? node.getParentNode().getNodeId()
                    : "");
    parentAttr.setAttribute(true);
    final Node nameAttr = new Node(NODE_NAME_ATTRIBUTE, node.getName());
    nameAttr.setAttribute(true);
    final Node typeAttr = new Node(NODE_TYPE_ATTRIBUTE, node.getType()
            .toString());
    typeAttr.setAttribute(true);
    configNode.addAttribute(idAttr);
    configNode.addAttribute(parentAttr);
    configNode.addAttribute(hashAttr);
    configNode.addAttribute(nameAttr);
    configNode.addAttribute(typeAttr);
    return configNode;
}
项目:KernelHive    文件:AbstractGraphConfiguration.java   
protected Node createPropertiesSubNode(final IGraphNode node)
        throws ConfigurationException {
    final Node propertiesNode = new Node(PROPERTIES_NODE);
    final Set<String> keySet = node.getProperties().keySet();
    for (final String key : keySet) {
        final Node propertyNode = new Node(PROPERTY_NODE);
        final Node keyAttr = new Node(PROPERTY_NODE_KEY_ATTRIBUTE, key);
        keyAttr.setAttribute(true);
        final Node valueAttr = new Node(PROPERTY_NODE_VALUE_ATTRIBUTE, node
                .getProperties().get(key));
        valueAttr.setAttribute(true);
        propertyNode.addAttribute(keyAttr);
        propertyNode.addAttribute(valueAttr);
        propertiesNode.addChild(propertyNode);
    }
    return propertiesNode;
}
项目:momo-2    文件:CommandHandler.java   
/**
 * Normalize all guild commands
 * @param collection All commands
 * @throws ConfigurationException If apache config throws an exception
 */
private static void normalizeCommands(Collection<Command> collection) throws ConfigurationException {
    Collection<File> found = FileUtils.listFiles(new File("resources/guilds"),
            TrueFileFilter.INSTANCE, TrueFileFilter.INSTANCE);
    found.add(new File("resources/guilds/template.properties"));
    for (File f : found) {
        if (f.getName().equals("GuildProperties.properties") || f.getName().equals("template.properties")) {
            PropertiesConfiguration config = new PropertiesConfiguration(f);
            List<String> enabledCommands = config.getList("EnabledCommands").stream()
                    .map(object -> Objects.toString(object, null))
                    .collect(Collectors.toList());
            List<String> disabledCommands = config.getList("DisabledCommands").stream()
                    .map(object -> Objects.toString(object, null))
                    .collect(Collectors.toList());
            for (Command c : collection) {
                if (!enabledCommands.contains(c.toString()) && !disabledCommands.contains(c.toString())) {
                    enabledCommands.add(c.toString());
                }
            }
            config.setProperty("EnabledCommands", enabledCommands);
            config.save();
        }
    }
}
项目:KernelHive    文件:EngineGraphConfigurationTest.java   
@Test
public void testSaveAndLoadGraphForEngine() throws IOException,
        ConfigurationException, GraphNodeBuilderException {
    File f = File.createTempFile("test", "test");
    List<EngineGraphNodeDecorator> list = new ArrayList<EngineGraphNodeDecorator>();
    list.add(new EngineGraphNodeDecorator(new GraphNodeBuilder()
            .setId("test").setType(GraphNodeType.GENERIC).build()));

    config.saveGraphForEngine(list, f);
    List<EngineGraphNodeDecorator> result = config.loadGraphForEngine(f);
    assertEquals(list, result);
}
项目:jbake-rtl-jalaali    文件:Main.java   
protected void run(String[] args) {
    SLF4JBridgeHandler.removeHandlersForRootLogger();
    SLF4JBridgeHandler.install();
    LaunchOptions res = parseArguments( args );

    final CompositeConfiguration config;
    try {
        config = ConfigUtil.load( res.getSource() );
    } catch( final ConfigurationException e ) {
        throw new JBakeException( "Configuration error: " + e.getMessage(), e );
    }

    run(res, config);
}
项目:athena    文件:YangXmlUtilsTest.java   
/**
 * Test reading an XML configuration and retrieving the requested elements.
 *
 * @throws ConfigurationException
 */
@Test
public void testReadLastXmlConfiguration() throws ConfigurationException {
    testCreateConfig.load(getClass().getResourceAsStream("/testYangConfig.xml"));
    List<YangElement> elements = utils.readXmlConfiguration(testCreateConfig,
                                                            "controller");
    List<YangElement> expected = ImmutableList.of(
            new YangElement("controller", ImmutableMap.of("id", "tcp:1.1.1.1:1",
                                                          "ip-address", "1.1.1.1")),
            new YangElement("controller", ImmutableMap.of("id", "tcp:2.2.2.2:2",
                                                          "ip-address", "2.2.2.2")));
    assertEquals("Wrong elements collected", expected, elements);
}
项目:athena    文件:XmlDriverLoader.java   
/**
 * Loads the specified drivers resource as an XML stream and parses it to
 * produce a ready-to-register driver provider.
 *
 * @param driversStream stream containing the drivers definitions
 * @param resolver      driver resolver
 * @return driver provider
 * @throws java.io.IOException if issues are encountered reading the stream
 *                             or parsing the driver definitions within
 */
public DefaultDriverProvider loadDrivers(InputStream driversStream,
                                         DriverResolver resolver) throws IOException {
    try {
        XMLConfiguration cfg = new XMLConfiguration();
        cfg.setRootElementName(DRIVERS);
        cfg.setAttributeSplittingDisabled(true);

        cfg.load(driversStream);
        return loadDrivers(cfg, resolver);
    } catch (ConfigurationException e) {
        throw new IOException("Unable to load drivers", e);
    }
}
项目:Equella    文件:UpgradeToEmbeddedTomcat.java   
private File getUpgradeZip(Path installPath, File versionProps) throws ConfigurationException
{
    final PropertiesConfiguration props = new PropertiesConfiguration(versionProps);
    final String mmr = (String) props.getProperty("version.mmr");
    final String display = (String) props.getProperty("version.display");
    String filename = MessageFormat.format("tle-upgrade-{0} ({1}).zip", mmr, display);
    return installPath.resolve("manager/updates/" + filename).toFile();
}
项目:nightwatch    文件:Configuration.java   
public static void init(String configFilePath) {
    try {
        defultConfigFilePath = configFilePath;
        config = new PropertiesConfiguration(defultConfigFilePath);
    } catch (ConfigurationException e) {
        e.printStackTrace();
    }
}
项目:Yidu    文件:IndexAction.java   
@SkipValidation
@Override
public String execute() {
    logger.debug("execute start.");

    File lockFile = new File(LOCK_FILE);
    if (lockFile.exists()) {
        addActionError(getText("errors.install.file.exist", new String[] { LOCK_FILE }));
        return ERROR;
    }

    // 设定文件初期读入
    try {
        PropertiesConfiguration jdbcConf = new PropertiesConfiguration("jdbc.properties");
        String dburl = jdbcConf.getString(YiDuConfig.JDBC_URL).substring(prefixjdbc.length());
        String[] dbinfo = StringUtils.split(dburl, ":");
        dbhost = dbinfo[0];
        dbinfo = StringUtils.split(dbinfo[1], "/");
        dbport = dbinfo[0];
        // 数据库名暂时固定
        dbname = "yidu";
        dbusername = jdbcConf.getString(YiDuConfig.JDBC_USERNAME);
        dbpassword = jdbcConf.getString(YiDuConfig.JDBC_PASSWORD);
        PropertiesConfiguration languageConf = new PropertiesConfiguration(Thread.currentThread()
                .getContextClassLoader().getResource("language/package.properties"));
        title = languageConf.getString(YiDuConfig.TITLE);
        siteKeywords = languageConf.getString(YiDuConfig.SITEKEYWORDS);
        siteDescription = languageConf.getString(YiDuConfig.SITEDESCRIPTION);
        name = languageConf.getString(YiDuConfig.NAME);
        url = languageConf.getString(YiDuConfig.URL);
        copyright = languageConf.getString(YiDuConfig.COPYRIGHT);
        beianNo = languageConf.getString(YiDuConfig.BEIANNO);
        analyticscode = languageConf.getString(YiDuConfig.ANALYTICSCODE);

    } catch (ConfigurationException e) {
        logger.error(e);
    }
    logger.debug("execute normally end.");
    return INPUT;
}
项目:newblog    文件:HttpHelper.java   
private HttpHelper() {
    try {
        initHttpClient();
    } catch (ConfigurationException e) {
        log.info("configuratio exception.", e);
    }
}
项目:athena    文件:ApplicationArchive.java   
private ApplicationDescription parsePlainAppDescription(InputStream stream)
        throws IOException {
    XMLConfiguration cfg = new XMLConfiguration();
    cfg.setAttributeSplittingDisabled(true);
    cfg.setDelimiterParsingDisabled(true);
    try {
        cfg.load(stream);
        return loadAppDescription(cfg);
    } catch (ConfigurationException e) {
        throw new IOException("Unable to parse " + APP_XML, e);
    }
}
项目:loom    文件:AdapterConfigTest.java   
/**
 * Test loading from a file vs load the same file into the PropertiesConfiguration the config
 *
 * @throws ConfigurationException
 */
@Test
public void testLoadingViaFileVsProperties() throws ConfigurationException, AdapterConfigException {
    AdapterConfig config = new AdapterConfig("./src/test/resources/test.properties");
    AdapterConfig config2 = new AdapterConfig(new PropertiesConfiguration("./src/test/resources/test.properties"));

    Assert.assertEquals(config.getAdapterClass(), config2.getAdapterClass());
    Assert.assertEquals(config.getAdapterDir(), config2.getAdapterDir());
    Assert.assertEquals(config.getAuthEndpoint(), config2.getAuthEndpoint());
    Assert.assertEquals(config.getProviderId(), config2.getProviderId());
    Assert.assertEquals(config.getProviderName(), config2.getProviderName());
    Assert.assertEquals(config.getProviderType(), config2.getProviderType());
    Assert.assertEquals(config.getCollectThreads(), config2.getCollectThreads());
    Assert.assertEquals(config.getSchedulingInterval(), config2.getSchedulingInterval());
}
项目:visitormanagement    文件:EmailService.java   
/** Test smtp authentication configuration.
 * 
 * @param smtpConfiguration
 * @throws MessagingException
 * @throws ConfigurationException
 */
public void authenticateAndLoadConfiguration(EmailConfigurationDTO smtpConfiguration) throws MessagingException, ConfigurationException {
    Transport transport = getSession().getTransport(SMTP_PROTOCOL);
    try {
        transport.connect(smtpConfiguration.getHost(), smtpConfiguration.getPort(), smtpConfiguration.getUserName(), 
                smtpConfiguration.getPassword());
    } finally {
        transport.close();
    }
    updateMailSenderConfig();
}
项目:KernelHive    文件:KernelRepository.java   
@Override
public List<KernelRepositoryEntry> getEntries()
        throws ConfigurationException {
    config.load(resource);

    List<KernelRepositoryEntry> entries = new ArrayList<>();

    List<ConfigurationNode> entryNodes = config.getRoot().getChildren(ENTRY_NODE);
    for(ConfigurationNode node : entryNodes){
        entries.add(getEntryFromConfigurationNode(node));
    }       
    return entries;
}
项目:HTAPBench    文件:RandomExecutor.java   
public static void main (String[]args) throws ConfigurationException, HTAPBException{
    // Initialize log4j
    String log4jPath = System.getProperty("log4j.configuration");
    if (log4jPath != null) {
        org.apache.log4j.PropertyConfigurator.configure(log4jPath);
    } else {
        throw new RuntimeException("Missing log4j.properties file");
    }

    String configFile = "config/htapb_config_postgres.xml";
    XMLConfiguration xmlConfig = new XMLConfiguration(configFile);
    xmlConfig.setExpressionEngine(new XPathExpressionEngine());


    WorkloadSetup setup = new WorkloadSetup(xmlConfig);
    setup.computeWorkloadSetup();


    DensityConsultant density = new DensityConsultant(10000);
    System.out.println("Density: "+density.getDensity());
    System.out.println("Delta TS: "+density.getDeltaTs());
    System.out.println("Target TPS "+density.getTargetTPS());

    long deltaTs = density.getDeltaTs();

    Clock clock = new Clock(deltaTs,false);

    System.out.println("Clock: current TS "+clock.getCurrentTs());

    int year = RandomParameters.randBetween(1993, 1997);
    int month = RandomParameters.randBetween(1, 12);
    long date1 = RandomParameters.convertDatetoLong(year, month, 1);
    long date2 = RandomParameters.convertDatetoLong(year+1, month, 1);
    Timestamp ts1 = new Timestamp(clock.transformTsFromSpecToLong(date1));  
    Timestamp ts2 = new Timestamp(clock.transformTsFromSpecToLong(date2));

    System.out.println(ts1.toString());
    System.out.println(ts2.toString());

}
项目:KernelHive    文件:KernelRepository.java   
private Map<String, Object> getKernelProperties(ConfigurationNode node) throws ConfigurationException{
    List<ConfigurationNode> propertiesNodeList = node.getChildren(KERNEL_PROPERTY_NODE);
    Map<String, Object> properties = new HashMap<String, Object>(propertiesNodeList.size());

    for(ConfigurationNode pNode : propertiesNodeList){
        String key;
        Object value;

        List<ConfigurationNode> keyAttrList = pNode.getAttributes(KERNEL_PROPERTY_NODE_KEY_ATTRIBUTE);
        List<ConfigurationNode> valueAttrList = pNode.getAttributes(KERNEL_PROPERTY_NODE_VALUE_ATTRIBUTE);

        if(keyAttrList.size()>0){
            key = (String) keyAttrList.get(0).getValue();
        } else{
            throw new ConfigurationException("KH: no required '"+KERNEL_PROPERTY_NODE_KEY_ATTRIBUTE+"' attribute in "+KERNEL_PROPERTY_NODE+" node");
        }

        if(valueAttrList.size()>0){
            value = valueAttrList.get(0).getValue();
        } else{
            throw new ConfigurationException("KH: no required '"+KERNEL_PROPERTY_NODE_VALUE_ATTRIBUTE+"' attribute in "+KERNEL_PROPERTY_NODE+" node");
        }

        properties.put(key, value);
    }
    return properties;
}
项目:obevo    文件:DbFileMerger.java   
public void execute(DbFileMergerArgs args) {
    try {
        PropertiesConfiguration config = new PropertiesConfiguration(args.getDbMergeConfigFile());
        DbPlatform dialect = DbPlatformConfiguration.getInstance().valueOf(config.getString("dbType"));
        this.generateDiffs(dialect, DbMergeInfo.parseFromProperties(config), args.getOutputDir());
    } catch (ConfigurationException e) {
        throw new DeployerRuntimeException(e);
    }
}
项目:automatic-mower    文件:CustomSettingLoader.java   
/**
 * A private constructor to avoid the instantiation
 */
private CustomSettingLoader() {
    try {
        this.configuration = new XMLConfiguration("");
    } catch (ConfigurationException e) {
        LoggerFactory.getLogger(CustomSettingLoader.class).warn(e.getMessage());
    }
}
项目:athena    文件:XmlConfigParser.java   
public static HierarchicalConfiguration loadXml(InputStream xmlStream) {
    XMLConfiguration cfg = new XMLConfiguration();
    try {
        cfg.load(xmlStream);
        return cfg;
    } catch (ConfigurationException e) {
        throw new IllegalArgumentException("Cannot load xml from Stream", e);
    }
}
项目:BUbiNG    文件:StartupConfiguration.java   
private void checkRootDir() throws ConfigurationException {
    if (rootDirChecked) return;
    final File d = new File(rootDir);
    if (crawlIsNew) {
        if (d.exists()) throw new ConfigurationException("Root directory " + d + " exists");
        if (! d.mkdirs()) throw new ConfigurationException("Cannot create root directory " + d);
    }
    else if (! d.exists()) throw new ConfigurationException("Cannot find root directory " + rootDir + " for the crawl");
    rootDirChecked = true;
}
项目:Equella    文件:UpgradeToEmbeddedTomcat.java   
private void updateMandatoryProperties(final UpgradeResult result, File configDir) throws ConfigurationException,
    IOException
{
    PropertyFileModifier propMod = new PropertyFileModifier(new File(configDir,
        PropertyFileModifier.MANDATORY_CONFIG))
    {
        @Override
        protected boolean modifyProperties(PropertiesConfiguration props)
        {
            // Add Tomcat ports
            String url = (String) props.getProperty("admin.url");
            String port = getPort(url);
            String tomcatComment = System.lineSeparator()
                + "# Tomcat ports. Specify the ports Tomcat should create connectors for";
            PropertiesConfigurationLayout layout = props.getLayout();
            layout.setLineSeparator(System.lineSeparator());
            if( url.contains("https") )
            {
                String httpsProp = "https.port";
                props.setProperty(httpsProp, port);
                layout.setComment(httpsProp, tomcatComment);
                props.setProperty("#http.port", "");
            }
            else
            {
                String httpProp = "http.port";
                props.setProperty(httpProp, port);
                layout.setComment(httpProp, tomcatComment);
                props.setProperty("#https.port", "");
            }
            props.setProperty("#ajp.port", "8009");

            // Remove Tomcat location
            props.clearProperty("tomcat.location");

            return true;
        }
    };
    propMod.updateProperties();
}
项目:BUbiNG    文件:StartupConfiguration.java   
private void chkSubDir(final String dir) throws ConfigurationException {
    final File d = subDir(rootDir, dir);
    if (crawlIsNew) {
        if (d.exists()) throw new ConfigurationException("Directory " + d + " exists");
        if (! d.mkdirs()) throw new ConfigurationException("Cannot create directory " + d);
    }
    else if (! d.exists()) throw new ConfigurationException("Directory " + d + " does not exist");
}
项目:KernelHive    文件:EngineGraphConfiguration.java   
private List<EngineGraphNodeDecorator> loadGraphFromXMLForEngine()
        throws ConfigurationException {
    final List<EngineGraphNodeDecorator> engineNodes = loadGraphNodesForEngine();
    final List<IGraphNode> nodes = new ArrayList<IGraphNode>();
    for (final EngineGraphNodeDecorator n : engineNodes) {
        nodes.add(n.getGraphNode());
    }
    linkGraphNodes(nodes);
    return engineNodes;
}
项目:redirector    文件:DataServiceInfo.java   
private ServiceInfo obtainServiceInfo() {
    try {
        Configuration config = new PropertiesConfiguration(CONFIG_FILE_NAME);
        return new ServiceInfo(config);
    } catch (ConfigurationException ce) {
        log.warn("Failed to load configuration file: {}", CONFIG_FILE_NAME);
    } catch (Exception e) {
        log.warn("Exception appears while configuration file is loading", e);
    }
    return null;
}
项目:KernelHive    文件:EngineGraphConfiguration.java   
private Map<String, Object> loadKernelProperties(
        final ConfigurationNode node) throws ConfigurationException {
    final List<ConfigurationNode> propList = node
            .getChildren(KERNEL_PROPERTY_NODE);
    final Map<String, Object> properties = new HashMap<String, Object>();
    for (final ConfigurationNode propNode : propList) {
        String key;
        Object value;

        final List<ConfigurationNode> keyAttrList = propNode
                .getAttributes(KERNEL_PROPERTY_NODE_KEY_ATTRIBUTE);
        if (keyAttrList.size() > 0) {
            key = (String) keyAttrList.get(0).getValue();
        } else {
            throw new ConfigurationException("KH: no required attribute '"
                    + KERNEL_PROPERTY_NODE_KEY_ATTRIBUTE + "' in "
                    + KERNEL_PROPERTY_NODE + " node");
        }
        final List<ConfigurationNode> valueAttrList = propNode
                .getAttributes(KERNEL_PROPERTY_NODE_VALUE_ATTRIBUTE);
        if (valueAttrList.size() > 0) {
            value = valueAttrList.get(0).getValue();
        } else {
            throw new ConfigurationException("KH: no required attribute '"
                    + KERNEL_PROPERTY_NODE_VALUE_ATTRIBUTE + "' in "
                    + KERNEL_PROPERTY_NODE + " node");
        }
        properties.put(key, value);
    }
    return properties;
}
项目:KernelHive    文件:EngineGraphConfiguration.java   
@Override
public void saveGraphForEngine(
        final List<EngineGraphNodeDecorator> graphNodes, final Writer writer)
        throws ConfigurationException {
    final XMLConfiguration tempConfig = (XMLConfiguration) config.clone();
    final File tempFile = config.getFile();
    try {
        config.clear();
        final List<ConfigurationNode> rootAttrs = tempConfig.getRootNode()
                .getAttributes();
        config.setRootNode((ConfigurationNode) tempConfig.getRootNode()
                .clone());
        config.getRootNode().removeChildren();
        for (final ConfigurationNode n : rootAttrs) {
            config.getRootNode()
                    .addAttribute((ConfigurationNode) n.clone());
        }
        final List<ConfigurationNode> inputDataURLNodes = tempConfig
                .getRoot().getChildren(INPUT_DATA_NODE);
        for (final ConfigurationNode node : inputDataURLNodes) {
            config.getRootNode().addChild(node);
        }
        for (final EngineGraphNodeDecorator engineNode : graphNodes) {
            config.getRoot().addChild(createGraphNodeForEngine(engineNode));
        }
        config.save(writer);
    } catch (final ConfigurationException e) {
        config = tempConfig;
        config.save(tempFile);
    }

}