Example usage for java.lang Boolean valueOf

List of usage examples for java.lang Boolean valueOf

Introduction

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

Prototype

public static Boolean valueOf(String s) 

Source Link

Document

Returns a Boolean with a value represented by the specified string.

Usage

From source file:com.emc.ecs.sync.SyncProcessTest.java

@Test
public void testSourceObjectNotFound() throws Exception {
    Properties syncProperties = SyncConfig.getProperties();
    String bucket = "ecs-sync-test-source-not-found";
    String endpoint = syncProperties.getProperty(SyncConfig.PROP_S3_ENDPOINT);
    String accessKey = syncProperties.getProperty(SyncConfig.PROP_S3_ACCESS_KEY_ID);
    String secretKey = syncProperties.getProperty(SyncConfig.PROP_S3_SECRET_KEY);
    boolean useVHost = Boolean.valueOf(syncProperties.getProperty(SyncConfig.PROP_S3_VHOST));
    Assume.assumeNotNull(endpoint, accessKey, secretKey);
    URI endpointUri = new URI(endpoint);

    S3Config s3Config;//from  www.j ava 2  s. c o  m
    if (useVHost)
        s3Config = new S3Config(endpointUri);
    else
        s3Config = new S3Config(Protocol.valueOf(endpointUri.getScheme().toUpperCase()), endpointUri.getHost());
    s3Config.withPort(endpointUri.getPort()).withUseVHost(useVHost).withIdentity(accessKey)
            .withSecretKey(secretKey);

    S3Client s3 = new S3JerseyClient(s3Config);

    try {
        s3.createBucket(bucket);
    } catch (S3Exception e) {
        if (!e.getErrorCode().equals("BucketAlreadyExists"))
            throw e;
    }

    try {
        File sourceKeyList = TestUtil.writeTempFile("this-key-does-not-exist");

        EcsS3Source source = new EcsS3Source();
        source.setEndpoint(endpointUri);
        source.setProtocol(endpointUri.getScheme());
        source.setVdcs(Collections.singletonList(new Vdc(endpointUri.getHost())));
        source.setPort(endpointUri.getPort());
        source.setEnableVHosts(useVHost);
        source.setAccessKey(accessKey);
        source.setSecretKey(secretKey);
        source.setBucketName(bucket);
        source.setSourceKeyList(sourceKeyList);

        DbService dbService = new SqliteDbService(":memory:");

        EcsSync sync = new EcsSync();
        sync.setSource(source);
        sync.setTarget(new TestObjectTarget());
        sync.setDbService(dbService);

        sync.run();

        Assert.assertEquals(0, sync.getObjectsComplete());
        Assert.assertEquals(1, sync.getObjectsFailed());
        Assert.assertEquals(1, sync.getFailedObjects().size());
        SyncObject syncObject = sync.getFailedObjects().iterator().next();
        Assert.assertNotNull(syncObject);
        SyncRecord syncRecord = dbService.getSyncRecord(sync.getFailedObjects().iterator().next());
        Assert.assertNotNull(syncRecord);
        Assert.assertEquals(ObjectStatus.Error, syncRecord.getStatus());
    } finally {
        try {
            s3.deleteBucket(bucket);
        } catch (Throwable t) {
            // ignore
        }
    }
}

From source file:com.cognifide.aet.job.common.modifiers.resolution.ResolutionModifier.java

@Override
public void setParameters(Map<String, String> params) throws ParametersException {
    String paramValue = params.get(PARAM_MAXIMIZE);
    maximize = Boolean.valueOf(paramValue);

    if (params.containsKey(WIDTH_PARAM) && params.containsKey(HEIGHT_PARAM)) {
        width = NumberUtils.toInt(params.get(WIDTH_PARAM));
        ParametersValidator.checkRange(width, 1, MAX_SIZE, "Width should be greater than 0");

        height = NumberUtils.toInt(params.get(HEIGHT_PARAM));
        ParametersValidator.checkRange(height, 1, MAX_SIZE, "Height should be greater than 0");

        ParametersValidator.checkParameter(!maximize,
                "You cannot maximize the window and specify the dimension");
    } else if (params.containsKey(WIDTH_PARAM) || params.containsKey(HEIGHT_PARAM)) {
        throw new ParametersException("You have to specify both width and height");
    }/*from  ww  w  .j  a  v  a2 s .  c  o  m*/
}

From source file:com.redhat.lightblue.metadata.types.BooleanType.java

@Override
public Object cast(Object obj) {
    Boolean value = null;//from   w  w  w. j  av  a  2  s . co m
    if (obj != null) {
        if (obj instanceof Boolean) {
            value = ((Boolean) obj);
        } else if (obj instanceof Number) {
            value = ((Number) obj).intValue() != 0;
        } else if (obj instanceof String) {
            value = Boolean.valueOf((String) obj);
        } else {
            throw Error.get(NAME, MetadataConstants.ERR_INCOMPATIBLE_VALUE, obj.toString());
        }
    }
    return value;
}

From source file:io.fabric8.jolokia.facade.FabricMBeanFacadeTest.java

@Test
public void testRequirements() {
    // this can only be run if you have a fabric running...
    Assume.assumeTrue(Boolean.valueOf(System.getProperty("hasFabric")));

    FabricMBean facade = getFabricMBean();

    String json = facade.requirements();

    try {/*from  w  ww.  j  ava  2s  .  c o m*/
        FabricRequirementsDTO dto = Helpers.getObjectMapper().readValue(json, FabricRequirementsDTO.class);
        Assume.assumeNotNull(dto);
        System.out.println(dto);
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:WSpatern.ValidTokenWS.java

private void parseXML(String line) {
    try {/*from   w  ww  .  j a v  a  2 s .co  m*/
        org.w3c.dom.Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder()
                .parse(new InputSource(new StringReader(line)));
        NodeList response = doc.getElementsByTagName("userToken");
        if (response.getLength() > 0) {
            Element err = (Element) response.item(0);
            expire = err.getElementsByTagName("expires").item(0).getTextContent();
            tokekn = err.getElementsByTagName("token").item(0).getTextContent();

            userId = err.getElementsByTagName("userId").item(0).getTextContent();
            valid = Boolean.valueOf(err.getElementsByTagName("valid").item(0).getTextContent());
        }
    } catch (ParserConfigurationException ex) {
        Logger.getLogger(LoginWS.class.getName()).log(Level.SEVERE, null, ex);
    } catch (SAXException ex) {
        Logger.getLogger(LoginWS.class.getName()).log(Level.SEVERE, null, ex);
    } catch (IOException ex) {
        Logger.getLogger(LoginWS.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:org.training.storefront.controllers.pages.AbstractLoginPageController.java

protected String getDefaultLoginPage(final boolean loginError, final HttpSession session, final Model model)
        throws CMSItemNotFoundException {
    final LoginForm loginForm = new LoginForm();
    model.addAttribute(loginForm);//from  w w w .j  a  va2 s  .c  om
    model.addAttribute(new RegisterForm());
    model.addAttribute(new GuestForm());

    final String username = (String) session.getAttribute(SPRING_SECURITY_LAST_USERNAME);
    if (username != null) {
        session.removeAttribute(SPRING_SECURITY_LAST_USERNAME);
    }

    loginForm.setJ_username(username);
    storeCmsPageInModel(model, getCmsPage());
    setUpMetaDataForContentPage(model, (ContentPageModel) getCmsPage());
    model.addAttribute("metaRobots", "index,no-follow");

    final Breadcrumb loginBreadcrumbEntry = new Breadcrumb("#",
            getMessageSource().getMessage("header.link.login", null, getI18nService().getCurrentLocale()),
            null);
    model.addAttribute("breadcrumbs", Collections.singletonList(loginBreadcrumbEntry));

    if (loginError) {
        model.addAttribute("loginError", Boolean.valueOf(loginError));
        GlobalMessages.addErrorMessage(model, "login.error.account.not.found.title");
    }

    return getView();
}

From source file:org.trustedanalytics.metadata.datacatalog.DataCatalogClientTest.java

/**
 * This test should prevent anyone from carelessly breaking the service communication.
 * *//*from   ww w  . ja  v  a2 s.c  o  m*/
@Test
public void metadataSerialization_requestProperlySerialized() throws IOException {
    // RestTemplate is using Jackson so we use it in the test
    ObjectMapper mapper = new ObjectMapper();

    Map<String, String> properSerilizedValues = new HashMap<String, String>() {
        {
            put("category", "test category");
            put("dataSample", "test sample");
            put("format", "test format");
            put("isPublic", "true");
            put("orgUUID", UUID.randomUUID().toString());
            put("recordCount", "13");
            put("size", "123");
            put("sourceUri", "test source uri");
            put("targetUri", "test target uri");
            put("title", "test title");
        }
    };

    Metadata meta = new Metadata();

    meta.setCategory(properSerilizedValues.get("category"));
    meta.setDataSample(properSerilizedValues.get("dataSample"));
    meta.setFormat(properSerilizedValues.get("format"));
    meta.setPublic(Boolean.valueOf(properSerilizedValues.get("isPublic")));
    meta.setOrgUUID(UUID.fromString(properSerilizedValues.get("orgUUID")));
    meta.setRecordCount(Integer.valueOf(properSerilizedValues.get("recordCount")));
    meta.setSize(Integer.valueOf(properSerilizedValues.get("size")));
    meta.setSourceUri(properSerilizedValues.get("sourceUri"));
    meta.setTargetUri(properSerilizedValues.get("targetUri"));
    meta.setTitle(properSerilizedValues.get("title"));

    String serializedMeta = mapper.writeValueAsString(meta);
    Map<String, String> deserializedMap = mapper.readValue(serializedMeta,
            new TypeReference<HashMap<String, String>>() {
            });

    Assert.assertEquals(properSerilizedValues, deserializedMap);
}

From source file:com.haulmont.cuba.gui.xml.layout.loaders.LookupPickerFieldLoader.java

@Override
public void loadComponent() {
    super.loadComponent();

    LookupPickerField lookupPickerField = (LookupPickerField) resultComponent;

    final String metaClass = element.attributeValue("metaClass");
    if (!StringUtils.isEmpty(metaClass)) {
        Metadata metadata = AppBeans.get(Metadata.NAME);
        lookupPickerField.setMetaClass(metadata.getSession().getClass(metaClass));
    }//  www . j a  v  a 2  s.  c om

    loadActions(lookupPickerField, element);

    if (lookupPickerField.getActions().isEmpty()) {
        boolean actionsByMetaAnnotations = ComponentsHelper.createActionsByMetaAnnotations(lookupPickerField);
        if (!actionsByMetaAnnotations) {
            lookupPickerField.addLookupAction();
            lookupPickerField.addOpenAction();
        }
    }

    String refreshOptionsOnLookupClose = element.attributeValue("refreshOptionsOnLookupClose");
    if (refreshOptionsOnLookupClose != null) {
        lookupPickerField.setRefreshOptionsOnLookupClose(Boolean.valueOf(refreshOptionsOnLookupClose));
    }
}

From source file:com.exxonmobile.ace.hybris.core.search.solrfacetsearch.provider.impl.MultidimentionalProductFlagValueProvider.java

@Override
public Collection<FieldValue> getFieldValues(final IndexConfig indexConfig,
        final IndexedProperty indexedProperty, final Object model) throws FieldValueProviderException {
    final List<FieldValue> fieldValues = new ArrayList<FieldValue>();
    if (model instanceof ProductModel) {
        final Object variants = modelService.getAttributeValue(model, "variants");

        final boolean isMultidimentional = CollectionUtils.isNotEmpty((Collection) variants);
        addFieldValues(fieldValues, indexedProperty, Boolean.valueOf(isMultidimentional));
    } else {//from  w  ww. j av a  2  s.co  m
        throw new FieldValueProviderException("Cannot tell if it is multidimentional for non-product item");
    }

    return fieldValues;
}

From source file:com.lynch.cms.core.util.PropertiesLoader.java

/**
 * ?PropertySystemProperty.
 */
public Boolean getBoolean(String key) {
    return Boolean.valueOf(getProperty(key));
}