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.wso2.am.integration.test.utils.generic.APIMTestCaseUtils.java

/**
 * create API bean object from response//from   w  ww.  j ava 2  s . c  o  m
 *
 * @param httpResponse - HTTP response
 * @return - APIBean instance
 */
public static APIBean getAPIBeanFromHttpResponse(HttpResponse httpResponse)
        throws APIManagerIntegrationTestException {
    JSONObject jsonObject;
    String APIName;
    String APIProvider;
    String APIVersion;
    APIBean apiBean;
    try {
        jsonObject = new JSONObject(httpResponse.getData());

        APIName = ((JSONObject) jsonObject.get("api")).getString("name");
        APIVersion = ((JSONObject) jsonObject.get("api")).getString("version");
        APIProvider = ((JSONObject) jsonObject.get("api")).getString("provider");

        APIIdentifier identifier = new APIIdentifier(APIProvider, APIName, APIVersion);

        apiBean = new APIBean(identifier);
        apiBean.setContext(((JSONObject) jsonObject.get("api")).getString("context"));
        apiBean.setDescription(((JSONObject) jsonObject.get("api")).getString("description"));
        apiBean.setWsdlUrl(((JSONObject) jsonObject.get("api")).getString("wsdl"));
        apiBean.setTags(((JSONObject) jsonObject.get("api")).getString("tags"));
        apiBean.setAvailableTiers(((JSONObject) jsonObject.get("api")).getString("availableTiers"));

        apiBean.setThumbnailUrl(((JSONObject) jsonObject.get("api")).getString("thumb"));
        apiBean.setSandboxUrl(((JSONObject) jsonObject.get("api")).getString("sandbox"));
        apiBean.setBusinessOwner(((JSONObject) jsonObject.get("api")).getString("bizOwner"));
        apiBean.setBusinessOwnerEmail(((JSONObject) jsonObject.get("api")).getString("bizOwnerMail"));
        apiBean.setTechnicalOwner(((JSONObject) jsonObject.get("api")).getString("techOwner"));
        apiBean.setTechnicalOwnerEmail(((JSONObject) jsonObject.get("api")).getString("techOwnerMail"));

        apiBean.setWadlUrl(((JSONObject) jsonObject.get("api")).getString("wadl"));
        apiBean.setVisibility(((JSONObject) jsonObject.get("api")).getString("visibility"));
        apiBean.setVisibleRoles(((JSONObject) jsonObject.get("api")).getString("roles"));
        apiBean.setEndpointUTUsername(((JSONObject) jsonObject.get("api")).getString("epUsername"));
        apiBean.setEndpointUTPassword(((JSONObject) jsonObject.get("api")).getString("epPassword"));

        apiBean.setEndpointSecured(
                (Boolean.getBoolean(((JSONObject) jsonObject.get("api")).getString("endpointTypeSecured"))));
        apiBean.setTransports(((JSONObject) jsonObject.get("api")).getString("transport_http"));
        apiBean.setTransports(((JSONObject) jsonObject.get("api")).getString("transport_https"));
        apiBean.setInSequence(((JSONObject) jsonObject.get("api")).getString("inSequence"));
        apiBean.setOutSequence(((JSONObject) jsonObject.get("api")).getString("outSequence"));
        apiBean.setAvailableTiers(((JSONObject) jsonObject.get("api")).getString("availableTiersDisplayNames"));

        //-----------Here are some of unused properties, if we need to use them add params to APIBean class
        //((JSONObject) jsonObject.get("api")).getString("name");
        //((JSONObject) jsonObject.get("api")).getString("endpoint");
        //((JSONObject) jsonObject.get("api")).getString("subscriptionAvailability");
        //((JSONObject) jsonObject.get("api")).getString("subscriptionTenants");
        //((JSONObject) jsonObject.get("api")).getString("endpointConfig");
        //((JSONObject) jsonObject.get("api")).getString("responseCache");
        //(((JSONObject) jsonObject.get("api")).getString("cacheTimeout");
        //((JSONObject) jsonObject.get("api")).getString("endpointConfig");
        //((JSONObject) jsonObject.get("api")).getString("version");
        //((JSONObject) jsonObject.get("api")).getString("apiStores");
        // ((JSONObject) jsonObject.get("api")).getString("provider");
        //)((JSONObject) jsonObject.get("api")).getString("tierDescs");
        //((JSONObject) jsonObject.get("api")).getString("subs");
        //((JSONObject) jsonObject.get("api")).getString("context");
        // apiBean.setLastUpdated(Date.parse((JSONObject); jsonObject.get("api")).getString("lastUpdated")));
        // apiBean.setUriTemplates((JSONObject) jsonObject.get("api")).getString("templates"));
    } catch (JSONException e) {
        throw new APIManagerIntegrationTestException("Generating APIBen instance fails ", e);
    }
    return apiBean;
}

From source file:org.rzo.yajsw.os.ms.win.w32.WindowsXPProcess.java

private String getSystemError(int code) {
    Kernel32 lib = Kernel32.INSTANCE;
    PointerByReference pref = new PointerByReference();
    lib.FormatMessage(Kernel32.FORMAT_MESSAGE_ALLOCATE_BUFFER | Kernel32.FORMAT_MESSAGE_FROM_SYSTEM
            | Kernel32.FORMAT_MESSAGE_IGNORE_INSERTS, null, code, 0, pref, 0, null);
    String s = pref.getValue().getString(0, !Boolean.getBoolean("w32.ascii"));
    s = s.replace(".\r", ".").replace(".\n", ".");
    lib.LocalFree(pref.getValue());/* w w w .  j a va2s  .c  om*/
    return s;
}

From source file:org.hyperic.hq.measurement.server.session.AvailabilityManagerImpl.java

private void sendDataToEventHandlers(List<DataPoint> data) {
    final StopWatch watch = new StopWatch();
    final boolean debug = log.isDebugEnabled();
    int maxCapacity = data.size();
    ArrayList<MeasurementEvent> events = new ArrayList<MeasurementEvent>(maxCapacity);
    Map<Integer, MeasurementEvent> downEvents = new HashMap<Integer, MeasurementEvent>(maxCapacity);
    List<MeasurementZevent> zevents = new ArrayList<MeasurementZevent>(maxCapacity);
    boolean allEventsInteresting = Boolean.getBoolean(ALL_EVENTS_INTERESTING_PROP);
    if (debug)/*from ww  w.  jav  a 2 s .c o m*/
        watch.markTimeBegin("isTriggerInterested");
    for (DataPoint dp : data) {
        Integer metricId = dp.getMeasurementId();
        MetricValue val = dp.getMetricValue();
        MeasurementEvent event = new MeasurementEvent(metricId, val);
        if (registeredTriggers.isTriggerInterested(event) || allEventsInteresting) {
            measurementManager.buildMeasurementEvent(event);
            if (event.getValue().getValue() == AVAIL_DOWN) {
                AppdefEntityID eventResourceAEID = event.getResource();
                Resource r = (null == eventResourceAEID ? null
                        : resourceManager.findResource(eventResourceAEID));
                if (r != null && !r.isInAsyncDeleteState()) {
                    downEvents.put(r.getId(), event);
                }
            } else {
                events.add(event);
            }
        }
        zevents.add(new MeasurementZevent(metricId.intValue(), val));
    }
    if (debug)
        watch.markTimeEnd("isTriggerInterested");
    if (!downEvents.isEmpty()) {
        if (debug)
            watch.markTimeBegin("suppressMeasurementEvents");
        // Determine whether the measurement events can
        // be suppressed as part of hierarchical alerting
        PermissionManagerFactory.getInstance().getHierarchicalAlertingManager()
                .suppressMeasurementEvents(downEvents, true);
        if (debug)
            watch.markTimeEnd("suppressMeasurementEvents");
        if (!downEvents.isEmpty()) {
            events.addAll(downEvents.values());
        }
    }

    if (!events.isEmpty()) {
        messenger.publishMessage(EventConstants.EVENTS_TOPIC, events);
    }

    if (!zevents.isEmpty()) {
        ZeventManager.getInstance().enqueueEventsAfterCommit(zevents);
    }
    if (debug) {
        log.debug("AvailabilityInserter sendDataToEventHandlers: " + watch + ", points {total=" + maxCapacity
                + ", downEvents=" + downEvents.size() + ", eventsToPublish=" + events.size()
                + ", zeventsToEnqueue=" + zevents.size() + "}");
    }
}

From source file:org.hyperic.hq.measurement.server.session.AvailabilityManagerImpl.java

/**
 * This method should only be called by the AvailabilityCheckService and is
 * used to filter availability data points based on hierarchical alerting
 * rules./*from  ww w .ja v a2s .  com*/
 * 
 * 
 */
public void sendDataToEventHandlers(Map<Integer, DataPoint> data) {
    int maxCapacity = data.size();
    Map<Integer, MeasurementEvent> events = new HashMap<Integer, MeasurementEvent>(maxCapacity);
    List<MeasurementZevent> zevents = new ArrayList<MeasurementZevent>(maxCapacity);
    boolean allEventsInteresting = Boolean.getBoolean(ALL_EVENTS_INTERESTING_PROP);
    for (Integer resourceIdKey : data.keySet()) {
        DataPoint dp = data.get(resourceIdKey);
        Integer metricId = dp.getMeasurementId();
        MetricValue val = dp.getMetricValue();
        MeasurementEvent event = new MeasurementEvent(metricId, val);
        if (registeredTriggers.isTriggerInterested(event) || allEventsInteresting) {
            measurementManager.buildMeasurementEvent(event);
            events.put(resourceIdKey, event);
        }
        zevents.add(new MeasurementZevent(metricId.intValue(), val));
    }
    if (!events.isEmpty()) {
        // Determine whether the measurement events can
        // be suppressed as part of hierarchical alerting
        PermissionManagerFactory.getInstance().getHierarchicalAlertingManager()
                .suppressMeasurementEvents(events, false);
        messagePublisher.publishMessage(EventConstants.EVENTS_TOPIC,
                new ArrayList<MeasurementEvent>(events.values()));
    }
    if (!zevents.isEmpty()) {
        ZeventManager.getInstance().enqueueEventsAfterCommit(zevents);
    }
}

From source file:org.apache.geode.internal.cache.GemFireCacheImpl.java

public void shutDownAll() {
    if (LocalRegion.ISSUE_CALLBACKS_TO_CACHE_OBSERVER) {
        try {/*  w w  w. j a v  a 2  s.  c  om*/
            CacheObserverHolder.getInstance().beforeShutdownAll();
        } finally {
            LocalRegion.ISSUE_CALLBACKS_TO_CACHE_OBSERVER = false;
        }
    }
    if (!this.isShutDownAll.compareAndSet(false, true)) {
        // it's already doing shutdown by another thread
        try {
            this.shutDownAllFinished.await();
        } catch (InterruptedException e) {
            logger.debug("Shutdown all interrupted while waiting for another thread to do the shutDownAll");
            Thread.currentThread().interrupt();
        }
        return;
    }
    synchronized (GemFireCacheImpl.class) {
        try {
            boolean testIGE = Boolean.getBoolean("TestInternalGemFireError");

            if (testIGE) {
                InternalGemFireError assErr = new InternalGemFireError(
                        LocalizedStrings.GemFireCache_UNEXPECTED_EXCEPTION.toLocalizedString());
                throw assErr;
            }

            // bug 44031 requires multithread shutdownall should be grouped
            // by root region. However, shutDownAllDuringRecovery.conf test revealed that
            // we have to close colocated child regions first.
            // Now check all the PR, if anyone has colocate-with attribute, sort all the
            // PRs by colocation relationship and close them sequentially, otherwise still
            // group them by root region.
            TreeMap<String, Map<String, PartitionedRegion>> prTrees = getPRTrees();
            if (prTrees.size() > 1 && shutdownAllPoolSize != 1) {
                ExecutorService es = getShutdownAllExecutorService(prTrees.size());
                for (final Map<String, PartitionedRegion> prSubMap : prTrees.values()) {
                    es.execute(new Runnable() {
                        public void run() {
                            ConnectionTable.threadWantsSharedResources();
                            shutdownSubTreeGracefully(prSubMap);
                        }
                    });
                } // for each root
                es.shutdown();
                try {
                    es.awaitTermination(Integer.MAX_VALUE, TimeUnit.SECONDS);
                } catch (InterruptedException e) {
                    logger.debug("Shutdown all interrupted while waiting for PRs to be shutdown gracefully.");
                }

            } else {
                for (final Map<String, PartitionedRegion> prSubMap : prTrees.values()) {
                    shutdownSubTreeGracefully(prSubMap);
                }
            }

            close("Shut down all members", null, false, true);
        } finally {
            this.shutDownAllFinished.countDown();
        }
    }
}

From source file:org.apache.camel.impl.DefaultCamelContext.java

protected ManagementStrategy createManagementStrategy() {
    ManagementStrategy answer;//  ww  w.  j ava 2s.com

    if (disableJMX || Boolean.getBoolean(JmxSystemPropertyKeys.DISABLED)) {
        log.info("JMX is disabled. Using DefaultManagementStrategy.");
        answer = new DefaultManagementStrategy();
    } else {
        try {
            log.info("JMX enabled. Using ManagedManagementStrategy.");
            answer = new ManagedManagementStrategy(new DefaultManagementAgent(this));
            // must start it to ensure JMX works and can load needed Spring JARs
            startServices(answer);
            // prefer to have it at first strategy
            lifecycleStrategies.add(0, new DefaultManagementLifecycleStrategy(this));
        } catch (NoClassDefFoundError e) {
            answer = null;

            // if we can't instantiate the JMX enabled strategy then fallback to default
            // could be because of missing .jars on the classpath
            log.warn("Cannot find needed classes for JMX lifecycle strategy."
                    + " Needed class is in spring-context.jar using Spring 2.5 or newer"
                    + " (spring-jmx.jar using Spring 2.0.x)." + " NoClassDefFoundError: " + e.getMessage());
        } catch (Exception e) {
            answer = null;
            log.warn(
                    "Cannot create JMX lifecycle strategy. Fallback to using DefaultManagementStrategy (non JMX).",
                    e);
        }
    }

    if (answer == null) {
        log.warn("Cannot use JMX. Fallback to using DefaultManagementStrategy (non JMX).");
        answer = new DefaultManagementStrategy();
    }

    // inject CamelContext
    if (answer instanceof CamelContextAware) {
        CamelContextAware aware = (CamelContextAware) answer;
        aware.setCamelContext(this);
    }

    return answer;
}

From source file:hudson.model.Hudson.java

private static void computeVersion(ServletContext context) {
    // set the version
    Properties props = new Properties();
    try {/*  w w w  .ja  va2 s . c  om*/
        InputStream is = Hudson.class.getResourceAsStream("hudson-version.properties");
        if (is != null)
            props.load(is);
    } catch (IOException e) {
        e.printStackTrace(); // if the version properties is missing, that's OK.
    }
    String ver = props.getProperty("version");
    if (ver == null)
        ver = "?";
    VERSION = ver;
    context.setAttribute("version", ver);
    VERSION_HASH = Util.getDigestOf(ver).substring(0, 8);

    if (ver.equals("?") || Boolean.getBoolean("hudson.script.noCache"))
        RESOURCE_PATH = "";
    else
        RESOURCE_PATH = "/static/" + VERSION_HASH;

    VIEW_RESOURCE_PATH = "/resources/" + VERSION_HASH;
}

From source file:org.apache.geode.distributed.internal.DistributionConfigImpl.java

/**
 * For dunit tests we do not allow use of the default multicast address/port. Please use
 * AvailablePort.getRandomAvailablePort(AvailablePort.JGROUPS) to obtain a free port for your
 * test.//from w  ww .j a v a 2s . com
 */
public void checkForDisallowedDefaults() {
    if (Boolean.getBoolean(DistributionConfig.GEMFIRE_PREFIX + "disallowMcastDefaults")) {
        if (getMcastPort() != 0) { // it is not disabled
            if (getMcastAddress().equals(DistributionConfig.DEFAULT_MCAST_ADDRESS)
                    && getMcastPort() == DistributionConfig.DEFAULT_MCAST_PORT) {
                throw new IllegalStateException(DistributionConfig.GEMFIRE_PREFIX
                        + "disallowMcastDefaults set and default address and port are being used");
            }
        }
    }
}

From source file:jenkins.model.Jenkins.java

private static void computeVersion(ServletContext context) {
    // set the version
    Properties props = new Properties();
    InputStream is = null;/*  www.  j a v a2  s .c om*/
    try {
        is = Jenkins.class.getResourceAsStream("jenkins-version.properties");
        if (is != null)
            props.load(is);
    } catch (IOException e) {
        e.printStackTrace(); // if the version properties is missing, that's OK.
    } finally {
        IOUtils.closeQuietly(is);
    }
    String ver = props.getProperty("version");
    if (ver == null)
        ver = "?";
    VERSION = ver;
    context.setAttribute("version", ver);

    VERSION_HASH = Util.getDigestOf(ver).substring(0, 8);
    SESSION_HASH = Util.getDigestOf(ver + System.currentTimeMillis()).substring(0, 8);

    if (ver.equals("?") || Boolean.getBoolean("hudson.script.noCache"))
        RESOURCE_PATH = "";
    else
        RESOURCE_PATH = "/static/" + SESSION_HASH;

    VIEW_RESOURCE_PATH = "/resources/" + SESSION_HASH;
}

From source file:org.openecomp.sdc.be.components.impl.ResourceBusinessLogic.java

private Either<Map<String, List<UploadPropInfo>>, ResponseFormat> createPropModuleFromYaml(
        Map<String, Object> nodeTemplateJsonMap) {
    Map<String, List<UploadPropInfo>> moduleProp = new HashMap<String, List<UploadPropInfo>>();
    Either<Map<String, List<UploadPropInfo>>, ResponseFormat> response = Either.left(moduleProp);
    Either<Map<String, Object>, ResultStatusEnum> toscaProperties = ImportUtils
            .findFirstToscaMapElement(nodeTemplateJsonMap, ToscaTagNamesEnum.PROPERTIES);
    if (toscaProperties.isLeft()) {
        Map<String, Object> jsonProperties = toscaProperties.left().value();
        for (Entry<String, Object> jsonPropObj : jsonProperties.entrySet()) {
            // Property
            String propName = jsonPropObj.getKey();
            Object propValue = jsonPropObj.getValue();

            if (valueContainsPattern(STR_REPLACE_PATTERN, propValue)) {
                log.debug("Ignore property value {}.", propName);
                continue;
            }//from   www.j  a v  a  2 s . com

            if (valueContainsPattern(TOKEN_PATTERN, propValue)) {
                log.debug("Ignore property value {}.", propName);
                continue;
            }
            if (valueContainsPattern(GET_PROPERTY_PATTERN, propValue)) {
                log.debug("Ignore property value {}.", propName);
                continue;
            }

            if (valueContainsPattern(CONCAT_PATTERN, propValue)) {
                log.debug("Ignore property value {}.", propName);
                continue;
            }

            UploadPropInfo propertyDef = new UploadPropInfo();
            propertyDef.setValue(propValue);
            if (propValue instanceof Map) {
                if (((Map<String, Object>) propValue).containsKey(ToscaTagNamesEnum.TYPE.getElementName())) {
                    propertyDef.setType(((Map<String, Object>) propValue)
                            .get(ToscaTagNamesEnum.TYPE.getElementName()).toString());
                }

                if (((Map<String, Object>) propValue).containsKey(ToscaTagNamesEnum.GET_INPUT.getElementName())
                        || ImportUtils.getPropertyJsonStringValue(propValue, ToscaPropertyType.MAP.getType())
                                .contains(ToscaTagNamesEnum.GET_INPUT.getElementName())) {
                    createGetInputModuleFromMap(propName, (Map<String, Object>) propValue, propertyDef);
                }

                if (((Map<String, Object>) propValue)
                        .containsKey(ToscaTagNamesEnum.DESCRIPTION.getElementName())) {
                    propertyDef.setDescription(((Map<String, Object>) propValue)
                            .get(ToscaTagNamesEnum.DESCRIPTION.getElementName()).toString());
                }
                if (((Map<String, Object>) propValue)
                        .containsKey(ToscaTagNamesEnum.DEFAULT_VALUE.getElementName())) {
                    propertyDef.setValue(((Map<String, Object>) propValue)
                            .get(ToscaTagNamesEnum.DEFAULT_VALUE.getElementName()));
                }
                if (((Map<String, Object>) propValue)
                        .containsKey(ToscaTagNamesEnum.IS_PASSWORD.getElementName())) {
                    propertyDef.setPassword(Boolean.getBoolean(((Map<String, Object>) propValue)
                            .get(ToscaTagNamesEnum.IS_PASSWORD.getElementName()).toString()));
                } else {
                    propertyDef.setValue(propValue);
                }
            } else if (propValue instanceof List) {
                List<Object> propValueList = (List<Object>) propValue;

                createInputPropList(propertyDef, propValueList);
                propertyDef.setValue(propValue);
            }

            propertyDef.setName(propName);
            if (moduleProp.containsKey(propName)) {
                moduleProp.get(propName).add(propertyDef);
            } else {
                List<UploadPropInfo> list = new ArrayList<UploadPropInfo>();
                list.add(propertyDef);
                moduleProp.put(propName, list);
            }
        }
    }
    return response;
}