Example usage for java.lang Boolean parseBoolean

List of usage examples for java.lang Boolean parseBoolean

Introduction

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

Prototype

public static boolean parseBoolean(String s) 

Source Link

Document

Parses the string argument as a boolean.

Usage

From source file:com.amediamanager.service.TagsServiceImpl.java

private Boolean cachingEnabled() {
    return Boolean.parseBoolean(config.getProperty(ConfigurationSettings.ConfigProps.CACHE_ENABLED));
}

From source file:net.sourceforge.ajaxtags.tags.AjaxToggleTag.java

public void setOnOff(final String onOff) {
    this.onOff = Boolean.parseBoolean(onOff);
}

From source file:com.redhat.coolstore.api_gateway.ProductGateway.java

@Override
public void configure() throws Exception {
    try {//from w ww  .j  av  a 2 s. c om
        getContext().setTracing(Boolean.parseBoolean(env.getProperty("ENABLE_TRACER", "false")));
    } catch (Exception e) {
        LOG.error("Failed to parse the ENABLE_TRACER value: {}", env.getProperty("ENABLE_TRACER", "false"));
    }

    JacksonDataFormat productFormatter = new ListJacksonDataFormat();
    productFormatter.setUnmarshalType(Product.class);

    rest("/products/").description("Product Catalog Service").produces(MediaType.APPLICATION_JSON_VALUE)
            // Handle CORS Pre-flight requests
            .options("/").route().id("productsOptions").end().endRest()

            .get("/").description("Get product catalog").outType(Product.class).route().id("productRoute")
            .hystrix().id("Product Service").hystrixConfiguration()
            .executionTimeoutInMilliseconds(hystrixExecutionTimeout).groupKey(hystrixGroupKey)
            .circuitBreakerEnabled(hystrixCircuitBreakerEnabled).end().setBody(simple("null"))
            .removeHeaders("CamelHttp*")
            .recipientList(simple("http4://{{env:CATALOG_ENDPOINT:catalog:8080}}/api/products")).end()
            .onFallback()
            //.setHeader(Exchange.HTTP_RESPONSE_CODE, constant(Response.Status.SERVICE_UNAVAILABLE.getStatusCode()))
            .to("direct:productFallback").stop().end().choice().when(body().isNull())
            .to("direct:productFallback").end().unmarshal(productFormatter).split(body()).parallelProcessing()
            .enrich("direct:inventory", new InventoryEnricher()).enrich("direct:rating", new RatingEnricher())
            .end().endRest();

    from("direct:productFallback").id("ProductFallbackRoute").transform().constant(
            Collections.singletonList(new Product("0", "Unavailable Product", "Unavailable Product", 0, null)));
    //.marshal().json(JsonLibrary.Jackson, List.class);

    from("direct:inventory").id("inventoryRoute").setHeader("itemId", simple("${body.itemId}")).hystrix()
            .id("Inventory Service").hystrixConfiguration()
            .executionTimeoutInMilliseconds(hystrixExecutionTimeout).groupKey(hystrixGroupKey)
            .circuitBreakerEnabled(hystrixCircuitBreakerEnabled).end().setBody(simple("null"))
            .removeHeaders("CamelHttp*")
            .recipientList(simple(
                    "http4://{{env:INVENTORY_ENDPOINT:inventory:8080}}/api/availability/${header.itemId}"))
            .end().onFallback()
            //.setHeader(Exchange.HTTP_RESPONSE_CODE, constant(Response.Status.SERVICE_UNAVAILABLE.getStatusCode()))
            .to("direct:inventoryFallback").end().choice().when(body().isNull()).to("direct:inventoryFallback")
            .end().setHeader("CamelJacksonUnmarshalType", simple(Inventory.class.getName())).unmarshal()
            .json(JsonLibrary.Jackson, Inventory.class);

    from("direct:inventoryFallback").id("inventoryFallbackRoute").transform()
            .constant(new Inventory("0", 0, "Local Store", "http://developers.redhat.com")).marshal()
            .json(JsonLibrary.Jackson, Inventory.class);

    from("direct:rating").id("ratingRoute").setHeader("itemId", simple("${body.itemId}"))
            .setBody(simple("null")).removeHeaders("CamelHttp*")
            .setHeader(Exchange.HTTP_METHOD, HttpMethods.GET)
            .setHeader(Exchange.HTTP_URI,
                    simple("http://{{env:RATING_ENDPOINT:rating:8080}}/api/rating/${header.itemId}"))
            .hystrix().id("Rating Service").hystrixConfiguration().executionTimeoutInMilliseconds(5000)
            .circuitBreakerSleepWindowInMilliseconds(10000).end().to("http4://DUMMY2").onFallback()
            .to("direct:ratingFallback").end().choice().when(body().isNull()).to("direct:ratingFallback").end()
            .setHeader("CamelJacksonUnmarshalType", simple(Rating.class.getName())).unmarshal()
            .json(JsonLibrary.Jackson, Rating.class);

    from("direct:ratingFallback").id("ratingFallbackRoute").transform().constant(new Rating("0", 2.0, 1))
            .marshal().json(JsonLibrary.Jackson, Rating.class);

}

From source file:com.junly.common.util.ReflectUtils.java

/**
 * <p class="detail">/*from   w w  w  . jav a 2s.  c om*/
 * 
 * </p>
 * @author wan.Dong
 * @date 20161112 
 * @param obj 
 * @param name    ??
 * @param value  (?)??false
 * @return
 */
public static boolean setProperty(Object obj, String name, Object value) {
    if (obj != null) {
        Class<?> clazz = obj.getClass();
        while (clazz != null) {
            Field field = null;
            try {
                field = clazz.getDeclaredField(name);
            } catch (Exception e) {
                clazz = clazz.getSuperclass();
                continue;
            }
            try {
                Class<?> type = field.getType();
                if (type.isPrimitive() == true && value != null) {
                    if (value instanceof String) {
                        if (type.equals(int.class) == true) {
                            value = Integer.parseInt((String) value);
                        } else if (type.equals(double.class) == true) {
                            value = Double.parseDouble((String) value);
                        } else if (type.equals(boolean.class) == true) {
                            value = Boolean.parseBoolean((String) value);
                        } else if (type.equals(long.class) == true) {
                            value = Long.parseLong((String) value);
                        } else if (type.equals(byte.class) == true) {
                            value = Byte.parseByte((String) value);
                        } else if (type.equals(char.class) == true) {
                            value = Character.valueOf(((String) value).charAt(0));
                        } else if (type.equals(float.class) == true) {
                            value = Float.parseFloat((String) value);
                        } else if (type.equals(short.class) == true) {
                            value = Short.parseShort((String) value);
                        }
                    }
                    field.setAccessible(true);
                    field.set(obj, value);
                    field.setAccessible(false);
                }
                if (value == null || type.equals(value.getClass()) == true) {
                    field.setAccessible(true);
                    field.set(obj, value);
                    field.setAccessible(false);
                }
                return true;
            } catch (Exception e) {
                return false;
            }
        }
    }
    return false;
}

From source file:com.seer.datacruncher.streams.ZipStreamTest.java

@Test
public void testZipStream() {
    String fileName = properties.getProperty("zip_test_stream_file_name");
    InputStream in = this.getClass().getClassLoader().getResourceAsStream(stream_file_path + fileName);
    byte[] arr = null;
    try {//from  w  w  w.j a v  a 2  s .c o m
        arr = IOUtils.toByteArray(in);
    } catch (IOException e) {
        assertTrue("IOException while Zip test file reading", false);
    }

    ZipInputStream inStream = null;
    try {
        inStream = new ZipInputStream(new ByteArrayInputStream(arr));
        ZipEntry entry;
        while (!(isStreamClose(inStream)) && (entry = inStream.getNextEntry()) != null) {
            if (!entry.isDirectory()) {
                DatastreamsInput datastreamsInput = new DatastreamsInput();
                datastreamsInput.setUploadedFileName(entry.getName());
                byte[] byteInput = IOUtils.toByteArray(inStream);
                String res = datastreamsInput.datastreamsInput(null, (Long) schemaEntity.getIdSchema(),
                        byteInput, true);
                assertTrue("Zip file validation failed", Boolean.parseBoolean(res));
            }
            inStream.closeEntry();
        }
    } catch (IOException ex) {
        assertTrue("Error occured during fetch records from ZIP file.", false);
    } finally {
        if (in != null)
            try {
                in.close();
            } catch (IOException e) {
            }
    }
}

From source file:com.signavio.warehouse.business.util.jpdl4.Sql.java

public Sql(org.w3c.dom.Node sql) {
    this.uuid = "oryx_" + UUID.randomUUID().toString();
    NamedNodeMap attributes = sql.getAttributes();
    this.name = JpdlToJson.getAttribute(attributes, "name");
    this.unique = Boolean.parseBoolean(JpdlToJson.getAttribute(attributes, "unique"));
    this.var = JpdlToJson.getAttribute(attributes, "var");

    this.bounds = JpdlToJson.getBounds(attributes.getNamedItem("g"));

    if (sql.hasChildNodes())
        for (org.w3c.dom.Node a = sql.getFirstChild(); a != null; a = a.getNextSibling()) {
            if (a.getNodeName().equals("query"))
                this.query = a.getTextContent();
            if (a.getNodeName().equals("parameters"))
                this.parameters = new Parameters(a);
        }//from   ww w .  j  a  va  2  s. com
}

From source file:com.impetus.ankush.agent.AgentConf.java

/**
 * Gets the boolean value.//  ww w.  j  a  v  a  2  s.c  om
 * 
 * @param key
 *            the key
 * @return Boolean value for key
 */
public boolean getBooleanValue(String key) {
    return Boolean.parseBoolean(this.properties.getProperty(key));
}

From source file:it.geosolutions.geoserver.jms.client.JMSContainer.java

@PostConstruct
private void init() {
    // change the default autostartup status to false
    setAutoStartup(false);/*  w ww .  ja  v a2 s .  c  om*/

    // force no concurrent consumers
    setConcurrentConsumers(1);

    // set to topic
    setPubSubDomain(true);

    // set subscription durability
    setSubscriptionDurable(
            Boolean.parseBoolean(config.getConfiguration(TopicConfiguration.DURABLE_KEY).toString()));

    // set subscription ID
    setDurableSubscriptionName(config.getConfiguration(JMSConfiguration.INSTANCE_NAME_KEY).toString());

    // times to test (connection)
    max = Integer.parseInt(config.getConfiguration(ConnectionConfiguration.CONNECTION_RETRY_KEY).toString());

    // millisecs to wait between tests (connection)
    maxWait = Long
            .parseLong(config.getConfiguration(ConnectionConfiguration.CONNECTION_MAXWAIT_KEY).toString());

    // check configuration for connection and try to start if needed
    final String startString = config.getConfiguration(ConnectionConfiguration.CONNECTION_KEY);
    if (startString != null && startString.equals(ConnectionConfigurationStatus.enabled.toString())) {
        if (!connect()) {
            if (LOGGER.isLoggable(Level.SEVERE)) {
                LOGGER.severe("Unable to connect to the broker, force connection status to disabled");
            }

            // change configuration status
            config.putConfiguration(ConnectionConfiguration.CONNECTION_KEY,
                    ConnectionConfigurationStatus.disabled.toString());

            // store changes to the configuration
            try {
                config.storeConfig();
            } catch (IOException e) {
                LOGGER.log(Level.SEVERE, e.getMessage(), e);
            }
        }
    } else {
        // configure (needed by initializeBean)
        configure();
    }
}

From source file:org.eclipse.vorto.remoterepository.internal.lucene.LuceneIndexService.java

/**
 * TODO : Should this be here? This is not the task of the indexing service
 *//*from w  ww. j a v a2 s  .  c om*/
@PostConstruct
public void init() {
    if (Boolean.parseBoolean(rebuildOnBoot)) {
        try {

            luceneHelper.cleanupIndexDirectory();
            for (ModelType modelType : ModelType.values()) {
                indexModelType(modelType);
            }
        } catch (IOException e) {
            log.error("IOException from cleaning index directory & re-index ", e);
        }
    }
}

From source file:org.openbaton.nfvo.vnfm_reg.tasks.ModifyTask.java

@Override
protected NFVMessage doWork() throws Exception {
    virtualNetworkFunctionRecord.setStatus(Status.INACTIVE);
    log.info("MODIFY finished for VNFR: " + virtualNetworkFunctionRecord.getName());
    log.trace("VNFR Verison is: " + virtualNetworkFunctionRecord.getHb_version());
    saveVirtualNetworkFunctionRecord();/*w  w w.ja  v a2s .  c o  m*/
    log.trace("Now VNFR Verison is: " + virtualNetworkFunctionRecord.getHb_version());
    log.debug("VNFR " + virtualNetworkFunctionRecord.getName() + " Status is: "
            + virtualNetworkFunctionRecord.getStatus());
    boolean allVnfrInInactive = allVnfrInInactive(
            networkServiceRecordRepository.findFirstById(virtualNetworkFunctionRecord.getParent_ns_id()));
    log.trace("Ordered string is: \"" + ordered + "\"");
    log.debug("Is ordered? " + Boolean.parseBoolean(ordered));
    log.debug("Are all VNFR in inactive? " + allVnfrInInactive);

    if (ordered != null && Boolean.parseBoolean(ordered)) {
        if (allVnfrInInactive) {
            VirtualNetworkFunctionRecord nextToCallStart = getNextToCallStart(virtualNetworkFunctionRecord);
            if (nextToCallStart != null) {
                vnfmManager.removeVnfrName(virtualNetworkFunctionRecord.getParent_ns_id(),
                        nextToCallStart.getName());
                sendStart(nextToCallStart);
            }
            log.info("Not found next VNFR to call start");
        } else {
            log.debug("After MODIFY of " + virtualNetworkFunctionRecord.getName()
                    + ", not calling start to next VNFR because not all VNFRs are in state INACTIVE");
        }
    } else {
        sendStart(virtualNetworkFunctionRecord);
    }
    return null;
}