Example usage for java.lang Boolean getBoolean

List of usage examples for java.lang Boolean getBoolean

Introduction

In this page you can find the example usage for java.lang Boolean getBoolean.

Prototype

public static boolean getBoolean(String name) 

Source Link

Document

Returns true if and only if the system property named by the argument exists and is equal to, ignoring case, the string "true" .

Usage

From source file:org.lockss.test.LockssTestCase.java

/**
 * Remove any temp dirs, cancel any outstanding {@link
 * org.lockss.test.LockssTestCase.DoLater}s
 * @throws Exception/*w  w  w .  jav  a  2  s .  c  o  m*/
 */
protected void tearDown() throws Exception {
    if (doLaters != null) {
        List copy;
        synchronized (this) {
            copy = new ArrayList(doLaters);
        }
        for (Iterator iter = copy.iterator(); iter.hasNext();) {
            DoLater doer = (DoLater) iter.next();
            doer.cancel();
        }
        // do NOT set doLaters to null here.  It may be referenced by
        // exiting DoLaters.  It won't hurt anything because the next test
        // will create a new instance of the test case, and get a different
        // doLaters list
    }
    // XXX this should be folded into LockssDaemon shutdown
    ConfigManager cfg = ConfigManager.getConfigManager();
    if (cfg != null) {
        cfg.stopService();
    }

    TimerQueue.stopTimerQueue();

    // delete temp dirs
    if (tmpDirs != null && !isKeepTempFiles()) {
        for (ListIterator iter = tmpDirs.listIterator(); iter.hasNext();) {
            File dir = (File) iter.next();
            File idFile = new File(dir, TEST_ID_FILE_NAME);
            String idContent = null;
            if (idFile.exists()) {
                idContent = StringUtil.fromFile(idFile);
            }
            if (FileUtil.delTree(dir)) {
                log.debug2("deltree(" + dir + ") = true");
                iter.remove();
            } else {
                log.debug2("deltree(" + dir + ") = false");
                if (idContent != null) {
                    FileTestUtil.writeFile(idFile, idContent);
                }
            }
        }
    }
    if (!StringUtil.isNullString(javaIoTmpdir)) {
        System.setProperty("java.io.tmpdir", javaIoTmpdir);
    }
    super.tearDown();
    if (Boolean.getBoolean("org.lockss.test.threadDump")) {
        PlatformUtil.getInstance().threadDump(true);
    }
    // don't reenable the watchdog; some threads may not have exited yet
    //     enableThreadWatchdog();
}

From source file:org.gradle.integtests.fixtures.executer.AbstractGradleExecuter.java

@Override
public GradleExecuter reset() {
    args.clear();/*from  w w w .  java2 s  .c  o  m*/
    tasks.clear();
    initScripts.clear();
    workingDir = null;
    projectDir = null;
    buildScript = null;
    settingsFile = null;
    quiet = false;
    taskList = false;
    dependencyList = false;
    searchUpwards = false;
    executable = null;
    javaHome = null;
    environmentVars.clear();
    stdinPipe = null;
    defaultCharacterEncoding = null;
    defaultLocale = null;
    commandLineJvmOpts.clear();
    buildJvmOpts.clear();
    useOnlyRequestedJvmOpts = false;
    expectedDeprecationWarnings = 0;
    stackTraceChecksOn = true;
    renderWelcomeMessage = false;
    debug = Boolean.getBoolean(DEBUG_SYSPROP);
    debugLauncher = Boolean.getBoolean(LAUNCHER_DEBUG_SYSPROP);
    profiler = System.getProperty(PROFILE_SYSPROP, "");
    interactive = false;
    checkDeprecations = true;
    durationMeasurement = null;
    consoleType = null;
    warningMode = WarningMode.All;
    return this;
}

From source file:org.apereo.portal.jmx.JavaManagementServerBean.java

/**
 * Generates the environment Map for the JMX server based on system properties
 * @return A non-null Map of environment settings for the JMX server.
 *//*www .  j  ava 2 s .  co m*/
protected Map<String, Object> getJmxServerEnvironment() {
    final Map<String, Object> jmxEnv = new HashMap<String, Object>();

    //SSL Options
    final String enableSSL = System.getProperty(JMX_SSL_PROPERTY);
    if (Boolean.getBoolean(enableSSL)) {
        SslRMIClientSocketFactory csf = new SslRMIClientSocketFactory();
        jmxEnv.put(RMIConnectorServer.RMI_CLIENT_SOCKET_FACTORY_ATTRIBUTE, csf);

        SslRMIServerSocketFactory ssf = new SslRMIServerSocketFactory();
        jmxEnv.put(RMIConnectorServer.RMI_SERVER_SOCKET_FACTORY_ATTRIBUTE, ssf);
    }

    //Password file options
    final String passwordFile = System.getProperty(JMX_PASSWORD_FILE_PROPERTY);
    if (passwordFile != null) {
        jmxEnv.put(JMX_REMOTE_X_PASSWORD_FILE, passwordFile);
    }

    //Access file options
    final String accessFile = System.getProperty(JMX_ACCESS_FILE_PROPERTY);
    if (accessFile != null) {
        jmxEnv.put(JMX_REMOTE_X_ACCESS_FILE, accessFile);
    }

    if (this.logger.isDebugEnabled()) {
        this.logger.debug("Configured JMX Server Environment = '" + jmxEnv + "'");
    }

    return jmxEnv;
}

From source file:com.bugvm.maven.plugin.AbstractBugVMMojo.java

protected Config.Builder configure(Config.Builder builder) throws MojoExecutionException {
    builder.logger(getBugVMLogger());//from w  w w .jav a2s.  com

    // load config base file if it exists (and properties)

    if (os != null) {
        builder.os(OS.valueOf(os));
    }

    if (propertiesFile != null) {
        if (!propertiesFile.exists()) {
            throw new MojoExecutionException(
                    "Invalid 'propertiesFile' specified for BugVM compile: " + propertiesFile);
        }
        try {
            getLog().debug(
                    "Including properties file in BugVM compiler config: " + propertiesFile.getAbsolutePath());
            builder.addProperties(propertiesFile);
        } catch (IOException e) {
            throw new MojoExecutionException(
                    "Failed to add properties file to BugVM config: " + propertiesFile);
        }
    } else {
        try {
            builder.readProjectProperties(project.getBasedir(), false);
        } catch (IOException e) {
            throw new MojoExecutionException("Failed to read BugVM project properties file(s) in "
                    + project.getBasedir().getAbsolutePath(), e);
        }
    }

    if (configFile != null) {
        if (!configFile.exists()) {
            throw new MojoExecutionException("Invalid 'configFile' specified for BugVM compile: " + configFile);
        }
        try {
            getLog().debug("Loading config file for BugVM compiler: " + configFile.getAbsolutePath());
            builder.read(configFile);
        } catch (Exception e) {
            throw new MojoExecutionException("Failed to read BugVM config file: " + configFile);
        }
    } else {
        try {
            builder.readProjectConfig(project.getBasedir(), false);
        } catch (Exception e) {
            throw new MojoExecutionException(
                    "Failed to read project BugVM config file in " + project.getBasedir().getAbsolutePath(), e);
        }
    }

    // Read embedded BugVM <config> if there is one
    Plugin plugin = project.getPlugin("com.bugvm:bugvm-maven-plugin");
    MavenProject p = project;
    while (p != null && plugin == null) {
        plugin = p.getPluginManagement().getPluginsAsMap().get("com.bugvm:bugvm-maven-plugin");
        if (plugin == null)
            p = p.getParent();
    }
    if (plugin != null) {
        getLog().debug("Reading BugVM plugin configuration from " + p.getFile().getAbsolutePath());
        Xpp3Dom configDom = (Xpp3Dom) plugin.getConfiguration();
        if (configDom != null && configDom.getChild("config") != null) {
            StringWriter sw = new StringWriter();
            XMLWriter xmlWriter = new PrettyPrintXMLWriter(sw, "UTF-8", null);
            Xpp3DomWriter.write(xmlWriter, configDom.getChild("config"));
            try {
                builder.read(new StringReader(sw.toString()), project.getBasedir());
            } catch (Exception e) {
                throw new MojoExecutionException("Failed to read BugVM config embedded in POM", e);
            }
        }
    }

    File tmpDir = new File(project.getBuild().getDirectory(), "bugvm.tmp");
    try {
        FileUtils.deleteDirectory(tmpDir);
    } catch (IOException e) {
        throw new MojoExecutionException("Failed to clean output dir " + tmpDir, e);
    }
    tmpDir.mkdirs();

    Home home = null;
    try {
        home = Home.find();
    } catch (Throwable t) {
    }
    if (home == null || !home.isDev()) {
        home = new Config.Home(unpackBugVMDist());
    }
    builder.home(home).tmpDir(tmpDir).skipInstall(true).installDir(installDir);
    if (home.isDev()) {
        builder.useDebugLibs(Boolean.getBoolean("bugvm.useDebugLibs"));
        builder.dumpIntermediates(true);
    }

    if (debug != null && !debug.equals("false")) {
        builder.debug(true);
        if (debugPort != -1) {
            builder.addPluginArgument("debug:jdwpport=" + debugPort);
        }
        if ("clientmode".equals(debug)) {
            builder.addPluginArgument("debug:clientmode=true");
        }
    }

    if (skipSigning) {
        builder.iosSkipSigning(true);
    } else {
        if (signIdentity != null) {
            getLog().debug("Using explicit signing identity: " + signIdentity);
            builder.iosSignIdentity(SigningIdentity.find(SigningIdentity.list(), signIdentity));
        }

        if (provisioningProfile != null) {
            getLog().debug("Using explicit provisioning profile: " + provisioningProfile);
            builder.iosProvisioningProfile(
                    ProvisioningProfile.find(ProvisioningProfile.list(), provisioningProfile));
        }

        // if (keychainPassword != null) {
        //     builder.keychainPassword(keychainPassword);
        // } else if (keychainPasswordFile != null) {
        //     builder.keychainPasswordFile(keychainPasswordFile);
        // }
    }

    if (cacheDir != null) {
        builder.cacheDir(cacheDir);
    }

    builder.clearClasspathEntries();

    // configure the runtime classpath

    try {
        for (Object object : project.getRuntimeClasspathElements()) {
            String path = (String) object;
            if (getLog().isDebugEnabled()) {
                getLog().debug("Including classpath element for BugVM app: " + path);
            }
            builder.addClasspathEntry(new File(path));
        }
    } catch (DependencyResolutionRequiredException e) {
        throw new MojoExecutionException("Error resolving application classpath for BugVM build", e);
    }

    return builder;
}

From source file:org.patientview.patientview.unit.UnitUtils.java

public static void buildUnit(Unit unit, Object form) throws Exception {

    // only change source type if set to null
    if (unit.getSourceType() == null) {
        // set defaults for sourceType and country, note this runs for updates as well as creates
        unit.setSourceType(BeanUtils.getProperty(form, "sourceType"));
        if (unit.getSourceType() == null || unit.getSourceType().length() == 0) {
            unit.setSourceType("renalunit");
        }//  ww w  . ja va  2  s .c o  m
    }

    if (unit.getCountry() == null || unit.getCountry().length() == 0) {
        unit.setCountry("1");
    }

    // build object
    unit.setUnitcode(BeanUtils.getProperty(form, "unitcode"));
    unit.setName(BeanUtils.getProperty(form, "name"));
    unit.setShortname(BeanUtils.getProperty(form, "shortname"));
    unit.setUnituser(BeanUtils.getProperty(form, "unituser"));
    unit.setAddress1(BeanUtils.getProperty(form, "address1"));
    unit.setAddress2(BeanUtils.getProperty(form, "address2"));
    unit.setAddress3(BeanUtils.getProperty(form, "address3"));
    unit.setPostcode(BeanUtils.getProperty(form, "postcode"));
    unit.setUniturl(BeanUtils.getProperty(form, "uniturl"));
    unit.setTrusturl(BeanUtils.getProperty(form, "trusturl"));
    unit.setRenaladminname(BeanUtils.getProperty(form, "renaladminname"));
    unit.setRenaladminphone(BeanUtils.getProperty(form, "renaladminphone"));
    unit.setRenaladminemail(BeanUtils.getProperty(form, "renaladminemail"));
    unit.setUnitenquiriesphone(BeanUtils.getProperty(form, "unitenquiriesphone"));
    unit.setUnitenquiriesemail(BeanUtils.getProperty(form, "unitenquiriesemail"));
    unit.setAppointmentphone(BeanUtils.getProperty(form, "appointmentphone"));
    unit.setAppointmentemail(BeanUtils.getProperty(form, "appointmentemail"));
    unit.setOutofhours(BeanUtils.getProperty(form, "outofhours"));
    unit.setPeritonealdialysisphone(BeanUtils.getProperty(form, "peritonealdialysisphone"));
    unit.setPeritonealdialysisemail(BeanUtils.getProperty(form, "peritonealdialysisemail"));

    unit.setHaemodialysisunitname1(BeanUtils.getProperty(form, "haemodialysisunitname1"));
    unit.setHaemodialysisunitphone1(BeanUtils.getProperty(form, "haemodialysisunitphone1"));
    unit.setHaemodialysisunitlocation1(BeanUtils.getProperty(form, "haemodialysisunitlocation1"));
    unit.setHaemodialysisuniturl1(BeanUtils.getProperty(form, "haemodialysisuniturl1"));

    unit.setHaemodialysisunitname2(BeanUtils.getProperty(form, "haemodialysisunitname2"));
    unit.setHaemodialysisunitphone2(BeanUtils.getProperty(form, "haemodialysisunitphone2"));
    unit.setHaemodialysisunitlocation2(BeanUtils.getProperty(form, "haemodialysisunitlocation2"));
    unit.setHaemodialysisuniturl2(BeanUtils.getProperty(form, "haemodialysisuniturl2"));

    unit.setHaemodialysisunitname3(BeanUtils.getProperty(form, "haemodialysisunitname3"));
    unit.setHaemodialysisunitphone3(BeanUtils.getProperty(form, "haemodialysisunitphone3"));
    unit.setHaemodialysisunitlocation3(BeanUtils.getProperty(form, "haemodialysisunitlocation3"));
    unit.setHaemodialysisuniturl3(BeanUtils.getProperty(form, "haemodialysisuniturl3"));

    unit.setHaemodialysisunitname4(BeanUtils.getProperty(form, "haemodialysisunitname4"));
    unit.setHaemodialysisunitphone4(BeanUtils.getProperty(form, "haemodialysisunitphone4"));
    unit.setHaemodialysisunitlocation4(BeanUtils.getProperty(form, "haemodialysisunitlocation4"));
    unit.setHaemodialysisuniturl4(BeanUtils.getProperty(form, "haemodialysisuniturl4"));

    unit.setHaemodialysisunitname5(BeanUtils.getProperty(form, "haemodialysisunitname5"));
    unit.setHaemodialysisunitphone5(BeanUtils.getProperty(form, "haemodialysisunitphone5"));
    unit.setHaemodialysisunitlocation5(BeanUtils.getProperty(form, "haemodialysisunitlocation5"));
    unit.setHaemodialysisuniturl5(BeanUtils.getProperty(form, "haemodialysisuniturl5"));

    unit.setHaemodialysisunitname6(BeanUtils.getProperty(form, "haemodialysisunitname6"));
    unit.setHaemodialysisunitphone6(BeanUtils.getProperty(form, "haemodialysisunitphone6"));
    unit.setHaemodialysisunitlocation6(BeanUtils.getProperty(form, "haemodialysisunitlocation6"));
    unit.setHaemodialysisuniturl6(BeanUtils.getProperty(form, "haemodialysisuniturl6"));

    unit.setHaemodialysisunitname7(BeanUtils.getProperty(form, "haemodialysisunitname7"));
    unit.setHaemodialysisunitphone7(BeanUtils.getProperty(form, "haemodialysisunitphone7"));
    unit.setHaemodialysisunitlocation7(BeanUtils.getProperty(form, "haemodialysisunitlocation7"));
    unit.setHaemodialysisuniturl7(BeanUtils.getProperty(form, "haemodialysisuniturl7"));

    unit.setHaemodialysisunitname8(BeanUtils.getProperty(form, "haemodialysisunitname8"));
    unit.setHaemodialysisunitphone8(BeanUtils.getProperty(form, "haemodialysisunitphone8"));
    unit.setHaemodialysisunitlocation8(BeanUtils.getProperty(form, "haemodialysisunitlocation8"));
    unit.setHaemodialysisuniturl8(BeanUtils.getProperty(form, "haemodialysisuniturl8"));

    unit.setHaemodialysisunitname9(BeanUtils.getProperty(form, "haemodialysisunitname9"));
    unit.setHaemodialysisunitphone9(BeanUtils.getProperty(form, "haemodialysisunitphone9"));
    unit.setHaemodialysisunitlocation9(BeanUtils.getProperty(form, "haemodialysisunitlocation9"));
    unit.setHaemodialysisuniturl9(BeanUtils.getProperty(form, "haemodialysisuniturl9"));

    unit.setHaemodialysisunitname10(BeanUtils.getProperty(form, "haemodialysisunitname10"));
    unit.setHaemodialysisunitphone10(BeanUtils.getProperty(form, "haemodialysisunitphone10"));
    unit.setHaemodialysisunitlocation10(BeanUtils.getProperty(form, "haemodialysisunitlocation10"));
    unit.setHaemodialysisuniturl10(BeanUtils.getProperty(form, "haemodialysisuniturl10"));

    unit.setHaemodialysisunitname11(BeanUtils.getProperty(form, "haemodialysisunitname11"));
    unit.setHaemodialysisunitphone11(BeanUtils.getProperty(form, "haemodialysisunitphone11"));
    unit.setHaemodialysisunitlocation11(BeanUtils.getProperty(form, "haemodialysisunitlocation11"));
    unit.setHaemodialysisuniturl11(BeanUtils.getProperty(form, "haemodialysisuniturl11"));

    unit.setHaemodialysisunitname12(BeanUtils.getProperty(form, "haemodialysisunitname12"));
    unit.setHaemodialysisunitphone12(BeanUtils.getProperty(form, "haemodialysisunitphone12"));
    unit.setHaemodialysisunitlocation12(BeanUtils.getProperty(form, "haemodialysisunitlocation12"));
    unit.setHaemodialysisuniturl12(BeanUtils.getProperty(form, "haemodialysisuniturl12"));
    unit.setVisible(Boolean.getBoolean(BeanUtils.getProperty(form, "visible")));
}

From source file:com.adeptj.runtime.server.Server.java

private Builder enableHttp2(Builder builder) throws GeneralSecurityException, IOException {
    if (Boolean.getBoolean(ServerConstants.SYS_PROP_ENABLE_HTTP2)) {
        Config httpsConf = Objects.requireNonNull(this.cfgReference.get()).getConfig(ServerConstants.KEY_HTTPS);
        int httpsPort = httpsConf.getInt(Constants.KEY_PORT);
        if (!Environment.useProvidedKeyStore()) {
            System.setProperty("adeptj.rt.keyStore", httpsConf.getString(ServerConstants.KEY_KEYSTORE));
            System.setProperty("adeptj.rt.keyStorePassword", httpsConf.getString("keyStorePwd"));
            System.setProperty("adeptj.rt.keyPassword", httpsConf.getString("keyPwd"));
            LOGGER.info("HTTP2 enabled @ port: [{}] using bundled KeyStore.", httpsPort);
        }/*from  ww  w .j a v a2 s .  co  m*/
        SSLContext sslContext = SslContextFactory.newSslContext(httpsConf.getString("tlsVersion"));
        builder.addHttpsListener(httpsPort, httpsConf.getString(Constants.KEY_HOST), sslContext);
    }
    return builder;
}

From source file:org.apache.geode.cache.client.internal.PoolImpl.java

protected PoolImpl(PoolManagerImpl pm, String name, Pool attributes, List<HostAddress> locAddresses) {
    this.pm = pm;
    this.name = name;
    this.socketConnectTimeout = attributes.getSocketConnectTimeout();
    this.freeConnectionTimeout = attributes.getFreeConnectionTimeout();
    this.loadConditioningInterval = attributes.getLoadConditioningInterval();
    this.socketBufferSize = attributes.getSocketBufferSize();
    this.threadLocalConnections = attributes.getThreadLocalConnections();
    this.readTimeout = attributes.getReadTimeout();
    this.minConnections = attributes.getMinConnections();
    this.maxConnections = attributes.getMaxConnections();
    this.retryAttempts = attributes.getRetryAttempts();
    this.idleTimeout = attributes.getIdleTimeout();
    this.pingInterval = attributes.getPingInterval();
    this.statisticInterval = attributes.getStatisticInterval();
    this.subscriptionEnabled = attributes.getSubscriptionEnabled();
    this.prSingleHopEnabled = attributes.getPRSingleHopEnabled();
    this.subscriptionRedundancyLevel = attributes.getSubscriptionRedundancy();
    this.subscriptionMessageTrackingTimeout = attributes.getSubscriptionMessageTrackingTimeout();
    this.subscriptionAckInterval = attributes.getSubscriptionAckInterval();
    this.serverGroup = attributes.getServerGroup();
    this.multiuserSecureModeEnabled = attributes.getMultiuserAuthentication();
    this.locatorAddresses = locAddresses;
    this.locators = attributes.getLocators();
    this.servers = attributes.getServers();
    this.startDisabled = ((PoolFactoryImpl.PoolAttributes) attributes).startDisabled || !pm.isNormal();
    this.usedByGateway = ((PoolFactoryImpl.PoolAttributes) attributes).isGateway();
    this.gatewaySender = ((PoolFactoryImpl.PoolAttributes) attributes).getGatewaySender();
    // if (this.subscriptionEnabled && this.multiuserSecureModeEnabled) {
    // throw new IllegalStateException(
    // "subscription-enabled and multiuser-authentication both cannot be true.");
    // }/*  w w  w .  j  ava  2  s.  com*/
    InternalDistributedSystem ds = InternalDistributedSystem.getAnyInstance();
    if (ds == null) {
        throw new IllegalStateException(
                LocalizedStrings.PoolImpl_DISTRIBUTED_SYSTEM_MUST_BE_CREATED_BEFORE_CREATING_POOL
                        .toLocalizedString());
    }
    this.securityLogWriter = ds.getSecurityInternalLogWriter();
    if (!ds.getConfig().getStatisticSamplingEnabled() && this.statisticInterval > 0) {
        logger.info(LocalizedMessage.create(
                LocalizedStrings.PoolImpl_STATISTIC_SAMPLING_MUST_BE_ENABLED_FOR_SAMPLING_RATE_OF_0_TO_TAKE_AFFECT,
                this.statisticInterval));
    }
    this.dsys = ds;
    this.cancelCriterion = new Stopper();
    if (Boolean.getBoolean(DistributionConfig.GEMFIRE_PREFIX + "SPECIAL_DURABLE")) {
        ClientProxyMembershipID.setPoolName(name);
        this.proxyId = ClientProxyMembershipID.getNewProxyMembership(ds);
        ClientProxyMembershipID.setPoolName(null);
    } else {
        this.proxyId = ClientProxyMembershipID.getNewProxyMembership(ds);
    }
    StatisticsFactory statFactory = null;
    if (this.gatewaySender != null) {
        statFactory = new DummyStatisticsFactory();
    } else {
        statFactory = ds;
    }
    this.stats = this.startDisabled ? null
            : new PoolStats(statFactory,
                    getName() + "->" + (isEmpty(serverGroup) ? "[any servers]" : "[" + getServerGroup() + "]"));

    source = getSourceImpl(((PoolFactoryImpl.PoolAttributes) attributes).locatorCallback);
    endpointManager = new EndpointManagerImpl(name, ds, this.cancelCriterion, this.stats);
    connectionFactory = new ConnectionFactoryImpl(source, endpointManager, ds, socketBufferSize,
            socketConnectTimeout, readTimeout, proxyId, this.cancelCriterion, usedByGateway, gatewaySender,
            pingInterval, multiuserSecureModeEnabled, this);
    if (subscriptionEnabled) {
        queueManager = new QueueManagerImpl(this, endpointManager, source, connectionFactory,
                subscriptionRedundancyLevel, pingInterval, securityLogWriter, proxyId);
    }

    manager = new ConnectionManagerImpl(name, connectionFactory, endpointManager, maxConnections,
            minConnections, idleTimeout, loadConditioningInterval, securityLogWriter, pingInterval,
            cancelCriterion, getStats());
    // Fix for 43468 - make sure we check the cache cancel criterion if we get
    // an exception, by passing in the poolOrCache stopper
    executor = new OpExecutorImpl(manager, queueManager, endpointManager, riTracker, retryAttempts,
            freeConnectionTimeout, threadLocalConnections, new PoolOrCacheStopper(), this);
    if (this.multiuserSecureModeEnabled) {
        this.proxyCacheList = new ArrayList<ProxyCache>();
    } else {
        this.proxyCacheList = null;
    }
}

From source file:nz.co.fortytwo.signalk.util.Util.java

public static SignalKModel populateModel(SignalKModel model, String mapDump) throws IOException {
    Properties props = new Properties();
    props.load(new StringReader(mapDump.substring(1, mapDump.length() - 1).replace(", ", "\n")));
    for (Map.Entry<Object, Object> e : props.entrySet()) {
        if (e.getValue().equals("true") || e.getValue().equals("false")) {
            model.put((String) e.getKey(), Boolean.getBoolean((String) e.getValue()));
        } else if (NumberUtils.isNumber((String) e.getValue())) {
            model.put((String) e.getKey(), NumberUtils.createDouble((String) e.getValue()));
        } else {/*from  w  w w  .ja v a  2  s. c  om*/
            model.put((String) e.getKey(), e.getValue());
        }
    }
    return model;
}

From source file:org.jahia.services.content.impl.jackrabbit.RepositoryMigrator.java

void migrate() {
    try {/* w ww  .  ja  va  2 s  .  c  o  m*/
        JahiaRepositoryConfig sourceCfg = performMigrationToDataStoreIfNeeded
                ? new JahiaRepositoryConfig(RepositoryConfig.create(configFile.toString(), repoHome.toString()))
                : null;

        if (targetConfigFile != null
                || performMigrationToDataStoreIfNeeded && sourceCfg.getDataStore() == null) {

            long timer = System.currentTimeMillis();
            if (targetConfigFile != null) {
                logger.info("Will perform repository migration using target configuration file {}",
                        targetConfigFile);
            } else {
                logger.info("Will perform repository migration from BLOB store to DataStore");
            }

            boolean clusterActivated = Boolean.getBoolean("cluster.activated");
            if (clusterActivated) {
                // deactivate the cluster for the time of migration
                System.setProperty("cluster.activated", "false");
                sourceCfg = null; // reload the configuration
            }

            keepBackup = Boolean.getBoolean("jahia.jackrabbit.backupRepositoryByMigration");

            try {
                dbInitSettings();

                dbExecute("jackrabbit-migration-1-create-temp-tables.sql", "Temporary DB tables created");

                File tempRepoHome = createTempRepoHome();
                File tempConfigFile = createTempConfigFile();

                if (sourceCfg == null) {
                    sourceCfg = new JahiaRepositoryConfig(
                            RepositoryConfig.create(configFile.toString(), repoHome.toString()));
                }

                JahiaRepositoryConfig targetCfg = new JahiaRepositoryConfig(
                        RepositoryConfig.create(tempConfigFile.toString(), tempRepoHome.toString()));

                performMigration(sourceCfg, targetCfg);

                JCRContentUtils.deleteJackrabbitIndexes(repoHome);
                JCRContentUtils.deleteJackrabbitIndexes(tempRepoHome);

                // swap configuration with the target one
                File target = new File(tempConfigFile.getParentFile(), "repository-migration-target.xml");
                removeCopyPrefix(tempConfigFile, target);
                logger.info("Created target repository configuration after migration at {}", target);

                if (keepBackup) {
                    File configBackup = new File(configFile.getParentFile(), "repository-original.xml");
                    FileUtils.copyFile(configFile, configBackup);
                    logger.info("Backup original configuration to {}", configBackup);
                }

                FileUtils.copyFile(target, configFile);
                logger.info("Replaced original repository.xml with the target one");

                if (!keepBackup) {
                    FileUtils.deleteQuietly(tempConfigFile);
                    FileUtils.deleteQuietly(target);
                }

                File workspaceConfig = new File(tempRepoHome, "workspaces/default/workspace.xml");
                removeCopyPrefix(workspaceConfig, workspaceConfig);
                workspaceConfig = new File(tempRepoHome, "workspaces/live/workspace.xml");
                removeCopyPrefix(workspaceConfig, workspaceConfig);

                dbExecute("jackrabbit-migration-2-drop-original-tables.sql", "Original DB tables dropped");

                dbExecute("jackrabbit-migration-3-rename-temp-tables.sql", "Temporary DB tables renamed");

                swapRepositoryHome(tempRepoHome);

                logger.info("Complete repository migration took {} ms", (System.currentTimeMillis() - timer));
            } catch (Exception e) {
                logger.warn(
                        "Unable to perform migration from BLOB store to DataStore. Cause: " + e.getMessage(),
                        e);
            } finally {
                if (clusterActivated) {
                    // activate the cluster back
                    System.setProperty("cluster.activated", "true");
                }
            }
        }
    } catch (Exception e) {
        logger.warn("Unable to check the source repository configuration." + " Skip DataStore migration check.",
                e);
    }
}

From source file:com.bugvm.maven.surefire.BugVMSurefireProvider.java

private Config.Builder createConfig() throws IOException {
    Config.Builder configBuilder = new Config.Builder();

    final Logger logger = new Logger() {
        public void debug(String format, Object... args) {
            if (Boolean.getBoolean(PROP_LOG_DEBUG)) {
                providerParameters.getConsoleLogger().info("[DEBUG] " + String.format(format, args) + "\n");
            }//from   w  w w  .j a va2  s.com
        }

        public void info(String format, Object... args) {
            providerParameters.getConsoleLogger().info("[INFO] " + String.format(format, args) + "\n");
        }

        public void warn(String format, Object... args) {
            providerParameters.getConsoleLogger().info("[WARNING] " + String.format(format, args) + "\n");
        }

        public void error(String format, Object... args) {
            providerParameters.getConsoleLogger().info("[ERROR] " + String.format(format, args) + "\n");
        }
    };
    configBuilder.logger(logger);

    BugVMResolver roboVMResolver = new BugVMResolver();
    roboVMResolver.setLogger(new com.bugvm.maven.resolver.Logger() {
        public void info(String logLine) {
            logger.info(logLine);
        }

        public void debug(String logLine) {
            logger.debug(logLine);
        }
    });

    Home home = null;
    try {
        home = Home.find();
    } catch (Throwable t) {
    }
    if (home == null || !home.isDev()) {
        home = new Home(roboVMResolver.resolveAndUnpackBugVMDistArtifact(Version.getVersion()));
    }
    configBuilder.home(home);
    if (home.isDev()) {
        configBuilder.useDebugLibs(Boolean.getBoolean("bugvm.useDebugLibs"));
        configBuilder.dumpIntermediates(true);
    }

    File basedir = new File(System.getProperty("basedir"));
    if (System.getProperties().containsKey(PROP_PROPERTIES_FILE)) {
        File propertiesFile = new File(System.getProperty(PROP_PROPERTIES_FILE));
        if (!propertiesFile.exists()) {
            throw new FileNotFoundException("Failed to find specified " + PROP_PROPERTIES_FILE + ": "
                    + propertiesFile.getAbsolutePath());
        }
        logger.debug("Loading BugVM config properties from " + propertiesFile.getAbsolutePath());
        configBuilder.addProperties(propertiesFile);
    } else {
        configBuilder.readProjectProperties(basedir, true);
    }

    if (System.getProperties().containsKey(PROP_CONFIG_FILE)) {
        File configFile = new File(System.getProperty(PROP_CONFIG_FILE));
        if (!configFile.exists()) {
            throw new FileNotFoundException(
                    "Failed to find specified " + PROP_CONFIG_FILE + ": " + configFile.getAbsolutePath());
        }
        logger.debug("Loading BugVM config from " + configFile.getAbsolutePath());
        configBuilder.read(configFile);
    } else {
        configBuilder.readProjectConfig(basedir, true);
    }

    if (System.getProperty(PROP_OS) != null) {
        configBuilder.os(OS.valueOf(System.getProperty(PROP_OS)));
    }
    if (System.getProperty(PROP_ARCH) != null) {
        configBuilder.arch(Arch.valueOf(System.getProperty(PROP_ARCH)));
    }
    if (Boolean.getBoolean(PROP_IOS_SKIP_SIGNING)) {
        configBuilder.iosSkipSigning(true);
    } else {
        if (System.getProperty(PROP_IOS_SIGNING_IDENTITY) != null) {
            String iosSignIdentity = System.getProperty(PROP_IOS_SIGNING_IDENTITY);
            logger.debug("Using explicit iOS Signing identity: " + iosSignIdentity);
            configBuilder.iosSignIdentity(SigningIdentity.find(SigningIdentity.list(), iosSignIdentity));
        }
        if (System.getProperty(PROP_IOS_PROVISIONING_PROFILE) != null) {
            String iosProvisioningProfile = System.getProperty(PROP_IOS_PROVISIONING_PROFILE);
            logger.debug("Using explicit iOS provisioning profile: " + iosProvisioningProfile);
            configBuilder.iosProvisioningProfile(
                    ProvisioningProfile.find(ProvisioningProfile.list(), iosProvisioningProfile));
        }

        // if (System.getProperty(PROP_KEYCHAIN_PASSWORD) != null) {
        //     configBuilder.keychainPassword(System.getProperty(PROP_KEYCHAIN_PASSWORD));
        // } else if (System.getProperty(PROP_KEYCHAIN_PASSWORD_FILE) != null) {
        //     configBuilder.keychainPasswordFile(new File(System.getProperty(PROP_KEYCHAIN_PASSWORD_FILE)));
        // }
    }

    if (System.getProperty(PROP_CACHE_DIR) != null) {
        File cacheDir = new File(System.getProperty(PROP_CACHE_DIR));
        logger.debug("Using explicit cache dir: " + cacheDir);
        configBuilder.cacheDir(cacheDir);
    }

    // Ignore any classpath entries in the loaded bugvm.xml file.
    configBuilder.clearClasspathEntries();

    configBuilder.addClasspathEntry(
            roboVMResolver.resolveArtifact("com.bugvm:bugvm-junit-server:" + Version.getVersion()).asFile());
    if (isIOS()) {
        configBuilder.addClasspathEntry(
                roboVMResolver.resolveArtifact("com.bugvm:bugvm-rt:" + Version.getVersion()).asFile());
        configBuilder.addClasspathEntry(
                roboVMResolver.resolveArtifact("com.bugvm:bugvm-objc:" + Version.getVersion()).asFile());
        configBuilder.addClasspathEntry(
                roboVMResolver.resolveArtifact("com.bugvm:bugvm-cocoatouch:" + Version.getVersion()).asFile());
    }
    for (String p : System.getProperty("java.class.path").split(File.pathSeparator)) {
        configBuilder.addClasspathEntry(new File(p));
    }

    if (testClassLoader.getClass().getName().equals("org.apache.maven.surefire.booter.IsolatedClassLoader")) {
        // Not fork mode. We need to get to the URLs of the IsolatedClassLoader.
        // Only way is to use reflection.
        try {
            Field f = testClassLoader.getClass().getDeclaredField("urls");
            f.setAccessible(true);
            @SuppressWarnings("unchecked")
            Collection<URL> urls = (Collection<URL>) f.get(testClassLoader);
            for (URL url : urls) {
                File file = new File(url.getFile());
                if (file.isDirectory() || file.getName().toLowerCase().matches(".*\\.(jar|zip)$")) {
                    configBuilder.addClasspathEntry(file);
                }
            }
        } catch (Throwable t) {
            throw new RuntimeException("Failed to get classpath URLs from IsolatedClassLoader using reflection",
                    t);
        }
    } else {
        Properties props = providerParameters.getProviderProperties();
        for (int i = 0; true; i++) {
            String path = props.getProperty("classPathUrl." + i);
            if (path == null) {
                break;
            }
            configBuilder.addClasspathEntry(new File(path));
        }
    }

    for (Class<?> c : testsToRun.getLocatedClasses()) {
        configBuilder.addForceLinkClass(c.getName());
    }
    configBuilder.skipInstall(true);

    return configBuilder;
}